Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
		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;
		}
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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);
        }