示例#1
0
        private void ProcessDataTemplate(DataBindingProcessingContext context, DocumentCompositeNode resolvedTemplateNode)
        {
            IType targetType = this.GetTargetType(resolvedTemplateNode, DataTemplateElement.DataTypeProperty);

            if (targetType == null)
            {
                this.ProcessResource(context, resolvedTemplateNode);
            }
            else
            {
                if (resolvedTemplateNode != context.DocumentCompositeNode)
                {
                    return;
                }
                RawDataSourceInfoBase dataContextFromType = this.GetDataContextFromType(targetType, resolvedTemplateNode.Properties[DataTemplateElement.DataTypeProperty]);
                if (dataContextFromType == null)
                {
                    return;
                }
                this.ProcessDocumentNodeChildren(new DataBindingProcessingContext((DocumentNode)resolvedTemplateNode, (DataBindingProcessingContext)null)
                {
                    DataContext = dataContextFromType
                });
            }
        }
        private RawDataSourceInfoBase UnwindElementNameBindingInternal(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource)
        {
            RawDataSourceInfoBase localDataSource1 = localDataSource;
            bool flag = false;

            while (true)
            {
                RawDataSourceInfoBase dataSourceInfoBase = this.MoveToElementNameBinding(walker, localDataSource1 as ElementDataSourceInfo);
                if (dataSourceInfoBase != null)
                {
                    localDataSource1 = dataSourceInfoBase;
                    if (localDataSource1.IsValid)
                    {
                        flag = true;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    goto label_5;
                }
            }
            return(localDataSource1);

label_5:
            if (flag)
            {
                return(this.NavigateSpecialDataContextInternal(walker, localDataSource1, false));
            }
            return(localDataSource1);
        }
示例#3
0
        public static RawDataSourceInfoBase GetDataSourceInfoFromBinding(DocumentCompositeNode bindingNode)
        {
            RawDataSourceInfoBase dataSourceInfoBase    = (RawDataSourceInfoBase)null;
            DocumentCompositeNode resourceReferenceNode = bindingNode.Properties[BindingSceneNode.SourceProperty] as DocumentCompositeNode;

            if (resourceReferenceNode == null)
            {
                dataSourceInfoBase = (RawDataSourceInfoBase)DataContextHelper.GetElementNameBinding(bindingNode);
            }
            if (dataSourceInfoBase == null)
            {
                string bindingPath = DataContextHelper.GetBindingPath(bindingNode);
                if (resourceReferenceNode != null && resourceReferenceNode.Type.IsResource)
                {
                    dataSourceInfoBase = DataContextHelper.GetDataSourceInfoFromResourceReference(resourceReferenceNode);
                    if (!dataSourceInfoBase.IsValid)
                    {
                        return(dataSourceInfoBase);
                    }
                    dataSourceInfoBase.AppendClrPath(bindingPath);
                }
                else
                {
                    dataSourceInfoBase = (RawDataSourceInfoBase) new RawDataSourceInfo((DocumentNode)resourceReferenceNode, bindingPath);
                }
            }
            string bindingXpath = DataContextHelper.GetBindingXPath(bindingNode);

            dataSourceInfoBase.XmlPath = XmlSchema.CombineXPaths(dataSourceInfoBase.XmlPath, bindingXpath);
            if (bindingNode.Properties[BindingSceneNode.RelativeSourceProperty] != null)
            {
                dataSourceInfoBase.SetInvalid();
            }
            return(dataSourceInfoBase);
        }
        public RawDataSourceInfoBase GetRawDataContextInfo(DocumentCompositeNode documentNode)
        {
            if (documentNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            IProperty    ptoperty       = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, documentNode.PlatformMetadata);
            DocumentNode dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty];

            if (dataSourceNode == null)
            {
                ptoperty = DataContextHelper.GetDataContextProperty(documentNode.Type);
                if (ptoperty != null)
                {
                    dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty];
                }
            }
            if (dataSourceNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataSourceNode);

            if (rawDataSourceInfo != null && rawDataSourceInfo.IsValid)
            {
                this.OnDataSourceFound(documentNode, ptoperty);
            }
            return(rawDataSourceInfo);
        }
示例#5
0
        private static RawDataSourceInfoBase GetDataSourceInfoFromResourceReference(DocumentCompositeNode resourceReferenceNode)
        {
            if (resourceReferenceNode.DocumentRoot == null)
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            DocumentNode          resourceKey        = ResourceNodeHelper.GetResourceKey(resourceReferenceNode);
            ResourceReferenceType resourceType       = ResourceNodeHelper.GetResourceType((DocumentNode)resourceReferenceNode);
            DocumentNodePath      nodePath           = new DocumentNodePath(resourceReferenceNode.DocumentRoot.RootNode, (DocumentNode)resourceReferenceNode);
            DocumentNode          sourceNode         = new ExpressionEvaluator((IDocumentRootResolver)resourceReferenceNode.Context).EvaluateResource(nodePath, resourceType, resourceKey);
            RawDataSourceInfoBase dataSourceInfoBase = (RawDataSourceInfoBase) new RawDataSourceInfo(sourceNode, (string)null);

            if (sourceNode != null && PlatformTypes.XmlDataProvider.IsAssignableFrom((ITypeId)sourceNode.Type))
            {
                DocumentNode node = ((DocumentCompositeNode)sourceNode).Properties[XmlDataProviderSceneNode.XPathProperty];
                if (node != null)
                {
                    string valueAsString = DocumentPrimitiveNode.GetValueAsString(node);
                    if (!string.IsNullOrEmpty(valueAsString))
                    {
                        dataSourceInfoBase.XmlPath = valueAsString;
                    }
                }
            }
            return(dataSourceInfoBase);
        }
示例#6
0
        private RawDataSourceInfoBase InitDataContext(DataBindingProcessingContext context)
        {
            if (PlatformTypes.ResourceDictionary.IsAssignableFrom((ITypeId)context.DocumentNode.Type))
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty);
            }
            if (DataContextHelper.IsDataContextProperty((DocumentNode)context.ParentNode, (IPropertyId)context.Property))
            {
                return(context.GrandparentDataContext);
            }
            DataBindingProcessor.DataContextWalker dataContextWalker = new DataBindingProcessor.DataContextWalker(context.ParentContext, context.Property, this.namedElementDataContexts);
            RawDataSourceInfoBase localDataContext = this.DataContextEvaluator.NavigateSpecialDataContext((IDataContextAncestorWalker)dataContextWalker, (RawDataSourceInfoBase)null);

            if (localDataContext == null)
            {
                RawDataSourceInfoBase rawDataContextInfo = this.DataContextEvaluator.GetRawDataContextInfo(context.DocumentCompositeNode);
                localDataContext = this.DataContextEvaluator.UnwindElementNameBinding((IDataContextAncestorWalker)dataContextWalker, rawDataContextInfo);
            }
            this.DataContextEvaluator.MoveUpIfDataContextLocation((IDataContextAncestorWalker)dataContextWalker);
            if (localDataContext is ElementDataSourceInfo)
            {
                return(localDataContext);
            }
            if (dataContextWalker.CurrentContext != null)
            {
                localDataContext = this.CombineDataSources(dataContextWalker.CurrentContext.DataContext, localDataContext);
            }
            if (localDataContext == null)
            {
                localDataContext = (RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty;
            }
            return(localDataContext);
        }
        private void ProcessPotentialDataContextOwner(DocumentNode documentNode, bool needDesignTimeProperty)
        {
            IProperty dataContextProperty = DataContextHelper.GetDataContextProperty(documentNode.Type, needDesignTimeProperty);

            if (dataContextProperty == null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode1 = documentNode as DocumentCompositeNode;

            if (documentCompositeNode1 == null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode2 = documentCompositeNode1.Properties[(IPropertyId)dataContextProperty] as DocumentCompositeNode;

            if (documentCompositeNode2 == null)
            {
                return;
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo((DocumentNode)documentCompositeNode2);

            if (!rawDataSourceInfo.HasSource || !rawDataSourceInfo.IsValidClr || !this.SampleData.IsTypeOwner(rawDataSourceInfo.SourceType))
            {
                return;
            }
            this.documentNodesToModify.Add(documentCompositeNode1);
        }
示例#8
0
        private RawDataSourceInfoBase GetRelativeSourceTargetBindingDataSource(DataBindingProcessingContext context)
        {
            if (context.OuterContext == null || !context.IsStyleOrControlTemplateScope)
            {
                return((RawDataSourceInfoBase)null);
            }
            string bindingRelativeSource = this.GetBindingRelativeSource(context);

            if (string.IsNullOrEmpty(bindingRelativeSource))
            {
                return((RawDataSourceInfoBase)null);
            }
            DataBindingProcessingContext context1 = (DataBindingProcessingContext)null;

            if (context.Scope == ProcessingContextScope.Style && bindingRelativeSource == "Self")
            {
                if (context.OuterContext != null)
                {
                    context1 = context.OuterContext.ParentContext;
                }
            }
            else if (context.Scope == ProcessingContextScope.ControlTemplate && bindingRelativeSource == "TemplatedParent")
            {
                context1 = this.GetTemplatedParentContext(context);
            }
            if (context1 == null || PlatformTypes.DictionaryEntry.IsAssignableFrom((ITypeId)context1.DocumentNode.Type))
            {
                return((RawDataSourceInfoBase)null);
            }
            string bindingPath = DataContextHelper.GetBindingPath(context.DocumentCompositeNode);

            if (string.IsNullOrEmpty(bindingPath))
            {
                return((RawDataSourceInfoBase)null);
            }
            IList <ClrPathPart> parts = ClrPropertyPathHelper.SplitPath(bindingPath);

            if (parts == null || parts.Count == 0)
            {
                return((RawDataSourceInfoBase)null);
            }
            ClrPathPart clrPathPart = parts[0];

            if (clrPathPart.Category != ClrPathPartCategory.PropertyName)
            {
                return((RawDataSourceInfoBase)null);
            }
            RawDataSourceInfoBase sourceFromProperty = this.GetDataSourceFromProperty(context1, clrPathPart.Path);

            if (sourceFromProperty == null || !sourceFromProperty.IsValid)
            {
                return((RawDataSourceInfoBase)null);
            }
            string path = ClrPropertyPathHelper.CombinePathParts(parts, 1);

            sourceFromProperty.AppendClrPath(path);
            return(sourceFromProperty);
        }
示例#9
0
        private bool ShouldProcess(RawDataSourceInfoBase dataSource)
        {
            if (dataSource == null || !dataSource.IsValidClr)
            {
                return(false);
            }
            ElementDataSourceInfo elementDataSourceInfo = dataSource as ElementDataSourceInfo;

            return(elementDataSourceInfo != null && elementDataSourceInfo.TargetProperty == null || (!dataSource.HasSource || this.ShouldProcessDataSourceType(dataSource.SourceType)));
        }
示例#10
0
        public RawDataSourceInfoBase GetRawDataContextInfo(IDataContextAncestorWalker walker)
        {
            RawDataSourceInfoBase rawDataContextInfo = this.GetRawDataContextInfo(walker.CurrentNode);

            if (rawDataContextInfo == null || !rawDataContextInfo.IsValid)
            {
                return(rawDataContextInfo);
            }
            return(this.UnwindElementNameBindingInternal(walker, rawDataContextInfo));
        }
示例#11
0
        private RawDataSourceInfoBase GetBindingAsDataSource(DataBindingProcessingContext context)
        {
            RawDataSourceInfoBase sourceInfoFromBinding = DataContextHelper.GetDataSourceInfoFromBinding(context.DocumentCompositeNode);
            RawDataSourceInfoBase dataSourceInfoBase    = this.CombineDataSources(context.DataContext, sourceInfoFromBinding);

            if (!dataSourceInfoBase.IsValid)
            {
                dataSourceInfoBase = this.GetRelativeSourceTargetBindingDataSource(context);
            }
            return(dataSourceInfoBase);
        }
示例#12
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);
        }
示例#13
0
        private RawDataSourceInfoBase NavigateSpecialDataContextInternal(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource, bool unwindElementName)
        {
            RawDataSourceInfoBase localDataSource1 = unwindElementName ? this.UnwindElementNameBindingInternal(walker, localDataSource) : localDataSource;
            RawDataSourceInfoBase dataSourceInfoBase;

            do
            {
                dataSourceInfoBase = this.MoveToDataContextProperty(walker, localDataSource1) ?? this.MoveToSpecialDataContextPathExtension(walker, localDataSource1);
                if (dataSourceInfoBase != null)
                {
                    localDataSource1 = dataSourceInfoBase;
                }
            }while (dataSourceInfoBase != null && dataSourceInfoBase.IsValid);
            return(localDataSource1);
        }
示例#14
0
        private static IType GetTypeFromDataSource(RawDataSourceInfoBase dataSource)
        {
            if (!dataSource.IsValid || dataSource.SourceNode == null)
            {
                return((IType)null);
            }
            IType type = DataContextHelper.GetDataType(dataSource.SourceNode);

            if (dataSource.HasClrPath && type != null && type.RuntimeType != (Type)null)
            {
                DataSchemaNodePath nodePathFromPath = new ClrObjectSchema(type.RuntimeType, dataSource.SourceNode).GetNodePathFromPath(dataSource.ClrPath);
                type = nodePathFromPath != null ? nodePathFromPath.Type : (IType)null;
            }
            return(type);
        }
示例#15
0
        private void ProcessPendingBindings()
        {
            List <DataBindingProcessor.PendingBindingInfo> list = new List <DataBindingProcessor.PendingBindingInfo>((IEnumerable <DataBindingProcessor.PendingBindingInfo>) this.pendingBindings);

            this.pendingBindings.Clear();
            foreach (DataBindingProcessor.PendingBindingInfo pendingBindingInfo in list)
            {
                RawDataSourceInfoBase dataSourceInfoBase = this.CombineDataSources((RawDataSourceInfoBase)null, (RawDataSourceInfoBase)pendingBindingInfo.BindingInfo);
                if (this.ShouldProcess(dataSourceInfoBase))
                {
                    this.HandleBinding(pendingBindingInfo.BindingContext, dataSourceInfoBase);
                }
            }
            this.pendingBindings.Clear();
        }
示例#16
0
        private RawDataSourceInfoBase GetDataSourceFromProperty(DataBindingProcessingContext context, IProperty property)
        {
            if (DataContextHelper.GetDataContextProperty(context.DocumentNode.Type) == property)
            {
                return(context.DataContext);
            }
            DocumentNode dataSourceNode = context.DocumentCompositeNode.Properties[(IPropertyId)property];

            if (dataSourceNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataSourceNode);

            return(this.CombineDataSources(context.DataContext, rawDataSourceInfo));
        }
示例#17
0
        private RawDataSourceInfoBase MoveToSpecialDataContextPathExtension(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource)
        {
            if (walker.CurrentNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            DataContextPropertyPathExtension propertyPathExtension1 = DataContextMetadata.GetDataContextPropertyPathExtension(walker.CurrentNode, walker.CurrentProperty);

            if (propertyPathExtension1 == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            string propertyPathExtension2 = this.GetPropertyPathExtension(walker.CurrentNode, walker.CurrentProperty, propertyPathExtension1);

            if (propertyPathExtension2 == null)
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            if (this.visitedLocations.IsVisited(walker))
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            DocumentNode          dataSourceNode = walker.CurrentNode.Properties[(IPropertyId)propertyPathExtension1.Property];
            RawDataSourceInfoBase dataSourceInfoBase;

            if (dataSourceNode == null)
            {
                dataSourceInfoBase = (RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty;
            }
            else
            {
                dataSourceInfoBase = DataContextHelper.GetRawDataSourceInfo(dataSourceNode);
                if (dataSourceInfoBase.IsValid)
                {
                    dataSourceInfoBase.AppendClrPath(propertyPathExtension2);
                }
            }
            RawDataSourceInfoBase localDataSource1 = dataSourceInfoBase.CombineWith(localDataSource);

            walker.MoveTo(walker.CurrentNode, propertyPathExtension1.Property, true);
            return(this.UnwindElementNameBindingInternal(walker, localDataSource1));
        }
示例#18
0
        protected RawDataSourceInfoBase CombineDataSources(RawDataSourceInfoBase inheritedDataContext, RawDataSourceInfoBase localDataContext)
        {
            if (localDataContext == null)
            {
                return(inheritedDataContext);
            }
            if (!localDataContext.IsValid || localDataContext.HasSource)
            {
                return(localDataContext);
            }
            ElementDataSourceInfo elementDataSourceInfo = localDataContext as ElementDataSourceInfo;
            RawDataSourceInfoBase localSource;

            if (elementDataSourceInfo == null)
            {
                localSource = inheritedDataContext == null || !inheritedDataContext.IsValid ? localDataContext : inheritedDataContext.CombineWith(localDataContext);
            }
            else
            {
                DataBindingProcessingContext context;
                if (!this.namedElementDataContexts.TryGetValue(elementDataSourceInfo.RootElement, out context))
                {
                    localSource = (RawDataSourceInfoBase)elementDataSourceInfo;
                }
                else
                {
                    DataBindingProcessor.DataContextWalker dataContextWalker = new DataBindingProcessor.DataContextWalker(context, (IProperty)null, this.namedElementDataContexts);
                    localSource = this.DataContextEvaluator.UnwindElementNameBinding((IDataContextAncestorWalker)dataContextWalker, (RawDataSourceInfoBase)elementDataSourceInfo);
                    if (!(localSource is ElementDataSourceInfo))
                    {
                        this.DataContextEvaluator.MoveUpIfDataContextLocation((IDataContextAncestorWalker)dataContextWalker);
                        if (dataContextWalker.CurrentContext != null)
                        {
                            localSource = dataContextWalker.CurrentContext.DataContext.CombineWith(localSource);
                        }
                    }
                }
            }
            return(localSource);
        }
示例#19
0
        public override RawDataSourceInfoBase CombineWith(RawDataSourceInfoBase localSource)
        {
            if (localSource == null)
            {
                return((RawDataSourceInfoBase)this);
            }
            if (!this.IsValid || !localSource.IsValid || (localSource.SourceNode != null || localSource is ElementDataSourceInfo))
            {
                return(localSource);
            }
            RawDataSourceInfo rawDataSourceInfo = (RawDataSourceInfo)localSource;

            if (rawDataSourceInfo.IsEmpty)
            {
                return((RawDataSourceInfoBase)this);
            }
            ElementDataSourceInfo elementDataSourceInfo = (ElementDataSourceInfo)this.Clone();

            elementDataSourceInfo.AppendClrPath(rawDataSourceInfo.ClrPath);
            elementDataSourceInfo.XmlPath = localSource.XmlPath;
            return((RawDataSourceInfoBase)elementDataSourceInfo);
        }
示例#20
0
        private void ProcessBinding(DataBindingProcessingContext context)
        {
            RawDataSourceInfoBase bindingAsDataSource = this.GetBindingAsDataSource(context);

            if (bindingAsDataSource == null || !bindingAsDataSource.IsValid)
            {
                return;
            }
            if (!bindingAsDataSource.HasSource && context.Scope != ProcessingContextScope.ResourceDictionary)
            {
                ElementDataSourceInfo bindingInfo = bindingAsDataSource as ElementDataSourceInfo;
                if (bindingInfo != null)
                {
                    this.pendingBindings.Add(new DataBindingProcessor.PendingBindingInfo(context, bindingInfo));
                }
            }
            if (!this.ShouldProcessDataSourceType(bindingAsDataSource.SourceType))
            {
                return;
            }
            this.HandleBinding(context, bindingAsDataSource);
        }
示例#21
0
        private void ProcessChangePropertyAction(DataBindingProcessingContext context)
        {
            INodeSourceContext    containerContext = (INodeSourceContext)null;
            DocumentCompositeNode bindingNode      = context.DocumentCompositeNode.GetValue(DataBindingProcessor.ChangePropetyActionTargetObject, out containerContext) as DocumentCompositeNode;

            if (bindingNode == null || !bindingNode.Type.IsBinding)
            {
                return;
            }
            RawDataSourceInfoBase sourceInfoFromBinding = DataContextHelper.GetDataSourceInfoFromBinding(bindingNode);
            RawDataSourceInfoBase bindingInfo           = this.CombineDataSources(context.DataContext, sourceInfoFromBinding);

            if (!bindingInfo.IsValid)
            {
                bindingInfo = this.GetRelativeSourceTargetBindingDataSource(context);
            }
            if (bindingInfo == null || !bindingInfo.IsValid)
            {
                return;
            }
            this.HandleBinding(context, bindingInfo);
        }
示例#22
0
        private RawDataSourceInfoBase MoveToDataContextProperty(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource)
        {
            if (walker.CurrentNode == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            DataContextProperty dataContextProperty = DataContextMetadata.GetDataContextProperty(walker.CurrentNode, walker.CurrentProperty);

            if (dataContextProperty == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            if (!dataContextProperty.IsValid)
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            if (this.visitedLocations.IsVisited(walker))
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            DocumentNode dataContextNode = dataContextProperty.DataContextNode;

            if (dataContextNode == null)
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            this.OnDataSourceFound(walker.CurrentNode, walker.CurrentProperty);
            RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataContextNode);

            if (rawDataSourceInfo.IsValid && dataContextProperty.IsCollectionItem)
            {
                rawDataSourceInfo.AppendIndexStep();
            }
            RawDataSourceInfoBase localDataSource1 = rawDataSourceInfo.CombineWith(localDataSource);

            walker.MoveTo(dataContextProperty.SourceNode, dataContextProperty.Property, true);
            return(this.UnwindElementNameBindingInternal(walker, localDataSource1));
        }
示例#23
0
        private RawDataSourceInfoBase MoveToElementNameBinding(IDataContextAncestorWalker walker, ElementDataSourceInfo elementBinding)
        {
            if (walker.CurrentNode == null || elementBinding == null || elementBinding.RootTargetProperty == null)
            {
                return((RawDataSourceInfoBase)null);
            }
            if (this.visitedLocations.IsVisited(walker))
            {
                return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid);
            }
            this.OnDataSourceFound(walker.CurrentNode, walker.CurrentProperty);
            if (!walker.MoveTo(elementBinding.RootElement, elementBinding.RootTargetProperty, true))
            {
                return((RawDataSourceInfoBase)null);
            }
            DocumentNode          dataSourceNode     = elementBinding.RootElement.Properties[(IPropertyId)elementBinding.RootTargetProperty];
            RawDataSourceInfoBase dataSourceInfoBase = dataSourceNode != null?DataContextHelper.GetRawDataSourceInfo(dataSourceNode) : (RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty;

            if (dataSourceInfoBase.IsValid)
            {
                dataSourceInfoBase.AppendClrPath(elementBinding.NormalizedClrPath);
            }
            return(dataSourceInfoBase);
        }
示例#24
0
        public override RawDataSourceInfoBase CombineWith(RawDataSourceInfoBase localSource)
        {
            if (localSource == null)
            {
                return((RawDataSourceInfoBase)this);
            }
            if (!localSource.IsValid || localSource.SourceNode != null)
            {
                return(localSource);
            }
            if (!this.IsValid)
            {
                return((RawDataSourceInfoBase)this);
            }
            RawDataSourceInfo rawDataSourceInfo1 = localSource as RawDataSourceInfo;
            RawDataSourceInfo rawDataSourceInfo2 = new RawDataSourceInfo(this.SourceNode, ClrPropertyPathHelper.CombinePaths(this.ClrPath, rawDataSourceInfo1.ClrPath));

            rawDataSourceInfo2.XmlPath = XmlSchema.CombineXPaths(this.XmlPath, rawDataSourceInfo1.XmlPath);
            for (int index = 0; index < rawDataSourceInfo1.pendingIndexSteps; ++index)
            {
                rawDataSourceInfo2.AppendIndexStep();
            }
            return((RawDataSourceInfoBase)rawDataSourceInfo2);
        }
示例#25
0
 public abstract RawDataSourceInfoBase CombineWith(RawDataSourceInfoBase localSource);
示例#26
0
 public RawDataSourceInfoBase NavigateSpecialDataContext(IDataContextAncestorWalker walker, RawDataSourceInfoBase localDataSource)
 {
     this.visitedLocations.Reset();
     return(this.NavigateSpecialDataContextInternal(walker, localDataSource, true));
 }
示例#27
0
 protected abstract void HandleDataContextPathExtension(DataBindingProcessingContext context, RawDataSourceInfoBase bindingInfo);
示例#28
0
 protected abstract void HandleBinding(DataBindingProcessingContext context, RawDataSourceInfoBase bindingInfo);
示例#29
0
 public RawDataSourceInfoBase UnwindElementNameBinding(IDataContextAncestorWalker walker, RawDataSourceInfoBase dataSource)
 {
     this.visitedLocations.Reset();
     return(this.UnwindElementNameBindingInternal(walker, dataSource));
 }
示例#30
0
        public DataContextInfo Evaluate(IDataContextAncestorWalker walker, bool isForSettingValue)
        {
            this.visitedLocations.Reset();
            DataContextInfo       dataContextInfo1    = new DataContextInfo();
            RawDataSourceInfoBase dataSourceInfoBase1 = (RawDataSourceInfoBase)null;
            bool flag = isForSettingValue;

            this.evaluatingInfo = dataContextInfo1;
            DataContextInfo dataContextInfo2 = (DataContextInfo)null;

            try
            {
                while (walker.MoveNext())
                {
                    if (flag)
                    {
                        flag = DataContextMetadata.GetDataContextAttribute <DualDataContextAttribute>(walker.CurrentProperty) != null;
                    }
                    RawDataSourceInfoBase dataSourceInfoBase2 = !flag?this.NavigateSpecialDataContextInternal(walker, dataSourceInfoBase1, true) : dataSourceInfoBase1;

                    flag = false;
                    if (dataSourceInfoBase2 != dataSourceInfoBase1)
                    {
                        dataSourceInfoBase1 = dataSourceInfoBase2;
                        this.MoveUpIfDataContextLocation(walker);
                    }
                    if (dataSourceInfoBase1 != null)
                    {
                        if (!dataSourceInfoBase1.IsValid)
                        {
                            break;
                        }
                    }
                    RawDataSourceInfoBase rawDataContextInfo = this.GetRawDataContextInfo(walker);
                    if (rawDataContextInfo != null)
                    {
                        if (rawDataContextInfo.IsValid)
                        {
                            dataSourceInfoBase1 = rawDataContextInfo.CombineWith(dataSourceInfoBase1);
                        }
                        else if (dataSourceInfoBase1 != null)
                        {
                            dataSourceInfoBase1.SetInvalid();
                        }
                        else
                        {
                            dataSourceInfoBase1 = rawDataContextInfo;
                        }
                    }
                    if (dataSourceInfoBase1 != null)
                    {
                        if (dataSourceInfoBase1.IsValid)
                        {
                            if (dataSourceInfoBase1.HasSource)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (dataContextInfo2 == null)
                    {
                        dataContextInfo2 = this.GetTypedTemplateDataContext(walker.CurrentNode, dataSourceInfoBase1);
                    }
                }
            }
            finally
            {
                this.evaluatingInfo = (DataContextInfo)null;
            }
            if (dataContextInfo2 != null && dataContextInfo2.DataSource.IsValidWithSource && (dataSourceInfoBase1 == null || !dataSourceInfoBase1.IsValid || !dataSourceInfoBase1.HasSource))
            {
                dataContextInfo1 = dataContextInfo2;
            }
            else
            {
                dataContextInfo1.RawDataSource = dataSourceInfoBase1;
            }
            return(dataContextInfo1);
        }