コード例 #1
0
        internal IWrappedCollection CreateWrapper(object list)
        {
            if (list is IList && (CollectionItemType == null || !_isCollectionItemTypeNullableType))
            {
                return(new CollectionWrapper <object>((IList)list));
            }

            if (_genericWrapperType == null)
            {
                _genericWrapperType = ReflectionUtils.MakeGenericType(typeof(CollectionWrapper <>), CollectionItemType);

                ConstructorInfo genericWrapperConstructor = _genericWrapperType.GetConstructor(new[] { _genericCollectionDefinitionType });
#if !PocketPC
                _genericWrapperCreator = LateBoundDelegateFactory.CreateMethodHandler(genericWrapperConstructor);
#else
                _genericWrapperCreator = (target, args) => genericWrapperConstructor.Invoke(new[] { args[0] });
#endif
            }

            return((IWrappedCollection)_genericWrapperCreator(null, list));
        }
コード例 #2
0
        internal IWrappedDictionary CreateWrapper(object dictionary)
        {
            if (dictionary is IDictionary)
            {
                return(new DictionaryWrapper <object, object>((IDictionary)dictionary));
            }

            if (_genericWrapperType == null)
            {
                _genericWrapperType = ReflectionUtils.MakeGenericType(typeof(DictionaryWrapper <,>), DictionaryKeyType, DictionaryValueType);

                ConstructorInfo genericWrapperConstructor = _genericWrapperType.GetConstructor(new[] { _genericCollectionDefinitionType });
#if !PocketPC
                _genericWrapperCreator = LateBoundDelegateFactory.CreateMethodHandler(genericWrapperConstructor);
#else
                _genericWrapperCreator = (target, args) => genericWrapperConstructor.Invoke(new[] { args[0] });
#endif
            }

            return((IWrappedDictionary)_genericWrapperCreator(null, dictionary));
        }