public void UnregisterName(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (name.Length == 0) { throw new ArgumentException(SR.Get(SRID.NameScopeNameNotEmptyString)); } if (_underlyingNameScope != null) { _underlyingNameScope.UnregisterName(name); _names.Remove(name); } else { if (_nameMap != null && _nameMap[name] != null) { _nameMap.Remove(name); } else { throw new ArgumentException(SR.Get(SRID.NameScopeNameNotFound, name)); } } }
void INameScope.UnregisterName(string name) { INameScope scope = GetNameScope(); if (null != scope) { scope.UnregisterName(name); } }
void INameScope.UnregisterName(string name) { INameScope namescope = GetNameScope(); if (namescope == null) { throw new InvalidOperationException("this element is not in a namescope"); } namescope.UnregisterName(name); }
/// <summary> /// Unregisters the name - element combination from the /// NameScope that the current element belongs to. /// </summary> /// <param name="name">Name of the element</param> public void UnregisterName(string name) { INameScope nameScope = FrameworkElement.FindScope(this); if (nameScope != null) { nameScope.UnregisterName(name); } else { throw new InvalidOperationException(SR.Get(SRID.NameScopeNotFound, name, "unregister")); } }
public override void UpdateProperty(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode) { string instance; string str; IPropertyId shadowProperty; ReferenceStep referenceStep = propertyKey as ReferenceStep; ViewNode item = viewNode.Properties[propertyKey]; if (item != null && DocumentNodeUtilities.IsBinding(item.DocumentNode) && referenceStep != null) { ReferenceStep referenceStep1 = referenceStep; if (context.UseShadowProperties) { shadowProperty = DesignTimeProperties.GetShadowProperty(propertyKey, viewNode.DocumentNode.Type); } else { shadowProperty = null; } IPropertyId propertyId = shadowProperty; if (propertyId != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(context.DocumentContext.TypeResolver, propertyId)) { referenceStep1 = propertyId as ReferenceStep; } if (referenceStep1 != null) { IInstantiatedElementViewNode instantiatedElementViewNode = viewNode as IInstantiatedElementViewNode; if (instantiatedElementViewNode == null) { referenceStep1.ClearValue(viewNode.Instance); } else { foreach (object instantiatedElement in instantiatedElementViewNode.InstantiatedElements) { referenceStep1.ClearValue(instantiatedElement); } } } } if (propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey) && InstanceBuilderOperations.GetIsInlinedResourceWithoutNamescope(viewNode)) { InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode); return; } INameScope nameScope = context.NameScope; bool flag = (nameScope == null ? false : propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey)); if (flag) { ViewNode item1 = viewNode.Properties[propertyKey]; if (item1 != null) { str = item1.Instance as string; } else { str = null; } string str1 = str; if (!string.IsNullOrEmpty(str1) && nameScope.FindName(str1) != null) { context.NameScope.UnregisterName(str1); } } if ((!context.IsSerializationScope || !(propertyKey is Event)) && (context.IsSerializationScope || !DesignTimeProperties.IsDocumentOnlyDesignTimeProperty(propertyKey))) { base.UpdateProperty(context, viewNode, propertyKey, valueNode); } else { InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode); } if (flag) { ViewNode viewNode1 = viewNode.Properties[propertyKey]; if (viewNode1 != null) { instance = viewNode1.Instance as string; } else { instance = null; } string str2 = instance; if (!string.IsNullOrEmpty(str2)) { try { if (!str2.StartsWith("~", StringComparison.Ordinal) && !str2.Contains(".")) { if (nameScope.FindName(str2) != null) { nameScope.UnregisterName(str2); } nameScope.RegisterName(str2, viewNode.Instance); } } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; ViewNodeManager viewNodeManager = viewNode1.ViewNodeManager; CultureInfo currentCulture = CultureInfo.CurrentCulture; string instanceBuilderUnableToRegisterName = ExceptionStringTable.InstanceBuilderUnableToRegisterName; object[] objArray = new object[] { str2 }; viewNodeManager.OnException(viewNode1, new InstanceBuilderException(string.Format(currentCulture, instanceBuilderUnableToRegisterName, objArray), argumentException, viewNode1.DocumentNode, viewNode), false); } } } }
public void UnregisterName(string name) { _scope.UnregisterName(name); }