Amido.SystemEx.Xml.Linq.XElementExtensions.SafeGetIntFromAttribute C# (CSharp) Метод

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

public static SafeGetIntFromAttribute ( System.Xml.Linq.XElement element, string attributeName ) : int
element System.Xml.Linq.XElement
attributeName string
Результат int
        public static int SafeGetIntFromAttribute(XElement element, string attributeName)
        {
            XAttribute a = GetAttribute(element, attributeName);

            int result;

            if (!int.TryParse(a.Value, out result))
            {
                throw new InvalidOperationException(string.Format("Integer not found in attribute {0} on element {1}", attributeName, element.Name));
            }

            return result;
        }

Same methods

XElementExtensions::SafeGetIntFromAttribute ( System.Xml.Linq.XElement element, string elementName, string attributeName ) : int