Пример #1
0
        /// <summary>
        /// Creates an element representing a conditional "Switch" block, which recursively contains another type
        /// </summary>
        /// <param name="InnerType">The base type for the do block to contain</param>
        /// <returns>New schema element for the block</returns>
        static XmlSchemaElement CreateSwitchElement(ScriptSchemaStandardType InnerType)
        {
            // Create the "Option" element
            XmlSchemaComplexContentExtension CaseExtension = new XmlSchemaComplexContentExtension();

            CaseExtension.BaseTypeName = GetQualifiedTypeName(InnerType);
            CaseExtension.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Required));

            XmlSchemaComplexContent CaseContentModel = new XmlSchemaComplexContent();

            CaseContentModel.Content = CaseExtension;

            XmlSchemaComplexType CaseSchemaType = new XmlSchemaComplexType();

            CaseSchemaType.ContentModel = CaseContentModel;

            XmlSchemaElement CaseElement = new XmlSchemaElement();

            CaseElement.Name            = "Case";
            CaseElement.SchemaType      = CaseSchemaType;
            CaseElement.MinOccurs       = 0;
            CaseElement.MaxOccursString = "unbounded";

            // Create the "Otherwise" element
            XmlSchemaElement OtherwiseElement = new XmlSchemaElement();

            OtherwiseElement.Name           = "Default";
            OtherwiseElement.SchemaTypeName = GetQualifiedTypeName(InnerType);
            OtherwiseElement.MinOccurs      = 0;
            OtherwiseElement.MaxOccurs      = 1;

            // Create the "Switch" element
            XmlSchemaSequence SwitchSequence = new XmlSchemaSequence();

            SwitchSequence.Items.Add(CaseElement);
            SwitchSequence.Items.Add(OtherwiseElement);

            XmlSchemaComplexType SwitchSchemaType = new XmlSchemaComplexType();

            SwitchSchemaType.Particle = SwitchSequence;

            XmlSchemaElement SwitchElement = new XmlSchemaElement();

            SwitchElement.Name       = "Switch";
            SwitchElement.SchemaType = SwitchSchemaType;
            return(SwitchElement);
        }
Пример #2
0
        /// <summary>
        /// Creates a simple type that matches a regex
        /// </summary>
        /// <param name="Type">The type enumeration to define</param>
        /// <param name="Pattern">Regex pattern to match</param>
        /// <returns>A simple type which will match the given pattern</returns>
        static XmlSchemaSimpleType CreateSimpleTypeFromRegex(ScriptSchemaStandardType Type, string Pattern)
        {
            XmlSchemaPatternFacet PatternFacet = new XmlSchemaPatternFacet();

            PatternFacet.Value = Pattern;

            XmlSchemaSimpleTypeRestriction Restriction = new XmlSchemaSimpleTypeRestriction();

            Restriction.BaseTypeName = StringTypeName;
            Restriction.Facets.Add(PatternFacet);

            XmlSchemaSimpleType SimpleType = new XmlSchemaSimpleType();

            SimpleType.Name    = GetTypeName(Type);
            SimpleType.Content = Restriction;
            return(SimpleType);
        }
Пример #3
0
        /// <summary>
        /// Creates an element representing a conditional "Do" block, which recursively contains another type
        /// </summary>
        /// <param name="InnerType">The base type for the do block to contain</param>
        /// <returns>New schema element for the block</returns>
        static XmlSchemaElement CreateDoElement(ScriptSchemaStandardType InnerType)
        {
            XmlSchemaComplexContentExtension Extension = new XmlSchemaComplexContentExtension();

            Extension.BaseTypeName = GetQualifiedTypeName(InnerType);
            Extension.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Optional));

            XmlSchemaComplexContent ContentModel = new XmlSchemaComplexContent();

            ContentModel.Content = Extension;

            XmlSchemaComplexType SchemaType = new XmlSchemaComplexType();

            SchemaType.ContentModel = ContentModel;

            XmlSchemaElement Element = new XmlSchemaElement();

            Element.Name       = "Do";
            Element.SchemaType = SchemaType;
            return(Element);
        }
Пример #4
0
 /// <summary>
 /// Constructs an XmlSchemaAttribute and initialize it with the given parameters
 /// </summary>
 /// <param name="Name">The attribute name</param>
 /// <param name="SchemaType">Type enumeration for the attribute</param>
 /// <param name="Use">Whether the attribute is required or optional</param>
 /// <returns>A new XmlSchemaAttribute object</returns>
 static XmlSchemaAttribute CreateSchemaAttribute(string Name, ScriptSchemaStandardType SchemaType, XmlSchemaUse Use)
 {
     return(CreateSchemaAttribute(Name, GetQualifiedTypeName(SchemaType), Use));
 }
Пример #5
0
 /// <summary>
 /// Constructs an XmlSchemaElement and initializes it with the given parameters
 /// </summary>
 /// <param name="Name">Element name</param>
 /// <param name="SchemaType">Type enumeration for the attribute</param>
 /// <returns>A new XmlSchemaElement object</returns>
 static XmlSchemaElement CreateSchemaElement(string Name, ScriptSchemaStandardType SchemaType)
 {
     return(CreateSchemaElement(Name, GetQualifiedTypeName(SchemaType)));
 }
Пример #6
0
 /// <summary>
 /// Gets the qualified name for the given script type
 /// </summary>
 /// <param name="Type">Script type to find the qualified name for</param>
 /// <returns>Qualified name of the schema type that matches the given script type</returns>
 static XmlQualifiedName GetQualifiedTypeName(ScriptSchemaStandardType Type)
 {
     return(new XmlQualifiedName(GetTypeName(Type), NamespaceURI));
 }
Пример #7
0
 /// <summary>
 /// Gets the bare name for the given script type
 /// </summary>
 /// <param name="Type">Script type to find the name of</param>
 /// <returns>Name of the schema type that matches the given script type</returns>
 static string GetTypeName(ScriptSchemaStandardType Type)
 {
     return(Type.ToString() + "Type");
 }
Пример #8
0
		/// <summary>
		/// Constructs an XmlSchemaAttribute and initialize it with the given parameters
		/// </summary>
		/// <param name="Name">The attribute name</param>
		/// <param name="SchemaType">Type enumeration for the attribute</param>
		/// <param name="Use">Whether the attribute is required or optional</param>
		/// <returns>A new XmlSchemaAttribute object</returns>
		static XmlSchemaAttribute CreateSchemaAttribute(string Name, ScriptSchemaStandardType SchemaType, XmlSchemaUse Use)
		{
			return CreateSchemaAttribute(Name, GetQualifiedTypeName(SchemaType), Use);
		}
Пример #9
0
		/// <summary>
		/// Constructs an XmlSchemaElement and initializes it with the given parameters
		/// </summary>
		/// <param name="Name">Element name</param>
		/// <param name="SchemaType">Type enumeration for the attribute</param>
		/// <returns>A new XmlSchemaElement object</returns>
		static XmlSchemaElement CreateSchemaElement(string Name, ScriptSchemaStandardType SchemaType)
		{
			return CreateSchemaElement(Name, GetQualifiedTypeName(SchemaType));
		}
Пример #10
0
		/// <summary>
		/// Creates an element representing a conditional "ForEach" block, which recursively contains another type
		/// </summary>
		/// <param name="InnerType">The base type for the foreach block to contain</param>
		/// <returns>New schema element for the block</returns>
		static XmlSchemaElement CreateForEachElement(ScriptSchemaStandardType InnerType)
		{
			XmlSchemaComplexContentExtension Extension = new XmlSchemaComplexContentExtension();
			Extension.BaseTypeName = GetQualifiedTypeName(InnerType);
			Extension.Attributes.Add(CreateSchemaAttribute("Name", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Required));
			Extension.Attributes.Add(CreateSchemaAttribute("Values", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Required));
			Extension.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Optional));

			XmlSchemaComplexContent ContentModel = new XmlSchemaComplexContent();
			ContentModel.Content = Extension;

			XmlSchemaComplexType SchemaType = new XmlSchemaComplexType();
			SchemaType.ContentModel = ContentModel;

			XmlSchemaElement Element = new XmlSchemaElement();
			Element.Name = "ForEach";
			Element.SchemaType = SchemaType;
			return Element;
		}
Пример #11
0
		/// <summary>
		/// Creates an element representing a conditional "Switch" block, which recursively contains another type
		/// </summary>
		/// <param name="InnerType">The base type for the do block to contain</param>
		/// <returns>New schema element for the block</returns>
		static XmlSchemaElement CreateSwitchElement(ScriptSchemaStandardType InnerType)
		{
			// Create the "Option" element
			XmlSchemaComplexContentExtension CaseExtension = new XmlSchemaComplexContentExtension();
			CaseExtension.BaseTypeName = GetQualifiedTypeName(InnerType);
			CaseExtension.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Required));

			XmlSchemaComplexContent CaseContentModel = new XmlSchemaComplexContent();
			CaseContentModel.Content = CaseExtension;

			XmlSchemaComplexType CaseSchemaType = new XmlSchemaComplexType();
			CaseSchemaType.ContentModel = CaseContentModel;

			XmlSchemaElement CaseElement = new XmlSchemaElement();
			CaseElement.Name = "Case";
			CaseElement.SchemaType = CaseSchemaType;
			CaseElement.MinOccurs = 0;
			CaseElement.MaxOccursString = "unbounded";

			// Create the "Otherwise" element
			XmlSchemaElement OtherwiseElement = new XmlSchemaElement();
			OtherwiseElement.Name = "Default";
			OtherwiseElement.SchemaTypeName = GetQualifiedTypeName(InnerType);
			OtherwiseElement.MinOccurs = 0;
			OtherwiseElement.MaxOccurs = 1;

			// Create the "Switch" element
			XmlSchemaSequence SwitchSequence = new XmlSchemaSequence();
			SwitchSequence.Items.Add(CaseElement);
			SwitchSequence.Items.Add(OtherwiseElement);

			XmlSchemaComplexType SwitchSchemaType = new XmlSchemaComplexType();
			SwitchSchemaType.Particle = SwitchSequence;

			XmlSchemaElement SwitchElement = new XmlSchemaElement();
			SwitchElement.Name = "Switch";
			SwitchElement.SchemaType = SwitchSchemaType;
			return SwitchElement;
		}
Пример #12
0
		/// <summary>
		/// Creates the schema type representing a warning or error type
		/// </summary>
		/// <returns>Type definition for a warning</returns>
		static XmlSchemaType CreateDiagnosticType(ScriptSchemaStandardType StandardType)
		{
			XmlSchemaComplexType PropertyType = new XmlSchemaComplexType();
			PropertyType.Name = GetTypeName(StandardType);
			PropertyType.Attributes.Add(CreateSchemaAttribute("Message", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Required));
			PropertyType.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Optional));
			return PropertyType;
		}
Пример #13
0
		/// <summary>
		/// Gets the qualified name for the given script type
		/// </summary>
		/// <param name="Type">Script type to find the qualified name for</param>
		/// <returns>Qualified name of the schema type that matches the given script type</returns>
		static XmlQualifiedName GetQualifiedTypeName(ScriptSchemaStandardType Type)
		{
			return new XmlQualifiedName(GetTypeName(Type), NamespaceURI);
		}
Пример #14
0
		/// <summary>
		/// Gets the bare name for the given script type
		/// </summary>
		/// <param name="Type">Script type to find the name of</param>
		/// <returns>Name of the schema type that matches the given script type</returns>
		static string GetTypeName(ScriptSchemaStandardType Type)
		{
			return Type.ToString() + "Type";
		}