private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject)
        {
            XmlNode[]          markup;
            XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated;

            if ((annotatedObject == null ? false : annotatedObject.Annotation != null))
            {
                foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items)
                {
                    XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation;
                    markup = (doc == null ? ((XmlSchemaAppInfo)annot).Markup : doc.Markup);
                    string    text          = string.Empty;
                    XmlNode[] xmlNodeArrays = markup;
                    for (int i = 0; i < (int)xmlNodeArrays.Length; i++)
                    {
                        XmlNode xn = xmlNodeArrays[i];
                        text = string.Concat(text, xn.InnerText);
                    }
                    if (text.Length > 0)
                    {
                        this.AppendMessage(annotations, "summary", text);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        internal static void WriteDescription(this XmlSchemaAnnotated annotated, string description)
        {
            if (string.IsNullOrEmpty(description) == true)
            {
                return;
            }

            if (annotated.Annotation == null)
            {
                annotated.Annotation = new XmlSchemaAnnotation();
            }

            var annotation = annotated.Annotation;
            {
                var documentation = new XmlSchemaDocumentation();
                {
                    var doc      = new XmlDocument();
                    var textNode = doc.CreateTextNode(description);
                    documentation.Markup = new XmlNode[1] {
                        textNode
                    };
                }
                annotation.Items.Add(documentation);
            }
        }
Ejemplo n.º 3
0
        private static IXSComponent CreateIXSAnnotated(XmlSchemaAnnotated xmlAnnotated)
        {
            if (xmlAnnotated is XmlSchemaType xmlType)
            {
                return(CreateIXSType(xmlType));
            }

            else if (xmlAnnotated is XmlSchemaParticle xmlParticle)
            {
                if (string.IsNullOrEmpty(xmlParticle.MinOccursString) && string.IsNullOrEmpty(xmlParticle.MaxOccursString))
                {
                    return(CreateIXSFragment(xmlParticle));
                }
                else
                {
                    return(new XSParticle(xmlParticle));
                }
            }
            else if (xmlAnnotated is XmlSchemaFacet xmlFacet)
            {
                return(CreateIXSFacet(xmlFacet));
            }

            else if (xmlAnnotated is XmlSchemaAttribute xmlAttribute)
            {
                return(new XSAttributeDeclaration(xmlAttribute));
            }

            else if (xmlAnnotated is XmlSchemaAnyAttribute xmlAnyAttribute)
            {
                return(CreateXSWildcard(xmlAnyAttribute));
            }

            else if (xmlAnnotated is XmlSchemaAttributeGroup xmlAttributeGroup)
            {
                return(new XSAttributeGroupDefinition(xmlAttributeGroup));
            }

            else if (xmlAnnotated is XmlSchemaAttributeGroupRef xmlAttributeGroupRef)
            {
                return(new XSAttributeGroupDefinition(xmlAttributeGroupRef));
            }

            else if (xmlAnnotated is XmlSchemaNotation xmlNotation)
            {
                return(new XSNotationDeclaration(xmlNotation));
            }

            else if (xmlAnnotated is XmlSchemaGroup xmlGroup)
            {
                return(new XSModelGroupDefinition(xmlGroup));
            }



            else
            {
                throw RuntimeException.InvalidArgumentType();
            }
        }
Ejemplo n.º 4
0
        internal static string ReadAppInfoAsString(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, string defaultValue)
        {
            var annotation = annotated.Annotation;

            if (annotation == null)
            {
                return(defaultValue);
            }

            foreach (XmlSchemaObject item in annotation.Items)
            {
                if (item is XmlSchemaAppInfo == true)
                {
                    var appInfo = item as XmlSchemaAppInfo;

                    foreach (XmlNode xmlNode in appInfo.Markup)
                    {
                        if (xmlNode.Name != nodeName)
                        {
                            continue;
                        }

                        var attr = xmlNode.Attributes[attributeName];
                        if (attr != null)
                        {
                            return(attr.Value);
                        }
                    }
                }
            }

            return(defaultValue);
        }
Ejemplo n.º 5
0
 private void InternalHandleId(XmlSchemaAnnotated element)
 {
     if (element.GetSchema() == _schema)
     {
         HandleId(element);
     }
 }
Ejemplo n.º 6
0
        private void AnnotateTaskElement(Type taskType, XmlSchemaAnnotated taskElement)
        {
            if (!this.documentationLoader.HasDocumentation(taskType.Assembly))
            {
                return;
            }
            // let's find the element
            string summary = this.documentationLoader.GetTypeSummary(taskType);

            if (string.IsNullOrEmpty(summary))
            {
                return;
            }

            taskElement.Annotation = new XmlSchemaAnnotation();
            XmlSchemaDocumentation doc = new XmlSchemaDocumentation();

            taskElement.Annotation.Items.Add(doc);
            XmlText text = new XmlDocument().CreateTextNode(summary);

            if (ReflectionHelper.HasAttribute <ObsoleteAttribute>(taskType))
            {
                text.Value = "[Obsolete] " + text.Value;
            }
            doc.Markup = new XmlNode[] { text };
        }
Ejemplo n.º 7
0
        internal XSModelGroupDefinition(XmlSchemaGroup xmlGroup)
        {
            _group = xmlGroup;
            _name  = xmlGroup.Name;

            if (_group.Annotation is XmlSchemaAnnotation annotation)
            {
                _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation);
                _annotation.BindToContainer(RootContainer, this);
            }

            if (xmlGroup.Particle is XmlSchemaGroupBase xmlGroupBase)
            {
                IXSComponent component = XMLSchemaSerializer.CreateInstance(xmlGroupBase);

                if (component is XSParticle particle)
                {
                    _modelGroup = particle;
                }

                else if (component is XSModelGroup modelGroup)
                {
                    _modelGroup = modelGroup;
                }
            }
        }
Ejemplo n.º 8
0
        private static int GetMinMaxOccValue(XmlSchemaAnnotated element, string attributeName)
        {
            if (element.Annotation == null)
            {
                return(-1);
            }

            var en = element.Annotation.Items.GetEnumerator();

            while (en.MoveNext())
            {
                if (en.Current is XmlSchemaAppInfo ai)
                {
                    if (ai.Source == "minOcc")
                    {
                        if (ai.Markup == null || !ai.Markup.Any())
                        {
                            return(-1);
                        }

                        if (int.TryParse(ai.Markup[0].Value, out var rValue))
                        {
                            return(rValue);
                        }
                    }
                }
            }

            return(-1);
        }
Ejemplo n.º 9
0
        private List <XmlNode> GetAnnotation(XmlSchemaAnnotated annotated)
        {
            List <XmlNode>      nodes      = new List <XmlNode>();
            XmlSchemaAnnotation annotation = annotated.Annotation;

            if (annotation != null)
            {
                // find the first <xs:appinfo> element
                foreach (XmlSchemaObject schemaObj in annotation.Items)
                {
                    XmlSchemaAppInfo appInfo = schemaObj as XmlSchemaAppInfo;
                    if (appInfo != null)
                    {
                        // copy annotation, removing comments
                        foreach (XmlNode node in appInfo.Markup)
                        {
                            if (node.NodeType != XmlNodeType.Comment)
                            {
                                nodes.Add(node);
                            }
                        }
                    }
                }
            }

            return(nodes);
        }
Ejemplo n.º 10
0
            protected override void HandleId(XmlSchemaAnnotated element)
            {
                var lookupId = Guid.NewGuid().ToString();

                var lookupAttributeId = _lookupIdAttributeOwner.CreateAttribute("temp", "lookupId", TempLookupIdNamespace);

                lookupAttributeId.Value = lookupId;

                XmlAttribute[] newUnhandledAttributes;

                if (element.UnhandledAttributes == null)
                {
                    newUnhandledAttributes = new XmlAttribute[1];
                }
                else
                {
                    newUnhandledAttributes = new XmlAttribute[element.UnhandledAttributes.Length + 1];
                    Array.Copy(element.UnhandledAttributes, newUnhandledAttributes, element.UnhandledAttributes.Length);
                }

                newUnhandledAttributes[newUnhandledAttributes.Length - 1] = lookupAttributeId;
                element.UnhandledAttributes = newUnhandledAttributes;

                _lookupIds[element] = lookupId;
            }
        private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject)
        {
            XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated;

            if (annotatedObject != null &&
                annotatedObject.Annotation != null)
            {
                XmlNode[] markup;
                foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items)
                {
                    XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation;
                    if (doc != null)
                    {
                        markup = doc.Markup;
                    }
                    else
                    {
                        markup = ((XmlSchemaAppInfo)annot).Markup;
                    }

                    string text = String.Empty;
                    foreach (XmlNode xn in markup)
                    {
                        text += xn.InnerText;
                    }

                    if (text.Length > 0)
                    {
                        AppendMessage(annotations, "summary", text);
                    }
                }
            }
        }
        private bool CheckUnhandledAttributes(XmlSchemaAnnotated annotated)
        {
            bool flag;

            if (annotated.UnhandledAttributes != null)
            {
                XmlAttribute[] unhandledAttributes = annotated.UnhandledAttributes;
                int            num = 0;
                while (num < (int)unhandledAttributes.Length)
                {
                    XmlAttribute att = unhandledAttributes[num];
                    if ((att.LocalName != "root" ? true : !(att.NamespaceURI == "http://www.microsoft.com/xml/schema/linq")))
                    {
                        num++;
                    }
                    else
                    {
                        flag = true;
                        return(flag);
                    }
                }
            }
            flag = false;
            return(flag);
        }
Ejemplo n.º 13
0
 protected override void Visit(XmlSchemaAnnotated annotated)
 {
     if (Add(annotated))
     {
         base.Visit(annotated);
     }
 }
        //public override string ImportSchemaType(
        //    string name,
        //    string ns,
        //    XmlSchemaObject context,
        //    XmlSchemas schemas,
        //    XmlSchemaImporter importer,
        //    CodeCompileUnit compileUnit,
        //    CodeNamespace mainNamespace,
        //    CodeGenerationOptions options,
        //    CodeDomProvider codeProvider)
        //{

        //    XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) schemas.Find(new XmlQualifiedName(name, ns), typeof(XmlSchemaSimpleType));
        //    return ImportSchemaType(
        //        simpleType,
        //        context,
        //        schemas,
        //        importer,
        //        compileUnit,
        //        mainNamespace,
        //        options,
        //        codeProvider);
        //}

        public override string ImportSchemaType(
            XmlSchemaType type,
            XmlSchemaObject context,
            XmlSchemas schemas,
            XmlSchemaImporter importer,
            CodeCompileUnit compileUnit,
            CodeNamespace mainNamespace,
            CodeGenerationOptions options,
            CodeDomProvider codeProvider)
        {
            XmlSchemaAnnotated annotatedType = type as XmlSchemaAnnotated;

            if (annotatedType == null)
            {
                return(null);
            }

            if (annotatedType.Annotation == null)
            {
                return(null);
            }

            // create the comments and add them to the hash table under the namespace of the object
            CreateComments(annotatedType);

            //mainNamespace.Types.

            return(null);
        }
Ejemplo n.º 15
0
        private TypeModel CreateTypeModel(Uri source, XmlSchemaAnnotated type, XmlQualifiedName qualifiedName)
        {
            var key = BuildKey(type, qualifiedName);

            if (!qualifiedName.IsEmpty && Types.TryGetValue(key, out TypeModel typeModel))
            {
                return(typeModel);
            }

            var namespaceModel = CreateNamespaceModel(source, qualifiedName);
            var docs           = GetDocumentation(type);

            if (type is XmlSchemaGroup group)
            {
                return(CreateTypeModel(source, group, namespaceModel, qualifiedName, docs));
            }
            else if (type is XmlSchemaAttributeGroup attributeGroup)
            {
                return(CreateTypeModel(source, attributeGroup, namespaceModel, qualifiedName, docs));
            }
            else if (type is XmlSchemaComplexType complexType)
            {
                return(CreateTypeModel(source, complexType, namespaceModel, qualifiedName, docs));
            }
            else if (type is XmlSchemaSimpleType simpleType)
            {
                return(CreateTypeModel(simpleType, namespaceModel, qualifiedName, docs));
            }

            throw new NotSupportedException($"Cannot build declaration for {qualifiedName}");
        }
        internal XSAttributeGroupDefinition(XmlSchemaAttributeGroup xmlAttributeGroup)
            : this()
        {
            _attributeGroup = xmlAttributeGroup;
            _name           = xmlAttributeGroup.Name;

            if (_attributeGroup.Annotation is XmlSchemaAnnotation annotation)
            {
                _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation);
                _annotation.BindToContainer(RootContainer, this);
            }

            if (xmlAttributeGroup.AnyAttribute is XmlSchemaAnyAttribute xmlAnyAttribute)
            {
                _wildcard = XMLSchemaSerializer.CreateXSWildcard(xmlAnyAttribute);
            }

            Content.Inserted -= Content_Inserted;
            foreach (XmlSchemaObject item in xmlAttributeGroup.Attributes)
            {
                IXSComponent component = XMLSchemaSerializer.CreateInstance(item);
                component.BindToContainer(RootContainer, this);
                Content.Add(component);
                Components.Add(component);
            }
            Content.Inserted += Content_Inserted;
        }
Ejemplo n.º 17
0
        private static void UpdatePropertyFormatInfo(XmlSchemaAnnotated schemaItem, SampleProperty sampleProperty)
        {
            XmlAttribute[] unhandledAttributes  = schemaItem.UnhandledAttributes;
            string         blendAttributeValue1 = SampleDataXsdParser.GetBlendAttributeValue(unhandledAttributes, SampleProperty.FormatAttribute);
            string         blendAttributeValue2 = SampleDataXsdParser.GetBlendAttributeValue(unhandledAttributes, SampleProperty.FormatParametersAttribute);

            sampleProperty.ChangeFormat(blendAttributeValue1, blendAttributeValue2);
        }
Ejemplo n.º 18
0
 internal static SignatureDate ReadAppInfoAsSigunatureDate(this XmlSchemaAnnotated annotated, string nodeName, string user, string dateTime)
 {
     return(new SignatureDate()
     {
         ID = annotated.ReadAppInfoAsString(nodeName, user) ?? string.Empty,
         DateTime = annotated.ReadAppInfoAsDateTime(nodeName, dateTime, XmlDateTimeSerializationMode.Utc),
     });
 }
        private XSAttributeGroupDefinition()
        {
            _attributeGroup = new XmlSchemaAttributeGroup();

            Components        = new XSComponentFixedList();
            Content           = new XSComponentList();
            Content.Inserted += Content_Inserted;
            Content.Cleared  += Content_Cleared;
        }
Ejemplo n.º 20
0
 private void ReadColumnInfo(XmlSchemaAnnotated annotated, CremaDataColumn dataColumn)
 {
     dataColumn.InternalCreationInfo     = annotated.ReadAppInfoAsSigunatureDate(CremaSchema.ColumnInfo, CremaSchema.Creator, CremaSchema.CreatedDateTime);
     dataColumn.InternalModificationInfo = annotated.ReadAppInfoAsSigunatureDate(CremaSchema.ColumnInfo, CremaSchema.Modifier, CremaSchema.ModifiedDateTime);
     dataColumn.InternalAutoIncrement    = annotated.ReadAppInfoAsBoolean(CremaSchema.ColumnInfo, CremaSchema.AutoIncrement);
     dataColumn.InternalColumnID         = annotated.ReadAppInfoAsGuid(CremaSchema.ColumnInfo, CremaSchema.ID);
     dataColumn.InternalTags             = annotated.ReadAppInfoAsTagInfo(CremaSchema.ColumnInfo, CremaSchema.Tags);
     dataColumn.InternalReadOnly         = annotated.ReadAppInfoAsBoolean(CremaSchema.ColumnInfo, CremaSchema.ReadOnly);
 }
Ejemplo n.º 21
0
        internal static void WriteAppInfo(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, string value, string ns, string defaultValue)
        {
            if (value == defaultValue || string.IsNullOrEmpty(value) == true)
            {
                return;
            }

            if (annotated.Annotation == null)
            {
                annotated.Annotation = new XmlSchemaAnnotation();
            }

            var annotation = annotated.Annotation;
            {
                XmlSchemaAppInfo appInfo = null;

                foreach (XmlSchemaObject item in annotation.Items)
                {
                    if (item is XmlSchemaAppInfo == true)
                    {
                        appInfo = item as XmlSchemaAppInfo;
                        break;
                    }
                }

                if (appInfo == null)
                {
                    appInfo = new XmlSchemaAppInfo();
                    annotation.Items.Add(appInfo);
                }

                var doc  = new XmlDocument();
                var root = doc.CreateElement("root", ns);
                doc.AppendChild(root);
                var element   = doc.CreateElement(nodeName, ns);
                var valueAttr = doc.CreateAttribute(attributeName);
                valueAttr.Value = value as string;
                element.Attributes.Append(valueAttr);

                doc.DocumentElement.AppendChild(element);

                if (appInfo.Markup == null)
                {
                    appInfo.Markup = new XmlNode[1] {
                        element
                    };
                }
                else
                {
                    var nodes = new XmlNode[appInfo.Markup.Length + 1];
                    appInfo.Markup.CopyTo(nodes, 0);
                    nodes[appInfo.Markup.Length] = element;
                    appInfo.Markup = nodes;
                }
            }
        }
Ejemplo n.º 22
0
        void AddAnnotation(XmlSchemaAnnotated element, string value)
        {
            var annotation    = new XmlSchemaAnnotation();
            var documentation = new XmlSchemaDocumentation();
            var document      = new XmlDocument();

            documentation.Markup = new[] { document.CreateTextNode(value) };
            annotation.Items.Add(documentation);
            element.Annotation = annotation;
        }
Ejemplo n.º 23
0
        private void AddBinaryAttribute(string schemaNamespace, XmlSchemaAnnotated schemaElement)
        {
            addRequiredImport(schemaNamespace, NamespaceConstants.XMIME, null);

#if NETSTANDARD1_6_1
            schemaElement.UnhandledAttributes.Add(protocol.Style.CreateExpectedContentType("application/octet-stream"));
#else
            schemaElement.UnhandledAttributes = new[] { protocol.Style.CreateExpectedContentType("application/octet-stream") };
#endif
        }
Ejemplo n.º 24
0
        //[Obsolete("for 2.0")]
        internal static Guid ReadAppInfoAsGuidVersion2(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, string nameToGenerate)
        {
            var text = ReadAppInfoAsString(annotated, nodeName, attributeName);

            if (string.IsNullOrEmpty(text) == true)
            {
                return(GuidUtility.FromName(nameToGenerate));
            }
            return(Guid.Parse(text));
        }
Ejemplo n.º 25
0
        internal static long ReadAppInfoComfortableAsInt64(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, params string[] comfortableNames)
        {
            var text = ReadAppInfoComfortableAsString(annotated, nodeName, attributeName, comfortableNames);

            if (string.IsNullOrEmpty(text) == true)
            {
                return(0);
            }
            return(long.Parse(text));
        }
Ejemplo n.º 26
0
        internal static TagInfo ReadAppInfoAsTagInfo(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, TagInfo defaultValue)
        {
            var text = ReadAppInfoAsString(annotated, nodeName, attributeName);

            if (text == null)
            {
                return(defaultValue);
            }
            return((TagInfo)text);
        }
Ejemplo n.º 27
0
        internal static Guid ReadAppInfoAsGuid(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, Guid defaultValue)
        {
            var text = ReadAppInfoAsString(annotated, nodeName, attributeName);

            if (text == null)
            {
                return(defaultValue);
            }
            return(CremaXmlConvert.ToGuid(text));
        }
Ejemplo n.º 28
0
        internal static DateTime ReadAppInfoAsDateTime(this XmlSchemaAnnotated annotated, string nodeName, string attributeName, XmlDateTimeSerializationMode mode, DateTime defaultValue)
        {
            var text = ReadAppInfoAsString(annotated, nodeName, attributeName);

            if (text == null)
            {
                return(defaultValue);
            }
            return(CremaXmlConvert.ToDateTime(text, mode));
        }
Ejemplo n.º 29
0
        public static void AddAnnotation(this XmlSchemaAnnotated annotatedType, Type type, ConfigurationPropertyAttribute configProperty)
        {
            annotatedType.Annotation = new XmlSchemaAnnotation();

            //  human documentation
            var descriptionAtts  = TypeParser.GetAttributes <DescriptionAttribute>(type);
            var xmlDocumentation = type.GetXmlDocumentation();
            var typeName         = type.FullName;

            ApplyAnnotation(annotatedType, descriptionAtts, configProperty, xmlDocumentation, typeName, typeName);
        }
Ejemplo n.º 30
0
        /// <summary>
        ///     Provides standard documentation for a type in the form of XmlSchemaDocumentation objects
        /// </summary>
        public static void AddAnnotation(this XmlSchemaAnnotated annotatedType, PropertyInfo property, ConfigurationPropertyAttribute configProperty)
        {
            annotatedType.Annotation = new XmlSchemaAnnotation();

            //  human documentation
            var descriptionAtts  = TypeParser.GetAttributes <DescriptionAttribute>(property);
            var xmlDocumentation = property.GetXmlDocumentation();
            var fullName         = property.PropertyType.FullName;
            var typeName         = String.Format("{0}{1}", property.DeclaringType.FullName, property.Name);

            ApplyAnnotation(annotatedType, descriptionAtts, configProperty, xmlDocumentation, typeName, fullName);
        }