pull/1/head
Ogoun 5 years ago
parent 689ffad9d4
commit 1acc3dd90c

@ -5,6 +5,10 @@
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BaGet.Protocol" Version="0.2.0-preview1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZeroLevel\ZeroLevel.csproj" />
</ItemGroup>

@ -1,11 +1,15 @@
using System;
using BaGet.Protocol;
using NuGet.Versioning;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using ZeroLevel;
namespace ConfigurationTests
{
class Program
{
{
static void Main(string[] args)
{
var config = Configuration.ReadSetFromIniFile("config.ini").Bind<AppConfig>();

@ -33,7 +33,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZeroNetworkMonitor", "ZeroN
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfigurationTests", "ConfigurationTests\ConfigurationTests.csproj", "{E37785CE-E75A-49FB-B17F-16A0F2C6D656}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyInjectionTests", "DependencyInjectionTests\DependencyInjectionTests.csproj", "{665B38E3-A5F2-4AD0-946B-209D80C1AA40}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionTests", "DependencyInjectionTests\DependencyInjectionTests.csproj", "{665B38E3-A5F2-4AD0-946B-209D80C1AA40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -3,6 +3,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using ZeroLevel.Services.Collections;
using ZeroLevel.Services.ObjectMapping;
using ZeroLevel.Services.Reflection;
@ -501,6 +502,26 @@ namespace ZeroLevel.Services.Config
}
member.Setter(instance, collectionBuilder.Complete());
}
else if (TypeHelpers.IsEnum(member.ClrType))
{
var value = Enum.Parse(member.ClrType, First(member.Name));
member.Setter(instance, value);
}
else if (TypeHelpers.IsUri(member.ClrType))
{
var uri = new Uri(First(member.Name));
member.Setter(instance, uri);
}
else if (TypeHelpers.IsIpEndPoint(member.ClrType))
{
var ep = ZeroLevel.Network.NetUtils.CreateIPEndPoint(First(member.Name));
member.Setter(instance, ep);
}
else if (member.ClrType == typeof(IPAddress))
{
var ip = IPAddress.Parse(First(member.Name));
member.Setter(instance, ip);
}
else
{
member.Setter(instance, First(member.Name));

@ -31,22 +31,5 @@ namespace ZeroLevel
{
return !IsEmpty(collection);
}
public static IEnumerable<IEnumerable<T>> Chunkify<T>(this IEnumerable<T> source, int size)
{
if (source == null)
{
yield break;
}
if (size <= 0)
{
throw new ArgumentException("chunkSize must be greater than 0.");
}
while (source.Any())
{
yield return source.Take(size);
source = source.Skip(size);
}
}
}
}

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace ZeroLevel
namespace System.Linq
{
public static class LinqExtension
{
@ -20,5 +19,35 @@ namespace ZeroLevel
}
}
}
public static IList<TSource> Materialize<TSource>(this IEnumerable<TSource> source)
{
if (source is IList<TSource>)
{
// Already a list, use it as is
return (IList<TSource>)source;
}
else
{
// Not a list, materialize it to a list
return source.ToList();
}
}
public static IEnumerable<IEnumerable<T>> Chunkify<T>(this IEnumerable<T> source, int size)
{
if (source == null)
{
yield break;
}
if (size <= 0)
{
throw new ArgumentException("chunkSize must be greater than 0.");
}
while (source.Any())
{
yield return source.Take(size);
source = source.Skip(size);
}
}
}
}

@ -28,6 +28,11 @@ namespace ZeroLevel.Services.Reflection
return IsAssignableToGenericType(baseType, genericType);
}
public static bool IsEnum(Type type)
{
return type.Return(t => t.IsEnum, false);
}
public static bool IsArray(Type type)
{
return type.Return(t => t.IsArray, false);

@ -0,0 +1,8 @@
namespace ZeroLevel.Services.Serialization
{
public interface ISerializer
{
void Serialize(IBinaryWriter writer);
object Deserialize(IBinaryReader writer);
}
}

@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace ZeroLevel.Services.Serialization

@ -6,17 +6,16 @@
</Description>
<Authors>ogoun</Authors>
<Company>ogoun</Company>
<AssemblyVersion>3.1.5.0</AssemblyVersion>
<PackageReleaseNotes>Append Configuration and ConfigurationSet Bind to object
Append runtime collection and array builders (CollectionFactory)</PackageReleaseNotes>
<AssemblyVersion>3.1.6.0</AssemblyVersion>
<PackageReleaseNotes>Fixes</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2019</Copyright>
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/ogoun/Zero/master/zero.png</PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Version>3.1.5</Version>
<FileVersion>3.1.5.0</FileVersion>
<Version>3.1.6</Version>
<FileVersion>3.1.6.0</FileVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.