// <summary> // Handler for the using element // </summary> private void HandleUsingElement(XmlReader reader) { var referencedNamespace = new UsingElement(this); referencedNamespace.Parse(reader); AliasResolver.Add(referencedNamespace); }
private void HandleUsingElement(XmlReader reader) { UsingElement usingElement = new UsingElement(this); usingElement.Parse(reader); this.AliasResolver.Add(usingElement); }
/// <summary> /// Check if the given name is a reserved keyword. if yes, add appropriate error to the refschema /// </summary> private bool CheckForSystemNamespace(UsingElement refSchema, string name, NameKind nameKind) { Debug.Assert( _definingSchema.ProviderManifest != null, "Since we don't allow using elements in provider manifest, provider manifest can never be null"); // We need to check for system namespace if (EdmItemCollection.IsSystemNamespace(_definingSchema.ProviderManifest, name)) { if (nameKind == NameKind.Alias) { refSchema.AddError( ErrorCode.CannotUseSystemNamespaceAsAlias, EdmSchemaErrorSeverity.Error, Strings.CannotUseSystemNamespaceAsAlias(name)); } else { refSchema.AddError( ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error, Strings.NeedNotUseSystemNamespaceInUsing(name)); } return(true); } return(false); }
public void Add(UsingElement usingElement) { string name = usingElement.NamespaceName; string str = usingElement.Alias; if (this.CheckForSystemNamespace(usingElement, str, AliasResolver.NameKind.Alias)) { str = (string)null; } if (this.CheckForSystemNamespace(usingElement, name, AliasResolver.NameKind.Namespace)) { name = (string)null; } if (str != null && this._aliasToNamespaceMap.ContainsKey(str)) { usingElement.AddError(ErrorCode.AlreadyDefined, EdmSchemaErrorSeverity.Error, (object)Strings.AliasNameIsAlreadyDefined((object)str)); str = (string)null; } if (str == null) { return; } this._aliasToNamespaceMap.Add(str, name); this._usingElementCollection.Add(usingElement); }
private bool CheckForSystemNamespace( UsingElement refSchema, string name, AliasResolver.NameKind nameKind) { if (!EdmItemCollection.IsSystemNamespace(this._definingSchema.ProviderManifest, name)) { return(false); } if (nameKind == AliasResolver.NameKind.Alias) { refSchema.AddError(ErrorCode.CannotUseSystemNamespaceAsAlias, EdmSchemaErrorSeverity.Error, (object)Strings.CannotUseSystemNamespaceAsAlias((object)name)); } else { refSchema.AddError(ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error, (object)Strings.NeedNotUseSystemNamespaceInUsing((object)name)); } return(true); }
/// <summary> /// Add a ReferenceSchema to the table /// </summary> /// <param name="refSchema"> the ReferenceSchema to add </param> public void Add(UsingElement usingElement) { DebugCheck.NotNull(usingElement); var newNamespace = usingElement.NamespaceName; var newAlias = usingElement.Alias; // Check whether the alias is a reserved keyword if (CheckForSystemNamespace(usingElement, newAlias, NameKind.Alias)) { newAlias = null; } //Check whether the namespace is a reserved keyword if (CheckForSystemNamespace(usingElement, newNamespace, NameKind.Namespace)) { newNamespace = null; } // see if the alias has already been used if (newAlias != null && _aliasToNamespaceMap.ContainsKey(newAlias)) { // it has, issue an error and make sure we don't try to add it usingElement.AddError(ErrorCode.AlreadyDefined, EdmSchemaErrorSeverity.Error, Strings.AliasNameIsAlreadyDefined(newAlias)); newAlias = null; } // If there's an alias, add it. // Its okay if they add the same namespace twice, until they have different alias if (newAlias != null) { _aliasToNamespaceMap.Add(newAlias, newNamespace); _usingElementCollection.Add(usingElement); } }
/// <summary> /// Add a UsingElement to the table /// </summary> /// <param name="usingElement"> the UsingElement to add </param> public void Add(UsingElement usingElement) { DebugCheck.NotNull(usingElement); var newNamespace = usingElement.NamespaceName; var newAlias = usingElement.Alias; // Check whether the alias is a reserved keyword if (CheckForSystemNamespace(usingElement, newAlias, NameKind.Alias)) { newAlias = null; } //Check whether the namespace is a reserved keyword if (CheckForSystemNamespace(usingElement, newNamespace, NameKind.Namespace)) { newNamespace = null; } // see if the alias has already been used if (newAlias != null && _aliasToNamespaceMap.ContainsKey(newAlias)) { // it has, issue an error and make sure we don't try to add it usingElement.AddError(ErrorCode.AlreadyDefined, EdmSchemaErrorSeverity.Error, Strings.AliasNameIsAlreadyDefined(newAlias)); newAlias = null; } // If there's an alias, add it. // Its okay if they add the same namespace twice, until they have different alias if (newAlias != null) { _aliasToNamespaceMap.Add(newAlias, newNamespace); _usingElementCollection.Add(usingElement); } }
/// <summary> /// Check if the given name is a reserved keyword. if yes, add appropriate error to the refschema /// </summary> /// <param name="refSchema"> </param> /// <param name="name"> </param> /// <param name="nameKind"> </param> /// <returns> </returns> private bool CheckForSystemNamespace(UsingElement refSchema, string name, NameKind nameKind) { Debug.Assert( _definingSchema.ProviderManifest != null, "Since we don't allow using elements in provider manifest, provider manifest can never be null"); // We need to check for system namespace if (EdmItemCollection.IsSystemNamespace(_definingSchema.ProviderManifest, name)) { if (nameKind == NameKind.Alias) { refSchema.AddError( ErrorCode.CannotUseSystemNamespaceAsAlias, EdmSchemaErrorSeverity.Error, Strings.CannotUseSystemNamespaceAsAlias(name)); } else { refSchema.AddError( ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error, Strings.NeedNotUseSystemNamespaceInUsing(name)); } return true; } return false; }