Exemplo n.º 1
0
 /// <summary>
 /// Gets the schema information that has been assigned to the <see cref="XAttribute"/> as a result of schema validation.
 /// </summary>
 /// <param name="source">Extension point</param>
 public static IXmlSchemaInfo?GetSchemaInfo(this XAttribute source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(source.Annotation <IXmlSchemaInfo>());
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Dump out an attribute.
        /// </summary>
        /// <param name="attribute">
        ///     The target attribute.
        /// </param>
        /// <param name="depth">
        ///     The current element depth.
        /// </param>
        static void DumpAttribute(XAttribute attribute, int depth)
        {
            AttributeLocation location = attribute.Annotation <AttributeLocation>();

            Log.Information("{Indent}@{Name}='{Value}' ({StartLine},{StartColumn}) to ({EndLine},{EndColumn})",
                            new String(' ', depth * 4 + 4 /* Extra indent for attributes */),
                            attribute.Name,
                            attribute.Value,
                            location.Start.LineNumber, location.Start.ColumnNumber,
                            location.End.LineNumber, location.End.ColumnNumber
                            );
        }
Exemplo n.º 3
0
        private string EvaluateOrderKey(XAttribute attribute, BxlGeneratorOptions options)
        {
            var oa = attribute.Annotation <OrderAnnotation>();

            if (null != oa)
            {
                return(oa.Value);
            }
            var name        = attribute.Name.LocalName;
            var inlineorder = 1;

            if (options.InlineAttributesByDefault)
            {
                inlineorder = 0;
            }
            if (-1 != Array.IndexOf(options.InlineAlwaysAttributes, name))
            {
                inlineorder = 0;
            }
            if (-1 != Array.IndexOf(options.NewlineAlwaysAttributes, name))
            {
                inlineorder = 0;
            }
            var grouporder = Array.IndexOf(options.FirstPlaceAttributes, name);

            if (-1 == grouporder)
            {
                grouporder = 99;
            }

            var result = string.Format("{0:00}{1:00}{2}", inlineorder, grouporder, name.ToUpper());

            oa = new OrderAnnotation {
                Value = result
            };
            attribute.AddAnnotation(oa);
            return(result);
        }
Exemplo n.º 4
0
 public static IXmlSchemaInfo GetSchemaInfo(this XAttribute attribute)
 {
     return(attribute.Annotation <IXmlSchemaInfo> ());
 }
Exemplo n.º 5
0
 public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List <XAttribute> attributes, XElement e)
 {
     checked
     {
         if (e != null)
         {
             XAttribute xAttribute = e.FirstAttribute;
             while (xAttribute != null)
             {
                 XAttribute nextAttribute = xAttribute.NextAttribute;
                 if (xAttribute.IsNamespaceDeclaration)
                 {
                     XNamespace xNamespace = xAttribute.Annotation <XNamespace>();
                     string     localName  = xAttribute.Name.LocalName;
                     if ((object)xNamespace != null)
                     {
                         if ((inScopePrefixes != null && inScopeNs != null) ? true : false)
                         {
                             int num  = inScopePrefixes.Length - 1;
                             int num2 = num;
                             int num3 = 0;
                             while (true)
                             {
                                 int num4 = num3;
                                 int num5 = num2;
                                 if (num4 > num5)
                                 {
                                     break;
                                 }
                                 string     value = inScopePrefixes[num3];
                                 XNamespace right = inScopeNs[num3];
                                 if (localName.Equals(value))
                                 {
                                     if (xNamespace == right)
                                     {
                                         xAttribute.Remove();
                                     }
                                     xAttribute = null;
                                     break;
                                 }
                                 num3++;
                             }
                         }
                         if (xAttribute != null)
                         {
                             if (attributes != null)
                             {
                                 int num6 = attributes.Count - 1;
                                 int num7 = num6;
                                 int num8 = 0;
                                 while (true)
                                 {
                                     int num9 = num8;
                                     int num5 = num7;
                                     if (num9 > num5)
                                     {
                                         break;
                                     }
                                     XAttribute xAttribute2 = attributes[num8];
                                     string     localName2  = xAttribute2.Name.LocalName;
                                     XNamespace xNamespace2 = xAttribute2.Annotation <XNamespace>();
                                     if ((object)xNamespace2 != null && localName.Equals(localName2))
                                     {
                                         if (xNamespace == xNamespace2)
                                         {
                                             xAttribute.Remove();
                                         }
                                         xAttribute = null;
                                         break;
                                     }
                                     num8++;
                                 }
                             }
                             if (xAttribute != null)
                             {
                                 xAttribute.Remove();
                                 attributes.Add(xAttribute);
                             }
                         }
                     }
                 }
                 xAttribute = nextAttribute;
             }
         }
         return(e);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the schema information that has been assigned to the <see cref="XAttribute"/> as a result of schema validation.
        /// </summary>
        /// <param name="source">Extension point</param>
        public static IXmlSchemaInfo?GetSchemaInfo(this XAttribute source)
        {
            ArgumentNullException.ThrowIfNull(source);

            return(source.Annotation <IXmlSchemaInfo>());
        }
Exemplo n.º 7
0
 public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List <XAttribute> attributes, XElement e)
 {
     checked
     {
         if (e != null)
         {
             XAttribute nextAttribute;
             for (XAttribute xattribute = e.FirstAttribute; xattribute != null; xattribute = nextAttribute)
             {
                 nextAttribute = xattribute.NextAttribute;
                 if (xattribute.IsNamespaceDeclaration)
                 {
                     XNamespace xnamespace = xattribute.Annotation <XNamespace>();
                     string     localName  = xattribute.Name.LocalName;
                     if (xnamespace != null)
                     {
                         if (inScopePrefixes != null && inScopeNs != null)
                         {
                             int        num  = inScopePrefixes.Length - 1;
                             int        num2 = 0;
                             int        num3 = num;
                             int        num4 = num2;
                             XNamespace right;
                             for (;;)
                             {
                                 int num5 = num4;
                                 int num6 = num3;
                                 if (num5 > num6)
                                 {
                                     goto Block_8;
                                 }
                                 string value = inScopePrefixes[num4];
                                 right = inScopeNs[num4];
                                 if (localName.Equals(value))
                                 {
                                     break;
                                 }
                                 num4++;
                             }
                             if (xnamespace == right)
                             {
                                 xattribute.Remove();
                             }
                             xattribute = null;
                             Block_8 :;
                         }
                         if (xattribute != null)
                         {
                             if (attributes != null)
                             {
                                 int        num7  = attributes.Count - 1;
                                 int        num8  = 0;
                                 int        num9  = num7;
                                 int        num10 = num8;
                                 XNamespace xnamespace2;
                                 for (;;)
                                 {
                                     int num11 = num10;
                                     int num6  = num9;
                                     if (num11 > num6)
                                     {
                                         goto Block_13;
                                     }
                                     XAttribute xattribute2 = attributes[num10];
                                     string     localName2  = xattribute2.Name.LocalName;
                                     xnamespace2 = xattribute2.Annotation <XNamespace>();
                                     if (xnamespace2 != null && localName.Equals(localName2))
                                     {
                                         break;
                                     }
                                     num10++;
                                 }
                                 if (xnamespace == xnamespace2)
                                 {
                                     xattribute.Remove();
                                 }
                                 xattribute = null;
                                 Block_13 :;
                             }
                             if (xattribute != null)
                             {
                                 xattribute.Remove();
                                 attributes.Add(xattribute);
                             }
                         }
                     }
                 }
             }
         }
         return(e);
     }
 }