Cilador.Fody.Core.ModuleWeaver.ReadCiladorConfig C# (CSharp) Метод

ReadCiladorConfig() публичный статический Метод

Deserializes a CiladorConfigType from within a config. XElement
The configuration type, CiladorConfigType, is primarily generated from WeaveConfig.xsd.
public static ReadCiladorConfig ( System.Xml.Linq.XElement config ) : CiladorConfigType
config System.Xml.Linq.XElement Item that contains the serialized config element.
Результат CiladorConfigType
        public static CiladorConfigType ReadCiladorConfig(XElement config)
        {
            Contract.Requires(config != null);
            Contract.Ensures(Contract.Result<CiladorConfigType>() != null);

            var childElements = config.Elements();
            var children = childElements as XElement[] ?? childElements.ToArray();
            if (children.Count() != 1)
            {
                throw new WeavingException("Cilador config in FodyWeavers.xml should have exactly one child");
            }

            var firstChild = children.First();
            if (firstChild.Name.NamespaceName != "urn:Cilador:Fody:Config" ||
                firstChild.Name.LocalName != "CiladorConfig")
            {
                throw new WeavingException("Child of Cilador config in FodyWeavers.xml should be CiladorConfig in namespace urn:Cilador:Fody:Config");
            }

            CiladorConfigType deserializedConfig;
            try
            {
                deserializedConfig = firstChild.FromXElement<CiladorConfigType>();
            }
            catch (Exception e)
            {
                throw new WeavingException(
                    "Element urn:Cilador:Fody:Config:CiladorConfig in FodyWeavers.xml could not be deserialized into type of CiladorConfigType",
                    e);
            }

            return deserializedConfig;
        }