コード例 #1
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));
        }
コード例 #2
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);
        }
コード例 #3
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);
        }