public void Execute() { if (!this.IsEnabled) { return; } ResourceEntryItem resourceEntryItem = (ResourceEntryItem)this.resourceManager.SelectedItems.Selection[0]; SceneNode sceneNode = resourceEntryItem.Container.ViewModel.GetSceneNode(resourceEntryItem.Resource.ValueNode); ConvertibleDrawing convertibleDrawing = ConvertibleDrawing.CreateConvertibleDrawing((object)(Brush)this.designerContext.ActiveSceneViewModel.CreateInstance(sceneNode.DocumentNodePath), sceneNode.ProjectContext.ProjectPath); if (convertibleDrawing == null) { return; } DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)sceneNode.DocumentNode; string valueAsString = DocumentPrimitiveNode.GetValueAsString(resourceEntryItem.Resource.KeyNode); string documentUrl = documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl; SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel; using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(this.CommandName)) { BaseFrameworkElement child = (BaseFrameworkElement)activeSceneViewModel.CreateSceneNode((object)convertibleDrawing.Convert()); activeSceneViewModel.ActiveSceneInsertionPoint.Insert((SceneNode)child); child.SetLocalValue(DesignTimeProperties.BrushDocumentReferenceProperty, (object)documentUrl); child.SetLocalValue(DesignTimeProperties.BrushKeyProperty, (object)valueAsString); child.Name = valueAsString + "_1"; this.point *= ElementUtilities.GetInverseMatrix(activeSceneViewModel.DefaultView.GetComputedTransformToRoot(activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement)); Rect rect = new Rect(this.point, new Size(child.Width, child.Height)); activeSceneViewModel.GetLayoutDesignerForChild((SceneElement)child, true).SetChildRect(child, rect, LayoutOverrides.None, LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None); this.designerContext.SelectionManager.ElementSelectionSet.SetSelection((SceneElement)child); editTransaction.Commit(); } }
private void ValidateRootXPath() { DocumentNode node = ((DocumentCompositeNode)this.DataSource.DocumentNode).Properties[XmlDataProviderSceneNode.XPathProperty]; if (node == null) { return; } string valueAsString = DocumentPrimitiveNode.GetValueAsString(node); if (string.IsNullOrEmpty(valueAsString)) { return; } DataSchemaNode dataSchemaNode = (DataSchemaNode)null; if ((int)valueAsString[0] == 47) { dataSchemaNode = this.GetNodeFromPath(valueAsString); } if (dataSchemaNode != null) { return; } this.invalidRootXPath = true; }
private void UpdateElementNameBindingsInternal(DocumentCompositeNode documentNode, IProperty elementNameProperty, string oldName, string newName) { DocumentNode node = documentNode.Properties[(IPropertyId)elementNameProperty]; if (node != null) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(node); if (oldName == valueAsString) { documentNode.Properties[(IPropertyId)elementNameProperty] = (DocumentNode)documentNode.Context.CreateNode(newName); } } foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentNode.Properties) { DocumentCompositeNode documentNode1 = keyValuePair.Value as DocumentCompositeNode; if (documentNode1 != null && documentNode1.NameScope == null) { this.UpdateElementNameBindingsInternal(documentNode1, elementNameProperty, oldName, newName); } } if (!documentNode.SupportsChildren) { return; } for (int index = 0; index < documentNode.Children.Count; ++index) { DocumentCompositeNode documentNode1 = documentNode.Children[index] as DocumentCompositeNode; if (documentNode1 != null && documentNode1.NameScope == null) { this.UpdateElementNameBindingsInternal(documentNode1, elementNameProperty, oldName, newName); } } }
private static RawDataSourceInfoBase GetDataSourceInfoFromResourceReference(DocumentCompositeNode resourceReferenceNode) { if (resourceReferenceNode.DocumentRoot == null) { return((RawDataSourceInfoBase)RawDataSourceInfo.Invalid); } DocumentNode resourceKey = ResourceNodeHelper.GetResourceKey(resourceReferenceNode); ResourceReferenceType resourceType = ResourceNodeHelper.GetResourceType((DocumentNode)resourceReferenceNode); DocumentNodePath nodePath = new DocumentNodePath(resourceReferenceNode.DocumentRoot.RootNode, (DocumentNode)resourceReferenceNode); DocumentNode sourceNode = new ExpressionEvaluator((IDocumentRootResolver)resourceReferenceNode.Context).EvaluateResource(nodePath, resourceType, resourceKey); RawDataSourceInfoBase dataSourceInfoBase = (RawDataSourceInfoBase) new RawDataSourceInfo(sourceNode, (string)null); if (sourceNode != null && PlatformTypes.XmlDataProvider.IsAssignableFrom((ITypeId)sourceNode.Type)) { DocumentNode node = ((DocumentCompositeNode)sourceNode).Properties[XmlDataProviderSceneNode.XPathProperty]; if (node != null) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(node); if (!string.IsNullOrEmpty(valueAsString)) { dataSourceInfoBase.XmlPath = valueAsString; } } } return(dataSourceInfoBase); }
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 string GetReferentialPropertyValue(DocumentCompositeNode compositeNode) { string str = (string)null; DocumentNode valueAsDocumentNode = this.GetReferentialPropertyValueAsDocumentNode(compositeNode); if (valueAsDocumentNode != null) { str = DocumentPrimitiveNode.GetValueAsString(valueAsDocumentNode); } return(str); }
public static string GetBindingPath(DocumentCompositeNode bindingNode) { string str = (string)null; DocumentCompositeNode documentCompositeNode = bindingNode.Properties[BindingSceneNode.PathProperty] as DocumentCompositeNode; if (documentCompositeNode != null) { str = DocumentPrimitiveNode.GetValueAsString(documentCompositeNode.Properties[documentCompositeNode.TypeResolver.PlatformMetadata.KnownProperties.PropertyPathPath]); } return(str); }
protected void InitializeCurrentValueConverter() { if (this.TargetProperty == null) { return; } BindingSceneNode binding = this.TargetElement.GetBinding((IPropertyId)this.TargetProperty); if (binding == null) { return; } string str = binding.ConverterParameter as string; if (str != null) { this.ValueConverterParameter = str; } DocumentCompositeNode node = binding.Converter as DocumentCompositeNode; if (node == null) { return; } ValueConverterModel valueConverterModel = (ValueConverterModel)null; if (node.Type.IsResource) { string key = DocumentPrimitiveNode.GetValueAsString(ResourceNodeHelper.GetResourceKey(node)); if (string.IsNullOrEmpty(key)) { return; } valueConverterModel = Enumerable.FirstOrDefault <ValueConverterModel>((IEnumerable <ValueConverterModel>) this.ValueConverters, (Func <ValueConverterModel, bool>)(vc => vc.DisplayName == key)); } else { SceneNode sceneNode = this.ViewModel.GetSceneNode((DocumentNode)node); if (sceneNode != null) { valueConverterModel = ValueConverterModelFactory.CreateValueConverterModel(sceneNode); if (valueConverterModel != null) { this.ValueConverters.Add(valueConverterModel); } } } if (valueConverterModel == null) { return; } this.CurrentValueConverter = valueConverterModel; }
private void SetExistingBindingValues(BindingSceneNode existingBinding) { string path = existingBinding.PathOrXPath; DocumentNode node1 = (DocumentNode)null; DocumentCompositeNode node2 = existingBinding.SupportsSource ? existingBinding.Source as DocumentCompositeNode : (DocumentCompositeNode)null; if (node2 != null && node2.Type.IsResource) { node1 = ResourceNodeHelper.GetResourceKey(node2); } if (node1 != null) { this.InitializeDataSource(DocumentPrimitiveNode.GetValueAsString(node1), path); } else if (existingBinding.SupportsElementName && existingBinding.ElementName != null && this.elementPropertyModel != null) { this.InitializeElementName(existingBinding.ElementName, path); } else { this.InitializeExplicitDataContext(path); } if (this.bindingSourcesProxy.Value.Path != path) { if (this.CurrentBindingSource.Schema is EmptySchema && existingBinding.SupportsXPath && !string.IsNullOrEmpty(existingBinding.XPath)) { path = "XPath=" + path; } this.CustomBindingExpression = path; this.UseCustomBindingExpression = true; } DocumentNode node3 = existingBinding.SupportsFallbackValue ? existingBinding.FallbackValue : (DocumentNode)null; if (node3 != null) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(node3); if (valueAsString != null) { this.BindingFallbackValue = valueAsString; } } if (existingBinding.IsModeSet) { this.CurrentBindingMode = existingBinding.Mode; } if (!existingBinding.SupportsUpdateSourceTrigger) { return; } this.CurrentUpdateSourceTrigger = existingBinding.UpdateSourceTrigger; }
internal static string TargetNameFromDocumentNode(DocumentCompositeNode node) { DocumentCompositeNode node1 = node.Properties[BeginActionNode.StoryboardProperty] as DocumentCompositeNode; if (node1 != null && node1.Type.IsResource) { DocumentNode resourceKey = ResourceNodeHelper.GetResourceKey(node1); if (resourceKey != null) { return(DocumentPrimitiveNode.GetValueAsString(resourceKey)); } } return((string)null); }
private string GetID(DocumentCompositeNode compositeNode) { string str; if (this.IsRootNode((DocumentNode)compositeNode)) { str = "~Self"; } else { IPropertyId index = (IPropertyId)compositeNode.Type.Metadata.NameProperty; str = DocumentPrimitiveNode.GetValueAsString(compositeNode.Properties[index]); } return(str); }
public static string GetBindingXPath(DocumentCompositeNode bindingNode) { string str = (string)null; IProperty property = bindingNode.TypeResolver.ResolveProperty(BindingSceneNode.XPathProperty); if (property != null) { DocumentPrimitiveNode documentPrimitiveNode = bindingNode.Properties[(IPropertyId)property] as DocumentPrimitiveNode; if (documentPrimitiveNode != null) { str = DocumentPrimitiveNode.GetValueAsString((DocumentNode)documentPrimitiveNode); } } return(str); }
private ResourceItem FindResourceItem(RegroupToResourceCommand.ConvertibleBrushReference brushReference) { ResourceContainer resourceContainer = this.designerContext.ResourceManager.FindResourceContainer(brushReference.DocumentUrl); if (resourceContainer != null) { foreach (ResourceItem resourceItem in (Collection <ResourceItem>)resourceContainer.ResourceItems) { ResourceEntryItem resourceEntryItem = resourceItem as ResourceEntryItem; if (resourceEntryItem != null && DocumentPrimitiveNode.GetValueAsString(resourceEntryItem.Resource.KeyNode) == brushReference.Key) { return((ResourceItem)resourceEntryItem); } } } return((ResourceItem)null); }
private static bool DoesAnimationTargetPath(DocumentNode pathNameNode, DocumentNode animationNode) { DocumentCompositeNode documentCompositeNode = animationNode as DocumentCompositeNode; if (documentCompositeNode == null) { return(false); } DocumentNode item = documentCompositeNode.Properties[KnownProperties.StoryboardTargetNameProperty]; string valueAsString = DocumentPrimitiveNode.GetValueAsString(pathNameNode); string str = DocumentPrimitiveNode.GetValueAsString(item); if (string.IsNullOrEmpty(valueAsString)) { return(false); } return(valueAsString == str); }
private string GetPropertyPathExtension(DocumentCompositeNode documentNode, IProperty targetProperty, DataContextPropertyPathExtension pathExtension) { if (!pathExtension.IsValid) { return((string)null); } DocumentNode node = documentNode.Properties[(IPropertyId)targetProperty]; if (node == null || !PlatformTypes.String.IsAssignableFrom((ITypeId)node.Type)) { return(string.Empty); } string localPath = DocumentPrimitiveNode.GetValueAsString(node); if (pathExtension.IsCollectionItem) { localPath = ClrObjectSchema.CombinePaths(DataSchemaNode.IndexNodePath, localPath); } return(localPath); }
public static string GetDataSourceName(DocumentNode dataSourceNode) { string str = (string)null; if (dataSourceNode != null) { DocumentCompositeNode parent = dataSourceNode.Parent; if (parent != null && PlatformTypes.DictionaryEntry.IsAssignableFrom((ITypeId)parent.Type)) { DocumentNode resourceEntryKey = DocumentNodeHelper.GetResourceEntryKey(parent); if (resourceEntryKey != null) { str = DocumentPrimitiveNode.GetValueAsString(resourceEntryKey); } } if (string.IsNullOrEmpty(str)) { str = dataSourceNode.Type.Name + (object)" " + (string)(object)dataSourceNode.GetHashCode(); } } return(str ?? string.Empty); }
private static ElementDataSourceInfo GetElementNameBinding(DocumentCompositeNode bindingNode) { DocumentNode node = bindingNode.Properties[BindingSceneNode.ElementNameProperty]; if (node == null) { return((ElementDataSourceInfo)null); } string valueAsString = DocumentPrimitiveNode.GetValueAsString(node); if (string.IsNullOrEmpty(valueAsString)) { return(ElementDataSourceInfo.Invalid); } DocumentCompositeNode namedElement = node.FindContainingNameScope().FindNode(valueAsString) as DocumentCompositeNode; if (namedElement == null) { return(ElementDataSourceInfo.Invalid); } string bindingPath = DataContextHelper.GetBindingPath(bindingNode); return(new ElementDataSourceInfo(namedElement, bindingPath)); }
public InvalidReferenceModel(DocumentCompositeNode invalidObjectNode, IPropertyId invalidProperty) : this(invalidObjectNode, invalidProperty, DocumentPrimitiveNode.GetValueAsString(invalidObjectNode.Properties[invalidProperty])) { }
private SerializedFormat ShouldSerializeProperty(XamlSerializerContext serializerContext, DocumentCompositeNode parentNode, IPropertyId propertyKey, DocumentNode valueNode, out bool useElementForOuterMostMarkupExtension) { bool flag; SerializedFormat serializedFormat; useElementForOuterMostMarkupExtension = false; DocumentCompositeNode documentCompositeNode = valueNode as DocumentCompositeNode; DocumentPrimitiveNode documentPrimitiveNode = valueNode as DocumentPrimitiveNode; IProperty valueProperty = valueNode.GetValueProperty(); if (valueProperty != null) { if (valueProperty.MemberType != MemberType.DesignTimeProperty && !this.ShouldSerialize(serializerContext, valueNode)) { return(SerializedFormat.DoNotSerialize); } if (valueProperty.MemberType == MemberType.DesignTimeProperty) { bool flag1 = true; if (!valueProperty.ShouldSerialize) { flag1 = this.ShouldSerializeDesignTimeProperty(valueProperty); } if (!flag1) { return(SerializedFormat.DoNotSerialize); } } if (!KnownProperties.SetterTargetNameProperty.Equals(valueProperty)) { if (parentNode.Type.Metadata.IsNameProperty(valueProperty)) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(valueNode); if (valueAsString != null) { if (valueAsString.StartsWith("~", StringComparison.Ordinal) && serializerContext.InStyleOrTemplate) { return(SerializedFormat.DoNotSerialize); } if (valueAsString.Length == 0) { return(SerializedFormat.DoNotSerialize); } } return(SerializedFormat.ComplexString); } if (DesignTimeProperties.UidProperty.Equals(valueProperty)) { return(SerializedFormat.ComplexString); } if (KnownProperties.FrameworkContentElementResourcesProperty.Equals(valueProperty)) { if (documentCompositeNode != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(documentCompositeNode.Type) && documentCompositeNode.SupportsChildren && documentCompositeNode.Children.Count == 0) { return(SerializedFormat.DoNotSerialize); } } else if (!PlatformTypes.Style.IsAssignableFrom(valueProperty.PropertyType)) { DependencyPropertyReferenceStep dependencyPropertyReferenceStep = valueProperty as DependencyPropertyReferenceStep; if (dependencyPropertyReferenceStep != null && dependencyPropertyReferenceStep.IsAttachable && !DefaultXamlSerializerFilter.IsTypeSerializable(serializerContext.TypeResolver, valueProperty.DeclaringType) && dependencyPropertyReferenceStep.MemberType != MemberType.DesignTimeProperty) { return(SerializedFormat.DoNotSerialize); } } else if (documentCompositeNode != null) { if (documentCompositeNode.GetValue <bool>(DesignTimeProperties.IsDefaultStyleProperty)) { return(SerializedFormat.DoNotSerialize); } } else if (documentPrimitiveNode != null && documentPrimitiveNode.Value is DocumentNodeReferenceValue) { return(SerializedFormat.DoNotSerialize); } } else { string str = DocumentPrimitiveNode.GetValueAsString(valueNode); if (str != null && str == "~Self") { return(SerializedFormat.DoNotSerialize); } } } IType type = valueNode.Type; if (PlatformTypes.XData.Equals(type)) { return(SerializedFormat.Element); } if (PlatformTypes.StaticResource.IsAssignableFrom(type) && documentCompositeNode != null && ResourceNodeHelper.GetResourceKey(documentCompositeNode) != null) { DocumentCompositeNode parent = documentCompositeNode.Parent; while (parent != null && parent.Type.IsExpression) { parent = parent.Parent; } if (parent != null) { IPropertyId resourcesProperty = parent.Type.Metadata.ResourcesProperty; if (resourcesProperty != null) { DocumentCompositeNode item = parent.Properties[resourcesProperty] as DocumentCompositeNode; if (item != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(item.Type)) { useElementForOuterMostMarkupExtension = true; return(SerializedFormat.ComplexString); } } } } if (type.IsExpression) { if (documentCompositeNode != null) { using (IEnumerator <KeyValuePair <IProperty, DocumentNode> > enumerator = documentCompositeNode.Properties.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <IProperty, DocumentNode> current = enumerator.Current; switch (this.ShouldSerializeProperty(serializerContext, documentCompositeNode, current.Key, current.Value, out flag)) { case SerializedFormat.SimpleString: { continue; } case SerializedFormat.ComplexString: { if (current.Value.Type.IsExpression) { if (!flag) { continue; } useElementForOuterMostMarkupExtension = true; continue; } else { serializedFormat = SerializedFormat.Element; return(serializedFormat); } } } serializedFormat = SerializedFormat.Element; return(serializedFormat); } return(SerializedFormat.ComplexString); } return(serializedFormat); } return(SerializedFormat.ComplexString); } if (this.PropertyValueRequiresElement(valueProperty, valueNode.Type)) { return(SerializedFormat.Element); } if (PlatformTypes.Uri.IsAssignableFrom(type)) { return(SerializedFormat.ComplexString); } if (PlatformTypes.PropertyPath.IsAssignableFrom(type)) { if (documentCompositeNode != null) { if (DocumentPrimitiveNode.GetValueAsString(documentCompositeNode.Properties[KnownProperties.PropertyPathPathProperty]) != null) { return(SerializedFormat.SimpleString); } return(SerializedFormat.Element); } } else if (PlatformTypes.SolidColorBrush.IsAssignableFrom(type)) { if (documentCompositeNode != null) { if (documentCompositeNode.Properties.Count == 0) { return(SerializedFormat.SimpleString); } if (documentCompositeNode.Properties.Count == 1) { DocumentPrimitiveNode item1 = documentCompositeNode.Properties[KnownProperties.SolidColorBrushColorProperty] as DocumentPrimitiveNode; if (item1 != null && PlatformTypes.Color.Equals(item1.Type)) { return(SerializedFormat.SimpleString); } } return(SerializedFormat.Element); } } else if (!PlatformTypes.Color.IsAssignableFrom(type)) { if (PlatformTypes.PathGeometry.IsAssignableFrom(type)) { if (valueProperty == null || PlatformTypes.PathGeometry.IsAssignableFrom(valueProperty.PropertyType)) { return(SerializedFormat.Element); } if (documentCompositeNode != null && !PathGeometrySerializationHelper.CanSerializeAsAttribute(documentCompositeNode)) { return(SerializedFormat.Element); } return(SerializedFormat.ComplexString); } if (PlatformTypes.PathFigureCollection.IsAssignableFrom(type)) { if (documentCompositeNode != null && !PathGeometrySerializationHelper.CanSerializeAsAttribute(documentCompositeNode)) { return(SerializedFormat.Element); } return(SerializedFormat.ComplexString); } if (PlatformTypes.DoubleCollection.IsAssignableFrom(type)) { if (documentCompositeNode != null && PointSerializationHelper.SerializeDoubleCollectionAsAttribute(documentCompositeNode) == null) { return(SerializedFormat.Element); } return(SerializedFormat.ComplexString); } } else if (documentCompositeNode == null && valueNode.Parent != null && valueNode.IsProperty) { return(SerializedFormat.SimpleString); } if (documentPrimitiveNode != null && documentPrimitiveNode.Value == null) { return(SerializedFormat.SimpleString); } if (XamlSerializerContext.IsXmlElement(valueNode)) { return(SerializedFormat.Element); } if (documentPrimitiveNode != null) { if (documentPrimitiveNode.Value is DocumentNodeStringValue) { return(SerializedFormat.SimpleString); } if (documentPrimitiveNode.Value is DocumentNodeMemberValue) { return(SerializedFormat.SimpleString); } } if (documentCompositeNode == null) { return(SerializedFormat.ComplexString); } return(SerializedFormat.Element); }
public static DocumentNode FindTargetElement(DocumentNode node, bool resolveTargetName) { DocumentCompositeNode documentCompositeNode1 = node as DocumentCompositeNode; if (documentCompositeNode1 != null) { DocumentNode documentNode1 = documentCompositeNode1.Properties[BehaviorTargetedTriggerActionNode.BehaviorTargetNameProperty]; string elementName = !resolveTargetName || documentNode1 == null || !DocumentNodeUtilities.IsResource(documentNode1) ? documentCompositeNode1.GetValueAsString(BehaviorTargetedTriggerActionNode.BehaviorTargetNameProperty) : DocumentPrimitiveNode.GetValueAsString(ExpressionEvaluator.EvaluateExpression(documentNode1)); IProperty property1 = node.PlatformMetadata.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty); if (property1 != null) { DocumentNode documentNode2 = documentCompositeNode1.Properties[(IPropertyId)property1]; if (documentNode2 != null) { if (DocumentNodeUtilities.IsMarkupExtension(documentNode2)) { if (!DocumentNodeUtilities.IsBinding(documentNode2) || !GoToStateActionNode.CanResolveTargetFromBinding(documentNode2)) { return(ExpressionEvaluator.EvaluateExpression(documentNode2)); } documentNode2 = GoToStateActionNode.ResolveTargetFromBinding(node, (DocumentCompositeNode)documentNode2); } return(documentNode2); } } if (!string.IsNullOrEmpty(elementName)) { return(BehaviorHelper.FindNamedElement(node, elementName)); } DocumentNode documentNode3; for (documentNode3 = (DocumentNode)documentCompositeNode1; documentNode3 != null; documentNode3 = (DocumentNode)documentNode3.Parent) { DocumentCompositeNode documentCompositeNode2 = documentNode3 as DocumentCompositeNode; IProperty property2 = node.TypeResolver.ResolveProperty(VisualStateManagerSceneNode.VisualStateGroupsProperty); if (property2 == null) { return((DocumentNode)null); } if (documentCompositeNode2 != null && documentCompositeNode2.Properties[(IPropertyId)property2] != null) { break; } } if (documentNode3 != null) { DocumentCompositeNode parent = documentNode3.Parent; if (parent != null && PlatformTypes.ICollection.IsAssignableFrom((ITypeId)parent.Type) && parent.Parent != null) { return((DocumentNode)parent.Parent); } return((DocumentNode)documentNode3.Parent); } } return((DocumentNode)null); }
private string GetTargetName(DocumentCompositeNode setterNode) { return(DocumentPrimitiveNode.GetValueAsString(setterNode.Properties[SetterSceneNode.TargetNameProperty]) ?? "~Self"); }
public override void ModifyValue(IInstanceBuilderContext context, ViewNode target, object onlyThisInstance, IProperty propertyKey, object value, PropertyModification modification) { IProperty shadowProperty; if (!context.IsSerializationScope) { IInstantiatedElementViewNode instantiatedElementViewNode = target as IInstantiatedElementViewNode; if (instantiatedElementViewNode != null && onlyThisInstance == null && instantiatedElementViewNode.InstantiatedElements.First != null) { if (context.UseShadowProperties) { shadowProperty = DesignTimeProperties.GetShadowProperty(propertyKey, target.DocumentNode.Type); } else { shadowProperty = null; } IProperty property = shadowProperty; if (property != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(target.TypeResolver, property)) { propertyKey = property; } ReferenceStep referenceStep = propertyKey as ReferenceStep; if (referenceStep != null) { foreach (object instantiatedElement in instantiatedElementViewNode.InstantiatedElements) { if (modification != PropertyModification.Set) { referenceStep.ClearValue(instantiatedElement); } else { InstanceBuilderOperations.SetValue(instantiatedElement, referenceStep, value); } } return; } } } if (propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey)) { string valueAsString = null; if (context.IsSerializationScope) { DocumentPrimitiveNode documentPrimitiveNode = value as DocumentPrimitiveNode; if (documentPrimitiveNode != null) { valueAsString = DocumentPrimitiveNode.GetValueAsString(documentPrimitiveNode); } } else { valueAsString = value as string; if (string.IsNullOrEmpty(valueAsString) && (ProjectNeutralTypes.VisualStateGroup.IsAssignableFrom(target.Type) || ProjectNeutralTypes.VisualState.IsAssignableFrom(target.Type))) { valueAsString = ((DocumentCompositeNode)target.DocumentNode).GetValueAsString(target.DocumentNode.NameProperty); } } if (valueAsString != null && string.IsNullOrEmpty(valueAsString)) { CultureInfo currentCulture = CultureInfo.CurrentCulture; string instanceBuilderNamePropertyNotValid = ExceptionStringTable.InstanceBuilderNamePropertyNotValid; object[] objArray = new object[] { valueAsString }; throw new InstanceBuilderException(string.Format(currentCulture, instanceBuilderNamePropertyNotValid, objArray), target.DocumentNode); } } base.ModifyValue(context, target, onlyThisInstance, propertyKey, value, modification); }