Append method TypeHelpers.GetElementTypeOfEnumerable
pull/1/head
unknown 3 years ago
parent 844c35f70a
commit ba83fcf848

@ -204,5 +204,16 @@ namespace ZeroLevel.Services.Reflection
} }
return FormatterServices.GetUninitializedObject(type); return FormatterServices.GetUninitializedObject(type);
} }
public static Type GetElementTypeOfEnumerable(object o)
{
var enumerable = o as IEnumerable;
if (enumerable == null)
return null;
Type[] interfaces = enumerable.GetType().GetInterfaces();
return (from i in interfaces
where i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>)
select i.GetGenericArguments()[0]).FirstOrDefault();
}
} }
} }

@ -6,16 +6,16 @@
</Description> </Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>3.3.5.5</AssemblyVersion> <AssemblyVersion>3.3.5.6</AssemblyVersion>
<PackageReleaseNotes>Update TypeMapper</PackageReleaseNotes> <PackageReleaseNotes>Append method TypeHelpers.GetElementTypeOfEnumerable</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.5</Version> <Version>3.3.5.6</Version>
<FileVersion>3.3.5.5</FileVersion> <FileVersion>3.3.5.6</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.