/// <summary>
 ///   Adds the contents of another <see cref='XmlCompletionDataCollection'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='XmlCompletionDataCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='XmlCompletionDataCollection.Add'/>
 public void AddRange(XmlCompletionDataCollection val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataCollection'/> based on another <see cref='XmlCompletionDataCollection'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='XmlCompletionDataCollection'/> from which the contents are copied
 /// </param>
 public XmlCompletionDataCollection(XmlCompletionDataCollection val)
 {
     this.AddRange(val);
 }
 /// <summary>
 ///   Adds the contents of another <see cref='XmlCompletionDataCollection'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='XmlCompletionDataCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='XmlCompletionDataCollection.Add'/>
 public void AddRange(XmlCompletionDataCollection val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }
Esempio n. 4
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaElement element)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = GetElementAsComplexType(element);

            if (complexType != null)
            {
                data.AddRange(GetAttributeCompletionData(complexType));
            }

            return data;
        }
Esempio n. 5
0
 /// <summary>
 /// Adds elements to the collection if it does not already exist.
 /// </summary>
 void AddElements(XmlCompletionDataCollection lhs, XmlCompletionDataCollection rhs)
 {
     foreach (XmlCompletionData data in rhs)
     {
         if (!lhs.Contains(data))
         {
             lhs.Add(data);
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Adds an element completion data to the collection if it does not 
 /// already exist.
 /// </summary>
 void AddElement(XmlCompletionDataCollection data, string name, string prefix, string documentation)
 {
     if (!data.Contains(name))
     {
         if (prefix.Length > 0)
         {
             name = String.Concat(prefix, ":", name);
         }
         XmlCompletionData completionData = new XmlCompletionData(name, documentation);
         data.Add(completionData);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Adds an attribute value to the completion data collection.
 /// </summary>
 void AddAttributeValue(XmlCompletionDataCollection data, string valueText)
 {
     XmlCompletionData completionData = new XmlCompletionData(valueText, XmlCompletionData.DataType.XmlAttributeValue);
     data.Add(completionData);
 }
Esempio n. 8
0
        /// <summary>
        /// Gets the possible root elements for an xml document using this schema.
        /// </summary>
        public ICompletionData[] GetElementCompletionData(string namespacePrefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaElement element in schema.Elements.Values)
            {
                if (element.Name != null)
                {
                    AddElement(data, element.Name, namespacePrefix, element.Annotation);
                }
                else
                {
                    // Do not add reference element.
                }
            }

            return data.ToArray();
        }
Esempio n. 9
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaElement element, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = GetElementAsComplexType(element);

            if (complexType != null)
            {
                data = GetChildElementCompletionData(complexType, prefix);
            }

            return data;
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the set of attribute values for an xs:boolean type.
        /// </summary>
        XmlCompletionDataCollection GetBooleanAttributeValueCompletionData()
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            AddAttributeValue(data, "0");
            AddAttributeValue(data, "1");
            AddAttributeValue(data, "true");
            AddAttributeValue(data, "false");

            return data;
        }
Esempio n. 11
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeList list)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            if (list.ItemType != null)
            {
                data.AddRange(GetAttributeValueCompletionData(list.ItemType));
            }
            else if (list.ItemTypeName != null)
            {
                XmlSchemaSimpleType simpleType = FindSimpleType(list.ItemTypeName);
                if (simpleType != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleType));
                }
            }

            return data;
        }
Esempio n. 12
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleType simpleType)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaSimpleTypeRestriction simpleTypeRestriction = simpleType.Content as XmlSchemaSimpleTypeRestriction;
            XmlSchemaSimpleTypeUnion union = simpleType.Content as XmlSchemaSimpleTypeUnion;
            XmlSchemaSimpleTypeList list = simpleType.Content as XmlSchemaSimpleTypeList;

            if (simpleTypeRestriction != null)
            {
                data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
            }
            else if (union != null)
            {
                data.AddRange(GetAttributeValueCompletionData(union));
            }
            else if (list != null)
            {
                data.AddRange(GetAttributeValueCompletionData(list));
            }

            return data;
        }
Esempio n. 13
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeUnion union)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in union.BaseTypes)
            {
                XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
                if (simpleType != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleType));
                }
            }

            return data;
        }
Esempio n. 14
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeRestriction simpleTypeRestriction)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in simpleTypeRestriction.Facets)
            {
                XmlSchemaEnumerationFacet enumFacet = schemaObject as XmlSchemaEnumerationFacet;
                if (enumFacet != null)
                {
                    AddAttributeValue(data, enumFacet.Value, enumFacet.Annotation);
                }
            }

            return data;
        }
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataCollection'/> based on another <see cref='XmlCompletionDataCollection'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='XmlCompletionDataCollection'/> from which the contents are copied
 /// </param>
 public XmlCompletionDataCollection(XmlCompletionDataCollection val)
 {
     this.AddRange(val);
 }
Esempio n. 16
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaAttribute attribute)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            if (attribute.SchemaType != null)
            {
                XmlSchemaSimpleTypeRestriction simpleTypeRestriction = attribute.SchemaType.Content as XmlSchemaSimpleTypeRestriction;
                if (simpleTypeRestriction != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction));
                }
            }
            else if (attribute.AttributeSchemaType != null)
            {
                XmlSchemaSimpleType simpleType = attribute.AttributeSchemaType as XmlSchemaSimpleType;

                if (simpleType != null)
                {
                    if (simpleType.Name == "boolean")
                    {
                        data.AddRange(GetBooleanAttributeValueCompletionData());
                    }
                    else
                    {
                        data.AddRange(GetAttributeValueCompletionData(simpleType));
                    }
                }
            }

            return data;
        }
Esempio n. 17
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexType complexType, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaSequence sequence = complexType.Particle as XmlSchemaSequence;
            XmlSchemaChoice choice = complexType.Particle as XmlSchemaChoice;
            XmlSchemaGroupRef groupRef = complexType.Particle as XmlSchemaGroupRef;
            XmlSchemaComplexContent complexContent = complexType.ContentModel as XmlSchemaComplexContent;
            XmlSchemaAll all = complexType.Particle as XmlSchemaAll;

            if (sequence != null)
            {
                data = GetChildElementCompletionData(sequence.Items, prefix);
            }
            else if (choice != null)
            {
                data = GetChildElementCompletionData(choice.Items, prefix);
            }
            else if (complexContent != null)
            {
                data = GetChildElementCompletionData(complexContent, prefix);
            }
            else if (groupRef != null)
            {
                data = GetChildElementCompletionData(groupRef, prefix);
            }
            else if (all != null)
            {
                data = GetChildElementCompletionData(all.Items, prefix);
            }

            return data;
        }
Esempio n. 18
0
        /// <summary>
        /// Adds an attribute to the completion data collection.
        /// </summary>
        /// <remarks>
        /// Note the special handling of xml:lang attributes.
        /// </remarks>
        void AddAttribute(XmlCompletionDataCollection data, XmlSchemaAttribute attribute)
        {
            string name = attribute.Name;
            if (name == null)
            {
                if (attribute.RefName.Namespace == "http://www.w3.org/XML/1998/namespace")
                {
                    name = String.Concat("xml:", attribute.RefName.Name);
                }
            }

            if (name != null)
            {
                string documentation = GetDocumentation(attribute.Annotation);
                XmlCompletionData completionData = new XmlCompletionData(name, documentation, XmlCompletionData.DataType.XmlAttribute);
                data.Add(completionData);
            }
        }
Esempio n. 19
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaObjectCollection items, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            foreach (XmlSchemaObject schemaObject in items)
            {

                XmlSchemaElement childElement = schemaObject as XmlSchemaElement;
                XmlSchemaSequence childSequence = schemaObject as XmlSchemaSequence;
                XmlSchemaChoice childChoice = schemaObject as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = schemaObject as XmlSchemaGroupRef;

                if (childElement != null)
                {
                    string name = childElement.Name;
                    if (name == null)
                    {
                        name = childElement.RefName.Name;
                        XmlSchemaElement element = FindElement(childElement.RefName);
                        if (element != null)
                        {
                            if (element.IsAbstract)
                            {
                                AddSubstitionGroupElements(data, element.QualifiedName, prefix);
                            }
                            else
                            {
                                AddElement(data, name, prefix, element.Annotation);
                            }
                        }
                        else
                        {
                            AddElement(data, name, prefix, childElement.Annotation);
                        }
                    }
                    else
                    {
                        AddElement(data, name, prefix, childElement.Annotation);
                    }
                }
                else if (childSequence != null)
                {
                    AddElements(data, GetChildElementCompletionData(childSequence.Items, prefix));
                }
                else if (childChoice != null)
                {
                    AddElements(data, GetChildElementCompletionData(childChoice.Items, prefix));
                }
                else if (groupRef != null)
                {
                    AddElements(data, GetChildElementCompletionData(groupRef, prefix));
                }
            }

            return data;
        }
Esempio n. 20
0
 /// <summary>
 /// Adds an attribute value to the completion data collection.
 /// </summary>
 void AddAttributeValue(XmlCompletionDataCollection data, string valueText, XmlSchemaAnnotation annotation)
 {
     string documentation = GetDocumentation(annotation);
     XmlCompletionData completionData = new XmlCompletionData(valueText, documentation, XmlCompletionData.DataType.XmlAttributeValue);
     data.Add(completionData);
 }
Esempio n. 21
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContent complexContent, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexContentExtension extension = complexContent.Content as XmlSchemaComplexContentExtension;
            if (extension != null)
            {
                data = GetChildElementCompletionData(extension, prefix);
            }
            else
            {
                XmlSchemaComplexContentRestriction restriction = complexContent.Content as XmlSchemaComplexContentRestriction;
                if (restriction != null)
                {
                    data = GetChildElementCompletionData(restriction, prefix);
                }
            }

            return data;
        }
Esempio n. 22
0
        /// <summary>
        /// Adds an element completion data to the collection if it does not 
        /// already exist.
        /// </summary>
        void AddElement(XmlCompletionDataCollection data, string name, string prefix, XmlSchemaAnnotation annotation)
        {
            // Get any annotation documentation.
            string documentation = GetDocumentation(annotation);

            AddElement(data, name, prefix, documentation);
        }
Esempio n. 23
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContentExtension extension, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = FindNamedType(schema, extension.BaseTypeName);
            if (complexType != null)
            {
                data = GetChildElementCompletionData(complexType, prefix);
            }

            // Add any elements.
            if (extension.Particle != null)
            {
                XmlSchemaSequence sequence = extension.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = extension.Particle as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = extension.Particle as XmlSchemaGroupRef;

                if (sequence != null)
                {
                    data.AddRange(GetChildElementCompletionData(sequence.Items, prefix));
                }
                else if (choice != null)
                {
                    data.AddRange(GetChildElementCompletionData(choice.Items, prefix));
                }
                else if (groupRef != null)
                {
                    data.AddRange(GetChildElementCompletionData(groupRef, prefix));
                }
            }

            return data;
        }
Esempio n. 24
0
 /// <summary>
 /// Adds any elements that have the specified substitution group.
 /// </summary>
 void AddSubstitionGroupElements(XmlCompletionDataCollection data, XmlQualifiedName group, string prefix)
 {
     foreach (XmlSchemaElement element in schema.Elements.Values)
     {
         if (element.SubstitutionGroup == group)
         {
             AddElement(data, element.Name, prefix, element.Annotation);
         }
     }
 }
Esempio n. 25
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaGroupRef groupRef, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaGroup group = FindGroup(groupRef.RefName.Name);
            if (group != null)
            {
                XmlSchemaSequence sequence = group.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = group.Particle as XmlSchemaChoice;

                if (sequence != null)
                {
                    data = GetChildElementCompletionData(sequence.Items, prefix);
                }
                else if (choice != null)
                {
                    data = GetChildElementCompletionData(choice.Items, prefix);
                }
            }

            return data;
        }
Esempio n. 26
0
        XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaComplexContentRestriction restriction)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            data.AddRange(GetAttributeCompletionData(restriction.Attributes));

            XmlSchemaComplexType baseComplexType = FindNamedType(schema, restriction.BaseTypeName);
            if (baseComplexType != null)
            {
                data.AddRange(GetAttributeCompletionData(baseComplexType));
            }

            return data;
        }
Esempio n. 27
0
        XmlCompletionDataCollection GetChildElementCompletionData(XmlSchemaComplexContentRestriction restriction, string prefix)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Add any elements.
            if (restriction.Particle != null)
            {
                XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence;
                XmlSchemaChoice choice = restriction.Particle as XmlSchemaChoice;
                XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef;

                if (sequence != null)
                {
                    data = GetChildElementCompletionData(sequence.Items, prefix);
                }
                else if (choice != null)
                {
                    data = GetChildElementCompletionData(choice.Items, prefix);
                }
                else if (groupRef != null)
                {
                    data = GetChildElementCompletionData(groupRef, prefix);
                }
            }

            return data;
        }
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataEnumerator'/>.
 /// </summary>
 public XmlCompletionDataEnumerator(XmlCompletionDataCollection mappings)
 {
     this.temp = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Esempio n. 29
0
        /// <summary>
        /// Gets the attribute completion data for the xml element that exists
        /// at the end of the specified path.
        /// </summary>
        public ICompletionData[] GetAttributeCompletionData(XmlElementPath path)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                prohibitedAttributes.Clear();
                data = GetAttributeCompletionData(element);
            }

            return data.ToArray();
        }
Esempio n. 30
0
        /// <summary>
        /// Gets the autocomplete data for the specified attribute value.
        /// </summary>
        public ICompletionData[] GetAttributeValueCompletionData(XmlElementPath path, string name)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                data = GetAttributeValueCompletionData(element, name);
            }

            return data.ToArray();
        }
Esempio n. 31
0
        /// <summary>
        /// Gets the child element completion data for the xml element that exists
        /// at the end of the specified path.
        /// </summary>
        public ICompletionData[] GetChildElementCompletionData(XmlElementPath path)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            // Locate matching element.
            XmlSchemaElement element = FindElement(path);

            // Get completion data.
            if (element != null)
            {
                data = GetChildElementCompletionData(element, path.Elements.LastPrefix);
            }

            return data.ToArray();
        }
 /// <summary>
 ///   Initializes a new instance of <see cref='XmlCompletionDataEnumerator'/>.
 /// </summary>
 public XmlCompletionDataEnumerator(XmlCompletionDataCollection mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Esempio n. 33
0
        XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaElement element, string name)
        {
            XmlCompletionDataCollection data = new XmlCompletionDataCollection();

            XmlSchemaComplexType complexType = GetElementAsComplexType(element);
            if (complexType != null)
            {
                XmlSchemaAttribute attribute = FindAttribute(complexType, name);
                if (attribute != null)
                {
                    data.AddRange(GetAttributeValueCompletionData(attribute));
                }
            }

            return data;
        }