Warning fixes

master
Ogoun 7 months ago
parent 37efc25915
commit e965b22304

@ -37,5 +37,10 @@ namespace ZeroLevel.UnitTests.Models
writer.WriteString(this.Title);
writer.WriteLong(this.Timestamp);
}
public override int GetHashCode()
{
return Id.GetHashCode() ^ (Title?.GetHashCode() ?? 0) ^ Timestamp.GetHashCode();
}
}
}

@ -37,6 +37,11 @@ namespace ZeroLevel.UnitTests
writer.WriteString(this.Login);
writer.WriteString(this.Name);
}
public override int GetHashCode()
{
return (Login?.GetHashCode() ?? 0) ^ (Name?.GetHashCode() ?? 0);
}
}
[Fact]

@ -104,7 +104,7 @@ p2 pixel units = -p2 focal units / focal length
public sealed class ImageMetainfo
{
private CameraMath _camera = null;
private CameraMath _camera = null!;
public CameraMath CreateCamera()
{
if (_camera == null)

@ -5,6 +5,9 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<Version>$(AssemblyVersion)</Version>
</PropertyGroup>
<ItemGroup>

@ -1,16 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<Version>$(AssemblyVersion)</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
</Project>

@ -1,12 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<Version>$(AssemblyVersion)</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>
</Project>

@ -56,7 +56,7 @@ namespace ZeroLevel.DataStructures
}
//If there is no item on the given position return defaault value
return default(T);
return default(T)!;
}
set
{

@ -42,7 +42,7 @@ namespace ZeroLevel
public bool Equals(ZeroServiceInfo other)
{
if (other == null) return false;
if (other == null!) return false;
if (object.ReferenceEquals(this, other)) return true;
if (string.Compare(this.Name, other.Name, true) != 0) return false;
if (string.Compare(this.ServiceKey, other.ServiceKey, true) != 0) return false;
@ -54,7 +54,7 @@ namespace ZeroLevel
public override bool Equals(object obj)
{
return this.Equals(obj as ZeroServiceInfo);
return this.Equals((obj as ZeroServiceInfo)!);
}
public override int GetHashCode()

@ -127,7 +127,7 @@ namespace ZeroLevel.Services.Applications
}
}
}
return default(T);
return default(T)!;
}
#endregion Config

@ -29,7 +29,7 @@ namespace ZeroLevel
public BootstrapFluent(IZeroService service)
{
if (service == null)
if (service == null!)
{
throw new ArgumentNullException(nameof(service));
}
@ -56,7 +56,7 @@ namespace ZeroLevel
catch (Exception ex)
{
Log.Error(ex, $"[Bootstrap] Service {_service?.Name} run error");
return null;
return null!;
}
return this;
}
@ -108,7 +108,7 @@ namespace ZeroLevel
{
Log.Info($"[Bootstrap] Resolve assembly '{args.Name}' {args.Name}");
string name = args.Name.Split(',')[0];
if (name.EndsWith(".resources")) return null;
if (name.EndsWith(".resources")) return null!;
foreach (string file in Directory.
GetFiles(Path.Combine(Configuration.BaseDirectory), "*.dll", SearchOption.TopDirectoryOnly))
{
@ -123,7 +123,7 @@ namespace ZeroLevel
{
Log.Error(ex, $"[Bootstrap] Fault load assembly '{args.Name}'");
}
return null;
return null!;
}
public static BootstrapFluent Startup<T>(string[] args,
@ -155,13 +155,13 @@ namespace ZeroLevel
IZeroService service = null!;
IConfigurationSet config = Configuration.DefaultSet;
config.CreateSection("commandline", Configuration.ReadFromCommandLine(args));
if (configurationSet != null)
if (configurationSet != null!)
{
config.Merge(configurationSet);
}
Log.CreateLoggingFromConfiguration(Configuration.DefaultSet);
if (preStartConfiguration != null)
if (preStartConfiguration != null!)
{
try
{
@ -185,20 +185,20 @@ namespace ZeroLevel
{
Log.SystemError(ex, "[Bootstrap] Service start canceled, service constructor call fault");
}
if (postStartConfiguration != null)
if (postStartConfiguration != null!)
{
try
{
if (postStartConfiguration() == false)
{
Log.SystemInfo("[Bootstrap] Service start canceled, because custom postconfig return false");
return null;
return null!;
}
}
catch (Exception ex)
{
Log.SystemError(ex, "[Bootstrap] Service start canceled, postconfig faulted");
return null;
return null!;
}
}
return service;

@ -58,7 +58,7 @@ namespace ZeroLevel.Services.Cache
}
}
value = default(TValue);
value = default(TValue)!;
return false;
}

@ -62,7 +62,7 @@ namespace ZeroLevel.Services.Cache
{
try
{
if (_onDisposeAction != null)
if (_onDisposeAction != null!)
{
_onDisposeAction.Invoke(v.Value);
}
@ -92,7 +92,7 @@ namespace ZeroLevel.Services.Cache
{
try
{
if (_onDisposeAction != null)
if (_onDisposeAction != null!)
{
_onDisposeAction.Invoke(_cachee[key].Value);
}
@ -114,7 +114,7 @@ namespace ZeroLevel.Services.Cache
{
try
{
if (_onDisposeAction != null)
if (_onDisposeAction != null!)
{
_onDisposeAction.Invoke(pair.Value.Value);
}

@ -18,7 +18,7 @@ namespace ZeroLevel.Services.Collections
public Capacitor(int dischargeValue, Action<T[], int> dischargeAction)
{
if (dischargeValue < 1) dischargeValue = 16;
if (dischargeAction == null) throw new ArgumentNullException(nameof(dischargeAction));
if (dischargeAction == null!) throw new ArgumentNullException(nameof(dischargeAction));
_buffer = new T[dischargeValue];
_dischargeAction = dischargeAction;
}

@ -187,7 +187,7 @@ namespace ZeroLevel.Collections
public ConcurrentHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
: this(comparer)
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
if (collection == null!) throw new ArgumentNullException(nameof(collection));
InitializeFromCollection(collection);
}
@ -214,7 +214,7 @@ namespace ZeroLevel.Collections
public ConcurrentHashSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
: this(concurrencyLevel, DefaultCapacity, false, comparer)
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
if (collection == null!) throw new ArgumentNullException(nameof(collection));
InitializeFromCollection(collection);
}
@ -337,7 +337,7 @@ namespace ZeroLevel.Collections
// The Volatile.Read ensures that the load of the fields of 'n' doesn't move before the load from buckets[i].
var current = Volatile.Read(ref tables.Buckets[bucketNo]);
while (current != null)
while (current != null!)
{
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, equalValue))
{
@ -348,7 +348,7 @@ namespace ZeroLevel.Collections
current = current.Next;
}
actualValue = default;
actualValue = default!;
return false;
}
@ -376,13 +376,13 @@ namespace ZeroLevel.Collections
}
Node previous = null!;
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
for (var current = tables.Buckets[bucketNo]; current != null!; current = current.Next)
{
Debug.Assert((previous == null && current == tables.Buckets[bucketNo]) || previous!.Next == current);
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
{
if (previous == null)
if (previous == null!)
{
Volatile.Write(ref tables.Buckets[bucketNo], current.Next);
}
@ -434,7 +434,7 @@ namespace ZeroLevel.Collections
// Provides a manually-implemented version of (approximately) this iterator:
// Node?[] buckets = _tables.Buckets;
// for (int i = 0; i < buckets.Length; i++)
// for (Node? current = Volatile.Read(ref buckets[i]); current != null; current = current.Next)
// for (Node? current = Volatile.Read(ref buckets[i]); current != null!; current = current.Next)
// yield return new current.Item;
private readonly ConcurrentHashSet<T> _set;
@ -502,7 +502,7 @@ namespace ZeroLevel.Collections
case StateOuterloop:
Node[] buckets = _buckets;
Debug.Assert(buckets != null);
Debug.Assert(buckets != null!);
int i = ++_i;
if ((uint)i < (uint)buckets!.Length)
@ -517,7 +517,7 @@ namespace ZeroLevel.Collections
case StateInnerLoop:
Node node = _node;
if (node != null)
if (node != null!)
{
Current = node.Item;
_node = node.Next;
@ -538,7 +538,7 @@ namespace ZeroLevel.Collections
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
if (array == null) throw new ArgumentNullException(nameof(array));
if (array == null!) throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex));
var locksAcquired = 0;
@ -606,8 +606,8 @@ namespace ZeroLevel.Collections
}
// Try to find this item in the bucket
Node previous = null;
for (var current = tables.Buckets[bucketNo]; current != null; current = current.Next)
Node previous = null!;
for (var current = tables.Buckets[bucketNo]; current != null!; current = current.Next)
{
Debug.Assert(previous == null && current == tables.Buckets[bucketNo] || previous!.Next == current);
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
@ -791,7 +791,7 @@ namespace ZeroLevel.Collections
for (var i = 0; i < tables.Buckets.Length; i++)
{
var current = tables.Buckets[i];
while (current != null)
while (current != null!)
{
var next = current.Next;
GetBucketAndLockNo(current.Hashcode, out int newBucketNo, out int newLockNo, newBuckets.Length, newLocks.Length);
@ -868,7 +868,7 @@ namespace ZeroLevel.Collections
var buckets = _tables.Buckets;
for (var i = 0; i < buckets.Length; i++)
{
for (var current = buckets[i]; current != null; current = current.Next)
for (var current = buckets[i]; current != null!; current = current.Next)
{
array[index] = current.Item;
index++; //this should never flow, CopyToItems is only called when there's no overflow risk

@ -59,14 +59,14 @@ namespace ZeroLevel.Services.Collections
public void Insert<T>(string key, T entity)
{
_insert.Invoke(_instance, new object[] { key, entity });
_insert.Invoke(_instance, new object[] { key, entity! });
}
public void InsertOrUpdate<T>(string key, T entity)
{
if ((bool)_containsKey.Invoke(_instance, key))
_remove.Invoke(_instance, key);
_insert.Invoke(_instance, new object[] { key, entity });
_insert.Invoke(_instance, new object[] { key, entity! });
}
public bool ContainsKey(string key)

@ -62,7 +62,7 @@ namespace ZeroLevel.Collections
=========================================================================*/
public FastBitArray(byte[] bytes)
{
if (bytes == null)
if (bytes == null!)
{
throw new ArgumentNullException(nameof(bytes));
}
@ -135,7 +135,7 @@ namespace ZeroLevel.Collections
private void SetValues(int[] values)
{
if (values == null)
if (values == null!)
{
throw new ArgumentNullException(nameof(values));
}
@ -157,7 +157,7 @@ namespace ZeroLevel.Collections
=========================================================================*/
public FastBitArray(FastBitArray bits)
{
if (bits == null)
if (bits == null!)
{
throw new ArgumentNullException(nameof(bits));
}
@ -183,7 +183,7 @@ namespace ZeroLevel.Collections
private void SetValues(bool[] values)
{
if (values == null)
if (values == null!)
{
throw new ArgumentNullException(nameof(values));
}
@ -276,7 +276,7 @@ namespace ZeroLevel.Collections
=========================================================================*/
public FastBitArray And(FastBitArray value)
{
if (value == null)
if (value == null!)
throw new ArgumentNullException(nameof(value));
if (Length != value.Length)
throw new ArgumentException("The array lengths differ.");
@ -303,7 +303,7 @@ namespace ZeroLevel.Collections
=========================================================================*/
public FastBitArray Or(FastBitArray value)
{
if (value == null)
if (value == null!)
throw new ArgumentNullException(nameof(value));
if (Length != value.Length)
throw new ArgumentException("The array lengths differ");
@ -385,7 +385,7 @@ namespace ZeroLevel.Collections
=========================================================================*/
public FastBitArray Xor(FastBitArray value)
{
if (value == null)
if (value == null!)
throw new ArgumentNullException(nameof(value));
if (Length != value.Length)
throw new ArgumentException("The array lengths differ");
@ -465,7 +465,7 @@ namespace ZeroLevel.Collections
// ICollection implementation
public void CopyTo(Array array, int index)
{
if (array == null)
if (array == null!)
throw new ArgumentNullException(nameof(array));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), "The index cannot be less than 0.");
@ -508,7 +508,7 @@ namespace ZeroLevel.Collections
public Object Clone()
{
Contract.Ensures(Contract.Result<Object>() != null);
Contract.Ensures(Contract.Result<Object>() != null!);
Contract.Ensures(((FastBitArray)Contract.Result<Object>()).Length == this.Length);
return new FastBitArray(this);
}
@ -517,9 +517,9 @@ namespace ZeroLevel.Collections
{
get
{
if (_syncRoot == null)
if (_syncRoot == null!)
{
System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot, new Object(), null);
System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot!, new Object(), null!);
}
return _syncRoot;
}

@ -45,8 +45,8 @@ namespace ZeroLevel.Services.Collections
public bool Equals(T x, T y)
{
if (x == null && y == null) return true;
if (x == null || y == null) return false;
if (x == null && y == null!) return true;
if (x == null || y == null!) return false;
if ((object)x == (object)y) return true;
if (ReferenceEquals(x, y)) return true;
return x.Equals(y);
@ -57,7 +57,7 @@ namespace ZeroLevel.Services.Collections
lock (_accessLocker)
{
Func<T, T, bool> eq_func;
if (comparer == null)
if (comparer == null!)
{
eq_func = Equals;
}
@ -94,13 +94,13 @@ namespace ZeroLevel.Services.Collections
if (_count > 0)
{
t = _array[_startIndex];
_array[_startIndex] = default(T);
_array[_startIndex] = default(T)!;
_startIndex = (_startIndex + 1) % _array.Length;
_count--;
return true;
}
}
t = default(T);
t = default(T)!;
return false;
}
@ -112,7 +112,7 @@ namespace ZeroLevel.Services.Collections
if (_count > 0)
{
ret = _array[_startIndex];
_array[_startIndex] = default(T);
_array[_startIndex] = default(T)!;
_startIndex = (_startIndex + 1) % _array.Length;
_count--;
return ret;

@ -14,6 +14,6 @@ namespace ZeroLevel.Services.Collections
IEnumerable<T> Dump();
bool Contains(T item, IComparer<T> comparer = null);
bool Contains(T item, IComparer<T> comparer = null!);
}
}

@ -208,7 +208,7 @@ namespace ZeroLevel.Services.Collections
{
if (disposing)
{
if (_collection != null)
if (_collection != null!)
{
_collection.Clear();
}

@ -179,7 +179,7 @@ namespace ZeroLevel.Services.Collections
}
else
{
if (!_collection[id].Equals(value))
if (!_collection[id]!.Equals(value))
{
if (false == _updatedRecords.ContainsKey(id))
{
@ -254,12 +254,12 @@ namespace ZeroLevel.Services.Collections
{
if (disposing)
{
if (_collection != null)
if (_collection != null!)
{
foreach (TKey key in _collection.Keys)
{
var disposable = _collection[key] as IDisposable;
if (disposable != null)
if (disposable != null!)
disposable.Dispose();
}
_collection.Clear();

@ -147,7 +147,7 @@ namespace ZeroLevel.Services.Collections
{
get
{
return _index == -1 ? default(T) : _collection[_index];
return (_index == -1 ? default(T) : _collection[_index])!;
}
}

@ -18,15 +18,15 @@ namespace ZeroLevel.Services.Collections
public class ZPriorityQueue<T>
: IPriorityQueue<T>
{
private sealed class PriorityQueueObject<T>
private sealed class PriorityQueueObject<T1>
{
public readonly int Priority;
public readonly T Value;
public readonly T1 Value;
public PriorityQueueObject<T> Next;
public PriorityQueueObject<T1> Next;
public PriorityQueueObject(T val, int priority)
public PriorityQueueObject(T1 val, int priority)
{
Value = val;
Priority = priority;
@ -34,7 +34,7 @@ namespace ZeroLevel.Services.Collections
}
private readonly Func<T, PriorityQueueObjectHandleResult> _handler;
private PriorityQueueObject<T> _head = null;
private PriorityQueueObject<T> _head = null!;
private readonly object _rw_lock = new object();
private int _counter = 0;
@ -42,7 +42,7 @@ namespace ZeroLevel.Services.Collections
public ZPriorityQueue(Func<T, PriorityQueueObjectHandleResult> handler)
{
if (handler == null)
if (handler == null!)
throw new ArgumentNullException(nameof(handler));
_handler = handler;
}
@ -59,7 +59,7 @@ namespace ZeroLevel.Services.Collections
else
{
var cursor = _head;
PriorityQueueObject<T> prev = null;
PriorityQueueObject<T> prev = null!;
do
{
if (cursor.Priority > insert.Priority)
@ -77,11 +77,11 @@ namespace ZeroLevel.Services.Collections
}
prev = cursor;
cursor = cursor.Next;
if (cursor == null)
if (cursor == null!)
{
prev.Next = insert;
}
} while (cursor != null);
} while (cursor != null!);
}
_counter++;
}
@ -90,17 +90,17 @@ namespace ZeroLevel.Services.Collections
public T HandleCurrentItem()
{
T v = default(T);
T v = default(T)!;
lock (_rw_lock)
{
var item = _head;
PriorityQueueObject<T> prev = null;
while (item != null)
PriorityQueueObject<T> prev = null!;
while (item != null!)
{
var result = this._handler.Invoke(item.Value);
if (result.IsCompleted)
{
if (prev != null)
if (prev != null!)
{
prev.Next = item.Next;
}

@ -118,7 +118,7 @@ namespace ZeroLevel.Services.Config
{
if (result.Count > 0)
return result[0];
return null;
return null!;
}
throw new KeyNotFoundException("Key not found: " + key);
}
@ -154,7 +154,7 @@ namespace ZeroLevel.Services.Config
{
return (T)StringToTypeConverter.TryConvert(result[0], typeof(T));
}
return default(T);
return default(T)!;
}
throw new KeyNotFoundException("Parameter not found: " + key);
}
@ -192,7 +192,7 @@ namespace ZeroLevel.Services.Config
return (T)StringToTypeConverter.TryConvert(result[0], typeof(T));
}
}
return default(T);
return default(T)!;
}
/// <summary>
@ -280,7 +280,7 @@ namespace ZeroLevel.Services.Config
{
_keyValues.TryAdd(key, new List<string>());
}
_keyValues[key].Add(value?.Trim() ?? null);
_keyValues[key].Add((value?.Trim() ?? null)!);
}
return this;
}
@ -296,7 +296,7 @@ namespace ZeroLevel.Services.Config
}
foreach (var value in values)
{
_keyValues[key].Add(value?.Trim() ?? null);
_keyValues[key].Add((value?.Trim() ?? null)!);
}
}
return this;
@ -318,7 +318,7 @@ namespace ZeroLevel.Services.Config
{
_keyValues[key].Clear();
}
_keyValues[key].Add(value?.Trim() ?? null);
_keyValues[key].Add((value?.Trim() ?? null)!);
}
return this;
}
@ -360,8 +360,7 @@ namespace ZeroLevel.Services.Config
{
if (false == _freezed)
{
IList<string> removed;
_keyValues.TryRemove(GetKey(key), out removed);
_keyValues.TryRemove(GetKey(key), out _);
}
return this;
}
@ -404,7 +403,7 @@ namespace ZeroLevel.Services.Config
public bool Equals(IConfiguration other)
{
if (other == null)
if (other == null!)
{
return false;
}
@ -508,12 +507,12 @@ namespace ZeroLevel.Services.Config
if (count > 0)
{
var values = this.Items(member.Name);
IConfigRecordParser parser = member.Original.GetCustomAttribute<ConfigRecordParseAttribute>()?.Parser;
IConfigRecordParser parser = member.Original.GetCustomAttribute<ConfigRecordParseAttribute>()?.Parser!;
if (TypeHelpers.IsArray(member.ClrType) && member.ClrType.GetArrayRank() == 1)
{
int index = 0;
var itemType = member.ClrType.GetElementType();
if (parser == null)
if (parser == null!)
{
var elements = values.SelectMany(v => SplitRange(v, itemType)).ToArray();
var arrayBuilder = CollectionFactory.CreateArray(itemType, elements.Length);
@ -540,7 +539,7 @@ namespace ZeroLevel.Services.Config
{
var itemType = member.ClrType.GenericTypeArguments.First();
var collectionBuilder = CollectionFactory.Create(itemType);
if (parser == null)
if (parser == null!)
{
var elements = values.SelectMany(v => SplitRange(v, itemType)).ToArray();
foreach (var item in elements)
@ -561,7 +560,7 @@ namespace ZeroLevel.Services.Config
else
{
var single = values.First();
if (parser != null)
if (parser != null!)
{
member.Setter(instance, parser.Parse(single));
}

@ -158,7 +158,7 @@ namespace ZeroLevel.Services.Config
public bool Equals(IConfigurationSet other)
{
if (other == null) return false;
if (other == null!) return false;
return this.SectionNames.NoOrderingEquals(other.SectionNames) &&
this.Sections.NoOrderingEquals(other.Sections);
}
@ -274,14 +274,17 @@ namespace ZeroLevel.Services.Config
{
var mapper = TypeMapper.Create<T>(true);
var instance = Default.Bind<T>();
mapper.TraversalMembers(member =>
if (instance != null)
{
if (ContainsSection(member.Name))
mapper.TraversalMembers(member =>
{
member.Setter(instance, GetSection(member.Name).Bind(member.ClrType));
}
});
return instance;
if (ContainsSection(member.Name))
{
member.Setter(instance, GetSection(member.Name).Bind(member.ClrType));
}
});
}
return instance!;
}
}
}

@ -9,7 +9,7 @@ namespace ZeroLevel.Services.Config
public ConfigRecordParseAttribute(Type parserType)
{
if (parserType == null) throw new ArgumentNullException(nameof(parserType));
if (parserType == null!) throw new ArgumentNullException(nameof(parserType));
Parser = (IConfigRecordParser)Activator.CreateInstance(parserType);
}
}

@ -29,7 +29,7 @@ namespace ZeroLevel
_emptySet.FreezeConfiguration(true);
DefaultSet = Configuration.CreateSet();
var assembly = EntryAssemblyAttribute.GetEntryAssembly();
if (assembly != null)
if (assembly != null!)
{
BaseDirectory = Path.GetDirectoryName(assembly.Location);
AppLocation = assembly.Location;
@ -52,7 +52,7 @@ namespace ZeroLevel
public static IConfiguration Empty { get { return _empty; } }
public static IConfigurationSet EmptySet { get { return _emptySet; } }
public static IConfiguration Default => DefaultSet?.Default;
public static IConfiguration Default => DefaultSet?.Default!;
public static IConfigurationSet DefaultSet { get; private set; }
public static void Save(string name, IConfiguration configuration)
@ -62,7 +62,7 @@ namespace ZeroLevel
public static void Save(IConfiguration configuration)
{
if (DefaultSet == null)
if (DefaultSet == null!)
{
DefaultSet = Configuration.CreateSet(configuration);
}
@ -79,7 +79,7 @@ namespace ZeroLevel
public static void Save(IConfigurationSet configuration)
{
if (DefaultSet == null)
if (DefaultSet == null!)
{
DefaultSet = configuration;
}

@ -14,7 +14,7 @@ namespace ZeroLevel.Services.Config.Implementation
internal AppWebConfigReader(string configFilePath = null!)
{
if (configFilePath == null)
if (configFilePath == null!)
{
var appConfig = Path.Combine(Configuration.BaseDirectory, $"{System.AppDomain.CurrentDomain.FriendlyName}.config");
if (File.Exists(appConfig))
@ -49,7 +49,7 @@ namespace ZeroLevel.Services.Config.Implementation
internal IEnumerable<string> GetSections()
{
if (_configFilePath != null)
if (_configFilePath != null!)
{
var xdoc = XDocument.Load(_configFilePath);
var cs = xdoc.Descendants("connectionStrings").
@ -62,7 +62,7 @@ namespace ZeroLevel.Services.Config.Implementation
internal IEnumerable<Tuple<string, string>> ReadSection(string sectionName)
{
if (_configFilePath != null)
if (_configFilePath != null!)
{
var xdoc = XDocument.Load(_configFilePath);
return xdoc.Descendants(sectionName).
@ -78,7 +78,7 @@ namespace ZeroLevel.Services.Config.Implementation
private static string FindName(XElement n)
{
if (n == null) return string.Empty;
if (n == null!) return string.Empty;
var attributes = n.Attributes().
ToDictionary(i => i.Name.LocalName.ToLowerInvariant(), j => j.Value);
foreach (var v in new[] { "key", "name", "code", "id" })
@ -91,7 +91,7 @@ namespace ZeroLevel.Services.Config.Implementation
private static string FindValue(XElement n)
{
if (n == null) return string.Empty;
if (n == null!) return string.Empty;
var attributes = n.Attributes().
ToDictionary(i => i.Name.LocalName.ToLowerInvariant(), j => j.Value);
foreach (var v in new[] { "value", "val", "file", "db", "connectionstring" })

@ -16,7 +16,7 @@ namespace ZeroLevel.Services.Config.Implementation
public IConfiguration ReadConfiguration()
{
var result = Configuration.Create();
if (_args != null)
if (_args != null!)
{
try
{

@ -30,7 +30,7 @@ namespace ZeroLevel.Services.Config.Implementation
public IConfiguration ReadConfiguration()
{
var result = Configuration.Create();
string sectionName = null;
string sectionName = null!;
foreach (var line in File.ReadAllLines(_iniPath))
{
if (string.IsNullOrWhiteSpace(line))
@ -82,7 +82,7 @@ namespace ZeroLevel.Services.Config.Implementation
public IConfigurationSet ReadConfigurationSet()
{
var result = Configuration.CreateSet();
string sectionName = null;
string sectionName = null!;
foreach (var line in File.ReadAllLines(_iniPath))
{
if (string.IsNullOrWhiteSpace(line))

@ -40,7 +40,7 @@ namespace DOM.DSL.Contexts
}
else
{
_next = new TSystemToken { Command = name, Arg = null };
_next = new TSystemToken { Command = name, Arg = null! };
}
}
else
@ -72,7 +72,7 @@ namespace DOM.DSL.Contexts
public TToken Complete()
{
return new TElementToken { ElementName = _name, NextToken = _next?.Clone() };
return new TElementToken { ElementName = _name, NextToken = _next?.Clone()! };
}
}
}

@ -38,7 +38,7 @@ namespace DOM.DSL.Contexts
{
if (argTokens.Count > 0)
{
_argTokens.Add(new TBlockToken("", null, argTokens.Select(t => t.Clone()).ToArray()));
_argTokens.Add(new TBlockToken("", null!, argTokens.Select(t => t.Clone()).ToArray()));
argTokens.Clear();
}
});
@ -187,8 +187,8 @@ namespace DOM.DSL.Contexts
return new TFunctionToken
{
FunctionName = _name,
NextToken = _nextToken?.Clone(),
FunctionArgs = _argTokens?.Select(t => t.Clone())
NextToken = _nextToken?.Clone()!,
FunctionArgs = _argTokens?.Select(t => t.Clone())!
};
}
}

@ -185,8 +185,8 @@ namespace DOM.DSL.Contexts
return new TPropertyToken
{
PropertyName = _name,
PropertyIndex = new TBlockToken(_name, null, _indexTokens.Select(t => t.Clone()).ToArray()),
NextToken = _nextToken?.Clone()
PropertyIndex = new TBlockToken(_name, null!, _indexTokens.Select(t => t.Clone()).ToArray()),
NextToken = _nextToken?.Clone()!
};
}
}

@ -14,7 +14,7 @@ namespace DOM.DSL.Contexts
public TRootContext()
{
ParentContext = null;
ParentContext = null!;
_tokens = new List<TToken>();
}
@ -109,7 +109,7 @@ namespace DOM.DSL.Contexts
_tokens.Add(blockContext.Complete());
}
else if (ParentContext != null && ParentContext is TBlockContext &&
name.Equals("end" + (ParentContext as TBlockContext).Name, StringComparison.OrdinalIgnoreCase))
name.Equals("end" + (ParentContext as TBlockContext)!.Name, StringComparison.OrdinalIgnoreCase))
{
reader.Move(name.Length);
flushTextToken();

@ -26,7 +26,7 @@ namespace DOM.DSL.Model
// Containers
case ContentElementType.Section:
var section = (element as Section);
foreach (var item in section.Parts)
foreach (var item in section!.Parts)
{
TraversElement(item, type, handler);
}
@ -34,7 +34,7 @@ namespace DOM.DSL.Model
case ContentElementType.Paragraph:
var paragraph = (element as Paragraph);
foreach (var item in paragraph.Parts)
foreach (var item in paragraph!.Parts)
{
TraversElement(item, type, handler);
}
@ -42,7 +42,7 @@ namespace DOM.DSL.Model
case ContentElementType.List:
var list = (element as List);
foreach (var item in list.Items)
foreach (var item in list!.Items)
{
TraversElement(item, type, handler);
}
@ -50,7 +50,7 @@ namespace DOM.DSL.Model
case ContentElementType.Gallery:
var gallery = (element as Gallery);
foreach (var item in gallery.Images)
foreach (var item in gallery!.Images)
{
TraversElement(item, type, handler);
}
@ -58,7 +58,7 @@ namespace DOM.DSL.Model
case ContentElementType.Audioplayer:
var audioplayer = (element as Audioplayer);
foreach (var item in audioplayer.Tracks)
foreach (var item in audioplayer!.Tracks)
{
TraversElement(item, type, handler);
}
@ -66,7 +66,7 @@ namespace DOM.DSL.Model
case ContentElementType.Videoplayer:
var videoplayer = (element as Videoplayer);
foreach (var item in videoplayer.Playlist)
foreach (var item in videoplayer!.Playlist)
{
TraversElement(item, type, handler);
}
@ -74,7 +74,7 @@ namespace DOM.DSL.Model
case ContentElementType.Table:
var table = (element as Table);
foreach (var column in table.Columns)
foreach (var column in table!.Columns)
{
TraversElement(column, type, handler);
}

@ -7,10 +7,10 @@ namespace DOM.DSL.Model
public sealed class TEnvironment
{
public int Delay { get; set; } = 0;
public string FileName { get; set; } = null;
public Encoding Encoding { get; set; } = null;
public string ContractName { get; set; } = null;
public string SubscriptionName { get; set; } = null;
public string FileName { get; set; } = null!;
public Encoding Encoding { get; set; } = null!;
public string ContractName { get; set; } = null!;
public string SubscriptionName { get; set; } = null!;
public Guid SubscriptionId { get; set; } = Guid.Empty;
public IDictionary<string, object> CustomVariables { get; }

@ -353,7 +353,7 @@ namespace DOM.DSL.Model
break;
case "special": // Using a hardcoded table conversion
//TablePrefix = TablePostfix = null;
//TablePrefix = TablePostfix = null!;
ColumnsPrefix = ColumnsPostfix = null!;
ColumnPrefix = ColumnTemplate = ColumnPostfix = null!;
RowPrefix = RowPostfix = null!;
@ -361,7 +361,7 @@ namespace DOM.DSL.Model
// Args: (style, paddings l-t-r-b, maxcellwidth, maxtablewidth)
UseSpecialTableBuilder = true;
SpecialTableBuilder = SpecialTableBuilderFactory.CreateSpecialTableBuilder(special);
if (SpecialTableBuilder == null) UseSpecialTableBuilder = false;
if (SpecialTableBuilder == null!) UseSpecialTableBuilder = false;
break;
}
break;

@ -19,10 +19,10 @@ namespace DOM.DSL.Services
public void FlushRow()
{
if (RowCells != null)
if (RowCells != null!)
{
Data.AppendRow(RowCells);
RowCells = null;
RowCells = null!;
}
}

@ -30,7 +30,7 @@ namespace DOM.DSL.Services
public void Append(object _item)
{
if (_item == null) return;
if (_item == null!) return;
object item;
if (_item is TContainer)
{
@ -40,7 +40,7 @@ namespace DOM.DSL.Services
{
item = _item;
}
if (_list == null)
if (_list == null!)
{
_elementType = item.GetType();
_list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(_elementType));
@ -159,7 +159,7 @@ namespace DOM.DSL.Services
public void MoveToProperty(string propertyName, string propertyIndex)
{
if (propertyName.Equals("order", StringComparison.OrdinalIgnoreCase)) { Reset(Index); return; }
if (_current == null) return;
if (_current == null!) return;
var buff_val = _current;
var buff_index = Index;
@ -211,7 +211,7 @@ namespace DOM.DSL.Services
{
var buff_val = _current;
var buff_index = Index;
TContainer[] args = null;
TContainer[] args = null!;
try
{
switch (GetFunctionType(functionName))
@ -242,7 +242,7 @@ namespace DOM.DSL.Services
_current = buff_val;
Index = buff_index;
}
if (args != null)
if (args != null!)
{
foreach (var a in args)
_factory.Release(a);
@ -253,7 +253,7 @@ namespace DOM.DSL.Services
public T As<T>()
{
if (_current == null) return default(T);
if (_current == null!) return default(T)!;
if (_current is T) return (T)_current;
var type = typeof(T);
if (_current is string)
@ -267,13 +267,13 @@ namespace DOM.DSL.Services
catch (Exception ex)
{
Log.SystemWarning($"[DOM.TContainer] Fault cast current value from type '{_current?.GetType()?.FullName ?? string.Empty}' to type '{type.FullName}'. {ex.ToString()}");
return default(T);
return default(T)!;
}
}
public object As(Type type)
{
if (_current == null) return TypeHelpers.CreateDefaultState(type);
if (_current == null!) return TypeHelpers.CreateDefaultState(type);
if (_current.GetType().IsAssignableFrom(type)) return _current;
if (_current is string)
{
@ -927,7 +927,7 @@ namespace DOM.DSL.Services
break;
}
if (enumerable != null)
if (enumerable != null!)
{
int index;
if (int.TryParse(propertyIndex, out index))
@ -1336,7 +1336,7 @@ namespace DOM.DSL.Services
}
else
{
Reset(null);
Reset(null!);
}
}
@ -1388,7 +1388,7 @@ namespace DOM.DSL.Services
private void ApplyStringFunction(string function, TContainer[] args)
{
if (_current == null)
if (_current == null!)
{
args = null!;
return;
@ -1774,7 +1774,7 @@ namespace DOM.DSL.Services
private void ApplyExtractionFunction(string function, Func<TContainer, TContainer[]> args_getter, out TContainer[] args)
{
if (_current == null)
if (_current == null!)
{
if (function.Equals("append", StringComparison.OrdinalIgnoreCase))
{
@ -1806,7 +1806,7 @@ namespace DOM.DSL.Services
}
if (function.Equals("where", StringComparison.OrdinalIgnoreCase))
{
if (args_getter != null)
if (args_getter != null!)
{
if (IsEnumerable)
{
@ -1814,10 +1814,10 @@ namespace DOM.DSL.Services
int index = 0;
foreach (var i in ((IEnumerable)_current))
{
if (i == null) continue;
if (i == null!) continue;
var container = _factory.Get(i, index);
var conditions = args_getter(container);
if (conditions != null)
if (conditions != null!)
{
bool success = conditions.Any();
foreach (var c in conditions)
@ -1836,7 +1836,7 @@ namespace DOM.DSL.Services
Reset(list.Complete());
}
}
args = null;
args = null!;
return;
}
else
@ -1856,7 +1856,7 @@ namespace DOM.DSL.Services
{
_render.BufferDictionary[key] = this._current;
}
Reset(null);
Reset(null!);
}
break;
@ -1967,7 +1967,7 @@ namespace DOM.DSL.Services
var list = new TDList();
foreach (var i in ((IEnumerable)_current))
{
if (i == null) continue;
if (i == null!) continue;
var container = _factory.Get(i);
container.MoveToProperty(property, property_index!);
list.Append(container.Current);
@ -1998,7 +1998,7 @@ namespace DOM.DSL.Services
var list = new TDList();
foreach (var i in ((IEnumerable)_current))
{
if (i == null) continue;
if (i == null!) continue;
var container = _factory.Get(i);
switch (functionType)
{
@ -2062,7 +2062,7 @@ namespace DOM.DSL.Services
case "tonum":
case "tonumber":
if (_current != null)
if (_current != null!)
{
var buf = _current.ToString();
int num;
@ -2081,7 +2081,7 @@ namespace DOM.DSL.Services
if (_current is List<TContainer>)
{
var list = _current as List<TContainer>;
if (list == null)
if (list == null!)
{
_current = new List<TContainer>();
list = _current as List<TContainer>;
@ -2455,7 +2455,7 @@ namespace DOM.DSL.Services
private void ChangeDateTime(TContainer value, ChangeDateTimeType type)
{
if (_current == null) return;
if (_current == null!) return;
if (_current is DateTime)
{
var dt = (DateTime)_current;
@ -2498,7 +2498,7 @@ namespace DOM.DSL.Services
public bool Any(TContainer[] set = null!, bool ignoreCase = true)
{
if (_current == null) return false;
if (_current == null!) return false;
if (set?.Any() ?? false)
{
if (_current is IEnumerable && false == (_current is string))
@ -2525,7 +2525,7 @@ namespace DOM.DSL.Services
public bool Contains(TContainer[] set, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null!) return false;
if (set == null || set?.Length == 0) return false;
if (_current is IEnumerable && false == (_current is string))
{
@ -2564,8 +2564,8 @@ namespace DOM.DSL.Services
public bool NoContains(TContainer[] test, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null) return false;
if (_current == null!) return false;
if (_current == null!) return false;
if (_current is IEnumerable && false == (_current is string))
{
foreach (var c in (IEnumerable)_current)
@ -2588,43 +2588,43 @@ namespace DOM.DSL.Services
public bool IsEmpty()
{
if (_current == null) return true;
if (_current == null!) return true;
return String.IsNullOrWhiteSpace(_current.ToString());
}
public bool Is(TContainer test, bool ignoreCase)
{
if (_current == null) return test.Current == null;
if (_current == null!) return test.Current == null!;
return CompareWith(test, ignoreCase) == 0;
}
public bool IsNot(TContainer test, bool ignoreCase)
{
if (_current == null) return test.Current != null;
if (_current == null!) return test.Current != null!;
return CompareWith(test, ignoreCase) != 0;
}
public bool LessThan(TContainer test, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null!) return false;
return CompareWith(test, ignoreCase) < 0;
}
public bool MoreThan(TContainer test, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null!) return false;
return CompareWith(test, ignoreCase) > 0;
}
public bool LessOrEq(TContainer test, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null!) return false;
return CompareWith(test, ignoreCase) <= 0;
}
public bool MoreOrEq(TContainer test, bool ignoreCase)
{
if (_current == null) return false;
if (_current == null!) return false;
return CompareWith(test, ignoreCase) >= 0;
}
@ -2734,7 +2734,7 @@ namespace DOM.DSL.Services
private static string FormattedDateTime(DateTime dt, string format = null!, string culture = null!)
{
CultureInfo ci;
if (culture != null)
if (culture != null!)
{
try
{
@ -2764,7 +2764,7 @@ namespace DOM.DSL.Services
public override string ToString()
{
if (_current == null) return string.Empty;
if (_current == null!) return string.Empty;
if (_current is string) return (string)_current;
else if (_current is DateTime) return FormattedDateTime((DateTime)_current);

@ -37,7 +37,7 @@ namespace DOM.DSL.Services
internal void Release(TContainer container)
{
if (container != null)
if (container != null!)
{
Interlocked.Increment(ref _release_count);
_pool.Return(container);

@ -22,7 +22,7 @@ namespace DOM.DSL.Services
_render = render;
_transformRules = rules;
_specialTableBuilder = rules.SpecialTableBuilder;
_useSpecialTableBuilder = rules.UseSpecialTableBuilder && rules.SpecialTableBuilder != null;
_useSpecialTableBuilder = rules.UseSpecialTableBuilder && rules.SpecialTableBuilder != null!;
_builder = new StringBuilder();
}
@ -58,15 +58,15 @@ namespace DOM.DSL.Services
public void ReadAudio(Audio audio, int order)
{
_render.Counter.IncAudioId();
if (_transformRules.AudioPrefix != null)
if (_transformRules.AudioPrefix != null!)
{
WriteText(Resolve(_transformRules.AudioPrefix, audio, order));
}
if (_transformRules.AudioTemplate != null)
if (_transformRules.AudioTemplate != null!)
{
WriteText(Resolve(_transformRules.AudioTemplate, audio, order));
}
if (_transformRules.AudioPostfix != null)
if (_transformRules.AudioPostfix != null!)
{
WriteText(Resolve(_transformRules.AudioPostfix, audio, order));
}
@ -75,15 +75,15 @@ namespace DOM.DSL.Services
public void ReadColumn(Table table, Column column, int order)
{
_render.Counter.IncColumnId();
if (_transformRules.ColumnPrefix != null)
if (_transformRules.ColumnPrefix != null!)
{
WriteText(Resolve(_transformRules.ColumnPrefix, column, order));
}
if (_transformRules.ColumnTemplate != null)
if (_transformRules.ColumnTemplate != null!)
{
WriteText(Resolve(_transformRules.ColumnTemplate, column, order));
}
if (_transformRules.ColumnPostfix != null)
if (_transformRules.ColumnPostfix != null!)
{
WriteText(Resolve(_transformRules.ColumnPostfix, column, order));
}
@ -92,15 +92,15 @@ namespace DOM.DSL.Services
public void ReadForm(FormContent form)
{
_render.Counter.IncFormId();
if (_transformRules.FormPrefix != null)
if (_transformRules.FormPrefix != null!)
{
WriteText(Resolve(_transformRules.FormPrefix, form, 0));
}
if (_transformRules.FormTemplate != null)
if (_transformRules.FormTemplate != null!)
{
WriteText(Resolve(_transformRules.FormTemplate, form, 0));
}
if (_transformRules.FormPostfix != null)
if (_transformRules.FormPostfix != null!)
{
WriteText(Resolve(_transformRules.FormPostfix, form, 0));
}
@ -109,15 +109,15 @@ namespace DOM.DSL.Services
public void ReadImage(Image image, int order)
{
_render.Counter.IncImageId();
if (_transformRules.ImagePrefix != null)
if (_transformRules.ImagePrefix != null!)
{
WriteText(Resolve(_transformRules.ImagePrefix, image, order));
}
if (_transformRules.ImageTemplate != null)
if (_transformRules.ImageTemplate != null!)
{
WriteText(Resolve(_transformRules.ImageTemplate, image, order));
}
if (_transformRules.ImagePostfix != null)
if (_transformRules.ImagePostfix != null!)
{
WriteText(Resolve(_transformRules.ImagePostfix, image, order));
}
@ -126,15 +126,15 @@ namespace DOM.DSL.Services
public void ReadLink(Link link, int order)
{
_render.Counter.IncLinkId();
if (_transformRules.LinkPrefix != null)
if (_transformRules.LinkPrefix != null!)
{
WriteText(Resolve(_transformRules.LinkPrefix, link, order));
}
if (_transformRules.LinkTemplate != null)
if (_transformRules.LinkTemplate != null!)
{
WriteText(Resolve(_transformRules.LinkTemplate, link, order));
}
if (_transformRules.LinkPostfix != null)
if (_transformRules.LinkPostfix != null!)
{
WriteText(Resolve(_transformRules.LinkPostfix, link, order));
}
@ -143,15 +143,15 @@ namespace DOM.DSL.Services
public void ReadQuote(Quote quote)
{
_render.Counter.IncQuoteId();
if (_transformRules.QuotePrefix != null)
if (_transformRules.QuotePrefix != null!)
{
WriteText(Resolve(_transformRules.QuotePrefix, quote, 0));
}
if (_transformRules.QuoteTemplate != null)
if (_transformRules.QuoteTemplate != null!)
{
WriteText(Resolve(_transformRules.QuoteTemplate, quote, 0));
}
if (_transformRules.QuotePostfix != null)
if (_transformRules.QuotePostfix != null!)
{
WriteText(Resolve(_transformRules.QuotePostfix, quote, 0));
}
@ -160,15 +160,15 @@ namespace DOM.DSL.Services
public void ReadText(Text text)
{
_render.Counter.IncTextId();
if (_transformRules.TextPrefix != null)
if (_transformRules.TextPrefix != null!)
{
WriteText(Resolve(_transformRules.TextPrefix, text, 0));
}
if (_transformRules.TextTemplate != null)
if (_transformRules.TextTemplate != null!)
{
WriteText(Resolve(_transformRules.TextTemplate, text, 0));
}
if (_transformRules.TextPostfix != null)
if (_transformRules.TextPostfix != null!)
{
WriteText(Resolve(_transformRules.TextPostfix, text, 0));
}
@ -177,15 +177,15 @@ namespace DOM.DSL.Services
public void ReadVideo(Video video, int order)
{
_render.Counter.IncVideoId();
if (_transformRules.VideoPrefix != null)
if (_transformRules.VideoPrefix != null!)
{
WriteText(Resolve(_transformRules.VideoPrefix, video, order));
}
if (_transformRules.VideoTemplate != null)
if (_transformRules.VideoTemplate != null!)
{
WriteText(Resolve(_transformRules.VideoTemplate, video, order));
}
if (_transformRules.VideoPostfix != null)
if (_transformRules.VideoPostfix != null!)
{
WriteText(Resolve(_transformRules.VideoPostfix, video, order));
}
@ -198,7 +198,7 @@ namespace DOM.DSL.Services
public void EnterParagraph(Paragraph paragraph)
{
_render.Counter.IncParagraphId();
if (_transformRules.ParagraphPrefix != null)
if (_transformRules.ParagraphPrefix != null!)
{
WriteText(Resolve(_transformRules.ParagraphPrefix, paragraph, _render.Counter.ParagraphId));
}
@ -206,7 +206,7 @@ namespace DOM.DSL.Services
public void LeaveParagraph(Paragraph paragraph)
{
if (_transformRules.ParagraphPostfix != null)
if (_transformRules.ParagraphPostfix != null!)
{
WriteText(Resolve(_transformRules.ParagraphPostfix, paragraph, _render.Counter.ParagraphId));
}
@ -215,7 +215,7 @@ namespace DOM.DSL.Services
public void EnterSection(Section section)
{
_render.Counter.IncSectionId();
if (_transformRules.SectionPrefix != null)
if (_transformRules.SectionPrefix != null!)
{
WriteText(Resolve(_transformRules.SectionPrefix, section, _render.Counter.SectionId));
}
@ -223,7 +223,7 @@ namespace DOM.DSL.Services
public void LeaveSection(Section section)
{
if (_transformRules.SectionPostfix != null)
if (_transformRules.SectionPostfix != null!)
{
WriteText(Resolve(_transformRules.SectionPostfix, section, _render.Counter.SectionId));
}
@ -236,7 +236,7 @@ namespace DOM.DSL.Services
public void EnterTable(Table table)
{
_render.Counter.IncTableId();
if (_transformRules.TablePrefix != null)
if (_transformRules.TablePrefix != null!)
{
_builder.Append(Resolve(_transformRules.TablePrefix, table, _render.Counter.TableId));
}
@ -249,7 +249,7 @@ namespace DOM.DSL.Services
public void EnterColumns(Table table)
{
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPrefix != null)
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPrefix != null!)
{
_builder.Append(Resolve(_transformRules.ColumnsPrefix, table.Columns, 0));
}
@ -262,7 +262,7 @@ namespace DOM.DSL.Services
{
_specialTableBuilder.EnterRow(row.Cells.Count);
}
else if (_transformRules.RowPrefix != null)
else if (_transformRules.RowPrefix != null!)
{
_builder.Append(Resolve(_transformRules.RowPrefix, row, order));
}
@ -277,11 +277,11 @@ namespace DOM.DSL.Services
}
else
{
if (order == 0 && _transformRules.FirstRowCellPrefix != null)
if (order == 0 && _transformRules.FirstRowCellPrefix != null!)
{
_builder.Append(Resolve(_transformRules.FirstRowCellPrefix, cell, order));
}
else if (_transformRules.CellPrefix != null)
else if (_transformRules.CellPrefix != null!)
{
_builder.Append(Resolve(_transformRules.CellPrefix, cell, order));
}
@ -290,7 +290,7 @@ namespace DOM.DSL.Services
public void LeaveColumns(Table table)
{
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPostfix != null)
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPostfix != null!)
{
_builder.Append(Resolve(_transformRules.ColumnsPostfix, table.Columns, 0));
}
@ -302,7 +302,7 @@ namespace DOM.DSL.Services
{
_specialTableBuilder.LeaveRow();
}
else if (_transformRules.RowPostfix != null)
else if (_transformRules.RowPostfix != null!)
{
_builder.Append(Resolve(_transformRules.RowPostfix, row, order));
}
@ -316,11 +316,11 @@ namespace DOM.DSL.Services
}
else
{
if (order == 0 && _transformRules.FirstRowCellPostfix != null)
if (order == 0 && _transformRules.FirstRowCellPostfix != null!)
{
_builder.Append(Resolve(_transformRules.FirstRowCellPostfix, cell, order));
}
else if (_transformRules.CellPostfix != null)
else if (_transformRules.CellPostfix != null!)
{
_builder.Append(Resolve(_transformRules.CellPostfix, cell, order));
}
@ -333,7 +333,7 @@ namespace DOM.DSL.Services
{
_specialTableBuilder.FlushTable(_builder);
}
if (_transformRules.TablePostfix != null)
if (_transformRules.TablePostfix != null!)
{
_builder.Append(Resolve(_transformRules.TablePostfix, table, _render.Counter.TableId));
}
@ -346,7 +346,7 @@ namespace DOM.DSL.Services
public void EnterList(List list)
{
_render.Counter.IncListId();
if (_transformRules.ListPrefix != null)
if (_transformRules.ListPrefix != null!)
{
WriteText(Resolve(_transformRules.ListPrefix, list, 0));
}
@ -355,7 +355,7 @@ namespace DOM.DSL.Services
public void EnterListItem(List list, IContentElement item, int order)
{
_render.Counter.IncListItemId();
if (_transformRules.ListItemPrefix != null)
if (_transformRules.ListItemPrefix != null!)
{
WriteText(Resolve(_transformRules.ListItemPrefix, item, order));
}
@ -363,7 +363,7 @@ namespace DOM.DSL.Services
public void LeaveList(List list)
{
if (_transformRules.ListPostfix != null)
if (_transformRules.ListPostfix != null!)
{
WriteText(Resolve(_transformRules.ListPostfix, list, 0));
}
@ -371,7 +371,7 @@ namespace DOM.DSL.Services
public void LeaveListItem(List list, IContentElement item, int order)
{
if (_transformRules.ListItemPostfix != null)
if (_transformRules.ListItemPostfix != null!)
{
WriteText(Resolve(_transformRules.ListItemPostfix, item, order));
}
@ -384,7 +384,7 @@ namespace DOM.DSL.Services
public void EnterAudioplayer(Audioplayer player)
{
_render.Counter.IncAudioplayerId();
if (_transformRules.AudioplayerPrefix != null)
if (_transformRules.AudioplayerPrefix != null!)
{
WriteText(Resolve(_transformRules.AudioplayerPrefix, player, 0));
}
@ -393,7 +393,7 @@ namespace DOM.DSL.Services
public void EnterGallery(Gallery gallery)
{
_render.Counter.IncGalleryId();
if (_transformRules.GalleryPrefix != null)
if (_transformRules.GalleryPrefix != null!)
{
WriteText(Resolve(_transformRules.GalleryPrefix, gallery, 0));
}
@ -402,7 +402,7 @@ namespace DOM.DSL.Services
public void EnterVideoplayer(Videoplayer player)
{
_render.Counter.IncVideoplayerId();
if (_transformRules.VideoplayerPrefix != null)
if (_transformRules.VideoplayerPrefix != null!)
{
WriteText(Resolve(_transformRules.VideoplayerPrefix, player, 0));
}
@ -410,7 +410,7 @@ namespace DOM.DSL.Services
public void LeaveAudioplayer(Audioplayer player)
{
if (_transformRules.AudioplayerPostfix != null)
if (_transformRules.AudioplayerPostfix != null!)
{
WriteText(Resolve(_transformRules.AudioplayerPostfix, player, 0));
}
@ -418,7 +418,7 @@ namespace DOM.DSL.Services
public void LeaveGallery(Gallery gallery)
{
if (_transformRules.GalleryPostfix != null)
if (_transformRules.GalleryPostfix != null!)
{
WriteText(Resolve(_transformRules.GalleryPostfix, gallery, 0));
}
@ -426,7 +426,7 @@ namespace DOM.DSL.Services
public void LeaveVideoplayer(Videoplayer player)
{
if (_transformRules.VideoplayerPostfix != null)
if (_transformRules.VideoplayerPostfix != null!)
{
WriteText(Resolve(_transformRules.VideoplayerPostfix, player, 0));
}

@ -21,7 +21,7 @@ namespace DOM.DSL.Services
_blocks.Add(name, tokens);
else
{
_blocks[name] = null;
_blocks[name] = null!;
_blocks[name] = tokens;
}
}
@ -157,7 +157,7 @@ namespace DOM.DSL.Services
{
var block = new TBlockToken(_blocks.Get(token.NextToken.AsPropertyToken().PropertyName));
var result = ResolveBlockToken(block, self);
container = Factory.Get(result.Where(c => c.Current != null).Select(c => c.Current).ToList());
container = Factory.Get(result.Where(c => c.Current != null!).Select(c => c.Current).ToList());
foreach (var c in result)
Factory.Release(c);
}
@ -165,7 +165,7 @@ namespace DOM.DSL.Services
}
}
if (container == null) container = Factory.Get(null!);
if (container == null!) container = Factory.Get(null!);
if (token.NextToken is TPropertyToken)
{
@ -255,7 +255,7 @@ namespace DOM.DSL.Services
{
var ls = self_parent == null ? null : Factory.Get(self_parent.Current, self_parent.Index);
result = ResolveSimpleBlockToken(blockToken, ls!);
Factory.Release(ls);
Factory.Release(ls!);
}
else
{
@ -268,7 +268,7 @@ namespace DOM.DSL.Services
var list = new List<TContainer>();
TContainer self_container = null!;
Resolve(blockToken.Condition, c => self_container = c, false, self_parent);
if (self_container != null)
if (self_container != null!)
{
if (self_container.IsEnumerable)
{
@ -319,7 +319,7 @@ namespace DOM.DSL.Services
{
var function = token.AsElementToken()?.NextToken?.AsFunctionToken();
var elementName = token.AsElementToken()?.ElementName;
if (elementName != null)
if (elementName != null!)
{
var functionName = function?.FunctionName ?? string.Empty;
var rule_token = function?.FunctionArgs == null ?

@ -36,11 +36,11 @@ namespace DOM.DSL
public static string Apply(Document document, IEnumerable<TToken> tokens, TEnvironment environment, bool ignore_fault = true)
{
if (document == null)
if (document == null!)
{
throw new ArgumentNullException(nameof(document));
}
if (tokens == null)
if (tokens == null!)
{
throw new ArgumentNullException(nameof(tokens));
}

@ -21,7 +21,7 @@
return new TElementToken
{
ElementName = this.ElementName,
NextToken = this.NextToken?.Clone()
NextToken = this.NextToken?.Clone()!
};
}
@ -30,7 +30,7 @@
return new TElementToken
{
ElementName = this.ElementName,
NextToken = null
NextToken = null!
};
}
}

@ -16,7 +16,7 @@ namespace DOM.DSL.Tokens
{
FunctionArgs = FunctionArgs.Select(a => a.Clone()).ToArray(),
FunctionName = this.FunctionName,
NextToken = this.NextToken?.Clone()
NextToken = this.NextToken?.Clone()!
};
}
@ -26,7 +26,7 @@ namespace DOM.DSL.Tokens
{
FunctionArgs = FunctionArgs.Select(a => a.Clone()).ToArray(),
FunctionName = this.FunctionName,
NextToken = null
NextToken = null!
};
}
}

@ -13,7 +13,7 @@
{
PropertyIndex = this.PropertyIndex,
PropertyName = this.PropertyName,
NextToken = this.NextToken?.Clone()
NextToken = this.NextToken?.Clone()!
};
}
@ -23,7 +23,7 @@
{
PropertyIndex = this.PropertyIndex,
PropertyName = this.PropertyName,
NextToken = null
NextToken = null!
};
}
}

@ -11,7 +11,7 @@
return new TSystemToken
{
Command = this.Command,
Arg = this.Arg?.Clone()
Arg = this.Arg?.Clone()!
};
}

@ -15,16 +15,16 @@ namespace DOM.DSL.Tokens
/// <returns></returns>
public abstract TToken CloneLocal();
public TElementToken AsElementToken() => this as TElementToken;
public TElementToken AsElementToken() => (this as TElementToken)!;
public TFunctionToken AsFunctionToken() => this as TFunctionToken;
public TFunctionToken AsFunctionToken() => (this as TFunctionToken)!;
public TTextToken AsTextToken() => this as TTextToken;
public TTextToken AsTextToken() => (this as TTextToken)!;
public TBlockToken AsBlockToken() => this as TBlockToken;
public TBlockToken AsBlockToken() => (this as TBlockToken)!;
public TPropertyToken AsPropertyToken() => this as TPropertyToken;
public TPropertyToken AsPropertyToken() => (this as TPropertyToken)!;
public TSystemToken AsSystemToken() => this as TSystemToken;
public TSystemToken AsSystemToken() => (this as TSystemToken)!;
}
}

@ -57,7 +57,7 @@ namespace ZeroLevel.DocumentObjectModel
public T Read<T>()
{
if (this.Payload == null || this.Payload.Length == 0) return default(T);
if (this.Payload == null || this.Payload.Length == 0) return default(T)!;
return MessageSerializer.DeserializeCompatible<T>(this.Payload);
}

@ -14,7 +14,7 @@ namespace ZeroLevel.DocumentObjectModel
{
}
public Category(string title, string code, string direction_code, string description = null,
public Category(string title, string code, string direction_code, string description = null!,
bool is_system = false)
{
this.Title = title;
@ -104,7 +104,7 @@ namespace ZeroLevel.DocumentObjectModel
public bool Equals(Category other)
{
if (other == null) return false;
if (other == null!) return false;
if (string.Compare(this.Title, other.Title, StringComparison.Ordinal) != 0) return false;
if (string.Compare(this.Code, other.Code, StringComparison.Ordinal) != 0) return false;
if (string.Compare(this.Description, other.Description, StringComparison.Ordinal) != 0) return false;
@ -119,7 +119,7 @@ namespace ZeroLevel.DocumentObjectModel
public override bool Equals(object obj)
{
return this.Equals(obj as Category);
return this.Equals((obj as Category)!);
}
public override int GetHashCode()

@ -77,7 +77,7 @@ namespace ZeroLevel.DocumentObjectModel
public bool Equals(Header other)
{
if (other == null) return false;
if (other == null!) return false;
if (string.Compare(this.Name, other.Name, StringComparison.Ordinal) != 0) return false;
if (string.Compare(this.Value, other.Value, StringComparison.Ordinal) != 0) return false;
if (string.Compare(this.Type, other.Type, StringComparison.Ordinal) != 0) return false;
@ -91,7 +91,7 @@ namespace ZeroLevel.DocumentObjectModel
public override bool Equals(object obj)
{
return this.Equals(obj as Header);
return this.Equals((obj as Header)!);
}
public override int GetHashCode()

@ -16,7 +16,7 @@ namespace DOM.Services
public ContentBuilder(Document document)
{
if (document == null)
if (document == null!)
{
throw new ArgumentNullException(nameof(document));
}
@ -318,7 +318,7 @@ namespace DOM.Services
{
RaiseIncorrectTypeException(section.Type, ContentElementType.Section);
}
_content.Sections.Add(section as Section);
_content.Sections.Add((section as Section)!);
}
public void EnterParagraph()
@ -482,7 +482,7 @@ namespace DOM.Services
public void WriteColumn(Column column)
{
if (column == null)
if (column == null!)
{
throw new ArgumentNullException(nameof(column));
}
@ -491,7 +491,7 @@ namespace DOM.Services
public void WriteText(Text text)
{
if (text == null)
if (text == null!)
{
throw new ArgumentNullException(nameof(text));
}
@ -515,7 +515,7 @@ namespace DOM.Services
public void WriteQuote(Quote quote)
{
if (quote == null)
if (quote == null!)
{
throw new ArgumentNullException(nameof(quote));
}
@ -529,7 +529,7 @@ namespace DOM.Services
public void WriteLink(Link link)
{
if (link == null)
if (link == null!)
{
throw new ArgumentNullException(nameof(link));
}
@ -543,7 +543,7 @@ namespace DOM.Services
public void WriteForm(FormContent form)
{
if (form == null)
if (form == null!)
{
throw new ArgumentNullException(nameof(form));
}
@ -552,7 +552,7 @@ namespace DOM.Services
public void WriteImage(Image image)
{
if (image == null)
if (image == null!)
{
throw new ArgumentNullException(nameof(image));
}
@ -561,7 +561,7 @@ namespace DOM.Services
public void WriteAudio(Audio audio)
{
if (audio == null)
if (audio == null!)
{
throw new ArgumentNullException(nameof(audio));
}
@ -570,7 +570,7 @@ namespace DOM.Services
public void WriteVideo(Video video)
{
if (video == null)
if (video == null!)
{
throw new ArgumentNullException(nameof(video));
}

@ -52,7 +52,7 @@ namespace DOM.Services
case ContentElementType.Content:
{
var content = (element as FlowContent);
if (content != null)
if (content != null!)
{
for (int i = 0; i < content.Sections.Count; i++)
{
@ -64,7 +64,7 @@ namespace DOM.Services
case ContentElementType.Section:
var section = (element as Section);
if (section != null)
if (section != null!)
{
reader.EnterSection(section);
for (int i = 0; i < section.Parts.Count; i++)
@ -77,7 +77,7 @@ namespace DOM.Services
case ContentElementType.Paragraph:
var paragraph = (element as Paragraph);
if (paragraph != null)
if (paragraph != null!)
{
reader.EnterParagraph(paragraph);
for (int i = 0; i < paragraph.Parts.Count; i++)
@ -90,7 +90,7 @@ namespace DOM.Services
case ContentElementType.List:
var list = (element as List);
if (list != null)
if (list != null!)
{
reader.EnterList(list);
for (int i = 0; i < list.Items.Count; i++)
@ -105,7 +105,7 @@ namespace DOM.Services
case ContentElementType.Gallery:
var gallery = (element as Gallery);
if (gallery != null)
if (gallery != null!)
{
reader.EnterGallery(gallery);
for (int i = 0; i < gallery.Images.Count; i++)
@ -118,7 +118,7 @@ namespace DOM.Services
case ContentElementType.Audioplayer:
var audioplayer = (element as Audioplayer);
if (audioplayer != null)
if (audioplayer != null!)
{
reader.EnterAudioplayer(audioplayer);
for (int i = 0; i < audioplayer.Tracks.Count; i++)
@ -131,7 +131,7 @@ namespace DOM.Services
case ContentElementType.Videoplayer:
var videoplayer = (element as Videoplayer);
if (videoplayer != null)
if (videoplayer != null!)
{
reader.EnterVideoplayer(videoplayer);
for (int i = 0; i < videoplayer.Playlist.Count; i++)
@ -144,7 +144,7 @@ namespace DOM.Services
case ContentElementType.Table:
var table = (element as Table);
if (table != null)
if (table != null!)
{
reader.EnterTable(table);
reader.EnterColumns(table);

@ -15,7 +15,7 @@ namespace ZeroLevel.DependencyInjection
private static object Activate(Type type, object[] args)
{
if (type == null) return null!;
if (type == null!) return null!;
var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public;
CultureInfo culture = null!; // use InvariantCulture or other if you prefer
return Activator.CreateInstance(type, flags, null, args, culture);
@ -157,7 +157,7 @@ namespace ZeroLevel.DependencyInjection
Type instanceType = resolveType.GenericCachee[genericType];
if (resolveType.IsShared)
{
if (resolveType.GenericInstanceCachee == null)
if (resolveType.GenericInstanceCachee == null!)
{
resolveType.GenericInstanceCachee = new Dictionary<Type, object>();
}
@ -188,7 +188,7 @@ namespace ZeroLevel.DependencyInjection
private static IEnumerable<PropertyInfo> CollectResolvingProperties(Type type)
{
return type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy).
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null);
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null!);
}
/// <summary>
@ -199,7 +199,7 @@ namespace ZeroLevel.DependencyInjection
private static IEnumerable<FieldInfo> CollectResolvingFields(Type type)
{
return type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy).
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null);
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null!);
}
/// <summary>
@ -212,7 +212,7 @@ namespace ZeroLevel.DependencyInjection
private ResolveTypeInfo FindResolving(Type type, string resolveName, Type contractType)
{
HashSet<Type> contract_candidates = new HashSet<Type>();
if (contractType != null)
if (contractType != null!)
{
if (contractType.IsInterface)
contract_candidates.Add(contractType);
@ -321,8 +321,8 @@ namespace ZeroLevel.DependencyInjection
/// <returns>Instance</returns>
private object MakeInstance(Type type, object[] args)
{
ConstructorInfo constructor = null;
object[] parameters = null;
ConstructorInfo constructor = null!;
object[] parameters = null!;
foreach (var ctor in GetConstructors(type))
{
if (ctor.IsMatch(args, out parameters))
@ -339,7 +339,7 @@ namespace ZeroLevel.DependencyInjection
{
return constructor.Invoke(parameters);
/*var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public;
CultureInfo culture = null; // use InvariantCulture or other if you prefer
CultureInfo culture = null!; // use InvariantCulture or other if you prefer
return Activator.CreateInstance(type, flags, null, args, culture);*/
}
}
@ -430,7 +430,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = typeof(TImplementation),
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = false,
ResolveKey = resolveName?.Trim()
ResolveKey = resolveName?.Trim()!
};
Register(typeof(TContract), resolveType);
}
@ -442,7 +442,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = typeof(TImplementation),
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = shared,
ResolveKey = resolveName?.Trim()
ResolveKey = resolveName?.Trim()!
};
Register(typeof(TContract), resolveType);
}
@ -466,7 +466,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = implementationType,
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = false,
ResolveKey = resolveName?.Trim()
ResolveKey = resolveName?.Trim()!
};
Register(contractType, resolveType);
}
@ -490,7 +490,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = implementationType,
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = shared,
ResolveKey = resolveName?.Trim()
ResolveKey = resolveName?.Trim()!
};
Register(contractType, resolveType);
}
@ -519,7 +519,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = typeof(TImplementation),
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = false,
ResolveKey = resolveName?.Trim(),
ResolveKey = resolveName?.Trim()!,
ConstructorParameters = constructorParameters
};
Register(typeof(TContract), resolveType);
@ -545,7 +545,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = typeof(TImplementation),
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = shared,
ResolveKey = resolveName?.Trim(),
ResolveKey = resolveName?.Trim()!,
ConstructorParameters = constructorParameters
};
Register(typeof(TContract), resolveType);
@ -571,7 +571,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = implementationType,
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = false,
ResolveKey = resolveName?.Trim(),
ResolveKey = resolveName?.Trim()!,
ConstructorParameters = constructorParameters
};
Register(contractType, resolveType);
@ -597,7 +597,7 @@ namespace ZeroLevel.DependencyInjection
ImplementationType = implementationType,
IsDefault = string.IsNullOrWhiteSpace(resolveName),
IsShared = shared,
ResolveKey = resolveName?.Trim(),
ResolveKey = resolveName?.Trim()!,
ConstructorParameters = constructorParameters
};
Register(contractType, resolveType);
@ -614,6 +614,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="implementation">Instance</param>
public void Register<TContract>(TContract implementation)
{
if(implementation == null) throw new ArgumentNullException(nameof(implementation));
var resolveType = new ResolveTypeInfo
{
ImplementationType = implementation.GetType(),
@ -627,6 +628,7 @@ namespace ZeroLevel.DependencyInjection
public void Register(Type contractType, object implementation)
{
if (implementation == null) throw new ArgumentNullException(nameof(implementation));
var resolveType = new ResolveTypeInfo
{
ImplementationType = implementation.GetType(),
@ -640,6 +642,7 @@ namespace ZeroLevel.DependencyInjection
public void Register<TContract>(TContract implementation, string resolveName)
{
if (implementation == null) throw new ArgumentNullException(nameof(implementation));
var resolveType = new ResolveTypeInfo
{
ImplementationType = implementation.GetType(),
@ -653,6 +656,7 @@ namespace ZeroLevel.DependencyInjection
public void Register(Type contractType, string resolveName, object implementation)
{
if (implementation == null) throw new ArgumentNullException(nameof(implementation));
var resolveType = new ResolveTypeInfo
{
ImplementationType = implementation.GetType(),
@ -952,7 +956,7 @@ namespace ZeroLevel.DependencyInjection
public bool IsResolvingExists(Type type, string resolveName)
{
return GetResolvedType(type, resolveName)?.Item1 != null;
return GetResolvedType(type, resolveName)?.Item1 != null!;
}
private Tuple<ResolveTypeInfo, bool> GetResolvedType(Type type, string resolveName)
@ -1110,12 +1114,12 @@ namespace ZeroLevel.DependencyInjection
/// </summary>
private void FillParametrizedFieldsAndProperties(object instance)
{
if (instance != null)
if (instance != null!)
{
foreach (var property in instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy))
{
var attr = property.GetCustomAttribute<ParameterAttribute>();
if (attr != null)
if (attr != null!)
{
var parameterType = attr.Type ?? property.PropertyType;
var parameterName = attr.Name ?? property.Name;
@ -1125,7 +1129,7 @@ namespace ZeroLevel.DependencyInjection
foreach (var field in instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy))
{
var attr = field.GetCustomAttribute<ParameterAttribute>();
if (attr != null)
if (attr != null!)
{
var parameterType = attr.Type ?? field.FieldType;
var parameterName = string.IsNullOrWhiteSpace(attr.Name) ? field.Name : attr.Name;
@ -1137,7 +1141,7 @@ namespace ZeroLevel.DependencyInjection
private void ComposeParts(object instance)
{
if (instance != null)
if (instance != null!)
{
var resolve_properties = CollectResolvingProperties(instance.GetType());
var resolve_fields = CollectResolvingFields(instance.GetType());
@ -1153,13 +1157,13 @@ namespace ZeroLevel.DependencyInjection
f.GetCustomAttribute<ResolveAttribute>());
f.SetValue(instance, resolve_instance);
}
FillParametrizedFieldsAndProperties(instance);
}
FillParametrizedFieldsAndProperties(instance);
}
private void RecursiveCompose(object instance, HashSet<object> set)
{
if (instance != null)
if (instance != null!)
{
foreach (var f in
instance.GetType().GetFields(BindingFlags.Public |
@ -1178,8 +1182,8 @@ namespace ZeroLevel.DependencyInjection
}
}
}
ComposeParts(instance);
}
ComposeParts(instance);
}
public void Compose(object instance, bool recursive = true)
@ -1229,7 +1233,7 @@ namespace ZeroLevel.DependencyInjection
{
Log.SystemError(ex, $"[Container] Singletone dispose error. Instance: '{item?.GetType()?.FullName ?? string.Empty}'");
}
if (item!.GenericInstanceCachee != null)
if (item!.GenericInstanceCachee != null!)
{
foreach (var gitem in item.GenericInstanceCachee.Values)
{
@ -1307,7 +1311,7 @@ namespace ZeroLevel.DependencyInjection
{
if (_everything.Value.ContainsKey<T>(key))
return _everything.Value.Get<T>(key);
return default(T);
return default(T)!;
}
public T GetOrDefault<T>(string key, T defaultValue)

@ -89,7 +89,7 @@ namespace ZeroLevel.DependencyInjection
{
return exists;
}
return null;
return null!;
}
public bool Remove(string containerName)

@ -161,7 +161,7 @@ namespace ZeroLevel.DependencyInjection
/// <typeparam name="TImplementation">Dependency resolution</typeparam>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(Action<Exception> fallback = null);
bool TryRegister<TContract, TImplementation>(Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -171,7 +171,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(string resolveName, Action<Exception> fallback = null);
bool TryRegister<TContract, TImplementation>(string resolveName, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -181,7 +181,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(bool shared, Action<Exception> fallback = null);
bool TryRegister<TContract, TImplementation>(bool shared, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -192,7 +192,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(string resolveName, bool shared, Action<Exception> fallback = null);
bool TryRegister<TContract, TImplementation>(string resolveName, bool shared, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -201,7 +201,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="implementationType">Dependency resolution</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, Action<Exception> fallback = null);
bool TryRegister(Type contractType, Type implementationType, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -211,7 +211,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, string resolveName, Action<Exception> fallback = null);
bool TryRegister(Type contractType, Type implementationType, string resolveName, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -221,7 +221,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, bool shared, Action<Exception> fallback = null);
bool TryRegister(Type contractType, Type implementationType, bool shared, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration
@ -232,7 +232,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, string resolveName, bool shared, Action<Exception> fallback = null);
bool TryRegister(Type contractType, Type implementationType, string resolveName, bool shared, Action<Exception> fallback = null!);
#endregion Safe register
@ -246,7 +246,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister<TContract, TImplementation>(object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -257,7 +257,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -268,7 +268,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(bool shared, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister<TContract, TImplementation>(bool shared, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -280,7 +280,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -290,7 +290,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -301,7 +301,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -312,7 +312,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters, Action<Exception> fallback = null!);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
@ -324,7 +324,7 @@ namespace ZeroLevel.DependencyInjection
/// <param name="constructorParameters">Ctor args</param>
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null!);
#endregion Safe register with parameters
}

@ -25,17 +25,17 @@ namespace ZeroLevel.DependencyInjection
var parameterAttribute = p.GetCustomAttribute<ParameterAttribute>();
var resolveAttribute = p.GetCustomAttribute<ResolveAttribute>();
var kind = (parameterAttribute != null) ? ConstructorParameterKind.Parameter :
(resolveAttribute != null) ? ConstructorParameterKind.Dependency : ConstructorParameterKind.None;
var kind = (parameterAttribute != null!) ? ConstructorParameterKind.Parameter :
(resolveAttribute != null!) ? ConstructorParameterKind.Dependency : ConstructorParameterKind.None;
return new ConstructorParameter
{
Type = p.ParameterType,
ParameterKind = kind,
ParameterResolveName = (kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Name ?? p.Name :
(kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ResolveName : null,
ParameterResolveName = ((kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Name ?? p.Name :
(kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ResolveName : null)!,
ParameterResolveType = (kind == ConstructorParameterKind.Parameter) ? parameterAttribute?.Type ?? p.ParameterType :
(kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ContractType ?? p.ParameterType : null,
(kind == ConstructorParameterKind.Dependency) ? resolveAttribute?.ContractType ?? p.ParameterType : null!,
IsNullable = IsNullable(p.ParameterType)
};
}).ToList();
@ -44,7 +44,7 @@ namespace ZeroLevel.DependencyInjection
private static bool IsNullable(Type type)
{
if (!type.IsValueType) return true; // ref-type
if (Nullable.GetUnderlyingType(type) != null) return true; // Nullable<T>
if (Nullable.GetUnderlyingType(type) != null!) return true; // Nullable<T>
return false; // value-type
}
@ -56,7 +56,7 @@ namespace ZeroLevel.DependencyInjection
/// <returns>true - if the constructor can be called with the arguments passed</returns>
public bool IsMatch(object[] args, out object[] parameters)
{
parameters = null;
parameters = null!;
int arg_index = 0;
if (Parameters.Count > 0)
{

@ -9,7 +9,7 @@ namespace ZeroLevel.DependencyInjection
public ParameterAttribute()
{
this.Type = null;
this.Type = null!;
this.Name = string.Empty;
}
@ -21,7 +21,7 @@ namespace ZeroLevel.DependencyInjection
public ParameterAttribute(string parameterName)
{
this.Type = null;
this.Type = null!;
this.Name = parameterName;
}

@ -9,12 +9,12 @@ namespace ZeroLevel.DependencyInjection
public ResolveAttribute()
{
ResolveName = string.Empty; ContractType = null;
ResolveName = string.Empty; ContractType = null!;
}
public ResolveAttribute(string resolveName)
{
ResolveName = resolveName; ContractType = null;
ResolveName = resolveName; ContractType = null!;
}
public ResolveAttribute(Type contractType)

@ -17,7 +17,7 @@ namespace ZeroLevel.Services.Encryption
#endregion Crypt fields
public AesEncryptor(Stream stream, string password, byte[] salt = null)
public AesEncryptor(Stream stream, string password, byte[] salt = null!)
{
_aes = Aes.Create();
using (var pdb = new Rfc2898DeriveBytes(password, SALT))
@ -54,7 +54,7 @@ namespace ZeroLevel.Services.Encryption
output.Flush();
}
public static byte[] Encrypt(byte[] plain, string password, byte[] salt = null)
public static byte[] Encrypt(byte[] plain, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{
@ -75,7 +75,7 @@ namespace ZeroLevel.Services.Encryption
}
}
public static byte[] Encrypt(Stream stream, string password, byte[] salt = null)
public static byte[] Encrypt(Stream stream, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{
@ -96,7 +96,7 @@ namespace ZeroLevel.Services.Encryption
}
}
public static void Encrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null)
public static void Encrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{
@ -113,7 +113,7 @@ namespace ZeroLevel.Services.Encryption
}
}
public static byte[] Decrypt(byte[] cipher, string password, byte[] salt = null)
public static byte[] Decrypt(byte[] cipher, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{
@ -134,7 +134,7 @@ namespace ZeroLevel.Services.Encryption
}
}
public static byte[] Decrypt(Stream stream, string password, byte[] salt = null)
public static byte[] Decrypt(Stream stream, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{
@ -155,7 +155,7 @@ namespace ZeroLevel.Services.Encryption
}
}
public static void Decrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null)
public static void Decrypt(Stream inputStream, Stream outputStream, string password, byte[] salt = null!)
{
using (var aes = Aes.Create())
{

@ -50,12 +50,12 @@ namespace ZeroLevel
for (int a = 0; a < array.Length; a++)
{
if (array[a].Equals(candidate[0]))
if (array[a]!.Equals(candidate[0]))
{
int i = 1;
for (; i < candidate.Length && (a + i) < array.Length; i++)
{
if (false == array[a + i].Equals(candidate[i]))
if (false == array[a + i]!.Equals(candidate[i]))
break;
}
if (i == candidate.Length)

@ -12,7 +12,7 @@ namespace ZeroLevel.Extensions
// <returns>The bit array converted to an array of bytes.</returns>
internal static byte[] ToBytes(this FastBitArray bits)
{
if (bits == null) return null;
if (bits == null!) return null!;
var numBytes = bits.Count / 8;
if (bits.Count % 8 != 0) numBytes++;
var bytes = new byte[numBytes];

@ -27,7 +27,7 @@ namespace ZeroLevel
public int GetHashCode(T obj)
{
return obj.GetHashCode();
return obj?.GetHashCode() ?? 0;
}
}
@ -36,8 +36,8 @@ namespace ZeroLevel
/// </summary>
public static bool StringEnumerableEquals(this IEnumerable<string> A, IEnumerable<string> B)
{
if (A == null && B == null) return true;
if (A == null || B == null) return false;
if (A == null && B == null!) return true;
if (A == null || B == null!) return false;
return A.Count() == B.Count() && A.Intersect(B).Count() == B.Count();
}
@ -46,15 +46,15 @@ namespace ZeroLevel
/// </summary>
public static bool NoOrderingEquals<T>(this IEnumerable<T> A, IEnumerable<T> B)
{
if (A == null && B == null) return true;
if (A == null || B == null) return false;
if (A == null && B == null!) return true;
if (A == null || B == null!) return false;
return A.Count() == B.Count() && A.Intersect(B, new SimpleComparer<T>()).Count() == B.Count();
}
public static bool NoOrderingEquals<T>(this IEnumerable<T> A, IEnumerable<T> B, Func<T, T, bool> comparer)
{
if (A == null && B == null) return true;
if (A == null || B == null) return false;
if (A == null && B == null!) return true;
if (A == null || B == null!) return false;
return A.Count() == B.Count() && A.Intersect(B, new SimpleComparer<T>(comparer)).Count() == B.Count();
}
@ -63,15 +63,15 @@ namespace ZeroLevel
/// </summary>
public static bool OrderingEquals<T>(this IEnumerable<T> A, IEnumerable<T> B)
{
if (A == null && B == null) return true;
if (A == null || B == null) return false;
if (A == null && B == null!) return true;
if (A == null || B == null!) return false;
if (A.Count() != B.Count()) return false;
var enumA = A.GetEnumerator();
var enumB = B.GetEnumerator();
while (enumA.MoveNext() && enumB.MoveNext())
{
if (enumA.Current == null && enumB.Current == null) continue;
if (enumA.Current == null || enumB.Current == null) return false;
if (enumA.Current == null && enumB.Current == null!) continue;
if (enumA.Current == null || enumB.Current == null!) return false;
if (enumA.Current.Equals(enumB.Current) == false) return false;
}
return true;
@ -79,15 +79,15 @@ namespace ZeroLevel
public static bool OrderingEquals<T>(this IEnumerable<T> A, IEnumerable<T> B, Func<T, T, bool> comparer)
{
if (A == null && B == null) return true;
if (A == null || B == null) return false;
if (A == null && B == null!) return true;
if (A == null || B == null!) return false;
if (A.Count() != B.Count()) return false;
var enumA = A.GetEnumerator();
var enumB = B.GetEnumerator();
while (enumA.MoveNext() && enumB.MoveNext())
{
if (enumA.Current == null && enumB.Current == null) continue;
if (enumA.Current == null || enumB.Current == null) return false;
if (enumA.Current == null && enumB.Current == null!) continue;
if (enumA.Current == null || enumB.Current == null!) return false;
if (comparer(enumA.Current, enumB.Current) == false) return false;
}
return true;
@ -99,10 +99,10 @@ namespace ZeroLevel
public static int GetEnumHashCode<T>(this IEnumerable<T> A)
{
int hc = 0;
if (A != null)
if (A != null!)
{
foreach (var p in A)
hc ^= p.GetHashCode();
hc ^= p?.GetHashCode() ?? 0;
}
return hc;
}

@ -25,7 +25,7 @@ namespace ZeroLevel.Services.Extensions
public EncodingEx(Encoding baseEncoding) : base(baseEncoding.CodePage)
{
if (baseEncoding == null) throw new ArgumentNullException("baseEncoding");
if (baseEncoding == null!) throw new ArgumentNullException("baseEncoding");
_baseEncoding = baseEncoding;
}

@ -7,23 +7,23 @@ namespace ZeroLevel.Extensions
public const string HTTP_SCHEMA = "http";
public const string HTTPS_SCHEMA = "https";
public static string ToHttpUrl(this EndPoint endPoint, string schema, string rawUrl = null)
public static string ToHttpUrl(this EndPoint endPoint, string schema, string rawUrl = null!)
{
if (endPoint is IPEndPoint)
{
var ipEndPoint = endPoint as IPEndPoint;
return CreateHttpUrl(schema, ipEndPoint.Address.ToString(), ipEndPoint.Port,
return CreateHttpUrl(schema, ipEndPoint?.Address?.ToString() ?? string.Empty, ipEndPoint?.Port ?? 0,
rawUrl != null ? rawUrl.TrimStart('/') : string.Empty);
}
if (endPoint is DnsEndPoint)
{
var dnsEndpoint = endPoint as DnsEndPoint;
return CreateHttpUrl(schema, dnsEndpoint.Host, dnsEndpoint.Port,
return CreateHttpUrl(schema, dnsEndpoint?.Host ?? string.Empty, dnsEndpoint?.Port ?? 0,
rawUrl != null ? rawUrl.TrimStart('/') : string.Empty);
}
return null;
return null!;
}
public static string ToHttpUrl(this EndPoint endPoint, string schema, string formatString,
@ -32,18 +32,18 @@ namespace ZeroLevel.Extensions
if (endPoint is IPEndPoint)
{
var ipEndPoint = endPoint as IPEndPoint;
return CreateHttpUrl(schema, ipEndPoint.Address.ToString(), ipEndPoint.Port,
return CreateHttpUrl(schema, ipEndPoint?.Address?.ToString() ?? string.Empty, ipEndPoint?.Port ?? 0,
string.Format(formatString.TrimStart('/'), args));
}
if (endPoint is DnsEndPoint)
{
var dnsEndpoint = endPoint as DnsEndPoint;
return CreateHttpUrl(schema, dnsEndpoint.Host, dnsEndpoint.Port,
return CreateHttpUrl(schema, dnsEndpoint?.Host ?? string.Empty, dnsEndpoint?.Port ?? 0,
string.Format(formatString.TrimStart('/'), args));
}
return null;
return null!;
}
private static string CreateHttpUrl(string schema, string host, int port, string path)

@ -18,13 +18,13 @@ namespace ZeroLevel
var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
return (attributes.Length > 0) ? (T)attributes[0] : null;
return ((attributes.Length > 0) ? (T)attributes[0] : null)!;
}
public static string Description(this Enum enumVal)
{
var attr = enumVal.GetAttributeOfType<DescriptionAttribute>();
return attr?.Description;
return attr?.Description!;
}
public static T GetValueFromDescription<T>(string description)
@ -35,7 +35,7 @@ namespace ZeroLevel
{
var attribute = Attribute.GetCustomAttribute(field,
typeof(DescriptionAttribute)) as DescriptionAttribute;
if (attribute != null)
if (attribute != null!)
{
if (attribute.Description == description)
return (T)field.GetValue(null);
@ -47,7 +47,7 @@ namespace ZeroLevel
}
}
throw new ArgumentException("Not found.", nameof(description));
// or return default(T);
// or return default(T)!;
}
}
}

@ -19,10 +19,10 @@ namespace ZeroLevel
public static bool IsEmpty<T>(this IEnumerable<T> collection)
{
if (collection == null)
if (collection == null!)
return true;
var coll = collection as ICollection;
if (coll != null)
if (coll != null!)
return coll.Count == 0;
return !collection.Any();
}

@ -82,12 +82,12 @@ namespace ZeroLevel.Services.Extensions
/// </exception>
public T Match<T>(Func<TL, T> ofLeft, Func<TR, T> ofRight)
{
if (ofLeft == null)
if (ofLeft == null!)
{
throw new ArgumentNullException(nameof(ofLeft));
}
if (ofRight == null)
if (ofRight == null!)
{
throw new ArgumentNullException(nameof(ofRight));
}
@ -104,12 +104,12 @@ namespace ZeroLevel.Services.Extensions
/// </exception>
public void Match(Action<TL> ofLeft, Action<TR> ofRight)
{
if (ofLeft == null)
if (ofLeft == null!)
{
throw new ArgumentNullException(nameof(ofLeft));
}
if (ofRight == null)
if (ofRight == null!)
{
throw new ArgumentNullException(nameof(ofRight));
}
@ -124,9 +124,9 @@ namespace ZeroLevel.Services.Extensions
}
}
public TL LeftOrDefault() => Match(l => l, r => default(TL));
public TL LeftOrDefault() => Match(l => l, r => default(TL))!;
public TR RightOrDefault() => Match(l => default(TR), r => r);
public TR RightOrDefault() => Match(l => default(TR), r => r)!;
public Either<TR, TL> Swap() => Match(Right<TR, TL>, Left<TR, TL>);

@ -4,7 +4,7 @@ namespace System.Linq
{
public static class LinqExtension
{
public static void ThrowIfNull<T>(this T val, string message = null)
public static void ThrowIfNull<T>(this T val, string message = null!)
{
if (null == val)
throw new ArgumentNullException(message);
@ -35,11 +35,11 @@ namespace System.Linq
}
else if (hasLeft)
{
yield return new T[] { leftEnumerator.Current, default(T) };
yield return new T[] { leftEnumerator.Current, default(T)! };
}
else if (hasRight)
{
yield return new T[] { default(T), rightEnumerator.Current };
yield return new T[] { default(T)!, rightEnumerator.Current };
}
hasLeft = leftEnumerator.MoveNext();
@ -50,7 +50,7 @@ namespace System.Linq
public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
if (source != null)
if (source != null!)
{
var seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
@ -78,7 +78,7 @@ namespace System.Linq
}
public static IEnumerable<IEnumerable<T>> Chunkify<T>(this IEnumerable<T> source, int size)
{
if (source == null)
if (source == null!)
{
yield break;
}

@ -9,7 +9,7 @@ namespace ZeroLevel
public static TResult With<TInput, TResult>(this TInput o, Func<TInput, TResult> evaluator)
{
if (null != o) return evaluator(o);
return default(TResult);
return default(TResult)!;
}
#endregion With
@ -25,7 +25,7 @@ namespace ZeroLevel
public static TResult Return<TInput, TResult>(this TInput o, Func<TInput, TResult> evaluator)
{
if (null != o) return evaluator(o);
return default(TResult);
return default(TResult)!;
}
#endregion Return
@ -44,8 +44,8 @@ namespace ZeroLevel
public static TInput If<TInput>(this TInput o, Predicate<TInput> evaluator)
{
if (null != o) return evaluator(o) ? o : default(TInput);
return default(TInput);
if (null != o) return evaluator(o) ? o : default(TInput)!;
return default(TInput)!;
}
public static TOutput Either<TInput, TOutput>(this TInput o, Func<TInput, bool> condition,
@ -54,7 +54,7 @@ namespace ZeroLevel
public static TOutput Either<TInput, TOutput>(this TInput o, Func<TInput, TOutput> ifTrue,
Func<TInput, TOutput> ifFalse)
=> o.Either(x => x != null, ifTrue, ifFalse);
=> o.Either(x => x != null!, ifTrue, ifFalse);
#endregion If

@ -7,28 +7,28 @@ namespace ZeroLevel.Services.Extensions
{
public static T WaitResult<T>(this Task<T> task)
{
if (task == null)
if (task == null!)
{
throw new ArgumentNullException(nameof(task));
}
task.Wait();
if (task.IsFaulted)
{
if (task.Exception != null) throw task.Exception;
if (task.Exception != null!) throw task.Exception;
}
return task.Result;
}
public static void WaitWithoutResult(this Task task)
{
if (task == null)
if (task == null!)
{
throw new ArgumentNullException(nameof(task));
}
task.Wait();
if (task.IsFaulted)
{
if (task.Exception != null) throw task.Exception;
if (task.Exception != null!) throw task.Exception;
}
}
}

@ -20,7 +20,7 @@ namespace ZeroLevel
// The value returned contains the StateMachineType property.
// Null is returned if the attribute isn't present for the method.
var attrib = (AsyncStateMachineAttribute)method.GetCustomAttribute(attType);
return (attrib != null);
return (attrib != null!);
}
public static object GetDefault(this Type type)
@ -29,12 +29,12 @@ namespace ZeroLevel
{
return Activator.CreateInstance(type);
}
return null;
return null!;
}
public static object GetPropValue(this object src, string propName)
{
return src?.GetType()?.GetProperty(propName)?.GetValue(src, null);
return (src?.GetType()?.GetProperty(propName)?.GetValue(src, null))!;
}
public static bool IsAssignableToGenericType(this Type givenType, Type genericType)
@ -51,7 +51,7 @@ namespace ZeroLevel
return true;
Type baseType = givenType.BaseType;
if (baseType == null) return false;
if (baseType == null!) return false;
return IsAssignableToGenericType(baseType, genericType);
}

@ -12,8 +12,8 @@ namespace ZeroLevel.Services
public Step _next;
}
Step _head = null;
Step _tail = null;
Step _head = null!;
Step _tail = null!;
public Fiber()
{
@ -21,13 +21,13 @@ namespace ZeroLevel.Services
public Fiber Add(Func<IEverythingStorage, IEverythingStorage> action)
{
if (_head == null)
if (_head == null!)
{
_head = _tail = new Step { _handler = action, _next = null };
_head = _tail = new Step { _handler = action, _next = null! };
}
else
{
var s = new Step { _handler = action, _next = null };
var s = new Step { _handler = action, _next = null! };
_tail._next = s;
_tail = s;
}
@ -36,16 +36,16 @@ namespace ZeroLevel.Services
public IEnumerable<Func<IEverythingStorage, IEverythingStorage>> Iterate()
{
if (_head == null) yield break;
if (_head == null!) yield break;
var current = _head;
while (current != null)
while (current != null!)
{
yield return current._handler;
current = current._next;
}
}
public IEverythingStorage Run(IEverythingStorage buffer = null)
public IEverythingStorage Run(IEverythingStorage buffer = null!)
{
var storage = buffer;
foreach (var a in Iterate())

@ -16,7 +16,7 @@ namespace ZeroLevel.Services.FileSystem
{
throw new ArgumentNullException(nameof(filePath));
}
if (parser == null)
if (parser == null!)
{
throw new ArgumentNullException(nameof(parser));
}
@ -42,10 +42,10 @@ namespace ZeroLevel.Services.FileSystem
{
string line;
buffer = new T[batchSize];
while ((line = sr.ReadLine()) != null)
while ((line = sr.ReadLine()) != null!)
{
var value = _parser.Invoke(line);
if (skipNull && value == null) continue;
if (skipNull && value == null!) continue;
buffer[buffer_index] = value;
buffer_index++;
if (buffer_index >= batchSize)
@ -77,7 +77,7 @@ namespace ZeroLevel.Services.FileSystem
using (StreamReader sr = new StreamReader(bs))
{
string line;
while ((line = sr.ReadLine()) != null)
while ((line = sr.ReadLine()) != null!)
{
yield return _parser.Invoke(line);
}

@ -42,7 +42,7 @@ namespace ZeroLevel.Services.FileSystem
return folderName;
}
public static string GetAppLocalDbDirectory(string dbFolderName = null)
public static string GetAppLocalDbDirectory(string dbFolderName = null!)
{
dbFolderName = Path.Combine(Configuration.BaseDirectory, dbFolderName ?? "db");
if (false == Directory.Exists(dbFolderName))
@ -153,7 +153,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
public static string PathCorrection(string path)
{
if (path == null) return string.Empty;
if (path == null!) return string.Empty;
var result = new char[path.Length];
var index = 0;
foreach (char c in path)
@ -173,7 +173,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
public static string FileNameCorrection(string name, bool isRootPath = false)
{
if (name == null) return string.Empty;
if (name == null!) return string.Empty;
// The reserved filenames
if (StartWithInvalidWindowsPrefix(name))
{
@ -207,7 +207,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
public static string FileNameCorrection(string name, char replacedSymbol, bool isRootPath = false)
{
if (name == null) return string.Empty;
if (name == null!) return string.Empty;
if (_invalid_filename_characters.IndexOf(replacedSymbol) >= 0)
{
throw new ArgumentException($"The sybmol '{replacedSymbol}' is invalid for windows filenames");
@ -250,7 +250,7 @@ namespace ZeroLevel.Services.FileSystem
/// <returns></returns>
public static string FileNameCorrection(string path, char replaceChar)
{
if (path == null) return string.Empty;
if (path == null!) return string.Empty;
var result = new char[path.Length];
var index = 0;
foreach (char c in path)
@ -286,7 +286,7 @@ namespace ZeroLevel.Services.FileSystem
}
finally
{
if (fileStream != null)
if (fileStream != null!)
{
fileStream.Close();
fileStream.Dispose();
@ -309,7 +309,7 @@ namespace ZeroLevel.Services.FileSystem
}
finally
{
if (fileStream != null)
if (fileStream != null!)
{
fileStream.Close();
fileStream.Dispose();
@ -319,14 +319,14 @@ namespace ZeroLevel.Services.FileSystem
return false;
}
public static void PackFolder(string sourceFolder, string zipPath, Func<FileInfo, bool> selector = null)
public static void PackFolder(string sourceFolder, string zipPath, Func<FileInfo, bool> selector = null!)
{
var tmp = FSUtils.GetAppLocalTemporaryDirectory();
var tmpDir = Directory.CreateDirectory(tmp);
var files = new DirectoryInfo(sourceFolder)
.GetFiles("*.*", SearchOption.AllDirectories)
.AsEnumerable();
if (selector != null)
if (selector != null!)
{
files = files.Where(selector);
}

@ -237,7 +237,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="text">Text</param>
/// <param name="subfolder_name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void StoreText(string text, string subfolder_name = null, string file_name = null)
public void StoreText(string text, string subfolder_name = null!, string file_name = null!)
{
Apply(new StoreText(text, CreateArchiveFilePath(subfolder_name, file_name)));
}
@ -248,12 +248,12 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="file_path">File path</param>
/// <param name="subfolder_name">Archive file name (original file name by default)</param>
/// <returns></returns>
public void Store(string file_path, string subfolder_name = null, string file_name = null)
public void Store(string file_path, string subfolder_name = null!, string file_name = null!)
{
Apply(new StoreFile(file_path, CreateArchiveFilePath(subfolder_name, file_name)));
}
public void Store(string file_path, bool immediate, string subfolder_name = null, string file_name = null)
public void Store(string file_path, bool immediate, string subfolder_name = null!, string file_name = null!)
{
if (immediate)
{
@ -271,7 +271,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="stream">Data stream for reading</param>
/// <param name="subfolder_name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void Store(Stream stream, string subfolder_name = null, string file_name = null)
public void Store(Stream stream, string subfolder_name = null!, string file_name = null!)
{
Apply(new StoreStream(stream, CreateArchiveFilePath(subfolder_name, file_name)));
}
@ -282,7 +282,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="data">Data</param>
/// <param name="subfolder_name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void StoreData(byte[] data, string subfolder_name = null, string file_name = null)
public void StoreData(byte[] data, string subfolder_name = null!, string file_name = null!)
{
Apply(new StoreData(data, CreateArchiveFilePath(subfolder_name, file_name)));
}
@ -410,7 +410,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="text">Text</param>
/// <param name="name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void StoreText(string text, string name = null)
public void StoreText(string text, string name = null!)
{
Apply(new StoreText(text, CreateArchiveFilePath(name)));
}
@ -421,7 +421,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="file_path">File path</param>
/// <param name="subfolder_name">Archive file name (original file name by default)</param>
/// <returns></returns>
public void Store(string file_path, string name = null)
public void Store(string file_path, string name = null!)
{
Apply(new StoreFile(file_path, CreateArchiveFilePath(name)));
}
@ -432,7 +432,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="file_path">File path</param>
/// <param name="subfolder_name">Archive file name (original file name by default)</param>
/// <returns></returns>
public void Store(string file_path, bool immediate, string name = null)
public void Store(string file_path, bool immediate, string name = null!)
{
if (immediate)
{
@ -450,7 +450,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="stream">Data stream for reading</param>
/// <param name="name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void Store(Stream stream, string name = null)
public void Store(Stream stream, string name = null!)
{
Apply(new StoreStream(stream, CreateArchiveFilePath(name)));
}
@ -461,7 +461,7 @@ namespace ZeroLevel.Services.FileSystem
/// <param name="data">Data</param>
/// <param name="name">Archive file name (HH_mm_ss_fff_counter.{ext} by default)</param>
/// <returns></returns>
public void StoreData(byte[] data, string name = null)
public void StoreData(byte[] data, string name = null!)
{
Apply(new StoreData(data, CreateArchiveFilePath(name)));
}

@ -24,7 +24,7 @@ namespace ZeroLevel.Services.FileSystem
private readonly bool _useSubdirectories = false;
public PeriodicFileSystemWatcher(TimeSpan period, string watch_folder, string temp_folder, Action<FileMeta> callback
, IEnumerable<string> extensions = null
, IEnumerable<string> extensions = null!
, bool removeTempFileAfterCallback = false
, bool useSubdirectories = false)
{
@ -32,7 +32,7 @@ namespace ZeroLevel.Services.FileSystem
{
throw new ArgumentNullException(nameof(watch_folder));
}
if (callback == null)
if (callback == null!)
{
throw new ArgumentNullException(nameof(callback));
}
@ -141,7 +141,7 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
private string MoveToTemporary(string from)
{
if (from == null)
if (from == null!)
{
throw new ArgumentException("from");
}
@ -156,7 +156,7 @@ namespace ZeroLevel.Services.FileSystem
File.Delete(from);
return tempFile;
}
return null;
return null!;
}
/// <summary>
@ -164,14 +164,14 @@ namespace ZeroLevel.Services.FileSystem
/// </summary>
private static string TrySolveCollision(string file)
{
if (file == null)
if (file == null!)
{
throw new ArgumentNullException("file");
}
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
string extension = Path.GetExtension(file);
string directoryName = Path.GetDirectoryName(file);
if (directoryName != null)
if (directoryName != null!)
{
int num = 0;
do
@ -200,17 +200,17 @@ namespace ZeroLevel.Services.FileSystem
{
files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)
?.Where(f => _extensions.Contains(Path.GetExtension(f).ToLowerInvariant()))
?.ToArray();
?.ToArray()!;
}
else
{
files = Directory.GetFiles(_sourceFolder, "*.*", _useSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
}
if (files != null)
if (files != null!)
{
Array.Sort<string>(files, FileNameSortCompare);
}
return files;
return files!;
}
/// <summary>

@ -12,7 +12,7 @@
{
int hash1 = (5381 << 16) + 5381;
int hash2 = hash1;
if (str != null)
if (str != null!)
{
for (int i = 0; i < str.Length; i += 2)
{

@ -48,7 +48,7 @@ namespace ZeroLevel.Services
// Поле для хранения метода обратного вызова
_callbackField = _typeBuilder.DefineField("_callbackHandler", CreateDecorateMethodCallHandlerDelegate(_moduleBuilder), FieldAttributes.Private);
_interfaces = interfaces;
_parentType = parentType;
_parentType = parentType!;
}
/// <summary>
/// Собирает конечный тип
@ -105,7 +105,7 @@ namespace ZeroLevel.Services
list.AddRange(_interfaces);
list.AddRange(GetInterfaces(_interfaces));
}
if (_parentType != null)
if (_parentType != null!)
{
list.AddRange(GetInterfaces(new Type[] { _parentType }));
}
@ -152,7 +152,7 @@ namespace ZeroLevel.Services
/// </summary>
private void ProceedParentAbstractMethods()
{
if (_parentType != null)
if (_parentType != null!)
{
foreach (var method in _parentType.GetMethods())
{

@ -109,6 +109,7 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Select(CreateCompiledExpression);
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
@ -121,6 +122,7 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName))
?.Select(CreateCompiledExpression);
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
@ -133,6 +135,7 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName))
?.Select(method => method.MakeGenericMethod(typeof(T))).Select(CreateCompiledExpression);
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
@ -145,6 +148,7 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(m => m.Name.Equals(methodName))
?.Select(method => method.MakeGenericMethod(genericType)).Select(CreateCompiledExpression);
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
@ -157,12 +161,9 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(filter)
?.Select(method => method.MakeGenericMethod(typeof(T))).Select(CreateCompiledExpression);
if (result != null)
{
Configure(result);
return result.Select(r => r.Item1).ToList();
}
return Enumerable.Empty<string>();
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
public IEnumerable<string> ConfigureGeneric(Type instanceType, Type genericType, Func<MethodInfo, bool> filter)
@ -173,12 +174,9 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(filter)
?.Select(method => method.MakeGenericMethod(genericType)).Select(CreateCompiledExpression);
if (result != null)
{
Configure(result);
return result.Select(r => r.Item1).ToList();
}
return Enumerable.Empty<string>();
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
public IEnumerable<string> Configure(Type instanceType, Func<MethodInfo, bool> filter)
@ -189,12 +187,9 @@ namespace ZeroLevel.Services.Invokation
BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy)?.Where(filter)
?.Select(CreateCompiledExpression);
if (result != null)
{
Configure(result);
return result.Select(r => r.Item1).ToList();
}
return Enumerable.Empty<string>();
if (result == null) return Enumerable.Empty<string>();
Configure(result);
return result.Select(r => r.Item1).ToList();
}
#endregion Configure by Type
@ -274,7 +269,7 @@ namespace ZeroLevel.Services.Invokation
{
if (_invokeCachee.ContainsKey(identity))
{
return _invokeCachee[identity](null, args);
return _invokeCachee[identity](null!, args);
}
throw new KeyNotFoundException(String.Format("Not found method with identity '{0}'", identity));
@ -301,7 +296,7 @@ namespace ZeroLevel.Services.Invokation
{
if (_invokeCachee.ContainsKey(identity))
{
return _invokeCachee[identity](target, null);
return _invokeCachee[identity](target, null!);
}
throw new KeyNotFoundException($"Not found method with identity '{identity}'");
@ -345,7 +340,7 @@ namespace ZeroLevel.Services.Invokation
return _invokeCachee[identity];
}
return null;
return null!;
}
/// <summary>

@ -10,7 +10,7 @@ namespace ZeroLevel.Logging
{
public EncryptedFileLogOptions()
{
Folder = null;
Folder = null!;
LimitFileSize = 0;
}
@ -77,7 +77,7 @@ namespace ZeroLevel.Logging
public EncryptedFileLog(EncryptedFileLogOptions options)
{
if (options == null)
if (options == null!)
throw new ArgumentNullException(nameof(options));
if (string.IsNullOrEmpty(options.Key))
throw new ArgumentNullException("options.Key");
@ -120,7 +120,7 @@ namespace ZeroLevel.Logging
}
catch
{
if (stream != null)
if (stream != null!)
{
stream.Dispose();
}
@ -134,10 +134,10 @@ namespace ZeroLevel.Logging
/// </summary>
private void CloseCurrentWriter()
{
if (_writer != null)
if (_writer != null!)
{
_writer.Dispose();
_writer = null;
_writer = null!;
}
}

@ -13,7 +13,7 @@ namespace ZeroLevel.Logging
{
public TextFileLoggerOptions()
{
Folder = null;
Folder = null!;
LimitFileSize = 0;
TextEncoding = DEFAULT_ENCODING;
RemoveOlderThen = TimeSpan.MinValue;
@ -211,7 +211,7 @@ namespace ZeroLevel.Logging
file.Delete();
}
});
dir = null;
dir = null!;
}
catch { }
}
@ -221,12 +221,12 @@ namespace ZeroLevel.Logging
/// </summary>
private void CloseCurrentWriter()
{
if (_writer != null)
if (_writer != null!)
{
_writer.Flush();
_writer.Close();
_writer.Dispose();
_writer = null;
_writer = null!;
}
}
@ -266,7 +266,7 @@ namespace ZeroLevel.Logging
{
RecreateLogFile();
}
fi = null;
fi = null!;
}
/// <summary>
@ -278,18 +278,18 @@ namespace ZeroLevel.Logging
{
var nextFileName = GetNextFileName();
CloseCurrentWriter();
Stream stream = null;
Stream stream = null!;
PackOldLogFile(_currentLogFile);
try
{
_currentLogFile = nextFileName;
stream = new FileStream(_currentLogFile, FileMode.Append, FileAccess.Write, FileShare.Read);
_writer = new StreamWriter(stream, _options.TextEncoding);
stream = null;
stream = null!;
}
catch
{
if (stream != null)
if (stream != null!)
{
stream.Dispose();
}
@ -316,7 +316,7 @@ namespace ZeroLevel.Logging
}
reader.Close();
}
buffer = null;
buffer = null!;
}
stream.Close();
}
@ -419,27 +419,27 @@ namespace ZeroLevel.Logging
/// </summary>
private void CloseCurrentWriter()
{
if (_writer != null)
if (_writer != null!)
{
_writer.Flush();
_writer.Close();
_writer.Dispose();
_writer = null;
_writer = null!;
}
}
private void CreateLogFile(string path)
{
Stream stream = null;
Stream stream = null!;
try
{
stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read);
_writer = new StreamWriter(stream, DEFAULT_ENCODING);
stream = null;
stream = null!;
}
catch
{
if (stream != null)
if (stream != null!)
{
stream.Dispose();
}

@ -206,7 +206,7 @@ namespace ZeroLevel
{
return;
}
string logPath = null;
string logPath = null!;
if (config.Contains("log"))
{
logPath = config.First("log");
@ -218,7 +218,7 @@ namespace ZeroLevel
if (false == string.IsNullOrWhiteSpace(logPath))
{
var options = TextFileLoggerOptions.CreateOptionsBy(config, logPath, log_section ? string.Empty : "log.");
if (options != null)
if (options != null!)
{
AddTextFileLogger(options);
}

@ -53,7 +53,7 @@ namespace ZeroLevel.Logging
_messageQueue.Push(t.Item1, t.Item2);
}
currentQueue.Dispose();
currentQueue = null;
currentQueue = null!;
GC.Collect();
GC.WaitForFullGCComplete();
}
@ -64,7 +64,7 @@ namespace ZeroLevel.Logging
while (false == _stopped || _messageQueue.Count > 0)
{
var message = _messageQueue.Take();
if (message != null)
if (message != null!)
{
lock (LogsCacheeLocker)
{
@ -79,7 +79,7 @@ namespace ZeroLevel.Logging
}
}
}
message = null;
message = null!;
}
}
}

@ -74,7 +74,7 @@ namespace ZeroLevel.Mathemathics
{
if ((Values?.Length ?? 0) <= 2) return 0;
int i = 0;
while (Values[i] <= float.Epsilon) { i++; continue; }
while (Values![i] <= float.Epsilon) { i++; continue; }
if ((Values.Length - i) <= 2) return 0;
var delta = Values[i + 1] - Values[i];
@ -112,7 +112,7 @@ namespace ZeroLevel.Mathemathics
if ((Values?.Length ?? 0) <= 2) return list;
int i = 0;
while (Values[i] <= float.Epsilon) { i++; continue; }
while (Values![i] <= float.Epsilon) { i++; continue; }
if ((Values.Length - i) <= 2) return list;
var delta = Values[i + 1] - Values[i];
@ -144,15 +144,15 @@ namespace ZeroLevel.Mathemathics
public int GetMaximum()
{
if ((Values?.Length ?? 0) <= 1) return Values[0];
if ((Values?.Length ?? 0) <= 1) return Values![0]!;
int maxi = 0;
int max = 0;
for (int i = 0; i < Values.Length; i++)
for (int i = 0; i < (Values?.Length ?? 0); i++)
{
if (Values[i] > max)
if (Values![i] > max)
{
max = Values[i];
maxi = i;
maxi = i;
}
}
return maxi;

@ -34,7 +34,7 @@ namespace ZeroLevel.Services.Memory
public async Task<byte[]> ReadBuffer(int count)
{
if (count == 0) return null;
if (count == 0) return null!;
var buffer = new byte[count];
var readedCount = await _accessor.ReadAsync(buffer, 0, count);
if (count != readedCount)

@ -25,7 +25,7 @@ namespace ZeroLevel.Services.Memory
public async Task<byte[]> ReadBuffer(int count)
{
if (count == 0) return null;
if (count == 0) return null!;
var buffer = new byte[count];
var readedCount = await _stream.ReadAsync(buffer, 0, count);
if (count != readedCount)

@ -6,12 +6,12 @@ namespace MemoryPools.Collections.Linq
{
public static TSource Aggregate<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, TSource, TSource> func)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (func == null)
if (func == null!)
{
throw new ArgumentNullException(nameof(func));
}
@ -34,12 +34,12 @@ namespace MemoryPools.Collections.Linq
public static TAccumulate Aggregate<TSource, TAccumulate>(this IPoolingEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (func == null)
if (func == null!)
{
throw new ArgumentNullException(nameof(func));
}
@ -55,17 +55,17 @@ namespace MemoryPools.Collections.Linq
public static TResult Aggregate<TSource, TAccumulate, TResult>(this IPoolingEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (func == null)
if (func == null!)
{
throw new ArgumentNullException(nameof(func));
}
if (resultSelector == null)
if (resultSelector == null!)
{
throw new ArgumentNullException(nameof(resultSelector));
}

@ -27,8 +27,8 @@
_count--;
if (_count == 0)
{
_src = default;
_element = default;
_src = default!;
_element = default!;
Pool<AppendExprEnumerable<T>>.Return(this);
}
}
@ -72,16 +72,16 @@
_src.Reset();
}
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => _overcount == 1 ? _element : (T) _src.Current;
public void Dispose()
{
_parent?.Dispose();
_parent = null;
_parent = null!;
_src?.Dispose();
_src = default;
_src = default!;
Pool<AppendExprEnumerator>.Return(this);
}
}

@ -9,7 +9,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average(this IPoolingEnumerable<int> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -41,7 +41,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average(this IPoolingEnumerable<int?> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -73,7 +73,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -81,7 +81,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average(this IPoolingEnumerable<long> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -113,7 +113,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average(this IPoolingEnumerable<long?> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -145,7 +145,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -153,7 +153,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static float Average(this IPoolingEnumerable<float> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -182,7 +182,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static float? Average(this IPoolingEnumerable<float?> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -214,7 +214,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -222,7 +222,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average(this IPoolingEnumerable<double> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -254,7 +254,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average(this IPoolingEnumerable<double?> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -286,7 +286,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -294,7 +294,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static decimal Average(this IPoolingEnumerable<decimal> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -323,7 +323,7 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static decimal? Average(this IPoolingEnumerable<decimal?> source)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
@ -352,7 +352,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -360,12 +360,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, int> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -397,12 +397,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, int?> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -434,7 +434,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -442,12 +442,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, long> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -479,12 +479,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, long?> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -516,7 +516,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -524,12 +524,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static float Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, float> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -558,12 +558,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static float? Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, float?> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -595,7 +595,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -603,12 +603,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, double> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -640,12 +640,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static double? Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, double?> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -677,7 +677,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
/// <summary>
@ -685,12 +685,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static decimal Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, decimal> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -719,12 +719,12 @@ namespace MemoryPools.Collections.Linq
/// </summary>
public static decimal? Average<TSource>(this IPoolingEnumerable<TSource> source, Func<TSource, decimal?> selector)
{
if (source == null)
if (source == null!)
{
throw new ArgumentNullException(nameof(source));
}
if (selector == null)
if (selector == null!)
{
throw new ArgumentNullException(nameof(selector));
}
@ -753,7 +753,7 @@ namespace MemoryPools.Collections.Linq
}
}
return null;
return null!;
}
}
}

@ -25,7 +25,7 @@
_count--;
if (_count == 0)
{
_src = default;
_src = default!;
Pool<CastExprEnumerable<T>>.Return(this);
}
}
@ -52,16 +52,16 @@
_src.Reset();
}
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => (T)_src.Current;
public void Dispose()
{
_parent?.Dispose();
_parent = null;
_parent = null!;
_src?.Dispose();
_src = default;
_src = default!;
Pool<CastExprEnumerator>.Return(this);
}
}

@ -25,8 +25,8 @@
_count--;
if (_count == 0)
{
_src = default;
_second = default;
_src = default!;
_second = default!;
Pool<ConcatExprEnumerable<T>>.Return(this);
}
}
@ -69,18 +69,18 @@
_second.Reset();
}
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => _first ? _src.Current : _second.Current;
public void Dispose()
{
_parent?.Dispose();
_parent = default;
_parent = default!;
_src?.Dispose();
_src = default;
_src = default!;
_second?.Dispose();
_second = default;
_second = default!;
Pool<ConcatExprEnumerator>.Return(this);
}
}

@ -11,7 +11,7 @@ namespace MemoryPools.Collections.Linq
private IEqualityComparer<TItem> _comparer;
private Func<T, TItem> _selector;
public DistinctExprEnumerable<T, TItem> Init(IPoolingEnumerator<T> parent, Func<T, TItem> selector, IEqualityComparer<TItem> comparer = default)
public DistinctExprEnumerable<T, TItem> Init(IPoolingEnumerator<T> parent, Func<T, TItem> selector, IEqualityComparer<TItem> comparer = default!)
{
_parent = parent;
_selector = selector;
@ -33,8 +33,8 @@ namespace MemoryPools.Collections.Linq
if (_count == 0)
{
_parent?.Dispose();
_parent = default;
_selector = default;
_parent = default!;
_selector = default!;
Pool<DistinctExprEnumerable<T, TItem>>.Return(this);
}
}

@ -10,7 +10,7 @@ namespace MemoryPools.Collections.Linq
private IEqualityComparer<T> _comparer;
private PoolingDictionary<T, int> _except;
public ExceptExprEnumerable<T> Init(IPoolingEnumerable<T> src, PoolingDictionary<T, int> except, IEqualityComparer<T> comparer = default)
public ExceptExprEnumerable<T> Init(IPoolingEnumerable<T> src, PoolingDictionary<T, int> except, IEqualityComparer<T> comparer = default!)
{
_src = src;
_except = except;
@ -31,11 +31,11 @@ namespace MemoryPools.Collections.Linq
_count--;
if (_count == 0)
{
_src = default;
_src = default!;
_except?.Dispose();
Pool<PoolingDictionary<T, int>>.Return(_except);
_except = default;
Pool<ExceptExprEnumerable<T>>.Return(this);
Pool<PoolingDictionary<T, int>>.Return(_except!);
_except = default!;
Pool<ExceptExprEnumerable<T>>.Return(this!);
}
}
internal class ExceptExprEnumerator : IPoolingEnumerator<T>
@ -63,17 +63,17 @@ namespace MemoryPools.Collections.Linq
public void Reset() => _src.Reset();
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => _src.Current;
public void Dispose()
{
_src?.Dispose();
_src = null;
_src = null!;
_parent?.Dispose();
_parent = default;
_parent = default!;
Pool<ExceptExprEnumerator>.Return(this);
}

@ -19,7 +19,7 @@ namespace MemoryPools.Collections.Linq
enumerator.Dispose();
return element;
}
/// <summary>
/// Gets first element from sequence by given <paramref name="condition"/>. Complexity = O(1) - O(N)
/// </summary>
@ -38,7 +38,7 @@ namespace MemoryPools.Collections.Linq
enumerator.Dispose();
throw new InvalidOperationException("Sequence is empty");
}
/// <summary>
/// Gets first element from sequence by given <paramref name="condition"/>. Complexity = O(1) - O(N)
/// </summary>
@ -48,7 +48,7 @@ namespace MemoryPools.Collections.Linq
while (enumerator.MoveNext())
{
if (!condition(context, enumerator.Current)) continue;
var item = enumerator.Current;
enumerator.Dispose();
return item;
@ -56,7 +56,7 @@ namespace MemoryPools.Collections.Linq
enumerator.Dispose();
throw new InvalidOperationException("Sequence is empty");
}
/// <summary>
/// Gets first element from sequence. Complexity = O(1)
/// </summary>
@ -65,12 +65,12 @@ namespace MemoryPools.Collections.Linq
var enumerator = source.GetEnumerator();
var hasItem = enumerator.MoveNext();
var item= hasItem ? enumerator.Current : default;
var item = hasItem ? enumerator.Current : default;
enumerator.Dispose();
return item;
return item!;
}
/// <summary>
/// Gets first element from sequence by given <paramref name="condition"/>. Complexity = O(1) - O(N)
/// </summary>
@ -80,15 +80,15 @@ namespace MemoryPools.Collections.Linq
while (enumerator.MoveNext())
{
if (!condition(enumerator.Current)) continue;
var elem = enumerator.Current;
enumerator.Dispose();
return elem;
}
enumerator.Dispose();
return default;
return default!;
}
/// <summary>
/// Gets first element from sequence by given <paramref name="condition"/>. Complexity = O(1) - O(N)
/// </summary>
@ -98,13 +98,13 @@ namespace MemoryPools.Collections.Linq
while (enumerator.MoveNext())
{
if (!condition(context, enumerator.Current)) continue;
var elem = enumerator.Current;
enumerator.Dispose();
return elem;
}
enumerator.Dispose();
return default;
return default!;
}
}
}

@ -16,7 +16,7 @@ namespace MemoryPools.Collections.Linq
public IPoolingEnumerator<T> GetEnumerator()
{
var enumerator = _enumerable.GetEnumerator();
_enumerable = default;
_enumerable = default!;
Pool<GenericPoolingEnumerable<T>>.Return(this);
return Pool<GenericPoolingEnumerator<T>>.Get().Init(enumerator);
}
@ -39,7 +39,7 @@ namespace MemoryPools.Collections.Linq
public IEnumerator<T> GetEnumerator()
{
var enumerator = _enumerable.GetEnumerator();
_enumerable = default;
_enumerable = default!;
Pool<GenericEnumerable<T>>.Return(this);
return Pool<GenericEnumerator<T>>.Get().Init(enumerator);
}

@ -17,14 +17,14 @@ namespace MemoryPools.Collections.Linq
public void Reset() => _source.Reset();
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => _source.Current;
public void Dispose()
{
_source.Dispose();
_source = default;
_source = default!;
Pool<GenericPoolingEnumerator<T>>.Return(this);
}
}
@ -43,14 +43,14 @@ namespace MemoryPools.Collections.Linq
public void Reset() => _source.Reset();
object IEnumerator.Current => Current;
object IEnumerator.Current => Current!;
public T Current => _source.Current;
public void Dispose()
{
_source.Dispose();
_source = default;
_source = default!;
Pool<GenericEnumerator<T>>.Return(this);
}
}

@ -53,9 +53,9 @@ namespace MemoryPools.Collections.Linq
if (_count == 0)
{
_comparer = default;
_elementSelector = default;
_keySelector = default;
_comparer = default!;
_elementSelector = default!;
_keySelector = default!;
Pool<GroupedEnumerable<TSource, TKey, TElement>>.Return(this);
}
}
@ -89,16 +89,16 @@ namespace MemoryPools.Collections.Linq
// cleanup collection
_src?.Dispose();
Pool<PoolingDictionary<TKey, PoolingGrouping>>.Return(_src);
_src = default;
Pool<PoolingDictionary<TKey, PoolingGrouping>>.Return(_src!);
_src = default!;
_enumerator?.Dispose();
_enumerator = default;
_enumerator = default!;
_parent?.Dispose();
_parent = default;
_parent = default!;
Pool<PoolingGroupingEnumerator>.Return(this);
Pool<PoolingGroupingEnumerator>.Return(this!);
}
public bool MoveNext() => _enumerator.MoveNext();
@ -107,7 +107,7 @@ namespace MemoryPools.Collections.Linq
public IPoolingGrouping<TKey, TElement> Current => _enumerator.Current.Value;
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
}
internal class PoolingGrouping : IPoolingGrouping<TKey, TElement>, IDisposable
@ -132,10 +132,10 @@ namespace MemoryPools.Collections.Linq
public void Dispose()
{
_elements?.Dispose();
Pool<PoolingList<TElement>>.Return(_elements);
_elements = null;
Pool<PoolingList<TElement>>.Return(_elements!);
_elements = null!;
Key = default;
Key = default!;
}
}
}

@ -53,9 +53,9 @@ namespace MemoryPools.Collections.Linq
if (_count == 0)
{
_comparer = default;
_resultSelector = default;
_keySelector = default;
_comparer = default!;
_resultSelector = default!;
_keySelector = default!;
Pool<GroupedResultEnumerable<TSource, TKey, TResult>>.Return(this);
}
}
@ -89,14 +89,14 @@ namespace MemoryPools.Collections.Linq
// cleanup collection
_src?.Dispose();
Pool<PoolingDictionary<TKey, PoolingGrouping>>.Return(_src);
_src = default;
Pool<PoolingDictionary<TKey, PoolingGrouping>>.Return(_src!);
_src = default!;
_enumerator?.Dispose();
_enumerator = default;
_enumerator = default!;
_parent?.Dispose();
_parent = default;
_parent = default!;
Pool<GroupedResultEnumerator>.Return(this);
}
@ -107,7 +107,7 @@ namespace MemoryPools.Collections.Linq
public TResult Current => _parent._resultSelector(_enumerator.Current.Key, _enumerator.Current.Value.InternalList);
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
}
internal class PoolingGrouping : IPoolingGrouping<TKey, TSource>, IDisposable
@ -132,10 +132,10 @@ namespace MemoryPools.Collections.Linq
public void Dispose()
{
_elements?.Dispose();
Pool<PoolingList<TSource>>.Return(_elements);
_elements = null;
Pool<PoolingList<TSource>>.Return(_elements!);
_elements = null!;
Key = default;
Key = default!;
}
}
}

@ -6,19 +6,19 @@ namespace MemoryPools.Collections.Linq
public static partial class PoolingEnumerable
{
public static IPoolingEnumerable<IPoolingGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IPoolingEnumerable<TSource> source, Func<TSource, TKey> keySelector) =>
Pool<GroupedEnumerable<TSource, TKey, TSource>>.Get().Init(source, keySelector, x => x, null);
Pool<GroupedEnumerable<TSource, TKey, TSource>>.Get().Init(source, keySelector, x => x, null!);
public static IPoolingEnumerable<IPoolingGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IPoolingEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) =>
Pool<GroupedEnumerable<TSource, TKey, TSource>>.Get().Init(source, keySelector, x => x, comparer);
public static IPoolingEnumerable<IPoolingGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IPoolingEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) =>
Pool<GroupedEnumerable<TSource, TKey, TElement>>.Get().Init(source, keySelector, elementSelector, null);
Pool<GroupedEnumerable<TSource, TKey, TElement>>.Get().Init(source, keySelector, elementSelector, null!);
public static IPoolingEnumerable<IPoolingGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IPoolingEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) =>
Pool<GroupedEnumerable<TSource, TKey, TElement>>.Get().Init(source, keySelector, elementSelector, comparer);
public static IPoolingEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IPoolingEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IPoolingEnumerable<TSource>, TResult> resultSelector) =>
Pool<GroupedResultEnumerable<TSource, TKey, TResult>>.Get().Init(source, keySelector, resultSelector, null);
Pool<GroupedResultEnumerable<TSource, TKey, TResult>>.Get().Init(source, keySelector, resultSelector, null!);
// public static IPoolingEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector) =>
// new GroupedResultEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, null);

@ -13,7 +13,7 @@ namespace MemoryPools.Collections.Linq
public IntersectExprEnumerable<T> Init(
IPoolingEnumerable<T> src,
PoolingDictionary<T, int> second,
IEqualityComparer<T> comparer = default)
IEqualityComparer<T> comparer = default!)
{
_src = src;
_count = 0;
@ -34,11 +34,11 @@ namespace MemoryPools.Collections.Linq
_count--;
if (_count == 0)
{
_src = default;
_src = default!;
_second?.Dispose();
Pool<PoolingDictionary<T, int>>.Return(_second);
Pool<PoolingDictionary<T, int>>.Return(_second!);
_second = default;
_second = default!;
Pool<IntersectExprEnumerable<T>>.Return(this);
}
}
@ -74,23 +74,23 @@ namespace MemoryPools.Collections.Linq
public void Reset() => _src.Reset();
object IPoolingEnumerator.Current => Current;
object IPoolingEnumerator.Current => Current!;
public T Current => _src.Current;
public void Dispose()
{
_src?.Dispose();
_src = null;
_src = null!;
_alreadyDoneItems?.Dispose();
Pool<PoolingDictionary<T, int>>.Return(_alreadyDoneItems);
_alreadyDoneItems = default;
Pool<PoolingDictionary<T, int>>.Return(_alreadyDoneItems!);
_alreadyDoneItems = default!;
_parent?.Dispose();
_parent = default;
_parent = default!;
Pool<IntersectExprEnumerator>.Return(this);
Pool<IntersectExprEnumerator>.Return(this!);
}
}
IPoolingEnumerator IPoolingEnumerable.GetEnumerator() => GetEnumerator();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.