コード例 #1
0
            protected override TCollection CreateDestinationObjectBase(Type destElementType, int sourceLength)
            {
                var list = typeof(TCollection).IsInterface
                                  ? new List <TElement>()
                                  : ObjectCreator.CreateDefaultValue(typeof(TCollection));

                return((TCollection)list);
            }
コード例 #2
0
            protected override TCollection CreateDestinationObjectBase(Type destElementType, int sourceLength)
            {
                Object collection;

                if (typeof(TCollection).IsInterface())
                {
                    collection = new HashSet <TElement>();
                }
                else
                {
                    collection = ObjectCreator.CreateDefaultValue(typeof(TCollection));
                }

                return((TCollection)collection);
            }
コード例 #3
0
            protected override TCollection CreateDestinationObjectBase(Type destElementType, int sourceLength)
            {
                Object collection;

                if (typeof(TCollection).IsInterface)
                {
                    if (typeof(TCollection).IsGenericType && (typeof(TCollection).GetGenericTypeDefinition() == typeof(ISet <>)))
                    {
                        collection = new HashSet <TElement>();
                    }
                    else
                    {
                        collection = new List <TElement>();
                    }
                }
                else
                {
                    collection = ObjectCreator.CreateDefaultValue(typeof(TCollection));
                }

                return((TCollection)collection);
            }