Beispiel #1
0
        private Type GetTypeFromInfoField(DRM.PropBagControlsWPF.TypeInfoField tif, PropKindEnum propKind,
                                          Type propertyType, out Type itemType)
        {
            itemType = null;
            switch (propKind)
            {
            case PropKindEnum.Prop:
                itemType = null;
                return(propertyType);

            case PropKindEnum.CollectionView:
                itemType = propertyType;
                Type pType = typeof(ListCollectionView);     // typeof(ICollectionView);
                return(pType);

            case PropKindEnum.Enumerable_RO:
                goto case PropKindEnum.ObservableCollection;

            case PropKindEnum.Enumerable:
                goto case PropKindEnum.ObservableCollection;

            case PropKindEnum.EnumerableTyped_RO:
                goto case PropKindEnum.ObservableCollection;

            case PropKindEnum.EnumerableTyped:
                goto case PropKindEnum.ObservableCollection;


            case PropKindEnum.ObservableCollection_RO:
                goto case PropKindEnum.ObservableCollection;

            case PropKindEnum.ObservableCollection:
                return(GetTypeFromCollInfoField(tif, propertyType, out itemType));


            case PropKindEnum.CollectionViewSource_RO:
                goto case PropKindEnum.CollectionViewSource;

            case PropKindEnum.CollectionViewSource:
                Type result = typeof(CollectionViewSource);
                itemType = propertyType;
                return(result);


            case PropKindEnum.DataTable_RO:
                goto case PropKindEnum.DataTable;

            case PropKindEnum.DataTable:
                itemType = null;
                return(typeof(DataTable));

            default:
                throw new InvalidOperationException($"PropKind = {propKind} is not recognized or is not supported.");
            }
        }
Beispiel #2
0
        private Type GetObsCollectionType(DRM.PropBagControlsWPF.TypeInfoField tif, out Type itemType, Func <Type, Type> typeGetter)
        {
            // Consider using the MemberType property of the "root" TypeInfoField itself.
            TypeInfoCollection tps;

            DRM.PropBagControlsWPF.TypeInfoField child;

            // Use our type parameter arguments 1-3
            if (tif.TypeParameter1 != null)
            {
                itemType = tif.TypeParameter1;
                return(GetObservableCollType(itemType));
            }

            // Use our child Type Parameters
            else if (tif.TypeParameters != null && tif.TypeParameters.Count > 0)
            {
                child    = tif.TypeParameters[0];
                itemType = child.MemberType;
                return(typeGetter(itemType)); // GetObservableCollType(itemType);
            }

            // Use a child control of type TypeInfoCollection
            else if (null != (tps = tif.Items.OfType <TypeInfoCollection>().FirstOrDefault()))
            {
                if (tps.Count > 0)
                {
                    child    = tps[0];
                    itemType = child.MemberType;
                    return(GetObservableCollType(itemType));
                }
            }

            // Use a child control of type TypeInfoField
            else if (null != (child = tif.Items.OfType <DRM.PropBagControlsWPF.TypeInfoField>().FirstOrDefault()))
            {
                itemType = child.MemberType;
                return(GetObservableCollType(itemType));
            }

            throw new ArgumentException("Cannot find a PropTypeInfoField for this collection.");
        }
Beispiel #3
0
        private Type GetTypeFromCollInfoField(DRM.PropBagControlsWPF.TypeInfoField tif, Type propertyType, out Type itemType)
        {
            WellKnownCollectionTypeEnum collectionType = tif?.CollectionType ?? WellKnownCollectionTypeEnum.ObservableCollection;

            switch (collectionType)
            {
            case WellKnownCollectionTypeEnum.ObservableCollection:
            {
                Type cType;
                if (tif == null)
                {
                    itemType = propertyType;
                    cType    = GetObservableCollType(itemType);
                }
                else
                {
                    cType = GetObsCollectionType(tif, out itemType, GetObservableCollType);
                }
                return(cType);
            }

            // Not Yet Supported
            //case WellKnownCollectionTypeEnum.TypedEnumerable:
            //    {
            //        break;
            //    }

            case WellKnownCollectionTypeEnum.Enumerable:
            {
                goto case WellKnownCollectionTypeEnum.ObservableCollection;
            }

            default:
            {
                throw new InvalidOperationException($"CollectionType = {collectionType} is not recognized or is not supported.");
            }
            }
        }
Beispiel #4
0
 private DRM.PropBagControlsWPF.TypeInfoField GetWrapperTypeInfo(PropBagTemplate pbt)
 {
     DRM.PropBagControlsWPF.TypeInfoField ptif = pbt.Items.OfType <DRM.PropBagControlsWPF.TypeInfoField>().FirstOrDefault();
     return(ptif);
 }