コード例 #1
0
        /// <summary>
        /// Gets the namespace prefix that is associated with the
        /// specified file extension.
        /// </summary>
        public static string GetNamespacePrefix(string extension)
        {
            string prefix = String.Empty;

            XmlSchemaAssociation association = GetSchemaAssociation(extension);

            if (association != null)
            {
                prefix = association.NamespacePrefix;
            }

            return(prefix);
        }
コード例 #2
0
        /// <summary>
        /// Gets the schema completion data that is associated with the
        /// specified file extension.
        /// </summary>
        internal XmlSchemaCompletionData GetSchemaCompletionData(string extension)
        {
            XmlSchemaCompletionData data = null;

            XmlSchemaAssociation association = GetSchemaAssociation(extension);

            if (association != null)
            {
                if (association.NamespaceUri.Length > 0)
                {
                    data = SchemaCompletionDataItems[association.NamespaceUri];
                }
            }
            return(data);
        }
コード例 #3
0
        /// <summary>
        /// Gets the default schema association for the file extension.
        /// </summary>
        /// <remarks>
        /// These defaults are hard coded.
        /// </remarks>
        public static XmlSchemaAssociation GetDefaultAssociation(string extension)
        {
            XmlSchemaAssociation association = null;

            switch (extension.ToLowerInvariant())
            {
            case ".wxs":
                association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/wix/2003/01/wi");
                break;

            case ".config":
                association = new XmlSchemaAssociation(extension, @"urn:app-config");
                break;

            case ".build":
                association = new XmlSchemaAssociation(extension, @"http://nant.sf.net/release/0.85/nant.xsd");
                break;

            case ".addin":
                association = new XmlSchemaAssociation(extension, @"http://www.icsharpcode.net/2005/addin");
                break;

            case ".xsl":
            case ".xslt":
                association = new XmlSchemaAssociation(extension, @"http://www.w3.org/1999/XSL/Transform", "xsl");
                break;

            case ".xsd":
                association = new XmlSchemaAssociation(extension, @"http://www.w3.org/2001/XMLSchema", "xs");
                break;

            case ".manifest":
                association = new XmlSchemaAssociation(extension, @"urn:schemas-microsoft-com:asm.v1");
                break;

            case ".xaml":
                association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/winfx/avalon/2005");
                break;

            default:
                association = new XmlSchemaAssociation(extension);
                break;
            }
            return(association);
        }
コード例 #4
0
        /// <summary>
        /// Two schema associations are considered equal if their file extension,
        /// prefix and namespaceUri are the same.
        /// </summary>
        public override bool Equals(object obj)
        {
            bool equals = false;

            XmlSchemaAssociation rhs = obj as XmlSchemaAssociation;

            if (rhs != null)
            {
                if ((this.namespacePrefix == rhs.namespacePrefix) &&
                    (this.extension == rhs.extension) &&
                    (this.namespaceUri == rhs.namespaceUri))
                {
                    equals = true;
                }
            }

            return(equals);
        }
コード例 #5
0
 /// <summary>
 /// Gets an association between a schema and a file extension.
 /// </summary>
 /// <remarks>
 /// <para>The property will be an xml element when the SharpDevelopProperties.xml
 /// is read on startup.  The property will be a schema association
 /// if the user changes the schema associated with the file
 /// extension in tools->options.</para>
 /// <para>The normal way of doing things is to
 /// pass the GetProperty method a default value which auto-magically
 /// turns the xml element into a schema association so we would not
 /// have to check for both.  In this case, however, I do not want
 /// a default saved to the SharpDevelopProperties.xml file unless the user
 /// makes a change using Tools->Options.</para>
 /// <para>If we have a file extension that is currently missing a default
 /// schema then if we  ship the schema at a later date the association will
 /// be updated by the code if the user has not changed the settings themselves.
 /// </para>
 /// <para>For example, the initial release of the xml editor add-in had
 /// no default schema for .xsl files, by default it was associated with
 /// no schema and this setting is saved if the user ever viewed the settings
 /// in the tools->options dialog.  Now, after the initial release the
 /// .xsl schema was created and shipped with SharpDevelop, there is
 /// no way to associate this schema to .xsl files by default since
 /// the property exists in the SharpDevelopProperties.xml file.</para>
 /// <para>An alternative way of doing this might be to have the
 /// config info in the schema itself, which a special SharpDevelop
 /// namespace.  I believe this is what Visual Studio does.  This
 /// way is not as flexible since it requires the user to locate
 /// the schema and change the association manually.</para>
 /// </remarks>
 private static XmlSchemaAssociation GetSchemaAssociation(string extension)
 {
     extension = extension.ToLower();
     return(XmlSchemaAssociation.GetDefaultAssociation(extension));
 }
コード例 #6
0
ファイル: XmlSchemaAssociation.cs プロジェクト: kanbang/Colt
        /// <summary>
        /// Gets the default schema association for the file extension. 
        /// </summary>
        /// <remarks>
        /// These defaults are hard coded.
        /// </remarks>
        public static XmlSchemaAssociation GetDefaultAssociation(string extension)
        {
            XmlSchemaAssociation association = null;

            switch (extension.ToLowerInvariant())
            {
                case ".wxs":
                    association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/wix/2003/01/wi");
                    break;
                case ".config":
                    association = new XmlSchemaAssociation(extension, @"urn:app-config");
                    break;
                case ".build":
                    association = new XmlSchemaAssociation(extension, @"http://nant.sf.net/release/0.85/nant.xsd");
                    break;
                case ".addin":
                    association = new XmlSchemaAssociation(extension, @"http://www.icsharpcode.net/2005/addin");
                    break;
                case ".xsl":
                case ".xslt":
                    association = new XmlSchemaAssociation(extension, @"http://www.w3.org/1999/XSL/Transform", "xsl");
                    break;
                case ".xsd":
                    association = new XmlSchemaAssociation(extension, @"http://www.w3.org/2001/XMLSchema", "xs");
                    break;
                case ".manifest":
                    association = new XmlSchemaAssociation(extension, @"urn:schemas-microsoft-com:asm.v1");
                    break;
                case ".xaml":
                    association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/winfx/avalon/2005");
                    break;
                default:
                    association = new XmlSchemaAssociation(extension);
                    break;
            }
            return association;
        }