private bool ShouldProcess(RawDataSourceInfoBase dataSource) { if (dataSource == null || !dataSource.IsValidClr) { return(false); } ElementDataSourceInfo elementDataSourceInfo = dataSource as ElementDataSourceInfo; return(elementDataSourceInfo != null && elementDataSourceInfo.TargetProperty == null || (!dataSource.HasSource || this.ShouldProcessDataSourceType(dataSource.SourceType))); }
public override RawDataSourceInfoBase Clone() { ElementDataSourceInfo elementDataSourceInfo = new ElementDataSourceInfo(this.TargetElement, (string)null); elementDataSourceInfo.clrPath = this.clrPath; elementDataSourceInfo.TargetProperty = this.TargetProperty; elementDataSourceInfo.TargetPropertyName = this.TargetPropertyName; elementDataSourceInfo.PathSuffix = this.PathSuffix; elementDataSourceInfo.IsCollectionItem = this.IsCollectionItem; elementDataSourceInfo.XmlPath = this.XmlPath; if (this.TargetDataSource != null) { elementDataSourceInfo.TargetDataSource = this.TargetDataSource.Clone(); } return((RawDataSourceInfoBase)elementDataSourceInfo); }
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); }
public override RawDataSourceInfoBase CombineWith(RawDataSourceInfoBase localSource) { if (localSource == null) { return((RawDataSourceInfoBase)this); } if (!this.IsValid || !localSource.IsValid || (localSource.SourceNode != null || localSource is ElementDataSourceInfo)) { return(localSource); } RawDataSourceInfo rawDataSourceInfo = (RawDataSourceInfo)localSource; if (rawDataSourceInfo.IsEmpty) { return((RawDataSourceInfoBase)this); } ElementDataSourceInfo elementDataSourceInfo = (ElementDataSourceInfo)this.Clone(); elementDataSourceInfo.AppendClrPath(rawDataSourceInfo.ClrPath); elementDataSourceInfo.XmlPath = localSource.XmlPath; return((RawDataSourceInfoBase)elementDataSourceInfo); }
private void ProcessBinding(DataBindingProcessingContext context) { RawDataSourceInfoBase bindingAsDataSource = this.GetBindingAsDataSource(context); if (bindingAsDataSource == null || !bindingAsDataSource.IsValid) { return; } if (!bindingAsDataSource.HasSource && context.Scope != ProcessingContextScope.ResourceDictionary) { ElementDataSourceInfo bindingInfo = bindingAsDataSource as ElementDataSourceInfo; if (bindingInfo != null) { this.pendingBindings.Add(new DataBindingProcessor.PendingBindingInfo(context, bindingInfo)); } } if (!this.ShouldProcessDataSourceType(bindingAsDataSource.SourceType)) { return; } this.HandleBinding(context, bindingAsDataSource); }
public PendingBindingInfo(DataBindingProcessingContext bindingContext, ElementDataSourceInfo bindingInfo) { this.BindingContext = bindingContext; this.BindingInfo = bindingInfo; }
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); }