public static DataContextPropertyPathExtension GetDataContextPropertyPathExtension(DocumentCompositeNode documentNode, IProperty property) { DataContextPropertyPathExtension extensionInternal = DataContextMetadata.GetDataContextPropertyPathExtensionInternal(documentNode, property); if (extensionInternal != null && !extensionInternal.IsValid) { DataContextMetadata.GetDataContextAttribute <DataContextPathExtensionAttribute>(property); } return(extensionInternal); }
public static DataContextProperty GetDataContextProperty(DocumentCompositeNode documentNode, IProperty property) { DataContextProperty dataContextProperty = DataContextMetadata.GetDataContextPropertyInternal(documentNode, property); if (dataContextProperty != null && dataContextProperty.IsValid && documentNode.Properties[(IPropertyId)property] != null) { DualDataContextAttribute contextAttribute = DataContextMetadata.GetDataContextAttribute <DualDataContextAttribute>(property); if (contextAttribute != null && contextAttribute.UseDefaultDataContextWhenValueSet) { dataContextProperty = (DataContextProperty)null; } } return(dataContextProperty); }
private void ProcessDataContextPathExtension(DataBindingProcessingContext context, DocumentNode childNode, IProperty property) { if (!PlatformTypes.String.IsAssignableFrom((ITypeId)childNode.Type) || DataContextMetadata.GetDataContextAttribute <DataContextPathExtensionAttribute>(property) == null) { return; } DataBindingProcessingContext context1 = new DataBindingProcessingContext(context, childNode, property); context1.DataContext = this.InitDataContext(context1); if (!this.ShouldProcess(context1.DataContext)) { return; } this.HandleDataContextPathExtension(context1, context1.DataContext); }
private static DataContextPropertyPathExtension GetDataContextPropertyPathExtensionInternal(DocumentCompositeNode documentNode, IProperty property) { DataContextPathExtensionAttribute contextAttribute = DataContextMetadata.GetDataContextAttribute <DataContextPathExtensionAttribute>(property); if (contextAttribute == null) { return((DataContextPropertyPathExtension)null); } IProperty property1 = DataContextMetadata.GetProperty((DocumentNode)documentNode, contextAttribute.Property); if (property1 == null || property1 == property) { return(DataContextPropertyPathExtension.Invalid); } return(new DataContextPropertyPathExtension(property1, contextAttribute.IsCollectionItem)); }
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)); }
private static DataContextProperty GetDataContextPropertyInternal(DocumentCompositeNode documentNode, IProperty property) { DataContextValueSourceAttribute contextAttribute = DataContextMetadata.GetDataContextAttribute <DataContextValueSourceAttribute>(property); if (contextAttribute == null) { return((DataContextProperty)null); } if (string.IsNullOrEmpty(contextAttribute.DataContextValueSourceProperty)) { return(DataContextProperty.Invalid); } PropertyReference ancestorPath = (PropertyReference)null; DocumentCompositeNode sourceNode; if (!string.IsNullOrEmpty(contextAttribute.AncestorPath)) { DataContextMetadata.AncestorPropertyPath ancestorPropertyPath = DataContextMetadata.AncestorPropertyPathParser.Parse(documentNode, contextAttribute.AncestorPath); if (ancestorPropertyPath == null) { return(DataContextProperty.Invalid); } sourceNode = ancestorPropertyPath.AncestorNode; ancestorPath = ancestorPropertyPath.PropertyPath; } else { sourceNode = documentNode; } if (sourceNode == null) { return(DataContextProperty.Invalid); } IProperty property1 = DataContextMetadata.GetProperty((DocumentNode)sourceNode, contextAttribute.DataContextValueSourceProperty); if (property1 == null || property1 == property) { return(DataContextProperty.Invalid); } return(new DataContextProperty(sourceNode, property1, contextAttribute.IsCollectionItem, ancestorPath)); }
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)); }
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); }