public CollectionTraits(CollectionDetailedKind type, MethodInfo addMethod, MethodInfo getEnumeratorMethod, PropertyInfo countProperty, Type elementType) { this.DetailedCollectionType = type; this.GetEnumeratorMethod = getEnumeratorMethod; this.AddMethod = addMethod; this.CountProperty = countProperty; this.ElementType = elementType; }
public CollectionTraits( CollectionDetailedKind type, MethodInfo addMethod, MethodInfo countPropertyGetter, MethodInfo getEnumeratorMethod, Type elementType ) { this.DetailedCollectionType = type; this.GetEnumeratorMethod = getEnumeratorMethod; this.AddMethod = addMethod; this.CountPropertyGetter = countPropertyGetter; this.ElementType = elementType; }
public CollectionTraits(CollectionDetailedKind type, MethodInfo addMethod, MethodInfo countPropertyGetter, MethodInfo getEnumeratorMethod, Type elementType) { this.DetailedCollectionType = type; this.GetEnumeratorMethod = getEnumeratorMethod; this.AddMethod = addMethod; #if UNITY this.CountPropertyGetter = countPropertyGetter; #endif // UNITY this.ElementType = elementType; }
private static bool TryCreateCollectionTraitsForIEnumerableT( Type source, GenericCollectionTypes genericTypes, CollectionTraitOptions options, MethodInfo getMethod, out CollectionTraits result ) { var elementType = genericTypes.IEnumerableT.GetGenericArguments()[0]; var addMethod = GetAddMethod(source, elementType, options); if (addMethod == null && ((options & CollectionTraitOptions.AllowNonCollectionEnumerableTypes) != 0)) { // This should be non collection object isntead of "unappendable" collection. result = default(CollectionTraits); return(false); } CollectionDetailedKind kind = CollectionDetailedKind.GenericEnumerable; if (genericTypes.IListT != null) { kind = CollectionDetailedKind.GenericList; } #if !NETFX_35 && !UNITY else if (genericTypes.ISetT != null) { kind = CollectionDetailedKind.GenericSet; } #endif // !NETFX_35 && !UNITY else if (genericTypes.ICollectionT != null) { kind = CollectionDetailedKind.GenericCollection; } #if !NETFX_35 && !UNITY && !NETFX_40 && !(SILVERLIGHT && !WINDOWS_PHONE) else if (genericTypes.IReadOnlyListT != null) { kind = CollectionDetailedKind.GenericReadOnlyList; } else if (genericTypes.IReadOnlyCollectionT != null) { kind = CollectionDetailedKind.GenericReadOnlyCollection; } #endif // !NETFX_35 && !UNITY && !NETFX_40 && !( SILVERLIGHT && !WINDOWS_PHONE ) result = new CollectionTraits( kind, elementType, getMethod ?? GetGetEnumeratorMethodFromElementType(source, elementType, options), addMethod, GetCountGetterMethod(source, elementType, options) ); return(true); }