コード例 #1
0
        /// <summary>
        /// Handler for the using element
        /// </summary>
        /// <param name="reader"></param>
        private void HandleUsingElement(XmlReader reader)
        {
            UsingElement referencedNamespace = new UsingElement(this);

            referencedNamespace.Parse(reader);
            AliasResolver.Add(referencedNamespace);
        }
コード例 #2
0
        /// <summary>
        /// Add a ReferenceSchema to the table
        /// </summary>
        /// <param name="refSchema">the ReferenceSchema to add</param>
        public void Add(UsingElement usingElement)
        {
            Debug.Assert(usingElement != null, "usingElement parameter is null");

            string newNamespace = usingElement.NamespaceName;
            string 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, System.Data.Entity.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);
            }
        }
コード例 #3
0
        /// <summary>
        /// Add a ReferenceSchema to the table
        /// </summary>
        /// <param name="refSchema">the ReferenceSchema to add</param>
        public void Add(UsingElement usingElement)
        {
            Debug.Assert(usingElement != null, "usingElement parameter is null");

            string newNamespace = usingElement.NamespaceName;
            string 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, System.Data.Entity.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);
            }
        }
コード例 #4
0
        /// <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,
                                       System.Data.Entity.Strings.CannotUseSystemNamespaceAsAlias(name));
                }
                else
                {
                    refSchema.AddError(ErrorCode.NeedNotUseSystemNamespaceInUsing, EdmSchemaErrorSeverity.Error,
                                       System.Data.Entity.Strings.NeedNotUseSystemNamespaceInUsing(name));
                }
                return(true);
            }
            return(false);
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
ファイル: Schema.cs プロジェクト: ItsVeryWindy/mono
 /// <summary>
 /// Handler for the using element
 /// </summary>
 /// <param name="reader"></param>
 private void HandleUsingElement(XmlReader reader)
 {
     UsingElement referencedNamespace = new UsingElement(this);
     referencedNamespace.Parse(reader);
     AliasResolver.Add(referencedNamespace);
 }