コード例 #1
0
 void PopulateXmlSchemaFileAssociationList()
 {
     foreach (string extension in xmlFileExtensions)
     {
         XmlSchemaFileAssociation         association = associations.GetSchemaFileAssociation(extension);
         XmlSchemaFileAssociationListItem item        = new XmlSchemaFileAssociationListItem(extension, association.NamespaceUri, association.NamespacePrefix);
         schemasPanel.AddXmlSchemaFileAssociationListItem(item);
     }
     schemasPanel.AddXmlSchemaFileAssociationListSortDescription("Extension", ListSortDirection.Ascending);
 }
コード例 #2
0
        public XmlSchemaCompletion GetSchemaCompletion(string fileName)
        {
            XmlSchemaFileAssociation association = GetSchemaFileAssociation(fileName);
            XmlSchemaCompletion      schema      = schemas[association.NamespaceUri];

            if (schema != null)
            {
                schema.DefaultNamespacePrefix = association.NamespacePrefix;
            }
            return(schema);
        }
コード例 #3
0
 void UpdateXmlSchemaFileAssociations()
 {
     for (int i = 0; i < schemasPanel.XmlSchemaFileAssociationListItemCount; ++i)
     {
         XmlSchemaFileAssociationListItem item = schemasPanel.GetXmlSchemaFileAssociationListItem(i);
         if (item.IsDirty)
         {
             XmlSchemaFileAssociation association = new XmlSchemaFileAssociation(item.Extension, item.NamespaceUri, item.NamespacePrefix);
             associations.SetSchemaFileAssociation(association);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Gets an association between a schema and a file extension.
        /// </summary>
        public XmlSchemaFileAssociation GetSchemaFileAssociation(string fileName)
        {
            string extension = Path.GetExtension(fileName).ToLowerInvariant();
            string property  = properties.Get("ext" + extension, String.Empty);
            XmlSchemaFileAssociation schemaFileAssociation = XmlSchemaFileAssociation.ConvertFromString(property);

            if (schemaFileAssociation.IsEmpty)
            {
                return(defaultSchemaFileAssociations.Find(extension));
            }
            return(schemaFileAssociation);
        }
コード例 #5
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)
        {
            XmlSchemaFileAssociation rhs = obj as XmlSchemaFileAssociation;

            if (rhs != null)
            {
                return((this.namespacePrefix == rhs.NamespacePrefix) &&
                       (this.fileExtension == rhs.fileExtension) &&
                       (this.namespaceUri == rhs.namespaceUri));
            }
            return(false);
        }
コード例 #6
0
		public void RegisteredSchemaAssociationMatchedByFullFileNameInsteadOfExtension()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".abc", "namespace-uri", "prefix");
			properties.Set("ext.abc", ".abc|namespace-uri|prefix");
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(@"d:\projects\a.abc"));
		}
コード例 #7
0
		public void RegisteredSchemaAssociationMatchedByFileExtensionIsCaseInsensitive()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".abc", "namespace-uri", "prefix");
			properties.Set("ext.abc", ".abc|namespace-uri|prefix");
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(".ABC"));
		}
コード例 #8
0
		public void DoNotMatchNamespacesDifferent()
		{
			XmlSchemaFileAssociation lhs = new XmlSchemaFileAssociation("ext", "namespaceUri", "prefix");
			XmlSchemaFileAssociation rhs = new XmlSchemaFileAssociation("ext", "different-namespaceUri", "prefix");
			Assert.IsFalse(lhs.Equals(rhs));
		}
コード例 #9
0
		public void SchemaAssociationWithPrefixConvertedToString()
		{
			XmlSchemaFileAssociation schemaAssocation = new XmlSchemaFileAssociation(".xml", "namespaceUri", "prefix");
			Assert.AreEqual(".xml|namespaceUri|prefix", schemaAssocation.ToString());
		}	
コード例 #10
0
		public void NamespacePrefixModifiesXmlSchemaFileAssociation()
		{
			panel.SetSelectedSchemaNamespacePrefix("modified-prefix");
			schemasEditor.SchemaNamespacePrefixChanged();
			schemasEditor.SaveOptions();
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".bar", "http://bar", "modified-prefix");
			
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(".bar"));
		}
コード例 #11
0
		public void SchemaAssociationWithFileExtensionIsNotEmpty()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(".fileExt", String.Empty, String.Empty);
			Assert.IsFalse(schemaAssociation.IsEmpty);
		}
 public void FileExtensionConvertedFromString()
 {
     XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation("ext", String.Empty);
     XmlSchemaFileAssociation schemaAssociation = XmlSchemaFileAssociation.ConvertFromString("ext||");
     Assert.AreEqual(expectedSchemaAssociation, schemaAssociation);
 }
 public void FileExtensionAndNamespaceUriConvertedFromString()
 {
     XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation("ext", "namespace-uri");
     XmlSchemaFileAssociation schemaAssociation = XmlSchemaFileAssociation.ConvertFromString("ext|namespace-uri|");
     Assert.AreEqual(expectedSchemaAssociation, schemaAssociation);
 }
 public void EmpyStringConverted()
 {
     XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(String.Empty, String.Empty);
     Assert.AreEqual(expectedSchemaAssociation, XmlSchemaFileAssociation.ConvertFromString(String.Empty));
 }
コード例 #15
0
 public void SetSchemaFileAssociation(XmlSchemaFileAssociation association)
 {
     properties.Set("ext" + association.FileExtension, association.ToString());
 }
		public void FileExtensionIsLowerCased()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(".XML", String.Empty);
			Assert.AreEqual(".xml", schemaAssociation.FileExtension);
		}
コード例 #17
0
		public void DefaultXmlExtensionRevertedToIfNoFileExtensionSavedInXmlEditorOptionsProperties()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".xml", "http://example.com", "e");
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(".xml"));
		}
コード例 #18
0
		public void SchemaAssociationWithNamespacePrefixIsNotEmpty()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(String.Empty, String.Empty, "prefix");
			Assert.IsFalse(schemaAssociation.IsEmpty);
		}		
コード例 #19
0
		public void SchemaAssociationWithBlankFileExtensionAndNamespaceUriAndNamespacePrefixIsEmpty()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(String.Empty, String.Empty, String.Empty);
			Assert.IsTrue(schemaAssociation.IsEmpty);
		}
コード例 #20
0
		public void SecondSchemaAssociationIsForXslFiles()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".xsl", "http://example.com/xsl", "xs");
			Assert.AreEqual(expectedSchemaAssociation, schemaAssociations[1]);
		}
コード例 #21
0
		public void SchemaAssociationWithNamespaceUriIsNotEmpty()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(String.Empty, "namespace-uri", String.Empty);
			Assert.IsFalse(schemaAssociation.IsEmpty);
		}
コード例 #22
0
		public void SetSchemaFileAssociation(XmlSchemaFileAssociation association)
		{
			properties.Set("ext" + association.FileExtension, association.ToString());
		}
コード例 #23
0
		public void FirstSchemaAssociationIsForXmlFiles()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".xml", "http://example.com", String.Empty);
			Assert.AreEqual(expectedSchemaAssociation, schemaAssociations[0]);
		}
コード例 #24
0
		public void UnknownFileExtensionReturnsEmptySchemaAssociation()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(String.Empty, String.Empty, String.Empty);
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(".unknown"));
		}
コード例 #25
0
		public void FindSchemaAssociationByFileExtensionIsCaseInsensitive()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".xsl", "http://example.com/xsl", "xs");
			Assert.AreEqual(expectedSchemaAssociation, schemaAssociations.Find(".XSL"));
		}	
コード例 #26
0
		public void RegisteredSchemaAssociationReturnedByXmlEditorOptions()
		{
			XmlSchemaFileAssociation expectedSchemaAssociation = new XmlSchemaFileAssociation(".abc", "namespace-uri", "prefix");
			properties.Set("ext.abc", ".abc|namespace-uri|prefix");
			Assert.AreEqual(expectedSchemaAssociation, associations.GetSchemaFileAssociation(".abc"));
		}
コード例 #27
0
		public void MatchIfFileExtensionAndNamespaceUriAndPrefixMatch()
		{
			XmlSchemaFileAssociation lhs = new XmlSchemaFileAssociation("ext", "namespaceUri", "prefix");
			XmlSchemaFileAssociation rhs = new XmlSchemaFileAssociation("ext", "namespaceUri", "prefix");
			Assert.IsTrue(lhs.Equals(rhs));
		}
コード例 #28
0
		public void RegisteredSchemaAssociationStoredInProperties()
		{
			XmlSchemaFileAssociation schemaAssociation = new XmlSchemaFileAssociation(".abc", "namespace-uri", "prefix");
			associations.SetSchemaFileAssociation(schemaAssociation);
			Assert.AreEqual(".abc|namespace-uri|prefix", properties.Get("ext.abc", String.Empty));
		}
コード例 #29
0
		public void DoesNotMatchAStringObject()
		{
			XmlSchemaFileAssociation lhs = new XmlSchemaFileAssociation("ext", "namespaceUri", "prefix");
			Assert.IsFalse(lhs.Equals("String"));
		}
コード例 #30
0
		void UpdateXmlSchemaFileAssociations()
		{
			for (int i = 0; i < schemasPanel.XmlSchemaFileAssociationListItemCount; ++i) {
				XmlSchemaFileAssociationListItem item = schemasPanel.GetXmlSchemaFileAssociationListItem(i);
				if (item.IsDirty) {
					XmlSchemaFileAssociation association = new XmlSchemaFileAssociation(item.Extension, item.NamespaceUri, item.NamespacePrefix);
					associations.SetSchemaFileAssociation(association);
				}
			}
		}