public void Init()
        {
            LoadBarSchema();
            LoadFooSchema();
            fooSchemaData.IsReadOnly = true;
            LoadXmlSchema();

            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(fooSchemaData);
            schemas.Add(barSchemaData);
            schemas.Add(xmlSchemaData);

            factory = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], String.Empty, new MockFileSystem(), factory);
            registeredXmlSchemas.Schemas.AddRange(schemas);

            string[] xmlFileExtensions = new string[] { ".foo", ".bar", ".xml" };

            DefaultXmlSchemaFileAssociations defaultSchemaFileAssociations = new DefaultXmlSchemaFileAssociations();

            defaultSchemaFileAssociations.Add(new XmlSchemaFileAssociation(".foo", "http://foo"));
            defaultSchemaFileAssociations.Add(new XmlSchemaFileAssociation(".bar", "http://bar", "b"));

            properties   = new Properties();
            associations = new XmlSchemaFileAssociations(properties, defaultSchemaFileAssociations, new XmlSchemaCompletionCollection());
            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://xml"));

            panel         = new MockXmlSchemasPanel();
            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, xmlFileExtensions, associations, panel, factory);
            schemasEditor.LoadOptions();
        }
        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));
        }
コード例 #3
0
        public void Init()
        {
            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema()));

            XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://www.w3.org/1999/xhtml"));

            textEditor = new MockTextEditor();
            textEditor.Document.Text = String.Empty;
            textEditor.FileName      = new FileName(@"c:\projects\test.xml");

            textEditor.Caret.Offset = 0;

            completionBinding = new XmlCodeCompletionBinding(associations);
        }
        public void Init()
        {
            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXsdSchema()));

            XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "<xs:schema></xs:schema>";

            // Put cursor after the first 'a' in "<xs:schema>"
            textEditor.Caret.Offset = 10;

            XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(associations);

            keyPressResult = completionBinding.HandleKeyPress(textEditor, ' ');
        }
        public void Init()
        {
            XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();

            xsdSchema = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
            schemas.Add(xsdSchema);

            associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "<xs:schema elementFormDefault=\"\"></xs:schema>";

            // Put cursor inside the double quotes following the elementFormDefault attribute
            textEditor.Caret.Offset = 31;

            completionBinding = new XmlCodeCompletionBinding(associations);
            result            = completionBinding.CtrlSpace(textEditor);
        }
        public void Init()
        {
            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], @"c:\users\user\sharpdevelop\schemas", fileSystem, factory);

            string testSchemaXml       = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />";
            XmlSchemaCompletion schema = new XmlSchemaCompletion(new StringReader(testSchemaXml));

            schema.IsReadOnly = false;
            registeredXmlSchemas.Schemas.Add(schema);

            XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(null), registeredXmlSchemas.Schemas);

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".test", "http://test"));
            panel = new MockXmlSchemasPanel();

            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[] { ".test" }, associations, panel, factory);
            schemasEditor.LoadOptions();

            string newXmlSchemaFileName = @"c:\projects\new.xsd";
            string newSchemaXml         = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://new' />";

            factory.AddSchemaXml(newXmlSchemaFileName, newSchemaXml);

            panel.OpenFileDialogFileNameToReturn = newXmlSchemaFileName;
            panel.OpenFileDialogResultToReturn   = true;

            // Add schema from file system to ensure that the list of schemas shown to the
            // user is from the list of schemas in the list box when changing the association
            // to a file extension
            schemasEditor.AddSchemaFromFileSystem();

            panel.SelectedXmlSchemaFileAssociationListItemIndex = 0;
            schemasEditor.XmlSchemaFileAssociationFileExtensionSelectionChanged();

            panel.SelectXmlSchemaWindowDialogResultToReturn = true;
            panel.SelectXmlSchemaWindowNamespaceToReturn    = "http://new";
            schemasEditor.ChangeSchemaAssociation();
        }