private IDocumentNodePropertyBuilder GetDefaultHandler(ITypeResolver typeResolver, Type type)
        {
            IDocumentNodePropertyBuilder documentNodePropertyBuilder;

            base.InitializeIfNecessary();
            IType type1 = typeResolver.GetType(type);

            if (type1 != null)
            {
                if (type.IsValueType && type1.TypeConverter != null && !PlatformTypes.TypeConverter.Equals(typeResolver.GetType(type1.TypeConverter.GetType())))
                {
                    return(null);
                }
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type1);
                using (IEnumerator <IProperty> enumerator = type1.Metadata.Properties.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IProperty current = enumerator.Current;
                        if (!current.ShouldSerialize || !TypeHelper.IsSet(allowableMemberAccess, current.WriteAccess) && current.PropertyType.ItemType == null)
                        {
                            continue;
                        }
                        documentNodePropertyBuilder = this.defaultPropertyBuilder;
                        return(documentNodePropertyBuilder);
                    }
                    return(null);
                }
                return(documentNodePropertyBuilder);
            }
            return(null);
        }
Esempio n. 2
0
        private DocumentCompositeNode BuildCompositeNode(IType type)
        {
            DocumentCompositeNode node = this.documentContext.CreateNode((ITypeId)type);

            ++this.complexDepth;
            bool recursionLimitReached = this.complexDepth > DesignDataGenerator.maxComplexDepth && !this.IsCollectionRecent;
            MemberAccessTypes  allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(this.documentContext.TypeResolver, type);
            SortedSet <string> sortedSet             = new SortedSet <string>();

            foreach (IProperty property in ITypeExtensions.GetProperties(type, allowableMemberAccess, true))
            {
                if (!sortedSet.Contains(property.Name))
                {
                    sortedSet.Add(property.Name);
                    if (DesignDataGenerator.IsPropertyWritable(property, this.documentContext.TypeResolver))
                    {
                        DocumentNode documentNode = this.BuildNode(property.PropertyType, true, recursionLimitReached);
                        if (documentNode != null)
                        {
                            node.Properties[(IPropertyId)property] = documentNode;
                        }
                    }
                }
            }
            if (type.ItemType != null && (this.IsTypeXamlFriendly(type.ItemType) || this.CanBuildSimpleNode(type.ItemType)))
            {
                this.stack.Add(DesignDataGenerator.NodeType.Collection);
                this.BuildCollectionNode(type, node);
                this.stack.RemoveAt(this.stack.Count - 1);
            }
            --this.complexDepth;
            return(node);
        }
            public IEnumerable <IProperty> GetProperties(MemberAccessTypes access)
            {
                ReadOnlyCollection <IProperty> readOnlyCollection1;

                if (this.designPropertySets.TryGetValue(access, out readOnlyCollection1))
                {
                    return((IEnumerable <IProperty>)readOnlyCollection1);
                }
                IEnumerable <IProperty> properties = this.designType.GetProperties(access);
                List <IProperty>        list       = new List <IProperty>();

                foreach (IProperty property in properties)
                {
                    ReferenceStep actualReferenceStep = property as ReferenceStep;
                    if (actualReferenceStep != null)
                    {
                        TypeReflectingProjectContext.DesignTypeProperty createDesignProperty = this.GetOrCreateDesignProperty(actualReferenceStep);
                        list.Add((IProperty)createDesignProperty);
                    }
                }
                ReadOnlyCollection <IProperty> readOnlyCollection2 = new ReadOnlyCollection <IProperty>((IList <IProperty>)list);

                this.designPropertySets[access] = readOnlyCollection2;
                return((IEnumerable <IProperty>)readOnlyCollection2);
            }
Esempio n. 4
0
        public static IEnumerable <EventInformation> GetEventsForType(ITypeResolver typeResolver, IType typeId, MemberType memberTypes)
        {
            IType mostDerivedType = (IType)null;

            for (; typeId != null; typeId = typeId.BaseType)
            {
                MemberAccessTypes allowableAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, typeId);
                foreach (IEvent eventKey in typeId.GetEvents(allowableAccess))
                {
                    if (TypeHelper.IsSet(memberTypes, MemberType.RoutedEvent) && eventKey.IncludesRoutedEvent && eventKey.RoutedEvent is RoutedEvent)
                    {
                        if (mostDerivedType == null)
                        {
                            mostDerivedType = typeId;
                        }
                        yield return((EventInformation) new RoutedEventInformation(eventKey, mostDerivedType));
                    }
                    else if (TypeHelper.IsSet(memberTypes, MemberType.ClrEvent) && eventKey.IncludesClrEvent)
                    {
                        if (mostDerivedType == null)
                        {
                            mostDerivedType = typeId;
                        }
                        yield return(new EventInformation(eventKey, mostDerivedType));
                    }
                }
            }
        }
Esempio n. 5
0
 public override IEnumerable <IProperty> GetProperties(MemberAccessTypes access)
 {
     if ((access & MemberAccessTypes.Public) != MemberAccessTypes.Public)
     {
         return((IEnumerable <IProperty>)SampleNonBasicType.emptyProperties);
     }
     return((IEnumerable <IProperty>) this.Properties);
 }
Esempio n. 6
0
        public static bool IsPropertyWritable(IProperty property, ITypeResolver typeResolver)
        {
            if (property == null)
            {
                return(false);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, property.DeclaringType);

            return(DesignDataGenerator.IsPropertyWritable(property, allowableMemberAccess));
        }
Esempio n. 7
0
        private DocumentCompositeNode GenerateHierarchicalDataTemplateIfNeeded(SceneNode targetNode)
        {
            DocumentCompositeNode documentCompositeNode = this.GenerateDataTemplateIfNeeded(targetNode, ProjectNeutralTypes.HierarchicalDataTemplate);

            if (documentCompositeNode == null)
            {
                return((DocumentCompositeNode)null);
            }
            IType type   = this.DragModel.RelativeDropSchemaPath.Type;
            IType typeId = type != null ? type.ItemType : (IType)null;

            if (typeId == null)
            {
                return(documentCompositeNode);
            }
            string path;

            if (PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)typeId) && !PlatformTypes.String.IsAssignableFrom((ITypeId)typeId))
            {
                path = string.Empty;
            }
            else
            {
                IProperty         property1             = (IProperty)null;
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)this.ProjectContext, typeId);
                List <IProperty>  list = new List <IProperty>(typeId.GetProperties(allowableMemberAccess));
                list.Sort((Comparison <IProperty>)((a, b) => StringLogicalComparer.Instance.Compare(a.Name, b.Name)));
                foreach (IProperty property2 in list)
                {
                    IType propertyType = property2.PropertyType;
                    if (propertyType == type)
                    {
                        property1 = property2;
                        break;
                    }
                    if (property1 == null && PlatformTypes.IEnumerable.IsAssignableFrom((ITypeId)propertyType) && !PlatformTypes.String.IsAssignableFrom((ITypeId)propertyType))
                    {
                        property1 = property2;
                    }
                }
                if (property1 == null)
                {
                    return(documentCompositeNode);
                }
                path = property1.Name;
            }
            BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding);

            if (!string.IsNullOrEmpty(path))
            {
                bindingSceneNode.SetPath(path);
            }
            documentCompositeNode.Properties[DataBindingDragDropDefaultHandler.HierarchicalItemsSourceProperty] = bindingSceneNode.DocumentNode;
            return(documentCompositeNode);
        }
            public IMemberId GetMember(MemberType memberTypes, string memberName, MemberAccessTypes access)
            {
                IMember       member = (IMember)this.designType.GetMember(memberTypes, memberName, access);
                ReferenceStep actualReferenceStep = member as ReferenceStep;

                if (actualReferenceStep != null)
                {
                    return((IMemberId)this.GetOrCreateDesignProperty(actualReferenceStep));
                }
                return((IMemberId)member);
            }
Esempio n. 9
0
        public static IMemberId GetRoutedCommandMember(ITypeResolver typeResolver, Type type, string commandName)
        {
            IType type1 = typeResolver.GetType(type);

            if (type1 == null)
            {
                return((IMemberId)null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type1);

            return(type1.GetMember(MemberType.LocalProperty | MemberType.Field, commandName, allowableMemberAccess) ?? type1.GetMember(MemberType.LocalProperty | MemberType.Field, commandName + "Command", allowableMemberAccess));
        }
Esempio n. 10
0
        public static ReferenceStep GetProperty(ITypeResolver typeResolver, ITypeId typeId, MemberType memberTypes, string memberName)
        {
            IType typeId1 = typeResolver.ResolveType(typeId);

            if (typeResolver.PlatformMetadata.IsNullType((ITypeId)typeId1))
            {
                return((ReferenceStep)null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, typeId1);

            return((ReferenceStep)typeId1.GetMember(memberTypes & MemberType.Property, memberName, allowableMemberAccess));
        }
Esempio n. 11
0
        public static IEvent GetEvent(ITypeResolver typeResolver, Type targetType, string memberName)
        {
            IType type = typeResolver.GetType(targetType);

            if (type == null)
            {
                return((IEvent)null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type);

            return((IEvent)type.GetMember(MemberType.Event, memberName, allowableMemberAccess));
        }
Esempio n. 12
0
        public static bool IsPropertyWritable(ITypeResolver typeResolver, IProperty propertyKey, bool allowProtectedProperties)
        {
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, propertyKey.DeclaringType);

            if (allowProtectedProperties && !propertyKey.IsAttachable || typeResolver.IsCapabilitySet(PlatformCapability.WorkaroundSL12782) && typeResolver.PlatformMetadata.KnownTypes.UserControl.IsAssignableFrom(propertyKey.DeclaringTypeId) && propertyKey.Equals((object)propertyKey.DeclaringType.Metadata.DefaultContentProperty))
            {
                allowableMemberAccess |= MemberAccessTypes.Protected;
            }
            MemberAccessType writeAccess = propertyKey.WriteAccess;

            return(TypeHelper.IsSet(allowableMemberAccess, writeAccess));
        }
Esempio n. 13
0
        private RawDataSourceInfoBase GetDataSourceFromProperty(DataBindingProcessingContext context, string propertyName)
        {
            IType                 type = context.DocumentNode.Type;
            MemberAccessTypes     allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)this.ProjectContext, type);
            IProperty             property           = type.GetMember(MemberType.Property, propertyName, allowableMemberAccess) as IProperty;
            RawDataSourceInfoBase dataSourceInfoBase = (RawDataSourceInfoBase)null;

            if (property != null)
            {
                dataSourceInfoBase = this.GetDataSourceFromProperty(context, property);
            }
            return(dataSourceInfoBase);
        }
Esempio n. 14
0
            private ReferenceStep GetProperty(string propertyName)
            {
                if (string.IsNullOrEmpty(propertyName))
                {
                    return((ReferenceStep)null);
                }
                if (propertyName == "\\")
                {
                    return((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep(this.ancestorNode.TypeResolver, this.ancestorNode.TargetType, 0, false));
                }
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(this.ancestorNode.TypeResolver, this.ancestorNode.Type);

                return(this.ancestorNode.Type.GetMember(MemberType.Property, propertyName, allowableMemberAccess) as ReferenceStep);
            }
Esempio n. 15
0
        public static IEvent GetEvent(ITypeResolver typeResolver, RoutedEvent routedEvent)
        {
            IType type = typeResolver.GetType(routedEvent.OwnerType);

            if (type != null)
            {
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type);
                Event             @event = (Event)type.GetMember(MemberType.Event, routedEvent.Name, allowableMemberAccess);
                if (@event != null && @event.RoutedEvent == routedEvent)
                {
                    return((IEvent)@event);
                }
            }
            return((IEvent)null);
        }
Esempio n. 16
0
        protected override ModelItem CreateStaticMemberItem(Type type, string memberName)
        {
            IType type1 = this.viewModel.ProjectContext.GetType(type);

            if (type1 != null)
            {
                MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)this.viewModel.ProjectContext, type1);
                IMember           memberId = type1.GetMember(MemberType.LocalProperty | MemberType.Field, memberName, allowableMemberAccess) as IMember;
                if (memberId != null)
                {
                    return((ModelItem)this.viewModel.GetSceneNode((DocumentNode)DocumentNodeHelper.NewStaticNode(this.viewModel.Document.DocumentContext, memberId)).ModelItem);
                }
            }
            return((ModelItem)null);
        }
Esempio n. 17
0
        public static IEnumerable <IProperty> GetProperties(this IType type, MemberAccessTypes access, bool flattenHierarchy)
        {
            if (!flattenHierarchy)
            {
                return(type.GetProperties(access));
            }
            List <IProperty> properties = new List <IProperty>();

            while (type != null)
            {
                properties.AddRange(type.GetProperties(access));
                type = type.BaseType;
            }
            return(properties);
        }
Esempio n. 18
0
        private static ReferenceStep GetDefaultBindingPropertyInternal(IType type, IProjectContext projectContext)
        {
            if (type.RuntimeType == (Type)null)
            {
                return((ReferenceStep)null);
            }
            string result;

            if (!PlatformNeutralAttributeHelper.TryGetAttributeValue <string>(type.RuntimeType, PlatformTypes.DefaultBindingPropertyAttribute, "Name", out result) || string.IsNullOrEmpty(result))
            {
                return((ReferenceStep)null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess((ITypeResolver)projectContext, type);

            return(type.GetMember(MemberType.Property, result, allowableMemberAccess) as ReferenceStep);
        }
Esempio n. 19
0
        private static ReferenceStep GetContentProperty(ITypeResolver typeResolver, Type type, string propertyName)
        {
            IType type1 = typeResolver.GetType(type);

            if (type1 == null)
            {
                return(null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type1);

            if (PlatformTypes.UserControl.IsAssignableFrom(type1))
            {
                allowableMemberAccess = allowableMemberAccess | MemberAccessTypes.Protected;
            }
            return((ReferenceStep)type1.GetMember(MemberType.Property, propertyName, allowableMemberAccess));
        }
Esempio n. 20
0
        public bool IsHierarchicalCollection(ITypeResolver typeResolver)
        {
            if (!this.IsCollection || this.type == (Type)null)
            {
                return(false);
            }
            IType collectionType = typeResolver.GetType(this.type);
            IType typeId         = collectionType != null ? collectionType.ItemType : (IType)null;

            if (typeId == null)
            {
                return(false);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, typeId);

            return(Enumerable.FirstOrDefault <IProperty>(typeId.GetProperties(allowableMemberAccess), (Func <IProperty, bool>)(prop => prop.PropertyType == collectionType)) != null);
        }
Esempio n. 21
0
        public static IProperty GetProperty(ITypeResolver typeResolver, Type targetType, PropertyDescriptor propertyDescriptor)
        {
            if (typeResolver.IsCapabilitySet(PlatformCapability.UseDependencyPropertyDescriptor))
            {
                DependencyPropertyDescriptor propertyDescriptor1 = DependencyPropertyDescriptor.FromProperty(propertyDescriptor);
                if (propertyDescriptor1 != null)
                {
                    return((IProperty)DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, targetType, propertyDescriptor1.DependencyProperty));
                }
            }
            IType type = typeResolver.GetType(targetType);

            if (typeResolver.PlatformMetadata.IsNullType((ITypeId)type))
            {
                return((IProperty)null);
            }
            MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type);

            return(type.GetMember(MemberType.Property, propertyDescriptor.Name, allowableMemberAccess) as IProperty);
        }
Esempio n. 22
0
 public IEnumerable <IProperty> GetProperties(MemberAccessTypes access)
 {
     yield break;
 }
Esempio n. 23
0
 public IMemberId GetMember(Microsoft.Expression.DesignModel.Metadata.MemberType memberTypes, string memberName, MemberAccessTypes access)
 {
     return(this.BaseType.GetMember(memberTypes, memberName, access));
 }
Esempio n. 24
0
 public IEnumerable <IEvent> GetEvents(MemberAccessTypes access)
 {
     yield break;
 }
Esempio n. 25
0
 public override IMemberId GetMember(MemberType memberTypes, string memberName, MemberAccessTypes access)
 {
     if ((memberTypes & MemberType.LocalProperty) != MemberType.LocalProperty)
     {
         return((IMemberId)null);
     }
     if ((access & MemberAccessTypes.Public) != MemberAccessTypes.Public)
     {
         return((IMemberId)null);
     }
     return((IMemberId)this.GetSampleProperty(memberName));
 }
Esempio n. 26
0
 public IEnumerable <IEvent> GetEvents(MemberAccessTypes access)
 {
     return((IEnumerable <IEvent>)ReadOnlyCollections <IEvent> .Empty);
 }
Esempio n. 27
0
 public abstract IEnumerable <IProperty> GetProperties(MemberAccessTypes access);
Esempio n. 28
0
 public abstract IMemberId GetMember(MemberType memberTypes, string memberName, MemberAccessTypes access);
Esempio n. 29
0
 public IEnumerable <IProperty> GetProperties(MemberAccessTypes access)
 {
     return(this.members.GetProperties(access));
 }
Esempio n. 30
0
 public IEnumerable <IEvent> GetEvents(MemberAccessTypes access)
 {
     return(this.members.GetEvents(access));
 }