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);
}
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>
<Authors>ogoun</Authors>
<Company>ogoun</Company>
<AssemblyVersion>3.3.5.5</AssemblyVersion>
<PackageReleaseNotes>Update TypeMapper</PackageReleaseNotes>
<AssemblyVersion>3.3.5.6</AssemblyVersion>
<PackageReleaseNotes>Append method TypeHelpers.GetElementTypeOfEnumerable</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2021</Copyright>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Version>3.3.5.5</Version>
<FileVersion>3.3.5.5</FileVersion>
<Version>3.3.5.6</Version>
<FileVersion>3.3.5.6</FileVersion>
<Platforms>AnyCPU;x64;x86</Platforms>
<PackageIcon>zero.png</PackageIcon>
</PropertyGroup>

Loading…
Cancel
Save

Powered by TurnKey Linux.