Esempio n. 1
0
        public static CustomMemberProvider For(CustomTypeProvider owner, Type type, string name)
        {
            var propertyInfo = type.GetRuntimeProperty(name);

            if (propertyInfo == null)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("The property {0} is not found in class {1}.", name, type));
                return(null);
            }
            var propertyTypeInfo = propertyInfo.PropertyType.GetTypeInfo();

            bool isCollection;
            bool isPrimitive;

            if (TypeIsPrimitive(propertyTypeInfo))
            {
                isCollection = false;
                isPrimitive  = true;
            }
            else if (IsCollectionType(propertyTypeInfo))
            {
                isCollection = true;
                isPrimitive  = TypeIsPrimitive(GetItemType(propertyTypeInfo));
            }
            else
            {
                isCollection = false;
                isPrimitive  = false;
            }

            return(new CustomMemberProvider(owner, type, name, propertyInfo, isPrimitive, isCollection));
        }
Esempio n. 2
0
 private CustomMemberProvider(CustomTypeProvider owner, Type type, string name, PropertyInfo propertyInfo, bool isPrimitive, bool isCollection)
 {
     _owner        = owner;
     _type         = type;
     _name         = name;
     _propertyInfo = propertyInfo;
     _isPrimitive  = isPrimitive;
     _isCollection = isCollection;
 }
Esempio n. 3
0
 public static IXamlType GetDependentType(Type wrappedType)
 {
     lock (_xamlTypeFromCLR)
     {
         IXamlType xamlType;
         if (!_xamlTypeFromCLR.TryGetValue(wrappedType, out xamlType))
         {
             xamlType = new CustomTypeProvider(wrappedType);
             _xamlTypeFromCLR.Add(wrappedType, xamlType);
         }
         return(xamlType);
     }
 }
 public static IXamlType GetDependentType(Type wrappedType)
 {
     lock (_xamlTypeFromCLR)
     {
         IXamlType xamlType;
         if (!_xamlTypeFromCLR.TryGetValue(wrappedType, out xamlType))
         {
             xamlType = new CustomTypeProvider(wrappedType);
             _xamlTypeFromCLR.Add(wrappedType, xamlType);
         }
         return xamlType;
     }
 }