public void Equality()
		{
			XmlElementPath newPath = new XmlElementPath();
			newPath.Elements.Add(new QualifiedName("foo", "http://foo"));
			
			Assert.IsTrue(newPath.Equals(path), "Should be equal.");
		}
		async Task Init ()
		{
			if (schemaChildElements != null)
				return;
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema"));
			
			schemaChildElements = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
			//schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get include elements attributes.
			path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema"));
			includeAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		
			// Get annotation element info.
			path.Elements.RemoveAt(path.Elements.Count - 1);
			path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
			
			annotationChildElements = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
			annotationAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		
			// Get app info attributes.
			path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema"));
			appInfoAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
			
			// Get foo attributes.
			path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema"));
			fooAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema"));
			
			schemaChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
			//schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get include elements attributes.
			path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema"));
			includeAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		
			// Get annotation element info.
			path.Elements.RemoveAt(path.Elements.Count - 1);
			path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
			
			annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
			annotationAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		
			// Get app info attributes.
			path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema"));
			appInfoAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			// Get foo attributes.
			path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema"));
			fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
		
			htmlChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
		}		
		public static XmlElementPath Resolve (IList<XObject> path, string defaultNamespace = null, string defaultPrefix = null)
		{
			var elementPath = new XmlElementPath ();

			if (!string.IsNullOrEmpty (defaultNamespace))
				elementPath.Namespaces.AddPrefix (defaultNamespace, defaultPrefix);

			foreach (var obj in path) {
				var el = obj as XElement;
				if (el == null)
					continue;
				foreach (var att in el.Attributes) {
					if (!string.IsNullOrEmpty (att.Value)) {
						if (att.Name.HasPrefix) {
							if (att.Name.Prefix == "xmlns")
								elementPath.Namespaces.AddPrefix (att.Value, att.Name.Name);
						} else if (att.Name.Name == "xmlns") {
							elementPath.Namespaces.AddPrefix (att.Value, "");
						}
					}
				}
				string ns = elementPath.Namespaces.GetNamespace (el.Name.HasPrefix? el.Name.Prefix : "");
				var qn = new QualifiedName (el.Name.Name, ns, el.Name.Prefix ?? "");
				elementPath.Elements.Add (qn);
			}
			return elementPath;
		}
		public override void FixtureInit()
		{			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			
			noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			
			attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public void NotEqual()
		{
			XmlElementPath newPath = new XmlElementPath();
			newPath.Elements.Add(new QualifiedName("Foo", "bar"));
			
			Assert.IsFalse(newPath.Equals(path), "Should not be equal.");
		}	
		public void TextHasNoChildElements()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
			Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Count, 
			                "Should be no child elements.");
		}		
		public void NoAttributesForUnknownElement()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com"));
			CompletionDataList attributes = SchemaCompletionData.GetAttributeCompletionData(path);
			
			Assert.AreEqual(0, attributes.Count, "Should not find attributes for unknown element.");
		}
		async Task Init ()
		{
			if (attributeCompletionData != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			attributeCompletionData = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
						
			attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path);
			attributeName = attributeCompletionData[0].DisplayText;
		}
		public void CompactPathItem()
		{
			XmlElementPath newPath = new XmlElementPath();
			newPath.Elements.Add(new QualifiedName("bar", "http://bar", "b"));
			
			path.Compact();
			Assert.IsTrue(newPath.Equals(path), "Should be equal.");
		}
		async Task Init ()
		{
			if (attributes != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
			attributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		async Task Init ()
		{
			if (barAttributeValuesCompletionData != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			barAttributeValuesCompletionData = await SchemaCompletionData.GetAttributeValueCompletionData(path, "bar", CancellationToken.None);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd"));
			path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
			
			attributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			
			XmlSchemaElement element = SchemaCompletionData.FindElement(path);
			attribute = SchemaCompletionData.FindAttribute(element, "name");
			missingAttribute = SchemaCompletionData.FindAttribute(element, "missing");
		}
		public async Task NoAttributesForUnknownElement()
		{
			await Init ();
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com"));
			CompletionDataList attributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
			
			Assert.AreEqual(0, attributes.Count, "Should not find attributes for unknown element.");
		}
		public override void FixtureInit()
		{
			rootElementCompletionData = SchemaCompletionData.GetElementCompletionData();
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			
			fooChildElementCompletionData = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		public async Task TextHasNoChildElements()
		{
			await Init ();
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
			path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
			Assert.AreEqual(0, (await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None)).Count, 
			                "Should be no child elements.");
		}		
		public void Init()
		{
			path = new XmlElementPath();
			firstQualifiedName = new QualifiedName("foo", "http://foo", "f");
			path.Elements.Add(firstQualifiedName);
			
			secondQualifiedName = new QualifiedName("bar", "http://bar", "b");
			path.Elements.Add(secondQualifiedName);
		}	
		async Task Init ()
		{
			if (attributes != null)
				return;
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("project", "http://nant.sf.net//nant-0.84.xsd"));
			path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
			
			attributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
		}
		async Task Init ()
		{
			if (elementData != null)
				return;
			
			noteElementPath = new XmlElementPath();
			noteElementPath.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));

			elementData = await SchemaCompletionData.GetChildElementCompletionData(noteElementPath, CancellationToken.None); 
		}
		public override void FixtureInit()
		{
			var path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("person", "http://foo"));
			personElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
			
			path.Elements.Add(new QualifiedName("firstname", "http://foo"));
			firstNameAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			firstNameElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
		}
		async Task Init ()
		{
			if (fooChildElementCompletionData != null)
				return;
			
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
			
			fooChildElementCompletionData = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
		}
		public override void FixtureInit()
		{
			XmlElementPath path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("root", "http://foo"));
			
			rootChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
		
			path.Elements.Add(new QualifiedName("foo", "http://foo"));
			
			fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
		}
		public override void FixtureInit()
		{
			// Note element path.
			noteElementPath = new XmlElementPath();
			QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com");
			noteElementPath.Elements.Add(noteQualifiedName);
		
			// Text element path.
			textElementPath = new XmlElementPath();
			textElementPath.Elements.Add(noteQualifiedName);
			textElementPath.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
		}	
		async Task Init ()
		{
			if (personElementChildren != null)
				return;
			
			var path = new XmlElementPath();
			path.Elements.Add(new QualifiedName("person", "http://foo"));
			personElementChildren = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
			
			path.Elements.Add(new QualifiedName("firstname", "http://foo"));
			firstNameAttributes = await SchemaCompletionData.GetAttributeCompletionData(path, CancellationToken.None);
			firstNameElementChildren = await SchemaCompletionData.GetChildElementCompletionData(path, CancellationToken.None);
		}
		public void FixtureInit()
		{
			XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
			schemaCompletionData = new XmlSchemaCompletionData(reader);
			
			// Set up h1 element's path.
			h1Path = new XmlElementPath();
			h1Path.Elements.Add(new QualifiedName("html", namespaceURI));
			h1Path.Elements.Add(new QualifiedName("body", namespaceURI));
			h1Path.Elements.Add(new QualifiedName("h1", namespaceURI));
			
			// Get h1 element info.
			h1Attributes = schemaCompletionData.GetAttributeCompletionData(h1Path);
		}
		public override void FixtureInit()
		{
			var path = new XmlElementPath();
			
			path.Elements.Add(new QualifiedName("project", "http://foo"));
			path.Elements.Add(new QualifiedName("items", "http://foo"));
			
			itemsElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
			
			path.Elements.Add(new QualifiedName("file", "http://foo"));
			
			fileElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
			fileElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
		}
Exemple #31
0
 public Task <CompletionDataList> GetAttributeCompletionData(XmlElementPath path, CancellationToken token)
 {
     return(GetCompletions(attributeCompletions, path, XmlCompletionData.DataType.XmlAttribute));
 }
Exemple #32
0
 public CompletionDataList GetChildElementCompletionData(XmlElementPath path)
 {
     return(new CompletionDataList());
 }
Exemple #33
0
 public Task <CompletionDataList> GetAttributeValueCompletionData(XmlElementPath path, string name, CancellationToken token)
 {
     return(Task.FromResult(new CompletionDataList {
         AutoSelect = false
     }));
 }
Exemple #34
0
 static Task <CompletionDataList> GetCompletions(Dictionary <string, HashSet <string> > map, XmlElementPath path, XmlCompletionData.DataType type)
 {
     if (path == null || path.Elements.Count == 0)
     {
         return(Task.FromResult(new CompletionDataList {
             AutoSelect = false
         }));
     }
     return(GetCompletions(map, path.Elements[path.Elements.Count - 1].Name, type));
 }
Exemple #35
0
 public CompletionDataList GetAttributeCompletionData(XmlElementPath path)
 {
     return(new CompletionDataList());
 }
Exemple #36
0
 public CompletionDataList GetAttributeValueCompletionData(XmlElementPath path, string name)
 {
     return(new CompletionDataList());
 }
Exemple #37
0
 public Task <CompletionDataList> GetChildElementCompletionData(XmlElementPath path, CancellationToken token)
 {
     return(GetCompletions(elementCompletions, path, XmlCompletionData.DataType.XmlElement));
 }