protected virtual void PopulateEnumerableItems(IEnumerable enumerable, Type exposedType)
        {
            if (_enumerableItems == null)
            {
                _enumerableItems = new Dictionary <object, WoopsaObjectAdapter>();
            }
            if (exposedType != null)
            {
                WoopsaTypeUtils.GetGenericEnumerableItemType(exposedType, out _itemExposedType);
            }
            _iNotifyCollectionChanged = enumerable as INotifyCollectionChanged;
            if (_iNotifyCollectionChanged != null)
            {
                _iNotifyCollectionChanged.CollectionChanged += EnumerableCollectionChanged;
            }
            int index = 0;

            foreach (object item in enumerable)
            {
                if (item != null)
                {
                    WoopsaObjectAdapter adapter = AddEnumerableItem(item);
                    adapter.EnumerableItemIndex = index;
                    index++;
                }
            }
        }
Ejemplo n.º 2
0
 private static bool InferWoopsaType(WoopsaConverters customValueTypeConverters, Type type, out WoopsaValueType woopsaValueType, out WoopsaConverter converter)
 {
     if (customValueTypeConverters != null)
     {
         return(customValueTypeConverters.InferWoopsaType(type, out woopsaValueType, out converter));
     }
     else
     {
         converter = WoopsaConverterDefault.Default;
         return(WoopsaTypeUtils.InferWoopsaType(type, out woopsaValueType));
     }
 }
Ejemplo n.º 3
0
        public virtual bool InferWoopsaType(Type type, out WoopsaValueType woopsaValueType, out WoopsaConverter converter)
        {
            WoopsaConverterDescription converterDescription;

            if (_converterDescriptions.TryGetValue(type, out converterDescription))
            {
                woopsaValueType = converterDescription.WoopsaValueType;
                converter       = converterDescription.Converter;
                return(true);
            }
            else
            {
                converter = WoopsaConverterDefault.Default;
                return(WoopsaTypeUtils.InferWoopsaType(type, out woopsaValueType));
            }
        }