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 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)); }
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); }