// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.My.InternalXmlHelper
// Assembly: SE0085CTdB, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
// MVID: F67560B6-58CB-4471-AAC9-80007CA3AF52
// Assembly location: C:\Users\Abishek\Downloads\SchneiderCode_Breaker_09292016\Breaker Schedule-20160930T014118Z\Breaker Schedule\Solution for gathering Breaker Data\DMS\bin\Debug\SE0085CTdB.dll

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Xml.Linq;

namespace SE0085.CTdB.My
{
  [EditorBrowsable(EditorBrowsableState.Never)]
  [CompilerGenerated]
  [DebuggerNonUserCode]
  internal sealed class InternalXmlHelper
  {
    [EditorBrowsable(EditorBrowsableState.Never)]
    private InternalXmlHelper()
    {
    }

    public static string get_Value(IEnumerable<XElement> source)
    {
      IEnumerator<XElement> enumerator;
      try
      {
        enumerator = source.GetEnumerator();
        if (enumerator.MoveNext())
          return enumerator.Current.Value;
      }
      finally
      {
        if (enumerator != null)
          enumerator.Dispose();
      }
      return (string) null;
    }

    public static void set_Value(IEnumerable<XElement> source, string value)
    {
      IEnumerator<XElement> enumerator;
      try
      {
        enumerator = source.GetEnumerator();
        if (!enumerator.MoveNext())
          return;
        enumerator.Current.Value = value;
      }
      finally
      {
        if (enumerator != null)
          enumerator.Dispose();
      }
    }

    public static string get_AttributeValue(IEnumerable<XElement> source, XName name)
    {
      IEnumerator<XElement> enumerator;
      try
      {
        enumerator = source.GetEnumerator();
        if (enumerator.MoveNext())
          return (string) enumerator.Current.Attribute(name);
      }
      finally
      {
        if (enumerator != null)
          enumerator.Dispose();
      }
      return (string) null;
    }

    public static void set_AttributeValue(IEnumerable<XElement> source, XName name, string value)
    {
      IEnumerator<XElement> enumerator;
      try
      {
        enumerator = source.GetEnumerator();
        if (!enumerator.MoveNext())
          return;
        enumerator.Current.SetAttributeValue(name, (object) value);
      }
      finally
      {
        if (enumerator != null)
          enumerator.Dispose();
      }
    }

    public static string get_AttributeValue(XElement source, XName name)
    {
      return (string) source.Attribute(name);
    }

    public static void set_AttributeValue(XElement source, XName name, string value)
    {
      source.SetAttributeValue(name, (object) value);
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public static XAttribute CreateAttribute(XName name, object value)
    {
      if (value == null)
        return (XAttribute) null;
      return new XAttribute(name, RuntimeHelpers.GetObjectValue(value));
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns)
    {
      XAttribute xattribute = new XAttribute(name, (object) ns.NamespaceName);
      xattribute.AddAnnotation((object) ns);
      return xattribute;
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, object obj)
    {
      if (obj != null)
      {
        XElement e = obj as XElement;
        if (e != null)
        {
          // ISSUE: reference to a compiler-generated method
          return (object) InternalXmlHelper.RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, e);
        }
        IEnumerable enumerable = obj as IEnumerable;
        if (enumerable != null)
        {
          // ISSUE: reference to a compiler-generated method
          return (object) InternalXmlHelper.RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, enumerable);
        }
      }
      return obj;
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, IEnumerable obj)
    {
      if (obj == null)
        return obj;
      IEnumerable<XElement> xelements1 = obj as IEnumerable<XElement>;
      if (xelements1 != null)
      {
        IEnumerable<XElement> xelements2 = xelements1;
        // ISSUE: object of a compiler-generated type is created
        // ISSUE: variable of a compiler-generated type
        InternalXmlHelper.RemoveNamespaceAttributesClosure attributesClosure = new InternalXmlHelper.RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes);
        // ISSUE: virtual method pointer
        IntPtr num = __vmethodptr(attributesClosure, ProcessXElement);
        Func<XElement, XElement> func = new Func<XElement, XElement>((object) attributesClosure, num);
        return (IEnumerable) Enumerable.Select<XElement, XElement>((IEnumerable<M0>) xelements2, (Func<M0, M1>) func);
      }
      IEnumerable<object> objects = obj.Cast<object>();
      // ISSUE: object of a compiler-generated type is created
      // ISSUE: variable of a compiler-generated type
      InternalXmlHelper.RemoveNamespaceAttributesClosure attributesClosure1 = new InternalXmlHelper.RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes);
      // ISSUE: virtual method pointer
      IntPtr num1 = __vmethodptr(attributesClosure1, ProcessObject);
      Func<object, object> func1 = new Func<object, object>((object) attributesClosure1, num1);
      return (IEnumerable) Enumerable.Select<object, object>((IEnumerable<M0>) objects, (Func<M0, M1>) func1);
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, XElement e)
    {
      XAttribute nextAttribute;
      if (e != null)
      {
        for (XAttribute xattribute = e.FirstAttribute; xattribute != null; xattribute = nextAttribute)
        {
          nextAttribute = xattribute.NextAttribute;
          if (xattribute.IsNamespaceDeclaration)
          {
            XNamespace xnamespace1 = xattribute.Annotation<XNamespace>();
            string localName1 = xattribute.Name.LocalName;
            if ((object) xnamespace1 != null)
            {
              if (inScopePrefixes != null && inScopeNs != null)
              {
                int num1 = checked (inScopePrefixes.Length - 1);
                int num2 = 0;
                int num3 = num1;
                int index = num2;
                while (index <= num3)
                {
                  string inScopePrefix = inScopePrefixes[index];
                  XNamespace inScopeN = inScopeNs[index];
                  if (localName1.Equals(inScopePrefix))
                  {
                    if (xnamespace1 == inScopeN)
                      xattribute.Remove();
                    xattribute = (XAttribute) null;
                    break;
                  }
                  checked { ++index; }
                }
              }
              if (xattribute != null)
              {
                if (attributes != null)
                {
                  int num1 = checked (attributes.Count - 1);
                  int num2 = 0;
                  int num3 = num1;
                  int index = num2;
                  while (index <= num3)
                  {
                    XAttribute attribute = attributes[index];
                    string localName2 = attribute.Name.LocalName;
                    XNamespace xnamespace2 = attribute.Annotation<XNamespace>();
                    if ((object) xnamespace2 != null && localName1.Equals(localName2))
                    {
                      if (xnamespace1 == xnamespace2)
                        xattribute.Remove();
                      xattribute = (XAttribute) null;
                      break;
                    }
                    checked { ++index; }
                  }
                }
                if (xattribute != null)
                {
                  xattribute.Remove();
                  attributes.Add(xattribute);
                }
              }
            }
          }
        }
      }
      return e;
    }
  }
}
