Ejemplo n.º 1
0
 internal static DocumentNode ValidateNodeTypeAndGetParent(DocumentNode childNode, ITypeId type)
 {
     if (childNode != null && type.IsAssignableFrom((ITypeId)childNode.Type))
     {
         return((DocumentNode)childNode.Parent);
     }
     return((DocumentNode)null);
 }
Ejemplo n.º 2
0
 public IEnumerable <DocumentNode> SelectDescendantNodes(ITypeId targetTypeId)
 {
     foreach (DocumentNode documentNode in this.DescendantNodes)
     {
         if (targetTypeId.IsAssignableFrom((ITypeId)documentNode.Type))
         {
             yield return(documentNode);
         }
     }
 }
Ejemplo n.º 3
0
 private static bool ValidateBehaviorTargets(bool isRoot, SceneElement target, SceneElement path, ITypeId constraintType)
 {
     if (isRoot || !target.CanNameElement)
     {
         return(false);
     }
     if (constraintType != null)
     {
         return(constraintType.IsAssignableFrom((ITypeId)target.Type));
     }
     return(true);
 }
Ejemplo n.º 4
0
        private static DataRemovalProcessor.ProcessingContext GetAncestorContext(DataRemovalProcessor.ProcessingContext context, int maxLevel, ITypeId ancestorType)
        {
            int num = maxLevel;

            for (DataRemovalProcessor.ProcessingContext parentContext = context.ParentContext; parentContext != null && num > 0; --num)
            {
                if (ancestorType.IsAssignableFrom((ITypeId)parentContext.NodeInfo.Node.Type))
                {
                    return(parentContext);
                }
                parentContext = parentContext.ParentContext;
            }
            return((DataRemovalProcessor.ProcessingContext)null);
        }
Ejemplo n.º 5
0
        public static bool ApplyProperties(SceneNode propertyTarget, Dictionary <IPropertyId, SceneNode> properties)
        {
            bool flag1 = true;

            foreach (KeyValuePair <IPropertyId, SceneNode> keyValuePair in properties)
            {
                IProperty     propertyKey   = (IProperty)keyValuePair.Key;
                SceneNode     valueNode     = keyValuePair.Value;
                ReferenceStep referenceStep = propertyKey as ReferenceStep;
                if (referenceStep != null)
                {
                    ReferenceStep appliedReferenceStep;
                    if (SceneElementHelper.DoesPropertyApply(propertyTarget, referenceStep, valueNode, out appliedReferenceStep))
                    {
                        if (propertyTarget.IsSet((IPropertyId)appliedReferenceStep) == PropertyState.Unset)
                        {
                            propertyTarget.SetValueAsSceneNode((IPropertyId)appliedReferenceStep, valueNode);
                        }
                        else
                        {
                            flag1 = false;
                        }
                    }
                }
                else
                {
                    bool flag2 = false;
                    bool flag3 = true;
                    DocumentCompositeNode documentCompositeNode = propertyTarget.DocumentNode as DocumentCompositeNode;
                    if (documentCompositeNode != null)
                    {
                        flag2 = documentCompositeNode.Properties.Contains(propertyKey);
                        ITypeId typeId = (ITypeId)documentCompositeNode.TypeResolver.GetType(propertyKey.TargetType);
                        flag3 = typeId != null && typeId.IsAssignableFrom((ITypeId)documentCompositeNode.Type);
                    }
                    if (!flag2 && flag3)
                    {
                        propertyTarget.SetValueAsSceneNode((IPropertyId)propertyKey, valueNode);
                    }
                    else
                    {
                        flag1 = false;
                    }
                }
            }
            return(flag1);
        }
        protected TypeHandler DetermineBestHandler(TypeHandler handler, IMetadataResolver typeResolver, IType type)
        {
            this.InitializeIfNecessary();
            ITypeId typeId           = typeResolver.ResolveType(PlatformTypes.Object);
            ITypeId implementingType = typeId;

            foreach (TypeHandler typeHandler in this.handlers)
            {
                IType type1 = typeResolver.ResolveType(this.GetBaseType(typeHandler));
                if (type1 == null || !type1.IsAssignableFrom(type) || !typeId.IsAssignableFrom(type1) && (!type1.IsInterface || type1.IsAssignableFrom(implementingType)))
                {
                    continue;
                }
                handler          = typeHandler;
                typeId           = type1;
                implementingType = this.GetImplementingType(type1, type);
            }
            return(handler);
        }
Ejemplo n.º 7
0
        private void AddProperties(SceneElement targetElement, ResourceEntryItem resource, System.Windows.Controls.ItemCollection menuItems)
        {
            Type filterType = (Type)null;
            bool flag       = true;

            if (PlatformTypes.Brush.IsAssignableFrom((ITypeId)resource.Resource.Type))
            {
                filterType = typeof(Brush);
            }
            else if (PlatformTypes.DrawingImage.IsAssignableFrom((ITypeId)resource.Resource.Type))
            {
                filterType = typeof(ImageSource);
            }
            else if (PlatformTypes.PlatformsCompatible(resource.Resource.ValueNode.Type.PlatformMetadata, targetElement.Type.PlatformMetadata))
            {
                IType   styleOrTemplateType;
                ITypeId typeAndTargetType = DocumentNodeUtilities.GetStyleOrTemplateTypeAndTargetType(resource.Resource.ValueNode, out styleOrTemplateType);
                if (typeAndTargetType != null)
                {
                    flag       = typeAndTargetType.IsAssignableFrom((ITypeId)targetElement.Type);
                    filterType = styleOrTemplateType.RuntimeType;
                }
            }
            else
            {
                flag = false;
            }
            if (!flag)
            {
                return;
            }
            int count = menuItems.Count;

            this.AddElementPropertiesWithTypeFilter(targetElement, resource, menuItems, filterType);
            if (menuItems.Count != count)
            {
                return;
            }
            this.AddElementPropertiesWithTypeFilter(targetElement, resource, menuItems, (Type)null);
        }