private bool ShouldPreservePropertyName(DataBindingProcessingContext context) { if (context.DocumentCompositeNode.Properties[BindingSceneNode.ElementNameProperty] != null || context.DocumentCompositeNode.Properties[BindingSceneNode.RelativeSourceProperty] != null) { return(true); } ElementDataSourceInfo elementDataSourceInfo = context.DataContext as ElementDataSourceInfo; return(elementDataSourceInfo != null && elementDataSourceInfo.TargetProperty == null); }
protected override void HandleDataContextPathExtension(DataBindingProcessingContext context, RawDataSourceInfoBase bindingInfo) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(context.DocumentNode); PathChangeInfo pathChange = this.GetPathChange(bindingInfo, valueAsString, false); if (pathChange == null) { return; } this.pathChanges.Add((PathChange) new SampleDataDocumentChangeProcessor.PrimitivePathChange(pathChange, context.ParentNode, context.Property)); }
protected override bool ShouldProcessDocumentNode(DataBindingProcessingContext context) { if (this.ownerProcessor.IsKilled) { return(false); } if (this.SampleData.IsTypeOwner(DataContextHelper.GetDataType(context.DocumentNode)) && this.SampleData.RootType != context.DocumentNode.Type) { this.nodesToInvalidate.Add(context.DocumentCompositeNode); } return(!(context.DocumentNode.Type is SampleNonBasicType)); }
private void HandleBindingOnChangePropertyAction(DataBindingProcessingContext context, RawDataSourceInfoBase bindingInfo) { string valueAsString = context.DocumentCompositeNode.GetValueAsString(SampleDataDocumentChangeProcessor.ChangePropertyActionNameProperty); if (string.IsNullOrEmpty(valueAsString)) { return; } PathChangeInfo pathChange = this.GetPathChange(bindingInfo.SourceType, valueAsString, valueAsString, false); if (pathChange == null) { return; } this.pathChanges.Add((PathChange) new SampleDataDocumentChangeProcessor.ChangePropertyActionPathChange(pathChange, context.DocumentCompositeNode)); }
protected override void HandleBinding(DataBindingProcessingContext context, RawDataSourceInfoBase bindingInfo) { if (!bindingInfo.HasSource || !bindingInfo.IsValidClr) { return; } if (ProjectNeutralTypes.ChangePropertyAction.IsAssignableFrom((ITypeId)context.DocumentNode.Type)) { this.HandleBindingOnChangePropertyAction(context, bindingInfo); } else { string bindingPath = DataContextHelper.GetBindingPath(context.DocumentCompositeNode); bool preservePropertyName = this.ShouldPreservePropertyName(context); PathChangeInfo change = this.GetPathChange(bindingInfo, bindingPath, preservePropertyName); if (change == null) { return; } if (change.BreakingChange && context.Scope == ProcessingContextScope.DataTemplate && this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { RawDataSourceInfoBase bindingInfo1 = this.ConvertDataTemplateContextToCollectionItem(context, bindingInfo); if (bindingInfo1 != null) { PathChangeInfo pathChange = this.GetPathChange(bindingInfo1, bindingPath, preservePropertyName); if (pathChange == null) { return; } if (!pathChange.BreakingChange) { change = pathChange; } } } if (change == null) { return; } this.pathChanges.Add((PathChange) new SampleDataDocumentChangeProcessor.BindingPathChange(change, context.DocumentCompositeNode)); } }
private RawDataSourceInfoBase ConvertDataTemplateContextToCollectionItem(DataBindingProcessingContext context, RawDataSourceInfoBase dataSource) { RawDataSourceInfo normalizedDataSource = context.RootContext.DataContext.NormalizedDataSource; if (dataSource.SourceNode != normalizedDataSource.SourceNode) { return((RawDataSourceInfoBase)null); } string inheritedPath = normalizedDataSource.NormalizedClrPath ?? string.Empty; string str = dataSource.NormalizedClrPath ?? string.Empty; if (!str.StartsWith(inheritedPath, StringComparison.Ordinal)) { return((RawDataSourceInfoBase)null); } string localPath = string.Empty; if (str.Length > inheritedPath.Length) { switch (str[inheritedPath.Length]) { case '[': localPath = str.Substring(inheritedPath.Length); break; case '.': case '/': localPath = str.Substring(inheritedPath.Length + 1); break; default: return((RawDataSourceInfoBase)null); } } string clrPath = ClrPropertyPathHelper.CombinePaths(ClrPropertyPathHelper.CombinePaths(inheritedPath, DataSchemaNode.IndexNodePath), localPath); return((RawDataSourceInfoBase) new RawDataSourceInfo(dataSource.SourceNode, clrPath)); }