Bleeding out Swan.Tiny

This commit is contained in:
BlubbFish 2019-12-10 20:01:19 +01:00
parent b4ae02a85f
commit b2f110b8d6
59 changed files with 254 additions and 200 deletions

View File

@ -9,7 +9,7 @@ namespace Swan.Configuration {
/// <seealso cref="System.Attribute" /> /// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class PropertyDisplayAttribute : Attribute { public sealed class PropertyDisplayAttribute : Attribute {
/// <summary> /*/// <summary>
/// Gets or sets the name. /// Gets or sets the name.
/// </summary> /// </summary>
/// <value> /// <value>
@ -37,7 +37,7 @@ namespace Swan.Configuration {
/// </value> /// </value>
public String GroupName { public String GroupName {
get; set; get; set;
} }*/
/// <summary> /// <summary>
/// Gets or sets the default value. /// Gets or sets the default value.

View File

@ -62,7 +62,7 @@ namespace Swan {
#endregion #endregion
/// <summary> /*/// <summary>
/// Contains all basic types, including string, date time, and all of their nullable counterparts. /// Contains all basic types, including string, date time, and all of their nullable counterparts.
/// </summary> /// </summary>
/// <value> /// <value>
@ -90,7 +90,7 @@ namespace Swan {
/// </value> /// </value>
public static IReadOnlyCollection<Type> AllNumericValueTypes { public static IReadOnlyCollection<Type> AllNumericValueTypes {
get; get;
} = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsNumeric && !kvp.Value.IsNullableValueType).Select(kvp => kvp.Key).ToArray()); } = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsNumeric && !kvp.Value.IsNullableValueType).Select(kvp => kvp.Key).ToArray());*/
/// <summary> /// <summary>
/// Contains all basic value types. i.e. excludes string and nullables. /// Contains all basic value types. i.e. excludes string and nullables.
@ -102,7 +102,7 @@ namespace Swan {
get; get;
} = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsValueType).Select(kvp => kvp.Key).ToArray()); } = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsValueType).Select(kvp => kvp.Key).ToArray());
/// <summary> /*/// <summary>
/// Contains all basic value types including the string type. i.e. excludes nullables. /// Contains all basic value types including the string type. i.e. excludes nullables.
/// </summary> /// </summary>
/// <value> /// <value>
@ -120,6 +120,6 @@ namespace Swan {
/// </value> /// </value>
public static IReadOnlyCollection<Type> AllBasicNullableValueTypes { public static IReadOnlyCollection<Type> AllBasicNullableValueTypes {
get; get;
} = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsNullableValueType).Select(kvp => kvp.Key).ToArray()); } = new ReadOnlyCollection<Type>(BasicTypesInfo.Value.Where(kvp => kvp.Value.IsNullableValueType).Select(kvp => kvp.Key).ToArray());*/
} }
} }

View File

@ -5,6 +5,7 @@ namespace Swan {
/// <summary> /// <summary>
/// Contains useful constants and definitions. /// Contains useful constants and definitions.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
public static partial class Definitions { public static partial class Definitions {
/// <summary> /// <summary>
/// The MS Windows codepage 1252 encoding used in some legacy scenarios /// The MS Windows codepage 1252 encoding used in some legacy scenarios

View File

@ -10,12 +10,12 @@ namespace Swan.DependencyInjection {
/// </summary> /// </summary>
/// <seealso cref="System.IDisposable" /> /// <seealso cref="System.IDisposable" />
public partial class DependencyContainer : IDisposable { public partial class DependencyContainer : IDisposable {
private readonly Object _autoRegisterLock = new Object(); /*private readonly Object _autoRegisterLock = new Object();*/
private Boolean _disposed; private Boolean _disposed;
static DependencyContainer() { /*static DependencyContainer() {
} }*/
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DependencyContainer"/> class. /// Initializes a new instance of the <see cref="DependencyContainer"/> class.
@ -25,7 +25,7 @@ namespace Swan.DependencyInjection {
_ = this.Register(this); _ = this.Register(this);
} }
private DependencyContainer(DependencyContainer parent) : this() => this.Parent = parent; /*private DependencyContainer(DependencyContainer parent) : this() => this.Parent = parent;*/
/// <summary> /// <summary>
/// Lazy created Singleton instance of the container for simple scenarios. /// Lazy created Singleton instance of the container for simple scenarios.
@ -55,15 +55,15 @@ namespace Swan.DependencyInjection {
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary> /*/// <summary>
/// Gets the child container. /// Gets the child container.
/// </summary> /// </summary>
/// <returns>A new instance of the <see cref="DependencyContainer"/> class.</returns> /// <returns>A new instance of the <see cref="DependencyContainer"/> class.</returns>
public DependencyContainer GetChildContainer() => new DependencyContainer(this); public DependencyContainer GetChildContainer() => new DependencyContainer(this);*/
#region Registration #region Registration
/// <summary> /*/// <summary>
/// Attempt to automatically register all non-generic classes and interfaces in the current app domain. /// Attempt to automatically register all non-generic classes and interfaces in the current app domain.
/// Types will only be registered if they pass the supplied registration predicate. /// Types will only be registered if they pass the supplied registration predicate.
/// </summary> /// </summary>
@ -138,7 +138,7 @@ namespace Swan.DependencyInjection {
/// <param name="registerImplementation">Type to instantiate that implements RegisterType.</param> /// <param name="registerImplementation">Type to instantiate that implements RegisterType.</param>
/// <param name="name">Name of registration.</param> /// <param name="name">Name of registration.</param>
/// <returns>RegisterOptions for fluent API.</returns> /// <returns>RegisterOptions for fluent API.</returns>
public RegisterOptions Register(Type registerType, Type registerImplementation, String name = "") => this.RegisteredTypes.Register(registerType, name, GetDefaultObjectFactory(registerType, registerImplementation)); public RegisterOptions Register(Type registerType, Type registerImplementation, String name = "") => this.RegisteredTypes.Register(registerType, name, GetDefaultObjectFactory(registerType, registerImplementation));*/
/// <summary> /// <summary>
/// Creates/replaces a named container class registration with a specific, strong referenced, instance. /// Creates/replaces a named container class registration with a specific, strong referenced, instance.
@ -149,7 +149,7 @@ namespace Swan.DependencyInjection {
/// <returns>RegisterOptions for fluent API.</returns> /// <returns>RegisterOptions for fluent API.</returns>
public RegisterOptions Register(Type registerType, Object instance, String name = "") => this.RegisteredTypes.Register(registerType, name, new InstanceFactory(registerType, registerType, instance)); public RegisterOptions Register(Type registerType, Object instance, String name = "") => this.RegisteredTypes.Register(registerType, name, new InstanceFactory(registerType, registerType, instance));
/// <summary> /*/// <summary>
/// Creates/replaces a named container class registration with a specific, strong referenced, instance. /// Creates/replaces a named container class registration with a specific, strong referenced, instance.
/// </summary> /// </summary>
/// <param name="registerType">Type to register.</param> /// <param name="registerType">Type to register.</param>
@ -183,7 +183,7 @@ namespace Swan.DependencyInjection {
/// <typeparam name="TRegisterImplementation">Type to instantiate that implements RegisterType.</typeparam> /// <typeparam name="TRegisterImplementation">Type to instantiate that implements RegisterType.</typeparam>
/// <param name="name">Name of registration.</param> /// <param name="name">Name of registration.</param>
/// <returns>RegisterOptions for fluent API.</returns> /// <returns>RegisterOptions for fluent API.</returns>
public RegisterOptions Register<TRegister, TRegisterImplementation>(String name = "") where TRegister : class where TRegisterImplementation : class, TRegister => this.Register(typeof(TRegister), typeof(TRegisterImplementation), name); public RegisterOptions Register<TRegister, TRegisterImplementation>(String name = "") where TRegister : class where TRegisterImplementation : class, TRegister => this.Register(typeof(TRegister), typeof(TRegisterImplementation), name);*/
/// <summary> /// <summary>
/// Creates/replaces a named container class registration with a specific, strong referenced, instance. /// Creates/replaces a named container class registration with a specific, strong referenced, instance.
@ -192,9 +192,10 @@ namespace Swan.DependencyInjection {
/// <param name="instance">Instance of RegisterType to register.</param> /// <param name="instance">Instance of RegisterType to register.</param>
/// <param name="name">Name of registration.</param> /// <param name="name">Name of registration.</param>
/// <returns>RegisterOptions for fluent API.</returns> /// <returns>RegisterOptions for fluent API.</returns>
// [Obsolete("NEED", false)]
public RegisterOptions Register<TRegister>(TRegister instance, String name = "") where TRegister : class => this.Register(typeof(TRegister), instance, name); public RegisterOptions Register<TRegister>(TRegister instance, String name = "") where TRegister : class => this.Register(typeof(TRegister), instance, name);
/// <summary> /*/// <summary>
/// Creates/replaces a named container class registration with a specific, strong referenced, instance. /// Creates/replaces a named container class registration with a specific, strong referenced, instance.
/// </summary> /// </summary>
/// <typeparam name="TRegister">Type to register.</typeparam> /// <typeparam name="TRegister">Type to register.</typeparam>
@ -257,13 +258,13 @@ namespace Swan.DependencyInjection {
List<RegisterOptions> registerOptions = implementationTypes.Select(type => this.Register(registrationType, type, type.FullName)).ToList(); List<RegisterOptions> registerOptions = implementationTypes.Select(type => this.Register(registrationType, type, type.FullName)).ToList();
return new MultiRegisterOptions(registerOptions); return new MultiRegisterOptions(registerOptions);
} }*/
#endregion #endregion
#region Unregistration #region Unregistration
/// <summary> /*/// <summary>
/// Remove a named container class registration. /// Remove a named container class registration.
/// </summary> /// </summary>
/// <typeparam name="TRegister">Type to unregister.</typeparam> /// <typeparam name="TRegister">Type to unregister.</typeparam>
@ -277,7 +278,7 @@ namespace Swan.DependencyInjection {
/// <param name="registerType">Type to unregister.</param> /// <param name="registerType">Type to unregister.</param>
/// <param name="name">Name of registration.</param> /// <param name="name">Name of registration.</param>
/// <returns><c>true</c> if the registration is successfully found and removed; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if the registration is successfully found and removed; otherwise, <c>false</c>.</returns>
public Boolean Unregister(Type registerType, String name = "") => this.RegisteredTypes.RemoveRegistration(new TypeRegistration(registerType, name)); public Boolean Unregister(Type registerType, String name = "") => this.RegisteredTypes.RemoveRegistration(new TypeRegistration(registerType, name));*/
#endregion #endregion
@ -294,6 +295,7 @@ namespace Swan.DependencyInjection {
/// <param name="options">Resolution options.</param> /// <param name="options">Resolution options.</param>
/// <returns>Instance of type.</returns> /// <returns>Instance of type.</returns>
/// <exception cref="DependencyContainerResolutionException">Unable to resolve the type.</exception> /// <exception cref="DependencyContainerResolutionException">Unable to resolve the type.</exception>
// [Obsolete("NEED", false)]
public Object Resolve(Type resolveType, String name = null, DependencyContainerResolveOptions options = null) => this.RegisteredTypes.ResolveInternal(new TypeRegistration(resolveType, name), options ?? DependencyContainerResolveOptions.Default); public Object Resolve(Type resolveType, String name = null, DependencyContainerResolveOptions options = null) => this.RegisteredTypes.ResolveInternal(new TypeRegistration(resolveType, name), options ?? DependencyContainerResolveOptions.Default);
/// <summary> /// <summary>
@ -307,6 +309,7 @@ namespace Swan.DependencyInjection {
/// <param name="options">Resolution options.</param> /// <param name="options">Resolution options.</param>
/// <returns>Instance of type.</returns> /// <returns>Instance of type.</returns>
/// <exception cref="DependencyContainerResolutionException">Unable to resolve the type.</exception> /// <exception cref="DependencyContainerResolutionException">Unable to resolve the type.</exception>
// [Obsolete("NEED", false)]
public TResolveType Resolve<TResolveType>(String name = null, DependencyContainerResolveOptions options = null) where TResolveType : class => (TResolveType)this.Resolve(typeof(TResolveType), name, options); public TResolveType Resolve<TResolveType>(String name = null, DependencyContainerResolveOptions options = null) where TResolveType : class => (TResolveType)this.Resolve(typeof(TResolveType), name, options);
/// <summary> /// <summary>
@ -321,6 +324,7 @@ namespace Swan.DependencyInjection {
/// <returns> /// <returns>
/// Bool indicating whether the type can be resolved. /// Bool indicating whether the type can be resolved.
/// </returns> /// </returns>
// [Obsolete("NEED", false)]
public Boolean CanResolve(Type resolveType, String name = null, DependencyContainerResolveOptions options = null) => this.RegisteredTypes.CanResolve(new TypeRegistration(resolveType, name), options); public Boolean CanResolve(Type resolveType, String name = null, DependencyContainerResolveOptions options = null) => this.RegisteredTypes.CanResolve(new TypeRegistration(resolveType, name), options);
/// <summary> /// <summary>
@ -335,9 +339,10 @@ namespace Swan.DependencyInjection {
/// <param name="name">Name of registration.</param> /// <param name="name">Name of registration.</param>
/// <param name="options">Resolution options.</param> /// <param name="options">Resolution options.</param>
/// <returns>Bool indicating whether the type can be resolved.</returns> /// <returns>Bool indicating whether the type can be resolved.</returns>
// [Obsolete("NEED", false)]
public Boolean CanResolve<TResolveType>(String name = null, DependencyContainerResolveOptions options = null) where TResolveType : class => this.CanResolve(typeof(TResolveType), name, options); public Boolean CanResolve<TResolveType>(String name = null, DependencyContainerResolveOptions options = null) where TResolveType : class => this.CanResolve(typeof(TResolveType), name, options);
/// <summary> /*/// <summary>
/// Attempts to resolve a type using the default options. /// Attempts to resolve a type using the default options.
/// </summary> /// </summary>
/// <param name="resolveType">Type to resolve.</param> /// <param name="resolveType">Type to resolve.</param>
@ -508,7 +513,7 @@ namespace Swan.DependencyInjection {
// Catch any resolution errors and ignore them // Catch any resolution errors and ignore them
} }
} }
} }*/
#endregion #endregion
@ -532,7 +537,7 @@ namespace Swan.DependencyInjection {
return true; return true;
} }
private static Boolean IsIgnoredAssembly(Assembly assembly) { /*private static Boolean IsIgnoredAssembly(Assembly assembly) {
// TODO - find a better way to remove "system" assemblies from the auto registration // TODO - find a better way to remove "system" assemblies from the auto registration
List<Func<Assembly, Boolean>> ignoreChecks = new List<Func<Assembly, Boolean>> List<Func<Assembly, Boolean>> ignoreChecks = new List<Func<Assembly, Boolean>>
{ {
@ -568,7 +573,7 @@ namespace Swan.DependencyInjection {
return ignoreChecks.Any(check => check(type)); return ignoreChecks.Any(check => check(type));
} }
private static ObjectFactoryBase GetDefaultObjectFactory(Type registerType, Type registerImplementation) => registerType.IsInterface || registerType.IsAbstract ? (ObjectFactoryBase)new SingletonFactory(registerType, registerImplementation) : new MultiInstanceFactory(registerType, registerImplementation); private static ObjectFactoryBase GetDefaultObjectFactory(Type registerType, Type registerImplementation) => registerType.IsInterface || registerType.IsAbstract ? (ObjectFactoryBase)new SingletonFactory(registerType, registerImplementation) : new MultiInstanceFactory(registerType, registerImplementation);*/
#endregion #endregion
} }

View File

@ -10,15 +10,15 @@ namespace Swan.DependencyInjection {
public class DependencyContainerRegistrationException : Exception { public class DependencyContainerRegistrationException : Exception {
private const String ConvertErrorText = "Cannot convert current registration of {0} to {1}"; private const String ConvertErrorText = "Cannot convert current registration of {0} to {1}";
private const String RegisterErrorText = "Cannot register type {0} - abstract classes or interfaces are not valid implementation types for {1}."; private const String RegisterErrorText = "Cannot register type {0} - abstract classes or interfaces are not valid implementation types for {1}.";
private const String ErrorText = "Duplicate implementation of type {0} found ({1})."; /*private const String ErrorText = "Duplicate implementation of type {0} found ({1}).";*/
/// <summary> /*/// <summary>
/// Initializes a new instance of the <see cref="DependencyContainerRegistrationException"/> class. /// Initializes a new instance of the <see cref="DependencyContainerRegistrationException"/> class.
/// </summary> /// </summary>
/// <param name="registerType">Type of the register.</param> /// <param name="registerType">Type of the register.</param>
/// <param name="types">The types.</param> /// <param name="types">The types.</param>
public DependencyContainerRegistrationException(Type registerType, IEnumerable<Type> types) : base(String.Format(ErrorText, registerType, GetTypesString(types))) { public DependencyContainerRegistrationException(Type registerType, IEnumerable<Type> types) : base(String.Format(ErrorText, registerType, GetTypesString(types))) {
} }*/
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DependencyContainerRegistrationException" /> class. /// Initializes a new instance of the <see cref="DependencyContainerRegistrationException" /> class.
@ -29,6 +29,6 @@ namespace Swan.DependencyInjection {
public DependencyContainerRegistrationException(Type type, String method, Boolean isTypeFactory = false) : base(isTypeFactory ? String.Format(RegisterErrorText, type.FullName, method) : String.Format(ConvertErrorText, type.FullName, method)) { public DependencyContainerRegistrationException(Type type, String method, Boolean isTypeFactory = false) : base(isTypeFactory ? String.Format(RegisterErrorText, type.FullName, method) : String.Format(ConvertErrorText, type.FullName, method)) {
} }
private static String GetTypesString(IEnumerable<Type> types) => String.Join(",", types.Select(type => type.FullName)); /*private static String GetTypesString(IEnumerable<Type> types) => String.Join(",", types.Select(type => type.FullName));*/
} }
} }

View File

@ -84,7 +84,7 @@ namespace Swan.DependencyInjection {
Fail, Fail,
} }
/// <summary> /*/// <summary>
/// Enumerates duplicate definition actions. /// Enumerates duplicate definition actions.
/// </summary> /// </summary>
public enum DependencyContainerDuplicateImplementationAction { public enum DependencyContainerDuplicateImplementationAction {
@ -102,5 +102,5 @@ namespace Swan.DependencyInjection {
/// The fail /// The fail
/// </summary> /// </summary>
Fail, Fail,
} }*/
} }

View File

@ -107,8 +107,7 @@ namespace Swan.DependencyInjection {
public override Type CreatesType => this._registerImplementation; public override Type CreatesType => this._registerImplementation;
public override ObjectFactoryBase SingletonVariant => public override ObjectFactoryBase SingletonVariant => new SingletonFactory(this._registerType, this._registerImplementation);
new SingletonFactory(this._registerType, this._registerImplementation);
public override ObjectFactoryBase MultiInstanceVariant => this; public override ObjectFactoryBase MultiInstanceVariant => this;
@ -130,9 +129,7 @@ namespace Swan.DependencyInjection {
private readonly Func<DependencyContainer, Dictionary<String, Object>, Object> _factory; private readonly Func<DependencyContainer, Dictionary<String, Object>, Object> _factory;
public DelegateFactory( public DelegateFactory( Type registerType, Func<DependencyContainer, Dictionary<String, Object>, Object> factory) {
Type registerType,
Func<DependencyContainer, Dictionary<String, Object>, Object> factory) {
this._factory = factory ?? throw new ArgumentNullException(nameof(factory)); this._factory = factory ?? throw new ArgumentNullException(nameof(factory));
this._registerType = registerType; this._registerType = registerType;
@ -316,13 +313,9 @@ namespace Swan.DependencyInjection {
public override ObjectFactoryBase SingletonVariant => this; public override ObjectFactoryBase SingletonVariant => this;
public override ObjectFactoryBase MultiInstanceVariant => public override ObjectFactoryBase MultiInstanceVariant => new MultiInstanceFactory(this._registerType, this._registerImplementation);
new MultiInstanceFactory(this._registerType, this._registerImplementation);
public override Object GetObject( public override Object GetObject( Type requestedType, DependencyContainer container, DependencyContainerResolveOptions options) {
Type requestedType,
DependencyContainer container,
DependencyContainerResolveOptions options) {
if(options.ConstructorParameters.Count != 0) { if(options.ConstructorParameters.Count != 0) {
throw new ArgumentException("Cannot specify parameters for singleton types"); throw new ArgumentException("Cannot specify parameters for singleton types");
} }
@ -336,10 +329,7 @@ namespace Swan.DependencyInjection {
return this._current; return this._current;
} }
public override ObjectFactoryBase GetFactoryForChildContainer( public override ObjectFactoryBase GetFactoryForChildContainer( Type type, DependencyContainer parent, DependencyContainer child) {
Type type,
DependencyContainer parent,
DependencyContainer child) {
// We make sure that the singleton is constructed before the child container takes the factory. // We make sure that the singleton is constructed before the child container takes the factory.
// Otherwise the results would vary depending on whether or not the parent container had resolved // Otherwise the results would vary depending on whether or not the parent container had resolved
// the type before the child container does. // the type before the child container does.

View File

@ -20,7 +20,7 @@ namespace Swan.DependencyInjection {
this._registration = registration; this._registration = registration;
} }
/// <summary> /*/// <summary>
/// Make registration a singleton (single instance) if possible. /// Make registration a singleton (single instance) if possible.
/// </summary> /// </summary>
/// <returns>A registration options for fluent API.</returns> /// <returns>A registration options for fluent API.</returns>
@ -78,14 +78,14 @@ namespace Swan.DependencyInjection {
} }
return this._registeredTypes.AddUpdateRegistration(this._registration, currentFactory.StrongReferenceVariant); return this._registeredTypes.AddUpdateRegistration(this._registration, currentFactory.StrongReferenceVariant);
} }*/
} }
/// <summary> /*/// <summary>
/// Registration options for "fluent" API when registering multiple implementations. /// Registration options for "fluent" API when registering multiple implementations.
/// </summary> /// </summary>
public sealed class MultiRegisterOptions { public sealed class MultiRegisterOptions {
private IEnumerable<RegisterOptions> _registerOptions; /*private IEnumerable<RegisterOptions> _registerOptions;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MultiRegisterOptions"/> class. /// Initializes a new instance of the <see cref="MultiRegisterOptions"/> class.
@ -113,7 +113,6 @@ namespace Swan.DependencyInjection {
return this; return this;
} }
private IEnumerable<RegisterOptions> ExecuteOnAllRegisterOptions( private IEnumerable<RegisterOptions> ExecuteOnAllRegisterOptions( Func<RegisterOptions, RegisterOptions> action) => this._registerOptions.Select(action).ToList();
Func<RegisterOptions, RegisterOptions> action) => this._registerOptions.Select(action).ToList(); }*/
}
} }

View File

@ -24,7 +24,7 @@ namespace Swan.DependencyInjection {
/// <returns>The built object.</returns> /// <returns>The built object.</returns>
public delegate Object ObjectConstructor(params Object?[] parameters); public delegate Object ObjectConstructor(params Object?[] parameters);
internal IEnumerable<Object> Resolve(Type resolveType, Boolean includeUnnamed) { /*internal IEnumerable<Object> Resolve(Type resolveType, Boolean includeUnnamed) {
IEnumerable<DependencyContainer.TypeRegistration> registrations = this.Keys.Where(tr => tr.Type == resolveType).Concat(this.GetParentRegistrationsForType(resolveType)).Distinct(); IEnumerable<DependencyContainer.TypeRegistration> registrations = this.Keys.Where(tr => tr.Type == resolveType).Concat(this.GetParentRegistrationsForType(resolveType)).Distinct();
if(!includeUnnamed) { if(!includeUnnamed) {
@ -38,7 +38,7 @@ namespace Swan.DependencyInjection {
_ = this.TryGetValue(registration, out ObjectFactoryBase? current); _ = this.TryGetValue(registration, out ObjectFactoryBase? current);
return current!; return current!;
} }*/
internal RegisterOptions Register(Type registerType, String name, ObjectFactoryBase factory) => this.AddUpdateRegistration(new DependencyContainer.TypeRegistration(registerType, name), factory); internal RegisterOptions Register(Type registerType, String name, ObjectFactoryBase factory) => this.AddUpdateRegistration(new DependencyContainer.TypeRegistration(registerType, name), factory);
@ -48,8 +48,9 @@ namespace Swan.DependencyInjection {
return new RegisterOptions(this, typeRegistration); return new RegisterOptions(this, typeRegistration);
} }
internal Boolean RemoveRegistration(DependencyContainer.TypeRegistration typeRegistration) => this.TryRemove(typeRegistration, out _); /*internal Boolean RemoveRegistration(DependencyContainer.TypeRegistration typeRegistration) => this.TryRemove(typeRegistration, out _);*/
// [Obsolete("NEED", false)]
internal Object ResolveInternal(DependencyContainer.TypeRegistration registration, DependencyContainerResolveOptions? options = null) { internal Object ResolveInternal(DependencyContainer.TypeRegistration registration, DependencyContainerResolveOptions? options = null) {
if(options == null) { if(options == null) {
options = DependencyContainerResolveOptions.Default; options = DependencyContainerResolveOptions.Default;
@ -102,6 +103,7 @@ namespace Swan.DependencyInjection {
return isValid && !registration.Type.IsAbstract && !registration.Type.IsInterface ? this.ConstructType(registration.Type, null, options) : throw new DependencyContainerResolutionException(registration.Type); return isValid && !registration.Type.IsAbstract && !registration.Type.IsInterface ? this.ConstructType(registration.Type, null, options) : throw new DependencyContainerResolutionException(registration.Type);
} }
// [Obsolete("NEED", false)]
internal Boolean CanResolve(DependencyContainer.TypeRegistration registration, DependencyContainerResolveOptions? options = null) { internal Boolean CanResolve(DependencyContainer.TypeRegistration registration, DependencyContainerResolveOptions? options = null) {
if(options == null) { if(options == null) {
options = DependencyContainerResolveOptions.Default; options = DependencyContainerResolveOptions.Default;

View File

@ -6,6 +6,7 @@ namespace Swan.Diagnostics {
/// Provides access to a high-resolution, time measuring device. /// Provides access to a high-resolution, time measuring device.
/// </summary> /// </summary>
/// <seealso cref="Stopwatch" /> /// <seealso cref="Stopwatch" />
// [Obsolete("NEED", false)]
public class HighResolutionTimer : Stopwatch { public class HighResolutionTimer : Stopwatch {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="HighResolutionTimer"/> class. /// Initializes a new instance of the <see cref="HighResolutionTimer"/> class.
@ -22,9 +23,9 @@ namespace Swan.Diagnostics {
/// </summary> /// </summary>
public static Double MicrosecondsPerTick { get; } = 1000000d / Frequency; public static Double MicrosecondsPerTick { get; } = 1000000d / Frequency;
/// <summary> /*/// <summary>
/// Gets the elapsed microseconds. /// Gets the elapsed microseconds.
/// </summary> /// </summary>
public Int64 ElapsedMicroseconds => (Int64)(this.ElapsedTicks * MicrosecondsPerTick); public Int64 ElapsedMicroseconds => (Int64)(this.ElapsedTicks * MicrosecondsPerTick);*/
} }
} }

View File

@ -1,7 +1,10 @@
namespace Swan { using System;
namespace Swan {
/// <summary> /// <summary>
/// Enumeration of Operating Systems. /// Enumeration of Operating Systems.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
public enum OperatingSystem { public enum OperatingSystem {
/// <summary> /// <summary>
/// Unknown OS /// Unknown OS

View File

@ -12,7 +12,7 @@ namespace Swan {
/// Provides various extension methods for byte arrays and streams. /// Provides various extension methods for byte arrays and streams.
/// </summary> /// </summary>
public static class ByteArrayExtensions { public static class ByteArrayExtensions {
/// <summary> /*/// <summary>
/// Converts an array of bytes to its lower-case, hexadecimal representation. /// Converts an array of bytes to its lower-case, hexadecimal representation.
/// </summary> /// </summary>
/// <param name="bytes">The bytes.</param> /// <param name="bytes">The bytes.</param>
@ -43,7 +43,7 @@ namespace Swan {
/// A string of hexadecimal pairs separated by hyphens, where each pair represents /// A string of hexadecimal pairs separated by hyphens, where each pair represents
/// the corresponding element in value; for example, "7F-2C-4A-00". /// the corresponding element in value; for example, "7F-2C-4A-00".
/// </returns> /// </returns>
public static String ToDashedHex(this Byte[] bytes) => BitConverter.ToString(bytes); public static String ToDashedHex(this Byte[] bytes) => BitConverter.ToString(bytes);*/
/// <summary> /// <summary>
/// Converts an array of bytes to a base-64 encoded string. /// Converts an array of bytes to a base-64 encoded string.
@ -70,7 +70,7 @@ namespace Swan {
return Enumerable.Range(0, @this.Length / 2).Select(x => Convert.ToByte(@this.Substring(x * 2, 2), 16)).ToArray(); return Enumerable.Range(0, @this.Length / 2).Select(x => Convert.ToByte(@this.Substring(x * 2, 2), 16)).ToArray();
} }
/// <summary> /*/// <summary>
/// Gets the bit value at the given offset. /// Gets the bit value at the given offset.
/// </summary> /// </summary>
/// <param name="this">The b.</param> /// <param name="this">The b.</param>
@ -493,6 +493,6 @@ namespace Swan {
} }
return $"{(addPrefix ? "0x" : String.Empty)}{sb}"; return $"{(addPrefix ? "0x" : String.Empty)}{sb}";
} }*/
} }
} }

View File

@ -65,7 +65,7 @@ namespace Swan {
return dict[key]; return dict[key];
} }
/// <summary> /*/// <summary>
/// Executes the item action for each element in the Dictionary. /// Executes the item action for each element in the Dictionary.
/// </summary> /// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam> /// <typeparam name="TKey">The type of the key.</typeparam>
@ -81,6 +81,6 @@ namespace Swan {
foreach(KeyValuePair<TKey, TValue> kvp in dict) { foreach(KeyValuePair<TKey, TValue> kvp in dict) {
itemAction(kvp.Key, kvp.Value); itemAction(kvp.Key, kvp.Value);
} }
} }*/
} }
} }

View File

@ -7,7 +7,7 @@ namespace Swan {
/// Functional programming extension methods. /// Functional programming extension methods.
/// </summary> /// </summary>
public static class FunctionalExtensions { public static class FunctionalExtensions {
/// <summary> /*/// <summary>
/// Whens the specified condition. /// Whens the specified condition.
/// </summary> /// </summary>
/// <typeparam name="T">The type of IQueryable.</typeparam> /// <typeparam name="T">The type of IQueryable.</typeparam>
@ -38,7 +38,7 @@ namespace Swan {
} }
return condition() ? fn(list) : list; return condition() ? fn(list) : list;
} }*/
/// <summary> /// <summary>
/// Whens the specified condition. /// Whens the specified condition.
@ -73,7 +73,7 @@ namespace Swan {
return condition() ? fn(list) : list; return condition() ? fn(list) : list;
} }
/// <summary> /*/// <summary>
/// Adds the value when the condition is true. /// Adds the value when the condition is true.
/// </summary> /// </summary>
/// <typeparam name="T">The type of IList element.</typeparam> /// <typeparam name="T">The type of IList element.</typeparam>
@ -168,6 +168,6 @@ namespace Swan {
} }
return list; return list;
} }*/
} }
} }

View File

@ -21,7 +21,7 @@ namespace Swan {
#region Assembly Extensions #region Assembly Extensions
/// <summary> /*/// <summary>
/// Gets all types within an assembly in a safe manner. /// Gets all types within an assembly in a safe manner.
/// </summary> /// </summary>
/// <param name="assembly">The assembly.</param> /// <param name="assembly">The assembly.</param>
@ -39,7 +39,7 @@ namespace Swan {
} catch(ReflectionTypeLoadException e) { } catch(ReflectionTypeLoadException e) {
return e.Types.Where(t => t != null); return e.Types.Where(t => t != null);
} }
} }*/
#endregion #endregion
@ -61,7 +61,7 @@ namespace Swan {
return type.IsValueType ? Activator.CreateInstance(type) : default; return type.IsValueType ? Activator.CreateInstance(type) : default;
} }
/// <summary> /*/// <summary>
/// Determines whether this type is compatible with ICollection. /// Determines whether this type is compatible with ICollection.
/// </summary> /// </summary>
/// <param name="sourceType">The type.</param> /// <param name="sourceType">The type.</param>
@ -117,7 +117,7 @@ namespace Swan {
.Where(mi => mi.GetParameters().Select(pi => pi.ParameterType).SequenceEqual(parameterTypes)).ToList(); .Where(mi => mi.GetParameters().Select(pi => pi.ParameterType).SequenceEqual(parameterTypes)).ToList();
return methods.Count > 1 ? throw new AmbiguousMatchException() : methods.FirstOrDefault(); return methods.Count > 1 ? throw new AmbiguousMatchException() : methods.FirstOrDefault();
} }*/
/// <summary> /// <summary>
/// Determines whether [is i enumerable request]. /// Determines whether [is i enumerable request].
@ -281,7 +281,7 @@ namespace Swan {
return true; return true;
} }
/// <summary> /*/// <summary>
/// Gets property actual value or <c>PropertyDisplayAttribute.DefaultValue</c> if presented. /// Gets property actual value or <c>PropertyDisplayAttribute.DefaultValue</c> if presented.
/// ///
/// If the <c>PropertyDisplayAttribute.Format</c> value is presented, the property value /// If the <c>PropertyDisplayAttribute.Format</c> value is presented, the property value
@ -312,7 +312,7 @@ namespace Swan {
} catch { } catch {
return null; return null;
} }
} }*/
/// <summary> /// <summary>
/// Gets a MethodInfo from a Property Get method. /// Gets a MethodInfo from a Property Get method.
@ -368,7 +368,7 @@ namespace Swan {
return false; return false;
} }
/// <summary> /*/// <summary>
/// Creates a property proxy that stores getter and setter delegates. /// Creates a property proxy that stores getter and setter delegates.
/// </summary> /// </summary>
/// <param name="this">The property information.</param> /// <param name="this">The property information.</param>
@ -384,7 +384,7 @@ namespace Swan {
Type genericType = typeof(PropertyProxy<,>).MakeGenericType(@this.DeclaringType!, @this.PropertyType); Type genericType = typeof(PropertyProxy<,>).MakeGenericType(@this.DeclaringType!, @this.PropertyType);
return Activator.CreateInstance(genericType, @this) as IPropertyProxy; return Activator.CreateInstance(genericType, @this) as IPropertyProxy;
} }*/
/// <summary> /// <summary>
/// Convert a object to a boolean. /// Convert a object to a boolean.
@ -395,7 +395,7 @@ namespace Swan {
/// </returns> /// </returns>
public static Boolean ToBoolean(this Object value) => value.ToStringInvariant().ToBoolean(); public static Boolean ToBoolean(this Object value) => value.ToStringInvariant().ToBoolean();
private static String ConvertObjectAndFormat(Type propertyType, Object value, String format) => /*private static String ConvertObjectAndFormat(Type propertyType, Object value, String format) =>
propertyType == typeof(DateTime) || propertyType == typeof(DateTime?) propertyType == typeof(DateTime) || propertyType == typeof(DateTime?)
? Convert.ToDateTime(value, CultureInfo.InvariantCulture).ToString(format) ? Convert.ToDateTime(value, CultureInfo.InvariantCulture).ToString(format)
: propertyType == typeof(Int32) || propertyType == typeof(Int32?) : propertyType == typeof(Int32) || propertyType == typeof(Int32?)
@ -406,6 +406,6 @@ namespace Swan {
? Convert.ToDouble(value, CultureInfo.InvariantCulture).ToString(format) ? Convert.ToDouble(value, CultureInfo.InvariantCulture).ToString(format)
: propertyType == typeof(Byte) || propertyType == typeof(Byte?) : propertyType == typeof(Byte) || propertyType == typeof(Byte?)
? Convert.ToByte(value, CultureInfo.InvariantCulture).ToString(format) ? Convert.ToByte(value, CultureInfo.InvariantCulture).ToString(format)
: value?.ToString() ?? String.Empty; : value?.ToString() ?? String.Empty;*/
} }
} }

View File

@ -16,11 +16,11 @@ namespace Swan {
private const RegexOptions StandardRegexOptions = RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.CultureInvariant; private const RegexOptions StandardRegexOptions = RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.CultureInvariant;
private static readonly String[] ByteSuffixes = { "B", "KB", "MB", "GB", "TB" }; /*private static readonly String[] ByteSuffixes = { "B", "KB", "MB", "GB", "TB" };*/
private static readonly Lazy<Regex> SplitLinesRegex = new Lazy<Regex>(() => new Regex("\r\n|\r|\n", StandardRegexOptions)); private static readonly Lazy<Regex> SplitLinesRegex = new Lazy<Regex>(() => new Regex("\r\n|\r|\n", StandardRegexOptions));
private static readonly Lazy<Regex> UnderscoreRegex = new Lazy<Regex>(() => new Regex(@"_", StandardRegexOptions)); /*private static readonly Lazy<Regex> UnderscoreRegex = new Lazy<Regex>(() => new Regex(@"_", StandardRegexOptions));
private static readonly Lazy<Regex> CamelCaseRegEx = new Lazy<Regex>(() => new Regex(@"[a-z][A-Z]", StandardRegexOptions)); private static readonly Lazy<Regex> CamelCaseRegEx = new Lazy<Regex>(() => new Regex(@"[a-z][A-Z]", StandardRegexOptions));
@ -29,7 +29,7 @@ namespace Swan {
return x[0] + " " + x[1..]; return x[0] + " " + x[1..];
}); });
private static readonly Lazy<String[]> InvalidFilenameChars = new Lazy<String[]>(() => Path.GetInvalidFileNameChars().Select(c => c.ToString()).ToArray()); private static readonly Lazy<String[]> InvalidFilenameChars = new Lazy<String[]>(() => Path.GetInvalidFileNameChars().Select(c => c.ToString()).ToArray());*/
#endregion #endregion
@ -69,6 +69,7 @@ namespace Swan {
/// A string that represents the current object. /// A string that represents the current object.
/// </returns> /// </returns>
/// <exception cref="ArgumentNullException">input.</exception> /// <exception cref="ArgumentNullException">input.</exception>
// [Obsolete("NEED", false)]
public static String RemoveControlCharsExcept(this String value, params Char[]? excludeChars) { public static String RemoveControlCharsExcept(this String value, params Char[]? excludeChars) {
if(value == null) { if(value == null) {
throw new ArgumentNullException(nameof(value)); throw new ArgumentNullException(nameof(value));
@ -81,7 +82,7 @@ namespace Swan {
return new String(value.Where(c => Char.IsControl(c) == false || excludeChars.Contains(c)).ToArray()); return new String(value.Where(c => Char.IsControl(c) == false || excludeChars.Contains(c)).ToArray());
} }
/// <summary> /*/// <summary>
/// Removes all control characters from a string, including new line sequences. /// Removes all control characters from a string, including new line sequences.
/// </summary> /// </summary>
/// <param name="value">The input.</param> /// <param name="value">The input.</param>
@ -95,7 +96,7 @@ namespace Swan {
/// <param name="this">The object.</param> /// <param name="this">The object.</param>
/// <param name="format">if set to <c>true</c> format the output.</param> /// <param name="format">if set to <c>true</c> format the output.</param>
/// <returns>A <see cref="String" /> that represents the current object.</returns> /// <returns>A <see cref="String" /> that represents the current object.</returns>
public static String ToJson(this Object @this, Boolean format = true) => @this == null ? String.Empty : Json.Serialize(@this, format); public static String ToJson(this Object @this, Boolean format = true) => @this == null ? String.Empty : Json.Serialize(@this, format);*/
/// <summary> /// <summary>
/// Returns text representing the properties of the specified object in a human-readable format. /// Returns text representing the properties of the specified object in a human-readable format.
@ -104,6 +105,7 @@ namespace Swan {
/// </summary> /// </summary>
/// <param name="this">The object.</param> /// <param name="this">The object.</param>
/// <returns>A <see cref="String" /> that represents the current object.</returns> /// <returns>A <see cref="String" /> that represents the current object.</returns>
// [Obsolete("NEED", false)]
public static String Stringify(this Object @this) { public static String Stringify(this Object @this) {
if(@this == null) { if(@this == null) {
return "(null)"; return "(null)";
@ -147,6 +149,7 @@ namespace Swan {
/// <param name="startIndex">The start index.</param> /// <param name="startIndex">The start index.</param>
/// <param name="length">The length.</param> /// <param name="length">The length.</param>
/// <returns>Retrieves a substring from this instance.</returns> /// <returns>Retrieves a substring from this instance.</returns>
// [Obsolete("NEED", false)]
public static String SliceLength(this String @this, Int32 startIndex, Int32 length) { public static String SliceLength(this String @this, Int32 startIndex, Int32 length) {
if(@this == null) { if(@this == null) {
return String.Empty; return String.Empty;
@ -168,7 +171,7 @@ namespace Swan {
/// </returns> /// </returns>
public static String[] ToLines(this String @this) => @this == null ? Array.Empty<String>() : SplitLinesRegex.Value.Split(@this); public static String[] ToLines(this String @this) => @this == null ? Array.Empty<String>() : SplitLinesRegex.Value.Split(@this);
/// <summary> /*/// <summary>
/// Humanizes (make more human-readable) an identifier-style string /// Humanizes (make more human-readable) an identifier-style string
/// in either camel case or snake case. For example, CamelCase will be converted to /// in either camel case or snake case. For example, CamelCase will be converted to
/// Camel Case and Snake_Case will be converted to Snake Case. /// Camel Case and Snake_Case will be converted to Snake Case.
@ -203,7 +206,7 @@ namespace Swan {
String stringValue => stringValue.Humanize(), String stringValue => stringValue.Humanize(),
Boolean boolValue => boolValue.Humanize(), Boolean boolValue => boolValue.Humanize(),
_ => value.Stringify() _ => value.Stringify()
}; };*/
/// <summary> /// <summary>
/// Indents the specified multi-line text with the given amount of leading spaces /// Indents the specified multi-line text with the given amount of leading spaces
@ -212,6 +215,7 @@ namespace Swan {
/// <param name="value">The text.</param> /// <param name="value">The text.</param>
/// <param name="spaces">The spaces.</param> /// <param name="spaces">The spaces.</param>
/// <returns>A <see cref="String" /> that represents the current object.</returns> /// <returns>A <see cref="String" /> that represents the current object.</returns>
// [Obsolete("NEED", false)]
public static String Indent(this String value, Int32 spaces = 4) { public static String Indent(this String value, Int32 spaces = 4) {
if(value == null) { if(value == null) {
value = String.Empty; value = String.Empty;
@ -267,7 +271,7 @@ namespace Swan {
return Tuple.Create(lineIndex + 1, colNumber); return Tuple.Create(lineIndex + 1, colNumber);
} }
/// <summary> /*/// <summary>
/// Makes the file name system safe. /// Makes the file name system safe.
/// </summary> /// </summary>
/// <param name="value">The s.</param> /// <param name="value">The s.</param>
@ -359,6 +363,6 @@ namespace Swan {
/// </summary> /// </summary>
/// <param name="value">The c.</param> /// <param name="value">The c.</param>
/// <returns>Converted integer.</returns> /// <returns>Converted integer.</returns>
public static Int32 Hex2Int(this Char value) => value >= '0' && value <= '9' ? value - '0' : value >= 'A' && value <= 'F' ? value - 'A' + 10 : value >= 'a' && value <= 'f' ? value - 'a' + 10 : -1; public static Int32 Hex2Int(this Char value) => value >= '0' && value <= '9' ? value - '0' : value >= 'A' && value <= 'F' ? value - 'A' + 10 : value >= 'a' && value <= 'f' ? value - 'a' + 10 : -1;*/
} }
} }

View File

@ -9,6 +9,7 @@ namespace Swan {
/// Provides various extension methods for value types and structs. /// Provides various extension methods for value types and structs.
/// </summary> /// </summary>
public static class ValueTypeExtensions { public static class ValueTypeExtensions {
/// <summary> /// <summary>
/// Clamps the specified value between the minimum and the maximum. /// Clamps the specified value between the minimum and the maximum.
/// </summary> /// </summary>
@ -17,6 +18,7 @@ namespace Swan {
/// <param name="min">The minimum.</param> /// <param name="min">The minimum.</param>
/// <param name="max">The maximum.</param> /// <param name="max">The maximum.</param>
/// <returns>A value that indicates the relative order of the objects being compared.</returns> /// <returns>A value that indicates the relative order of the objects being compared.</returns>
// [Obsolete("NEED", false)]
public static T Clamp<T>(this T @this, T min, T max) where T : struct, IComparable => @this.CompareTo(min) < 0 ? min : @this.CompareTo(max) > 0 ? max : @this; public static T Clamp<T>(this T @this, T min, T max) where T : struct, IComparable => @this.CompareTo(min) < 0 ? min : @this.CompareTo(max) > 0 ? max : @this;
/// <summary> /// <summary>
@ -26,8 +28,9 @@ namespace Swan {
/// <param name="min">The minimum.</param> /// <param name="min">The minimum.</param>
/// <param name="max">The maximum.</param> /// <param name="max">The maximum.</param>
/// <returns>A value that indicates the relative order of the objects being compared.</returns> /// <returns>A value that indicates the relative order of the objects being compared.</returns>
// [Obsolete("NEED",false)]
public static Int32 Clamp(this Int32 @this, Int32 min, Int32 max) => @this < min ? min : (@this > max ? max : @this); public static Int32 Clamp(this Int32 @this, Int32 min, Int32 max) => @this < min ? min : (@this > max ? max : @this);
/*
/// <summary> /// <summary>
/// Determines whether the specified value is between a minimum and a maximum value. /// Determines whether the specified value is between a minimum and a maximum value.
/// </summary> /// </summary>
@ -131,5 +134,6 @@ namespace Swan {
return data; return data;
} }
*/
} }
} }

View File

@ -27,7 +27,7 @@ namespace Swan {
/// </returns> /// </returns>
public static Int32 CopyPropertiesTo<T>(this T source, Object? target, params String[]? ignoreProperties) where T : class => ObjectMapper.Copy(source, target, GetCopyableProperties(target), ignoreProperties); public static Int32 CopyPropertiesTo<T>(this T source, Object? target, params String[]? ignoreProperties) where T : class => ObjectMapper.Copy(source, target, GetCopyableProperties(target), ignoreProperties);
/// <summary> /*/// <summary>
/// Iterates over the public, instance, readable properties of the source and /// Iterates over the public, instance, readable properties of the source and
/// tries to write a compatible value to a public, instance, writable property in the destination. /// tries to write a compatible value to a public, instance, writable property in the destination.
/// </summary> /// </summary>
@ -37,7 +37,7 @@ namespace Swan {
/// <returns> /// <returns>
/// Number of properties that were successfully copied. /// Number of properties that were successfully copied.
/// </returns> /// </returns>
public static Int32 CopyOnlyPropertiesTo(this Object source, Object target, params String[]? propertiesToCopy) => ObjectMapper.Copy(source, target, propertiesToCopy); public static Int32 CopyOnlyPropertiesTo(this Object source, Object target, params String[]? propertiesToCopy) => ObjectMapper.Copy(source, target, propertiesToCopy);*/
/// <summary> /// <summary>
/// Copies the properties to new instance of T. /// Copies the properties to new instance of T.
@ -60,7 +60,7 @@ namespace Swan {
return target; return target;
} }
/// <summary> /*/// <summary>
/// Copies the only properties to new instance of T. /// Copies the only properties to new instance of T.
/// </summary> /// </summary>
/// <typeparam name="T">Object Type.</typeparam> /// <typeparam name="T">Object Type.</typeparam>
@ -161,7 +161,7 @@ namespace Swan {
} }
throw new AggregateException(exceptions); throw new AggregateException(exceptions);
} }*/
/// <summary> /// <summary>
/// Gets the copyable properties. /// Gets the copyable properties.

View File

@ -15,8 +15,7 @@ namespace Swan.Formatters {
/// serializer such as the beloved Json.NET. /// serializer such as the beloved Json.NET.
/// </summary> /// </summary>
public class SerializerOptions { public class SerializerOptions {
private static readonly ConcurrentDictionary<Type, Dictionary<Tuple<String, String>, MemberInfo>> private static readonly ConcurrentDictionary<Type, Dictionary<Tuple<String, String>, MemberInfo>> TypeCache = new ConcurrentDictionary<Type, Dictionary<Tuple<String, String>, MemberInfo>>();
TypeCache = new ConcurrentDictionary<Type, Dictionary<Tuple<String, String>, MemberInfo>>();
private readonly String[]? _includeProperties; private readonly String[]? _includeProperties;
private readonly String[]? _excludeProperties; private readonly String[]? _excludeProperties;

View File

@ -99,7 +99,7 @@ namespace Swan.Formatters {
/// </example> /// </example>
public static String Serialize(Object? obj, Boolean format = false, String? typeSpecifier = null, Boolean includeNonPublic = false, String[]? includedNames = null, params String[] excludedNames) => Serialize(obj, format, typeSpecifier, includeNonPublic, includedNames, excludedNames, null, JsonSerializerCase.None); public static String Serialize(Object? obj, Boolean format = false, String? typeSpecifier = null, Boolean includeNonPublic = false, String[]? includedNames = null, params String[] excludedNames) => Serialize(obj, format, typeSpecifier, includeNonPublic, includedNames, excludedNames, null, JsonSerializerCase.None);
/// <summary> /*/// <summary>
/// Serializes the specified object into a JSON string. /// Serializes the specified object into a JSON string.
/// </summary> /// </summary>
/// <param name="obj">The object.</param> /// <param name="obj">The object.</param>
@ -109,7 +109,7 @@ namespace Swan.Formatters {
/// <returns> /// <returns>
/// A <see cref="System.String" /> that represents the current object. /// A <see cref="System.String" /> that represents the current object.
/// </returns> /// </returns>
public static String Serialize(Object? obj, JsonSerializerCase jsonSerializerCase, Boolean format = false, String? typeSpecifier = null) => Serialize(obj, format, typeSpecifier, false, null, null, null, jsonSerializerCase); public static String Serialize(Object? obj, JsonSerializerCase jsonSerializerCase, Boolean format = false, String? typeSpecifier = null) => Serialize(obj, format, typeSpecifier, false, null, null, null, jsonSerializerCase);*/
/// <summary> /// <summary>
/// Serializes the specified object into a JSON string. /// Serializes the specified object into a JSON string.
@ -145,7 +145,7 @@ namespace Swan.Formatters {
/// </returns> /// </returns>
public static String Serialize(Object? obj, SerializerOptions options) => Serializer.Serialize(obj, 0, options); public static String Serialize(Object? obj, SerializerOptions options) => Serializer.Serialize(obj, 0, options);
/// <summary> /*/// <summary>
/// Serializes the specified object only including the specified property names. /// Serializes the specified object only including the specified property names.
/// </summary> /// </summary>
/// <param name="obj">The object.</param> /// <param name="obj">The object.</param>
@ -205,7 +205,7 @@ namespace Swan.Formatters {
/// } /// }
/// </code> /// </code>
/// </example> /// </example>
public static String SerializeExcluding(Object? obj, Boolean format, params String[] excludeNames) => Serialize(obj, new SerializerOptions(format, null, null, excludeNames)); public static String SerializeExcluding(Object? obj, Boolean format, params String[] excludeNames) => Serialize(obj, new SerializerOptions(format, null, null, excludeNames));*/
/// <summary> /// <summary>
/// Deserializes the specified json string as either a Dictionary[string, object] or as a List[object] /// Deserializes the specified json string as either a Dictionary[string, object] or as a List[object]
@ -258,7 +258,7 @@ namespace Swan.Formatters {
/// </code></example> /// </code></example>
public static Object? Deserialize(String? json) => Deserialize(json, JsonSerializerCase.None); public static Object? Deserialize(String? json) => Deserialize(json, JsonSerializerCase.None);
/// <summary> /*/// <summary>
/// Deserializes the specified JSON string and converts it to the specified object type. /// Deserializes the specified JSON string and converts it to the specified object type.
/// Non-public constructors and property setters are ignored. /// Non-public constructors and property setters are ignored.
/// </summary> /// </summary>
@ -304,7 +304,7 @@ namespace Swan.Formatters {
/// <returns> /// <returns>
/// Type of the current conversion from json result. /// Type of the current conversion from json result.
/// </returns> /// </returns>
public static Object? Deserialize(String json, Type resultType, Boolean includeNonPublic = false, JsonSerializerCase jsonSerializerCase = JsonSerializerCase.None) => Converter.FromJsonResult(Deserializer.DeserializeInternal(json), jsonSerializerCase, resultType, includeNonPublic); public static Object? Deserialize(String json, Type resultType, Boolean includeNonPublic = false, JsonSerializerCase jsonSerializerCase = JsonSerializerCase.None) => Converter.FromJsonResult(Deserializer.DeserializeInternal(json), jsonSerializerCase, resultType, includeNonPublic);*/
#endregion #endregion

View File

@ -7,7 +7,7 @@ namespace Swan.Formatters {
/// <seealso cref="Attribute" /> /// <seealso cref="Attribute" />
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class JsonPropertyAttribute : Attribute { public sealed class JsonPropertyAttribute : Attribute {
/// <summary> /*/// <summary>
/// Initializes a new instance of the <see cref="JsonPropertyAttribute" /> class. /// Initializes a new instance of the <see cref="JsonPropertyAttribute" /> class.
/// </summary> /// </summary>
/// <param name="propertyName">Name of the property.</param> /// <param name="propertyName">Name of the property.</param>
@ -15,7 +15,7 @@ namespace Swan.Formatters {
public JsonPropertyAttribute(String propertyName, Boolean ignored = false) { public JsonPropertyAttribute(String propertyName, Boolean ignored = false) {
this.PropertyName = propertyName ?? throw new ArgumentNullException(nameof(propertyName)); this.PropertyName = propertyName ?? throw new ArgumentNullException(nameof(propertyName));
this.Ignored = ignored; this.Ignored = ignored;
} }*/
/// <summary> /// <summary>
/// Gets or sets the name of the property. /// Gets or sets the name of the property.

View File

@ -6,6 +6,7 @@ namespace Swan.Logging {
/// Represents a Console implementation of <c>ILogger</c>. /// Represents a Console implementation of <c>ILogger</c>.
/// </summary> /// </summary>
/// <seealso cref="ILogger" /> /// <seealso cref="ILogger" />
// [Obsolete("NEED", false)]
public class ConsoleLogger : TextLogger, ILogger { public class ConsoleLogger : TextLogger, ILogger {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ConsoleLogger"/> class. /// Initializes a new instance of the <see cref="ConsoleLogger"/> class.
@ -122,6 +123,7 @@ namespace Swan.Logging {
public LogLevel LogLevel { get; set; } = DebugLogger.IsDebuggerAttached ? LogLevel.Trace : LogLevel.Info; public LogLevel LogLevel { get; set; } = DebugLogger.IsDebuggerAttached ? LogLevel.Trace : LogLevel.Info;
/// <inheritdoc /> /// <inheritdoc />
// [Obsolete("NEED", false)]
public void Log(LogMessageReceivedEventArgs logEvent) { public void Log(LogMessageReceivedEventArgs logEvent) {
// Select the writer based on the message type // Select the writer based on the message type
TerminalWriters writer = logEvent.MessageType == LogLevel.Error ? TerminalWriters.StandardError : TerminalWriters.StandardOutput; TerminalWriters writer = logEvent.MessageType == LogLevel.Error ? TerminalWriters.StandardError : TerminalWriters.StandardOutput;

View File

@ -7,6 +7,7 @@ namespace Swan.Logging {
/// Debug console using System.Diagnostics.Debug. /// Debug console using System.Diagnostics.Debug.
/// </summary> /// </summary>
/// <seealso cref="ILogger" /> /// <seealso cref="ILogger" />
// [Obsolete("NEED", false)]
public class DebugLogger : TextLogger, ILogger { public class DebugLogger : TextLogger, ILogger {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DebugLogger"/> class. /// Initializes a new instance of the <see cref="DebugLogger"/> class.
@ -35,6 +36,7 @@ namespace Swan.Logging {
public LogLevel LogLevel { get; set; } = IsDebuggerAttached ? LogLevel.Trace : LogLevel.None; public LogLevel LogLevel { get; set; } = IsDebuggerAttached ? LogLevel.Trace : LogLevel.None;
/// <inheritdoc/> /// <inheritdoc/>
// [Obsolete("NEED", false)]
public void Log(LogMessageReceivedEventArgs logEvent) { public void Log(LogMessageReceivedEventArgs logEvent) {
(String outputMessage, ConsoleColor _) = this.GetOutputAndColor(logEvent); (String outputMessage, ConsoleColor _) = this.GetOutputAndColor(logEvent);

View File

@ -4,6 +4,7 @@ namespace Swan.Logging {
/// <summary> /// <summary>
/// Interface for a logger implementation. /// Interface for a logger implementation.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
public interface ILogger : IDisposable { public interface ILogger : IDisposable {
/// <summary> /// <summary>
/// Gets the log level. /// Gets the log level.

View File

@ -8,6 +8,7 @@ namespace Swan {
/// your logger of choice. /// your logger of choice.
/// </summary> /// </summary>
/// <seealso cref="System.EventArgs" /> /// <seealso cref="System.EventArgs" />
// [Obsolete("NEED", false)]
public class LogMessageReceivedEventArgs : EventArgs { public class LogMessageReceivedEventArgs : EventArgs {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LogMessageReceivedEventArgs" /> class. /// Initializes a new instance of the <see cref="LogMessageReceivedEventArgs" /> class.

View File

@ -10,11 +10,14 @@ namespace Swan.Logging {
/// loggers instances. By default, the <c>ConsoleLogger</c> is registered. /// loggers instances. By default, the <c>ConsoleLogger</c> is registered.
/// </summary> /// </summary>
public static class Logger { public static class Logger {
private static readonly Object SyncLock = new Object(); /*private static readonly Object SyncLock = new Object();*/
// [Obsolete("NEED", false)]
private static readonly List<ILogger> Loggers = new List<ILogger>(); private static readonly List<ILogger> Loggers = new List<ILogger>();
// [Obsolete("NEED", false)]
private static UInt64 _loggingSequence; private static UInt64 _loggingSequence;
// [Obsolete("NEED", false)]
static Logger() { static Logger() {
if(Terminal.IsConsolePresent) { if(Terminal.IsConsolePresent) {
Loggers.Add(ConsoleLogger.Instance); Loggers.Add(ConsoleLogger.Instance);
@ -25,7 +28,7 @@ namespace Swan.Logging {
} }
} }
#region Standard Public API /*#region Standard Public API
/// <summary> /// <summary>
/// Registers the logger. /// Registers the logger.
@ -298,11 +301,11 @@ namespace Swan.Logging {
#endregion #endregion
#endregion #endregion*/
#region Extended Public API #region Extended Public API
/// <summary> /*/// <summary>
/// Logs the specified message. /// Logs the specified message.
/// </summary> /// </summary>
/// <param name="message">The message.</param> /// <param name="message">The message.</param>
@ -324,7 +327,7 @@ namespace Swan.Logging {
/// <param name="callerMemberName">Name of the caller member.</param> /// <param name="callerMemberName">Name of the caller member.</param>
/// <param name="callerFilePath">The caller file path.</param> /// <param name="callerFilePath">The caller file path.</param>
/// <param name="callerLineNumber">The caller line number.</param> /// <param name="callerLineNumber">The caller line number.</param>
public static void Log(this String message, Type source, LogLevel messageType, Object extendedData = null, [CallerMemberName] String callerMemberName = "", [CallerFilePath] String callerFilePath = "", [CallerLineNumber] Int32 callerLineNumber = 0) => LogMessage(messageType, message, source?.FullName, extendedData, callerMemberName, callerFilePath, callerLineNumber); public static void Log(this String message, Type source, LogLevel messageType, Object extendedData = null, [CallerMemberName] String callerMemberName = "", [CallerFilePath] String callerFilePath = "", [CallerLineNumber] Int32 callerLineNumber = 0) => LogMessage(messageType, message, source?.FullName, extendedData, callerMemberName, callerFilePath, callerLineNumber);*/
/// <summary> /// <summary>
/// Logs an error message to the console's standard error. /// Logs an error message to the console's standard error.
@ -335,9 +338,10 @@ namespace Swan.Logging {
/// <param name="callerMemberName">Name of the caller member. This is automatically populated.</param> /// <param name="callerMemberName">Name of the caller member. This is automatically populated.</param>
/// <param name="callerFilePath">The caller file path. This is automatically populated.</param> /// <param name="callerFilePath">The caller file path. This is automatically populated.</param>
/// <param name="callerLineNumber">The caller line number. This is automatically populated.</param> /// <param name="callerLineNumber">The caller line number. This is automatically populated.</param>
// [Obsolete("NEED", false)]
public static void Log(this Exception ex, String source = null, String message = null, [CallerMemberName] String callerMemberName = "", [CallerFilePath] String callerFilePath = "", [CallerLineNumber] Int32 callerLineNumber = 0) => LogMessage(LogLevel.Error, message ?? ex.Message, source ?? ex.Source, ex, callerMemberName, callerFilePath, callerLineNumber); public static void Log(this Exception ex, String source = null, String message = null, [CallerMemberName] String callerMemberName = "", [CallerFilePath] String callerFilePath = "", [CallerLineNumber] Int32 callerLineNumber = 0) => LogMessage(LogLevel.Error, message ?? ex.Message, source ?? ex.Source, ex, callerMemberName, callerFilePath, callerLineNumber);
/// <summary> /*/// <summary>
/// Logs an error message to the console's standard error. /// Logs an error message to the console's standard error.
/// </summary> /// </summary>
/// <param name="ex">The ex.</param> /// <param name="ex">The ex.</param>
@ -384,11 +388,11 @@ namespace Swan.Logging {
String message = $"{text} ({obj.GetType()}): {Environment.NewLine}{obj.Stringify().Indent(5)}"; String message = $"{text} ({obj.GetType()}): {Environment.NewLine}{obj.Stringify().Indent(5)}";
LogMessage(LogLevel.Trace, message, source?.FullName, obj, callerMemberName, callerFilePath, callerLineNumber); LogMessage(LogLevel.Trace, message, source?.FullName, obj, callerMemberName, callerFilePath, callerLineNumber);
} }*/
#endregion #endregion
private static void RemoveLogger(Func<ILogger, Boolean> criteria) { /*private static void RemoveLogger(Func<ILogger, Boolean> criteria) {
lock(SyncLock) { lock(SyncLock) {
ILogger loggerInstance = Loggers.FirstOrDefault(criteria); ILogger loggerInstance = Loggers.FirstOrDefault(criteria);
@ -400,8 +404,9 @@ namespace Swan.Logging {
_ = Loggers.Remove(loggerInstance); _ = Loggers.Remove(loggerInstance);
} }
} }*/
// [Obsolete("NEED", false)]
private static void LogMessage(LogLevel logLevel, String message, String sourceName, Object extendedData, String callerMemberName, String callerFilePath, Int32 callerLineNumber) { private static void LogMessage(LogLevel logLevel, String message, String sourceName, Object extendedData, String callerMemberName, String callerFilePath, Int32 callerLineNumber) {
UInt64 sequence = _loggingSequence; UInt64 sequence = _loggingSequence;
DateTime date = DateTime.UtcNow; DateTime date = DateTime.UtcNow;

View File

@ -5,6 +5,7 @@ namespace Swan.Lite.Logging {
/// <summary> /// <summary>
/// Use this class for text-based logger. /// Use this class for text-based logger.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
public abstract class TextLogger { public abstract class TextLogger {
/// <summary> /// <summary>
/// Gets or sets the logging time format. /// Gets or sets the logging time format.
@ -22,6 +23,7 @@ namespace Swan.Lite.Logging {
/// <returns> /// <returns>
/// The output message formatted and the color of the console to be used. /// The output message formatted and the color of the console to be used.
/// </returns> /// </returns>
// [Obsolete("NEED", false)]
protected (String outputMessage, ConsoleColor color) GetOutputAndColor(LogMessageReceivedEventArgs logEvent) { protected (String outputMessage, ConsoleColor color) GetOutputAndColor(LogMessageReceivedEventArgs logEvent) {
(String prefix, ConsoleColor color) = GetConsoleColorAndPrefix(logEvent.MessageType); (String prefix, ConsoleColor color) = GetConsoleColorAndPrefix(logEvent.MessageType);

View File

@ -33,7 +33,7 @@ namespace Swan.Mappers {
get; get;
} }
/// <summary> /*/// <summary>
/// Maps the property. /// Maps the property.
/// </summary> /// </summary>
/// <typeparam name="TDestinationProperty">The type of the destination property.</typeparam> /// <typeparam name="TDestinationProperty">The type of the destination property.</typeparam>
@ -104,6 +104,6 @@ namespace Swan.Mappers {
} }
return sourceMembers; return sourceMembers;
} }*/
} }
} }

View File

@ -1,4 +1,4 @@
using System; /*using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -17,4 +17,4 @@ namespace Swan.Mappers {
public Int32 GetHashCode(PropertyInfo obj) => obj.Name.GetHashCode() + obj.PropertyType.Name.GetHashCode(); public Int32 GetHashCode(PropertyInfo obj) => obj.Name.GetHashCode() + obj.PropertyType.Name.GetHashCode();
} }
} }
} }*/

View File

@ -79,17 +79,17 @@ namespace Swan.Mappers {
/// </code> /// </code>
/// </example> /// </example>
public partial class ObjectMapper { public partial class ObjectMapper {
private static readonly Lazy<ObjectMapper> LazyInstance = new Lazy<ObjectMapper>(() => new ObjectMapper()); /*private static readonly Lazy<ObjectMapper> LazyInstance = new Lazy<ObjectMapper>(() => new ObjectMapper());
private readonly List<IObjectMap> _maps = new List<IObjectMap>(); private readonly List<IObjectMap> _maps = new List<IObjectMap>();*/
/// <summary> /*/// <summary>
/// Gets the current. /// Gets the current.
/// </summary> /// </summary>
/// <value> /// <value>
/// The current. /// The current.
/// </value> /// </value>
public static ObjectMapper Current => LazyInstance.Value; public static ObjectMapper Current => LazyInstance.Value;*/
/// <summary> /// <summary>
/// Copies the specified source. /// Copies the specified source.
@ -145,7 +145,7 @@ namespace Swan.Mappers {
return CopyInternal(target, source.ToDictionary(x => x.Key.ToLowerInvariant(), x => Tuple.Create(typeof(Object), x.Value)), propertiesToCopy, ignoreProperties); return CopyInternal(target, source.ToDictionary(x => x.Key.ToLowerInvariant(), x => Tuple.Create(typeof(Object), x.Value)), propertiesToCopy, ignoreProperties);
} }
/// <summary> /*/// <summary>
/// Creates the map. /// Creates the map.
/// </summary> /// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam> /// <typeparam name="TSource">The type of the source.</typeparam>
@ -215,7 +215,7 @@ namespace Swan.Mappers {
} }
return destination; return destination;
} }*/
private static Int32 CopyInternal(Object target, Dictionary<String, Tuple<Type, Object>> sourceProperties, IEnumerable<String>? propertiesToCopy, IEnumerable<String>? ignoreProperties) { private static Int32 CopyInternal(Object target, Dictionary<String, Tuple<Type, Object>> sourceProperties, IEnumerable<String>? propertiesToCopy, IEnumerable<String>? ignoreProperties) {
// Filter properties // Filter properties

View File

@ -1,4 +1,4 @@
using System; /*using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
@ -93,4 +93,4 @@ namespace Swan.Net.Dns {
Task<DnsClientResponse> Request(DnsClientRequest request); Task<DnsClientResponse> Request(DnsClientRequest request);
} }
} }
} }*/

View File

@ -1,4 +1,5 @@
#nullable enable /*
#nullable enable
using Swan.Formatters; using Swan.Formatters;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -555,4 +556,4 @@ namespace Swan.Net.Dns {
} }
} }
} }
} }*/

View File

@ -1,4 +1,4 @@
using Swan.Formatters; /*using Swan.Formatters;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -341,4 +341,4 @@ namespace Swan.Net.Dns {
} }
} }
} }
} }*/

View File

@ -1,4 +1,4 @@
using Swan.Formatters; /*using Swan.Formatters;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -171,4 +171,4 @@ namespace Swan.Net.Dns {
} }
} }
} }
} }*/

View File

@ -1,4 +1,4 @@
using System; /*using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
#nullable enable #nullable enable
@ -62,4 +62,4 @@ namespace Swan.Net.Dns {
return request.Resolve(); return request.Resolve();
} }
} }
} }*/

View File

@ -1,4 +1,4 @@
#nullable enable /*#nullable enable
using System; using System;
namespace Swan.Net.Dns { namespace Swan.Net.Dns {
@ -26,3 +26,4 @@ namespace Swan.Net.Dns {
private static String Format(DnsClient.IDnsResponse response) => $"Invalid response received with code {response.ResponseCode}"; private static String Format(DnsClient.IDnsResponse response) => $"Invalid response received with code {response.ResponseCode}";
} }
} }
*/

View File

@ -1,4 +1,4 @@
namespace Swan.Net.Dns { /*namespace Swan.Net.Dns {
using System.Collections.Generic; using System.Collections.Generic;
/// <summary> /// <summary>
@ -128,3 +128,4 @@
public IList<DnsRecord> AuthorityRecords => this._mAuthorityRecords; public IList<DnsRecord> AuthorityRecords => this._mAuthorityRecords;
} }
} }
*/

View File

@ -1,4 +1,4 @@
using System; /*using System;
using System.Net; using System.Net;
using System.Text; using System.Text;
@ -237,3 +237,4 @@ namespace Swan.Net.Dns {
} }
} }
} }
*/

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming /*// ReSharper disable InconsistentNaming
namespace Swan.Net.Dns { namespace Swan.Net.Dns {
/// <summary> /// <summary>
/// Enumerates the different DNS record types. /// Enumerates the different DNS record types.
@ -165,3 +165,4 @@ namespace Swan.Net.Dns {
NotZone, NotZone,
} }
} }
*/

View File

@ -1,4 +1,4 @@
using Swan.Net.Dns; //using Swan.Net.Dns;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,7 +15,7 @@ namespace Swan.Net {
/// a DNS client to query DNS records of any kind, and an NTP client. /// a DNS client to query DNS records of any kind, and an NTP client.
/// </summary> /// </summary>
public static class Network { public static class Network {
/// <summary> /*/// <summary>
/// The DNS default port. /// The DNS default port.
/// </summary> /// </summary>
public const Int32 DnsDefaultPort = 53; public const Int32 DnsDefaultPort = 53;
@ -23,7 +23,7 @@ namespace Swan.Net {
/// <summary> /// <summary>
/// The NTP default port. /// The NTP default port.
/// </summary> /// </summary>
public const Int32 NtpDefaultPort = 123; public const Int32 NtpDefaultPort = 123;*/
/// <summary> /// <summary>
/// Gets the name of the host. /// Gets the name of the host.
@ -31,9 +31,10 @@ namespace Swan.Net {
/// <value> /// <value>
/// The name of the host. /// The name of the host.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static String HostName => IPGlobalProperties.GetIPGlobalProperties().HostName; public static String HostName => IPGlobalProperties.GetIPGlobalProperties().HostName;
/// <summary> /*/// <summary>
/// Gets the name of the network domain. /// Gets the name of the network domain.
/// </summary> /// </summary>
/// <value> /// <value>
@ -284,6 +285,6 @@ namespace Swan.Net {
return await GetNetworkTimeUtcAsync(addresses.First(), port).ConfigureAwait(false); return await GetNetworkTimeUtcAsync(addresses.First(), port).ConfigureAwait(false);
} }
#endregion #endregion*/
} }
} }

View File

@ -5,6 +5,7 @@ namespace Swan {
/// Represents the text of the standard output and standard error /// Represents the text of the standard output and standard error
/// of a process, including its exit code. /// of a process, including its exit code.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
public class ProcessResult { public class ProcessResult {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ProcessResult" /> class. /// Initializes a new instance of the <see cref="ProcessResult" /> class.

View File

@ -19,6 +19,7 @@ namespace Swan {
/// </summary> /// </summary>
/// <param name="processData">The process data.</param> /// <param name="processData">The process data.</param>
/// <param name="process">The process.</param> /// <param name="process">The process.</param>
// [Obsolete("NEED", false)]
public delegate void ProcessDataReceivedCallback(Byte[] processData, Process process); public delegate void ProcessDataReceivedCallback(Byte[] processData, Process process);
/// <summary> /// <summary>
@ -53,12 +54,13 @@ namespace Swan {
/// } /// }
/// </code> /// </code>
/// </example> /// </example>
// [Obsolete("NEED", false)]
public static async Task<String> GetProcessOutputAsync(String filename, String arguments = "", String? workingDirectory = null, CancellationToken cancellationToken = default) { public static async Task<String> GetProcessOutputAsync(String filename, String arguments = "", String? workingDirectory = null, CancellationToken cancellationToken = default) {
ProcessResult result = await GetProcessResultAsync(filename, arguments, workingDirectory, cancellationToken: cancellationToken).ConfigureAwait(false); ProcessResult result = await GetProcessResultAsync(filename, arguments, workingDirectory, cancellationToken: cancellationToken).ConfigureAwait(false);
return result.ExitCode == 0 ? result.StandardOutput : result.StandardError; return result.ExitCode == 0 ? result.StandardOutput : result.StandardError;
} }
/// <summary> /*/// <summary>
/// Runs the process asynchronously and if the exit code is 0, /// Runs the process asynchronously and if the exit code is 0,
/// returns all of the standard output text. If the exit code is something other than 0 /// returns all of the standard output text. If the exit code is something other than 0
/// it returns the contents of standard error. /// it returns the contents of standard error.
@ -75,7 +77,7 @@ namespace Swan {
public static async Task<String> GetProcessEncodedOutputAsync(String filename, String arguments = "", Encoding? encoding = null, CancellationToken cancellationToken = default) { public static async Task<String> GetProcessEncodedOutputAsync(String filename, String arguments = "", Encoding? encoding = null, CancellationToken cancellationToken = default) {
ProcessResult result = await GetProcessResultAsync(filename, arguments, null, encoding, cancellationToken).ConfigureAwait(false); ProcessResult result = await GetProcessResultAsync(filename, arguments, null, encoding, cancellationToken).ConfigureAwait(false);
return result.ExitCode == 0 ? result.StandardOutput : result.StandardError; return result.ExitCode == 0 ? result.StandardOutput : result.StandardError;
} }*/
/// <summary> /// <summary>
/// Executes a process asynchronously and returns the text of the standard output and standard error streams /// Executes a process asynchronously and returns the text of the standard output and standard error streams
@ -89,6 +91,7 @@ namespace Swan {
/// Text of the standard output and standard error streams along with the exit code as a <see cref="ProcessResult" /> instance. /// Text of the standard output and standard error streams along with the exit code as a <see cref="ProcessResult" /> instance.
/// </returns> /// </returns>
/// <exception cref="ArgumentNullException">filename.</exception> /// <exception cref="ArgumentNullException">filename.</exception>
// [Obsolete("NEED", false)]
public static Task<ProcessResult> GetProcessResultAsync(String filename, String arguments = "", CancellationToken cancellationToken = default) => GetProcessResultAsync(filename, arguments, null, Definitions.CurrentAnsiEncoding, cancellationToken); public static Task<ProcessResult> GetProcessResultAsync(String filename, String arguments = "", CancellationToken cancellationToken = default) => GetProcessResultAsync(filename, arguments, null, Definitions.CurrentAnsiEncoding, cancellationToken);
/// <summary> /// <summary>
@ -128,6 +131,7 @@ namespace Swan {
/// } /// }
/// } /// }
/// </code></example> /// </code></example>
// [Obsolete("NEED", false)]
public static async Task<ProcessResult> GetProcessResultAsync(String filename, String arguments, String? workingDirectory, Encoding? encoding = null, CancellationToken cancellationToken = default) { public static async Task<ProcessResult> GetProcessResultAsync(String filename, String arguments, String? workingDirectory, Encoding? encoding = null, CancellationToken cancellationToken = default) {
if(filename == null) { if(filename == null) {
throw new ArgumentNullException(nameof(filename)); throw new ArgumentNullException(nameof(filename));
@ -163,6 +167,7 @@ namespace Swan {
/// <returns> /// <returns>
/// Value type will be -1 for forceful termination of the process. /// Value type will be -1 for forceful termination of the process.
/// </returns> /// </returns>
// [Obsolete("NEED", false)]
public static Task<Int32> RunProcessAsync(String filename, String arguments, String? workingDirectory, ProcessDataReceivedCallback onOutputData, ProcessDataReceivedCallback? onErrorData, Encoding encoding, Boolean syncEvents = true, CancellationToken cancellationToken = default) { public static Task<Int32> RunProcessAsync(String filename, String arguments, String? workingDirectory, ProcessDataReceivedCallback onOutputData, ProcessDataReceivedCallback? onErrorData, Encoding encoding, Boolean syncEvents = true, CancellationToken cancellationToken = default) {
if(filename == null) { if(filename == null) {
throw new ArgumentNullException(nameof(filename)); throw new ArgumentNullException(nameof(filename));
@ -273,6 +278,7 @@ namespace Swan {
/// } /// }
/// </code> /// </code>
/// </example> /// </example>
// [Obsolete("NEED", false)]
public static Task<Int32> RunProcessAsync(String filename, String arguments, ProcessDataReceivedCallback onOutputData, ProcessDataReceivedCallback? onErrorData, Boolean syncEvents = true, CancellationToken cancellationToken = default) => RunProcessAsync(filename, arguments, null, onOutputData, onErrorData, Definitions.CurrentAnsiEncoding, syncEvents, cancellationToken); public static Task<Int32> RunProcessAsync(String filename, String arguments, ProcessDataReceivedCallback onOutputData, ProcessDataReceivedCallback? onErrorData, Boolean syncEvents = true, CancellationToken cancellationToken = default) => RunProcessAsync(filename, arguments, null, onOutputData, onErrorData, Definitions.CurrentAnsiEncoding, syncEvents, cancellationToken);
/// <summary> /// <summary>
@ -284,6 +290,7 @@ namespace Swan {
/// <param name="syncEvents">if set to <c>true</c> [synchronize events].</param> /// <param name="syncEvents">if set to <c>true</c> [synchronize events].</param>
/// <param name="ct">The cancellation token.</param> /// <param name="ct">The cancellation token.</param>
/// <returns>Total copies stream.</returns> /// <returns>Total copies stream.</returns>
// [Obsolete("NEED", false)]
private static Task<UInt64> CopyStreamAsync(Process process, Stream baseStream, ProcessDataReceivedCallback? onDataCallback, Boolean syncEvents, CancellationToken ct) => Task.Run(async () => { private static Task<UInt64> CopyStreamAsync(Process process, Stream baseStream, ProcessDataReceivedCallback? onDataCallback, Boolean syncEvents, CancellationToken ct) => Task.Run(async () => {
// define some state variables // define some state variables
Byte[] swapBuffer = new Byte[2048]; // the buffer to copy data from one stream to the next Byte[] swapBuffer = new Byte[2048]; // the buffer to copy data from one stream to the next

View File

@ -37,7 +37,7 @@ namespace Swan.Reflection {
get; get;
} }
/// <summary> /*/// <summary>
/// Determines whether [contains] [the specified member]. /// Determines whether [contains] [the specified member].
/// </summary> /// </summary>
/// <typeparam name="T">The type of the attribute to be retrieved.</typeparam> /// <typeparam name="T">The type of the attribute to be retrieved.</typeparam>
@ -79,7 +79,7 @@ namespace Swan.Reflection {
} }
return this.Retrieve(new Tuple<Object, Type>(member, type), t => member.GetCustomAttributes(type, inherit)); return this.Retrieve(new Tuple<Object, Type>(member, type), t => member.GetCustomAttributes(type, inherit));
} }*/
/// <summary> /// <summary>
/// Gets one attribute of a specific type from a member. /// Gets one attribute of a specific type from a member.
@ -98,7 +98,7 @@ namespace Swan.Reflection {
return ConvertToAttribute<T>(attr); return ConvertToAttribute<T>(attr);
} }
/// <summary> /*/// <summary>
/// Gets one attribute of a specific type from a generic type. /// Gets one attribute of a specific type from a generic type.
/// </summary> /// </summary>
/// <typeparam name="TAttribute">The type of the attribute.</typeparam> /// <typeparam name="TAttribute">The type of the attribute.</typeparam>
@ -146,7 +146,7 @@ namespace Swan.Reflection {
} }
return this.PropertyTypeCache.RetrieveAllProperties<T>(true).ToDictionary(x => x, x => this.Retrieve(x, attributeType, inherit)); return this.PropertyTypeCache.RetrieveAllProperties<T>(true).ToDictionary(x => x, x => this.Retrieve(x, attributeType, inherit));
} }*/
private static T ConvertToAttribute<T>(IEnumerable<Object> attr) where T : Attribute => attr?.Any() != true ? (default!) : attr.Count() == 1 ? (T)Convert.ChangeType(attr.First(), typeof(T)) : throw new AmbiguousMatchException("Multiple custom attributes of the same type found."); private static T ConvertToAttribute<T>(IEnumerable<Object> attr) where T : Attribute => attr?.Any() != true ? (default!) : attr.Count() == 1 ? (T)Convert.ChangeType(attr.First(), typeof(T)) : throw new AmbiguousMatchException("Multiple custom attributes of the same type found.");

View File

@ -17,7 +17,7 @@ namespace Swan.Lite.Reflection {
/// </value> /// </value>
public static Lazy<ConstructorTypeCache> DefaultCache { get; } = new Lazy<ConstructorTypeCache>(() => new ConstructorTypeCache()); public static Lazy<ConstructorTypeCache> DefaultCache { get; } = new Lazy<ConstructorTypeCache>(() => new ConstructorTypeCache());
/// <summary> /*/// <summary>
/// Retrieves all constructors order by the number of parameters ascending. /// Retrieves all constructors order by the number of parameters ascending.
/// </summary> /// </summary>
/// <typeparam name="T">The type to inspect.</typeparam> /// <typeparam name="T">The type to inspect.</typeparam>
@ -25,7 +25,7 @@ namespace Swan.Lite.Reflection {
/// <returns> /// <returns>
/// A collection with all the constructors in the given type. /// A collection with all the constructors in the given type.
/// </returns> /// </returns>
public IEnumerable<Tuple<ConstructorInfo, ParameterInfo[]>> RetrieveAllConstructors<T>(Boolean includeNonPublic = false) => this.Retrieve<T>(GetConstructors(includeNonPublic)); public IEnumerable<Tuple<ConstructorInfo, ParameterInfo[]>> RetrieveAllConstructors<T>(Boolean includeNonPublic = false) => this.Retrieve<T>(GetConstructors(includeNonPublic));*/
/// <summary> /// <summary>
/// Retrieves all constructors order by the number of parameters ascending. /// Retrieves all constructors order by the number of parameters ascending.

View File

@ -235,13 +235,13 @@ namespace Swan.Reflection {
// placeholder // placeholder
} }
/// <summary> /*/// <summary>
/// Converts this instance to its string representation, /// Converts this instance to its string representation,
/// trying to use the CultureInfo.InvariantCulture /// trying to use the CultureInfo.InvariantCulture
/// IFormat provider if the overload is available. /// IFormat provider if the overload is available.
/// </summary> /// </summary>
/// <param name="instance">The instance.</param> /// <param name="instance">The instance.</param>
/// <returns>A <see cref="System.String" /> that represents the current object.</returns> /// <returns>A <see cref="System.String" /> that represents the current object.</returns>
public String ToStringInvariant(T instance) => base.ToStringInvariant(instance); public String ToStringInvariant(T instance) => base.ToStringInvariant(instance);*/
} }
} }

View File

@ -1,4 +1,4 @@
using System; /*using System;
namespace Swan.Reflection { namespace Swan.Reflection {
/// <summary> /// <summary>
@ -19,4 +19,4 @@ namespace Swan.Reflection {
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
void SetValue(Object instance, Object value); void SetValue(Object instance, Object value);
} }
} }*/

View File

@ -1,4 +1,4 @@
using System; /*using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -41,4 +41,4 @@ namespace Swan.Reflection {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
void IPropertyProxy.SetValue(Object instance, Object value) => this._setter(instance as TClass, (TProperty)value); void IPropertyProxy.SetValue(Object instance, Object value) => this._setter(instance as TClass, (TProperty)value);
} }
} }*/

View File

@ -16,7 +16,7 @@ namespace Swan.Reflection {
/// </value> /// </value>
public static Lazy<PropertyTypeCache> DefaultCache { get; } = new Lazy<PropertyTypeCache>(() => new PropertyTypeCache()); public static Lazy<PropertyTypeCache> DefaultCache { get; } = new Lazy<PropertyTypeCache>(() => new PropertyTypeCache());
/// <summary> /*/// <summary>
/// Retrieves all properties. /// Retrieves all properties.
/// </summary> /// </summary>
/// <typeparam name="T">The type to inspect.</typeparam> /// <typeparam name="T">The type to inspect.</typeparam>
@ -24,7 +24,7 @@ namespace Swan.Reflection {
/// <returns> /// <returns>
/// A collection with all the properties in the given type. /// A collection with all the properties in the given type.
/// </returns> /// </returns>
public IEnumerable<PropertyInfo> RetrieveAllProperties<T>(Boolean onlyPublic = false) => this.Retrieve<T>(onlyPublic ? GetAllPublicPropertiesFunc() : GetAllPropertiesFunc()); public IEnumerable<PropertyInfo> RetrieveAllProperties<T>(Boolean onlyPublic = false) => this.Retrieve<T>(onlyPublic ? GetAllPublicPropertiesFunc() : GetAllPropertiesFunc());*/
/// <summary> /// <summary>
/// Retrieves all properties. /// Retrieves all properties.

View File

@ -13,7 +13,7 @@ namespace Swan.Reflection {
/// </summary> /// </summary>
/// <typeparam name="T">The type of Member to be cached.</typeparam> /// <typeparam name="T">The type of Member to be cached.</typeparam>
public abstract class TypeCache<T> : CollectionCacheRepository<T> { public abstract class TypeCache<T> : CollectionCacheRepository<T> {
/// <summary> /*/// <summary>
/// Determines whether the cache contains the specified type. /// Determines whether the cache contains the specified type.
/// </summary> /// </summary>
/// <typeparam name="TOut">The type of the out.</typeparam> /// <typeparam name="TOut">The type of the out.</typeparam>
@ -30,7 +30,7 @@ namespace Swan.Reflection {
/// <typeparam name="TOut">The type of the out.</typeparam> /// <typeparam name="TOut">The type of the out.</typeparam>
/// <param name="factory">The factory.</param> /// <param name="factory">The factory.</param>
/// <returns>An array of the properties stored for the specified type.</returns> /// <returns>An array of the properties stored for the specified type.</returns>
public IEnumerable<T> Retrieve<TOut>(Func<Type, IEnumerable<T>> factory) => this.Retrieve(typeof(TOut), factory); public IEnumerable<T> Retrieve<TOut>(Func<Type, IEnumerable<T>> factory) => this.Retrieve(typeof(TOut), factory);*/
} }
/// <summary> /// <summary>
@ -48,14 +48,14 @@ namespace Swan.Reflection {
/// </value> /// </value>
public static Lazy<FieldTypeCache> DefaultCache { get; } = new Lazy<FieldTypeCache>(() => new FieldTypeCache()); public static Lazy<FieldTypeCache> DefaultCache { get; } = new Lazy<FieldTypeCache>(() => new FieldTypeCache());
/// <summary> /*/// <summary>
/// Retrieves all fields. /// Retrieves all fields.
/// </summary> /// </summary>
/// <typeparam name="T">The type to inspect.</typeparam> /// <typeparam name="T">The type to inspect.</typeparam>
/// <returns> /// <returns>
/// A collection with all the fields in the given type. /// A collection with all the fields in the given type.
/// </returns> /// </returns>
public IEnumerable<FieldInfo> RetrieveAllFields<T>() => this.Retrieve<T>(GetAllFieldsFunc()); public IEnumerable<FieldInfo> RetrieveAllFields<T>() => this.Retrieve<T>(GetAllFieldsFunc());*/
/// <summary> /// <summary>
/// Retrieves all fields. /// Retrieves all fields.

View File

@ -1,6 +1,7 @@
using System; using System;
namespace Swan { namespace Swan {
// [Obsolete("NEED", false)]
/// <summary> /// <summary>
/// Represents a singleton pattern abstract class. /// Represents a singleton pattern abstract class.
/// </summary> /// </summary>
@ -20,6 +21,7 @@ namespace Swan {
/// <value> /// <value>
/// The instance. /// The instance.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static T Instance => LazyInstance.Value; public static T Instance => LazyInstance.Value;
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,4 +1,4 @@
using System; /*using System;
namespace Swan { namespace Swan {
/// <summary> /// <summary>
@ -24,4 +24,4 @@ namespace Swan {
get; get;
} }
} }
} }*/

View File

@ -9,7 +9,7 @@ namespace Swan {
/// Provides utility methods to retrieve information about the current application. /// Provides utility methods to retrieve information about the current application.
/// </summary> /// </summary>
public static class SwanRuntime { public static class SwanRuntime {
private static readonly Lazy<Assembly> EntryAssemblyLazy = new Lazy<Assembly>(Assembly.GetEntryAssembly); /*private static readonly Lazy<Assembly> EntryAssemblyLazy = new Lazy<Assembly>(Assembly.GetEntryAssembly);
private static readonly Lazy<String> CompanyNameLazy = new Lazy<String>(() => { private static readonly Lazy<String> CompanyNameLazy = new Lazy<String>(() => {
AssemblyCompanyAttribute attribute = EntryAssembly.GetCustomAttribute(typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute; AssemblyCompanyAttribute attribute = EntryAssembly.GetCustomAttribute(typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
@ -28,18 +28,19 @@ namespace Swan {
private static readonly String ApplicationMutexName = "Global\\{{" + EntryAssembly.FullName + "}}"; private static readonly String ApplicationMutexName = "Global\\{{" + EntryAssembly.FullName + "}}";
private static readonly Object SyncLock = new Object(); private static readonly Object SyncLock = new Object();*/
// [Obsolete("NEED", false)]
private static OperatingSystem? _oS; private static OperatingSystem? _oS;
#region Properties #region Properties
/// <summary> /// <summary>
/// Gets the current Operating System. /// Gets the current Operating System.
/// </summary> /// </summary>
/// <value> /// <value>
/// The os. /// The os.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static OperatingSystem OS { public static OperatingSystem OS {
get { get {
if(_oS.HasValue == false) { if(_oS.HasValue == false) {
@ -54,7 +55,7 @@ namespace Swan {
} }
/// <summary> /*/// <summary>
/// Checks if this application (including version number) is the only instance currently running. /// Checks if this application (including version number) is the only instance currently running.
/// </summary> /// </summary>
/// <value> /// <value>
@ -171,11 +172,11 @@ namespace Swan {
return returnPath; return returnPath;
} }
} }*/
#endregion #endregion
#region Methods /*#region Methods
/// <summary> /// <summary>
/// Build a full path pointing to the current user's desktop with the given filename. /// Build a full path pointing to the current user's desktop with the given filename.
@ -195,6 +196,6 @@ namespace Swan {
return Path.GetFullPath(pathWithFilename); return Path.GetFullPath(pathWithFilename);
} }
#endregion #endregion*/
} }
} }

View File

@ -7,7 +7,7 @@ namespace Swan {
/// This class is thread-safe :). /// This class is thread-safe :).
/// </summary> /// </summary>
public static partial class Terminal { public static partial class Terminal {
/// <summary> /*/// <summary>
/// Writes a character a number of times, optionally adding a new line at the end. /// Writes a character a number of times, optionally adding a new line at the end.
/// </summary> /// </summary>
/// <param name="charCode">The character code.</param> /// <param name="charCode">The character code.</param>
@ -32,7 +32,7 @@ namespace Swan {
EnqueueOutput(context); EnqueueOutput(context);
} }
} }*/
/// <summary> /// <summary>
/// Writes the specified text in the given color. /// Writes the specified text in the given color.
@ -40,6 +40,7 @@ namespace Swan {
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="writerFlags">The writer flags.</param> /// <param name="writerFlags">The writer flags.</param>
// [Obsolete("NEED", false)]
public static void Write(String? text, ConsoleColor? color = null, TerminalWriters writerFlags = TerminalWriters.StandardOutput) { public static void Write(String? text, ConsoleColor? color = null, TerminalWriters writerFlags = TerminalWriters.StandardOutput) {
if(text == null) { if(text == null) {
return; return;
@ -57,7 +58,7 @@ namespace Swan {
} }
} }
/// <summary> /*/// <summary>
/// Writes a New Line Sequence to the standard output. /// Writes a New Line Sequence to the standard output.
/// </summary> /// </summary>
/// <param name="writerFlags">The writer flags.</param> /// <param name="writerFlags">The writer flags.</param>
@ -83,6 +84,6 @@ namespace Swan {
Write($"\r{text ?? String.Empty}", color, writerFlags); Write($"\r{text ?? String.Empty}", color, writerFlags);
Flush(); Flush();
CursorLeft = 0; CursorLeft = 0;
} }*/
} }
} }

View File

@ -18,7 +18,7 @@ namespace Swan {
/// </value> /// </value>
public static ConsoleColor DefaultColor { get; set; } = Console.ForegroundColor; public static ConsoleColor DefaultColor { get; set; } = Console.ForegroundColor;
/// <summary> /*/// <summary>
/// Gets the color of the border. /// Gets the color of the border.
/// </summary> /// </summary>
/// <value> /// <value>
@ -40,7 +40,7 @@ namespace Swan {
/// <value> /// <value>
/// The user option text. /// The user option text.
/// </value> /// </value>
public static String UserOptionText { get; set; } = " Option: "; public static String UserOptionText { get; set; } = " Option: ";*/
} }
} }
} }

View File

@ -12,15 +12,20 @@ namespace Swan {
/// </summary> /// </summary>
public static partial class Terminal { public static partial class Terminal {
#region Private Declarations #region Private Declarations
// [Obsolete("NEED", false)]
private const Int32 OutputFlushInterval = 15; private const Int32 OutputFlushInterval = 15;
// [Obsolete("NEED", false)]
private static readonly ExclusiveTimer DequeueOutputTimer; private static readonly ExclusiveTimer DequeueOutputTimer;
// [Obsolete("NEED", false)]
private static readonly Object SyncLock = new Object(); private static readonly Object SyncLock = new Object();
// [Obsolete("NEED", false)]
private static readonly ConcurrentQueue<OutputContext> OutputQueue = new ConcurrentQueue<OutputContext>(); private static readonly ConcurrentQueue<OutputContext> OutputQueue = new ConcurrentQueue<OutputContext>();
// [Obsolete("NEED", false)]
private static readonly ManualResetEventSlim OutputDone = new ManualResetEventSlim(false); private static readonly ManualResetEventSlim OutputDone = new ManualResetEventSlim(false);
// [Obsolete("NEED", false)]
private static readonly ManualResetEventSlim InputDone = new ManualResetEventSlim(true); private static readonly ManualResetEventSlim InputDone = new ManualResetEventSlim(true);
// [Obsolete("NEED", false)]
private static Boolean? _isConsolePresent; private static Boolean? _isConsolePresent;
#endregion #endregion
@ -30,6 +35,7 @@ namespace Swan {
/// <summary> /// <summary>
/// Initializes static members of the <see cref="Terminal"/> class. /// Initializes static members of the <see cref="Terminal"/> class.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
static Terminal() { static Terminal() {
lock(SyncLock) { lock(SyncLock) {
if(DequeueOutputTimer != null) { if(DequeueOutputTimer != null) {
@ -48,7 +54,7 @@ namespace Swan {
#endregion #endregion
#region Synchronized Cursor Movement /*#region Synchronized Cursor Movement
/// <summary> /// <summary>
/// Gets or sets the cursor left position. /// Gets or sets the cursor left position.
@ -108,7 +114,7 @@ namespace Swan {
} }
} }
#endregion #endregion*/
#region Properties #region Properties
@ -118,6 +124,7 @@ namespace Swan {
/// <value> /// <value>
/// <c>true</c> if this instance is console present; otherwise, <c>false</c>. /// <c>true</c> if this instance is console present; otherwise, <c>false</c>.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static Boolean IsConsolePresent { public static Boolean IsConsolePresent {
get { get {
if(_isConsolePresent == null) { if(_isConsolePresent == null) {
@ -140,6 +147,7 @@ namespace Swan {
/// <value> /// <value>
/// The available writers. /// The available writers.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static TerminalWriters AvailableWriters => IsConsolePresent ? TerminalWriters.StandardError | TerminalWriters.StandardOutput : TerminalWriters.None; public static TerminalWriters AvailableWriters => IsConsolePresent ? TerminalWriters.StandardError | TerminalWriters.StandardOutput : TerminalWriters.None;
/// <summary> /// <summary>
@ -148,6 +156,7 @@ namespace Swan {
/// <value> /// <value>
/// The output encoding. /// The output encoding.
/// </value> /// </value>
// [Obsolete("NEED", false)]
public static Encoding OutputEncoding { public static Encoding OutputEncoding {
get => Console.OutputEncoding; get => Console.OutputEncoding;
set => Console.OutputEncoding = value; set => Console.OutputEncoding = value;
@ -157,7 +166,7 @@ namespace Swan {
#region Methods #region Methods
/// <summary> /*/// <summary>
/// Waits for all of the queued output messages to be written out to the console. /// Waits for all of the queued output messages to be written out to the console.
/// Call this method if it is important to display console text before /// Call this method if it is important to display console text before
/// quitting the application such as showing usage or help. /// quitting the application such as showing usage or help.
@ -224,7 +233,7 @@ namespace Swan {
public static void WriteWelcomeBanner(ConsoleColor color = ConsoleColor.Gray) { public static void WriteWelcomeBanner(ConsoleColor color = ConsoleColor.Gray) {
WriteLine($"{SwanRuntime.CompanyName} {SwanRuntime.ProductName} [Version {SwanRuntime.EntryAssemblyVersion}]", color); WriteLine($"{SwanRuntime.CompanyName} {SwanRuntime.ProductName} [Version {SwanRuntime.EntryAssemblyVersion}]", color);
WriteLine($"{SwanRuntime.ProductTrademark}", color); WriteLine($"{SwanRuntime.ProductTrademark}", color);
} }*/
/// <summary> /// <summary>
/// Enqueues the output to be written to the console /// Enqueues the output to be written to the console
@ -232,6 +241,7 @@ namespace Swan {
/// Please note that if AvailableWriters is None, then no output will be enqueued. /// Please note that if AvailableWriters is None, then no output will be enqueued.
/// </summary> /// </summary>
/// <param name="context">The context.</param> /// <param name="context">The context.</param>
// [Obsolete("NEED", false)]
private static void EnqueueOutput(OutputContext context) { private static void EnqueueOutput(OutputContext context) {
lock(SyncLock) { lock(SyncLock) {
TerminalWriters availableWriters = AvailableWriters; TerminalWriters availableWriters = AvailableWriters;
@ -253,6 +263,7 @@ namespace Swan {
/// <summary> /// <summary>
/// Runs a Terminal I/O cycle in the <see cref="ThreadPool"/> thread. /// Runs a Terminal I/O cycle in the <see cref="ThreadPool"/> thread.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
private static void DequeueOutputCycle() { private static void DequeueOutputCycle() {
if(AvailableWriters == TerminalWriters.None) { if(AvailableWriters == TerminalWriters.None) {
OutputDone.Set(); OutputDone.Set();
@ -302,6 +313,7 @@ namespace Swan {
/// <summary> /// <summary>
/// Represents an asynchronous output context. /// Represents an asynchronous output context.
/// </summary> /// </summary>
// [Obsolete("NEED", false)]
private sealed class OutputContext { private sealed class OutputContext {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="OutputContext"/> class. /// Initializes a new instance of the <see cref="OutputContext"/> class.

View File

@ -54,7 +54,7 @@ namespace Swan.Threading {
/// </returns> /// </returns>
public static Boolean operator !=(AtomicTypeBase<T> a, T b) => a?.Equals(b) == false; public static Boolean operator !=(AtomicTypeBase<T> a, T b) => a?.Equals(b) == false;
/// <summary> /*/// <summary>
/// Implements the operator &gt;. /// Implements the operator &gt;.
/// </summary> /// </summary>
/// <param name="a">a.</param> /// <param name="a">a.</param>
@ -142,7 +142,7 @@ namespace Swan.Threading {
public static AtomicTypeBase<T> operator -(AtomicTypeBase<T> instance, Int64 operand) { public static AtomicTypeBase<T> operator -(AtomicTypeBase<T> instance, Int64 operand) {
instance.BackingValue -= operand; instance.BackingValue -= operand;
return instance; return instance;
} }*/
/// <summary> /// <summary>
/// Compares the value to the other instance. /// Compares the value to the other instance.

View File

@ -29,7 +29,7 @@ namespace Swan.Threading {
this._backingTimer = new Timer(this.InternalCallback, state ?? this, dueTime, Timeout.Infinite); this._backingTimer = new Timer(this.InternalCallback, state ?? this, dueTime, Timeout.Infinite);
} }
/// <summary> /*/// <summary>
/// Initializes a new instance of the <see cref="ExclusiveTimer"/> class. /// Initializes a new instance of the <see cref="ExclusiveTimer"/> class.
/// </summary> /// </summary>
/// <param name="timerCallback">The timer callback.</param> /// <param name="timerCallback">The timer callback.</param>
@ -38,15 +38,15 @@ namespace Swan.Threading {
/// <param name="period">The period.</param> /// <param name="period">The period.</param>
public ExclusiveTimer(TimerCallback timerCallback, Object state, TimeSpan dueTime, TimeSpan period) : this(timerCallback, state, Convert.ToInt32(dueTime.TotalMilliseconds), Convert.ToInt32(period.TotalMilliseconds)) { public ExclusiveTimer(TimerCallback timerCallback, Object state, TimeSpan dueTime, TimeSpan period) : this(timerCallback, state, Convert.ToInt32(dueTime.TotalMilliseconds), Convert.ToInt32(period.TotalMilliseconds)) {
// placeholder // placeholder
} }*/
/// <summary> /*/// <summary>
/// Initializes a new instance of the <see cref="ExclusiveTimer"/> class. /// Initializes a new instance of the <see cref="ExclusiveTimer"/> class.
/// </summary> /// </summary>
/// <param name="timerCallback">The timer callback.</param> /// <param name="timerCallback">The timer callback.</param>
public ExclusiveTimer(TimerCallback timerCallback) : this(timerCallback, null, Timeout.Infinite, Timeout.Infinite) { public ExclusiveTimer(TimerCallback timerCallback) : this(timerCallback, null, Timeout.Infinite, Timeout.Infinite) {
// placeholder // placeholder
} }*/
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ExclusiveTimer"/> class. /// Initializes a new instance of the <see cref="ExclusiveTimer"/> class.
@ -58,7 +58,7 @@ namespace Swan.Threading {
// placeholder // placeholder
} }
/// <summary> /*/// <summary>
/// Initializes a new instance of the <see cref="ExclusiveTimer"/> class. /// Initializes a new instance of the <see cref="ExclusiveTimer"/> class.
/// </summary> /// </summary>
/// <param name="timerCallback">The timer callback.</param> /// <param name="timerCallback">The timer callback.</param>
@ -66,12 +66,13 @@ namespace Swan.Threading {
/// <param name="period">The period.</param> /// <param name="period">The period.</param>
public ExclusiveTimer(Action timerCallback, TimeSpan dueTime, TimeSpan period) : this(s => timerCallback?.Invoke(), null, dueTime, period) { public ExclusiveTimer(Action timerCallback, TimeSpan dueTime, TimeSpan period) : this(s => timerCallback?.Invoke(), null, dueTime, period) {
// placeholder // placeholder
} }*/
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ExclusiveTimer"/> class. /// Initializes a new instance of the <see cref="ExclusiveTimer"/> class.
/// </summary> /// </summary>
/// <param name="timerCallback">The timer callback.</param> /// <param name="timerCallback">The timer callback.</param>
// [Obsolete("NEED", false)]
public ExclusiveTimer(Action timerCallback) : this(timerCallback, Timeout.Infinite, Timeout.Infinite) { public ExclusiveTimer(Action timerCallback) : this(timerCallback, Timeout.Infinite, Timeout.Infinite) {
// placeholder // placeholder
} }
@ -92,7 +93,7 @@ namespace Swan.Threading {
/// </value> /// </value>
public Boolean IsDisposed => this._isDisposed.Value; public Boolean IsDisposed => this._isDisposed.Value;
/// <summary> /*/// <summary>
/// Waits until the time is elapsed. /// Waits until the time is elapsed.
/// </summary> /// </summary>
/// <param name="untilDate">The until date.</param> /// <param name="untilDate">The until date.</param>
@ -112,15 +113,15 @@ namespace Swan.Threading {
while(!cancellationToken.IsCancellationRequested && DateTime.UtcNow < untilDate) { while(!cancellationToken.IsCancellationRequested && DateTime.UtcNow < untilDate) {
delayLock.Wait(); delayLock.Wait();
} }
} }*/
/// <summary> /*/// <summary>
/// Waits the specified wait time. /// Waits the specified wait time.
/// </summary> /// </summary>
/// <param name="waitTime">The wait time.</param> /// <param name="waitTime">The wait time.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
public static void Wait(TimeSpan waitTime, CancellationToken cancellationToken = default) => public static void Wait(TimeSpan waitTime, CancellationToken cancellationToken = default) =>
WaitUntil(DateTime.UtcNow.Add(waitTime), cancellationToken); WaitUntil(DateTime.UtcNow.Add(waitTime), cancellationToken);*/
/// <summary> /// <summary>
/// Changes the start time and the interval between method invocations for the internal timer. /// Changes the start time and the interval between method invocations for the internal timer.
@ -133,24 +134,25 @@ namespace Swan.Threading {
_ = this._backingTimer.Change(dueTime, Timeout.Infinite); _ = this._backingTimer.Change(dueTime, Timeout.Infinite);
} }
/// <summary> /*/// <summary>
/// Changes the start time and the interval between method invocations for the internal timer. /// Changes the start time and the interval between method invocations for the internal timer.
/// </summary> /// </summary>
/// <param name="dueTime">The due time.</param> /// <param name="dueTime">The due time.</param>
/// <param name="period">The period.</param> /// <param name="period">The period.</param>
public void Change(TimeSpan dueTime, TimeSpan period) => this.Change(Convert.ToInt32(dueTime.TotalMilliseconds), Convert.ToInt32(period.TotalMilliseconds)); public void Change(TimeSpan dueTime, TimeSpan period) => this.Change(Convert.ToInt32(dueTime.TotalMilliseconds), Convert.ToInt32(period.TotalMilliseconds));*/
/// <summary> /// <summary>
/// Changes the interval between method invocations for the internal timer. /// Changes the interval between method invocations for the internal timer.
/// </summary> /// </summary>
/// <param name="period">The period.</param> /// <param name="period">The period.</param>
// [Obsolete("NEED", false)]
public void Resume(Int32 period) => this.Change(0, period); public void Resume(Int32 period) => this.Change(0, period);
/// <summary> /*/// <summary>
/// Changes the interval between method invocations for the internal timer. /// Changes the interval between method invocations for the internal timer.
/// </summary> /// </summary>
/// <param name="period">The period.</param> /// <param name="period">The period.</param>
public void Resume(TimeSpan period) => this.Change(TimeSpan.Zero, period); public void Resume(TimeSpan period) => this.Change(TimeSpan.Zero, period);*/
/// <summary> /// <summary>
/// Pauses this instance. /// Pauses this instance.

View File

@ -67,13 +67,13 @@ namespace Swan.Threading {
/// <returns>The Wait Event.</returns> /// <returns>The Wait Event.</returns>
public static IWaitEvent CreateSlim(Boolean isCompleted) => new WaitEventSlim(isCompleted); public static IWaitEvent CreateSlim(Boolean isCompleted) => new WaitEventSlim(isCompleted);
/// <summary> /*/// <summary>
/// Creates a Wait Event backed by a ManualResetEventSlim. /// Creates a Wait Event backed by a ManualResetEventSlim.
/// </summary> /// </summary>
/// <param name="isCompleted">if initially set to completed. Generally true.</param> /// <param name="isCompleted">if initially set to completed. Generally true.</param>
/// <param name="useSlim">if set to <c>true</c> creates a slim version of the wait event.</param> /// <param name="useSlim">if set to <c>true</c> creates a slim version of the wait event.</param>
/// <returns>The Wait Event.</returns> /// <returns>The Wait Event.</returns>
public static IWaitEvent Create(Boolean isCompleted, Boolean useSlim) => useSlim ? CreateSlim(isCompleted) : Create(isCompleted); public static IWaitEvent Create(Boolean isCompleted, Boolean useSlim) => useSlim ? CreateSlim(isCompleted) : Create(isCompleted);*/
#endregion #endregion

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using Swan; using Swan;
namespace Unosquare.RaspberryIO.Camera { namespace Unosquare.RaspberryIO.Camera {