예제 #1
0
        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);
        }
        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);
        }
예제 #3
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));
        }
예제 #4
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));
        }
예제 #5
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));
        }
예제 #6
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);
        }