private RawDataSourceInfoBase InitDataContext(DataBindingProcessingContext context) { if (PlatformTypes.ResourceDictionary.IsAssignableFrom((ITypeId)context.DocumentNode.Type)) { return((RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty); } if (DataContextHelper.IsDataContextProperty((DocumentNode)context.ParentNode, (IPropertyId)context.Property)) { return(context.GrandparentDataContext); } DataBindingProcessor.DataContextWalker dataContextWalker = new DataBindingProcessor.DataContextWalker(context.ParentContext, context.Property, this.namedElementDataContexts); RawDataSourceInfoBase localDataContext = this.DataContextEvaluator.NavigateSpecialDataContext((IDataContextAncestorWalker)dataContextWalker, (RawDataSourceInfoBase)null); if (localDataContext == null) { RawDataSourceInfoBase rawDataContextInfo = this.DataContextEvaluator.GetRawDataContextInfo(context.DocumentCompositeNode); localDataContext = this.DataContextEvaluator.UnwindElementNameBinding((IDataContextAncestorWalker)dataContextWalker, rawDataContextInfo); } this.DataContextEvaluator.MoveUpIfDataContextLocation((IDataContextAncestorWalker)dataContextWalker); if (localDataContext is ElementDataSourceInfo) { return(localDataContext); } if (dataContextWalker.CurrentContext != null) { localDataContext = this.CombineDataSources(dataContextWalker.CurrentContext.DataContext, localDataContext); } if (localDataContext == null) { localDataContext = (RawDataSourceInfoBase)RawDataSourceInfo.NewEmpty; } return(localDataContext); }
public static BindingModeInfo GetDefaultBindingMode(DocumentNode targetNode, IPropertyId targetProperty, DataSchemaNodePath schemaPath) { BindingMode mode = (BindingMode)targetNode.TypeResolver.GetCapabilityValue(PlatformCapability.DefaultBindingMode); BindingDirection bindingDirection = (BindingDirection)targetNode.TypeResolver.GetCapabilityValue(PlatformCapability.DefaultBindingDirection); DependencyPropertyReferenceStep propertyReferenceStep = targetNode.TypeResolver.ResolveProperty(targetProperty) as DependencyPropertyReferenceStep; bool flag = false; if (schemaPath != null) { if (schemaPath.Node.IsReadOnly) { flag = true; } else if (schemaPath.Node == schemaPath.Schema.Root) { flag = !DataContextHelper.IsDataContextProperty(targetNode, (IPropertyId)propertyReferenceStep); } } if (flag) { if (mode == BindingMode.Default && bindingDirection == BindingDirection.TwoWay && (propertyReferenceStep != null && propertyReferenceStep.BindsTwoWayByDefault(targetNode.Type.RuntimeType))) { return(new BindingModeInfo(BindingMode.OneWay, false)); } if (schemaPath.IsCollection) { return(new BindingModeInfo(mode, true)); } return(new BindingModeInfo(BindingMode.OneWay, false)); } if (bindingDirection == BindingDirection.TwoWay) { return(new BindingModeInfo(mode, true)); } IProperty property = targetNode.TypeResolver.ResolveProperty(targetProperty); if (property != null) { BindableAttribute bindableAttribute = property.Attributes[typeof(BindableAttribute)] as BindableAttribute; if (bindableAttribute != null && bindableAttribute.Direction == BindingDirection.TwoWay) { return(new BindingModeInfo(BindingMode.TwoWay, false)); } } return(new BindingModeInfo(mode, true)); }
public DataContextInfo Evaluate(SceneNode target, IPropertyId targetProperty, bool isForSettingValue) { SceneNode targetNode = target; IProperty targetProperty1 = (IProperty)null; if (targetProperty != null) { targetProperty1 = target.ProjectContext.ResolveProperty(targetProperty); if (DataContextHelper.IsDataContextProperty(target.DocumentNode, (IPropertyId)targetProperty1)) { targetNode = target.Parent; targetProperty1 = (IProperty)null; if (targetNode == null) { return(new DataContextInfo()); } } } return(this.Evaluate((IDataContextAncestorWalker) new DataContextAncestorWalker(targetNode, targetProperty1), isForSettingValue)); }
public bool IsDataContextLocation(IDataContextAncestorWalker walker) { return(DataContextHelper.IsDataContextProperty((DocumentNode)walker.CurrentNode, (IPropertyId)walker.CurrentProperty)); }