Extend TypeMapper
pull/1/head
unknown 3 years ago
parent 516407064b
commit 844c35f70a

@ -65,7 +65,7 @@ namespace ZeroLevel
return false; return false;
} }
private static bool IsEmptyLocate<T>(T[] array, T[] candidate) private static bool IsEmptyLocate<T>(this T[] array, T[] candidate)
{ {
return array == null return array == null
|| candidate == null || candidate == null
@ -74,7 +74,7 @@ namespace ZeroLevel
|| candidate.Length > array.Length; || candidate.Length > array.Length;
} }
public static IEnumerable<T> GetRow<T>(T[,] array, int row) public static IEnumerable<T> GetRow<T>(this T[,] array, int row)
{ {
for (int i = 0; i < array.GetLength(1); i++) for (int i = 0; i < array.GetLength(1); i++)
{ {
@ -82,6 +82,14 @@ namespace ZeroLevel
} }
} }
public static IEnumerable<T> GetColumn<T>(this T[,] array, int column)
{
for (int i = 0; i < array.GetLength(0); i++)
{
yield return array[i, column];
}
}
public static bool Equals(byte[] first, byte[] second) public static bool Equals(byte[] first, byte[] second)
{ {
if (null == first && null == second) if (null == first && null == second)

@ -1,4 +1,5 @@
using System; using System;
using System.Reflection;
namespace ZeroLevel.Services.ObjectMapping namespace ZeroLevel.Services.ObjectMapping
{ {
@ -13,5 +14,6 @@ namespace ZeroLevel.Services.ObjectMapping
Type ClrType { get; } Type ClrType { get; }
Action<object, object> Setter { get; } Action<object, object> Setter { get; }
Func<object, object> Getter { get; } Func<object, object> Getter { get; }
MemberInfo Original { get; }
} }
} }

@ -12,8 +12,9 @@ namespace ZeroLevel.Services.ObjectMapping
public bool IsField { get; set; } public bool IsField { get; set; }
public string Name { get; set; } public string Name { get; set; }
public Type ClrType { get; set; } public Type ClrType { get; set; }
public Action<object, object> Setter { get; set; } public Action<object, object> Setter { get; private set; }
public Func<object, object> Getter { get; set; } public Func<object, object> Getter { get; private set; }
public MemberInfo Original { get; private set; }
#endregion Properties #endregion Properties
@ -57,7 +58,8 @@ namespace ZeroLevel.Services.ObjectMapping
{ {
var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(fieldInfo), TypeGetterSetterBuilder.BuildGetter(fieldInfo)) var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(fieldInfo), TypeGetterSetterBuilder.BuildGetter(fieldInfo))
{ {
Name = fieldInfo.Name Name = fieldInfo.Name,
Original = fieldInfo
}; };
field.IsField = true; field.IsField = true;
var type = fieldInfo.FieldType; var type = fieldInfo.FieldType;
@ -69,7 +71,8 @@ namespace ZeroLevel.Services.ObjectMapping
{ {
var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(propertyInfo), TypeGetterSetterBuilder.BuildGetter(propertyInfo)) var field = new MapMemberInfo(TypeGetterSetterBuilder.BuildSetter(propertyInfo), TypeGetterSetterBuilder.BuildGetter(propertyInfo))
{ {
Name = propertyInfo.Name Name = propertyInfo.Name,
Original = propertyInfo
}; };
field.IsField = false; field.IsField = false;
var type = propertyInfo.PropertyType; var type = propertyInfo.PropertyType;

@ -6,16 +6,16 @@
</Description> </Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>3.3.5.3</AssemblyVersion> <AssemblyVersion>3.3.5.5</AssemblyVersion>
<PackageReleaseNotes>Collection lazy deserialization</PackageReleaseNotes> <PackageReleaseNotes>Update TypeMapper</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl> <PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2021</Copyright> <Copyright>Copyright Ogoun 2021</Copyright>
<PackageLicenseUrl></PackageLicenseUrl> <PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl> <PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl> <RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType> <RepositoryType>GitHub</RepositoryType>
<Version>3.3.5.3</Version> <Version>3.3.5.5</Version>
<FileVersion>3.3.5.3</FileVersion> <FileVersion>3.3.5.5</FileVersion>
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
<PackageIcon>zero.png</PackageIcon> <PackageIcon>zero.png</PackageIcon>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.