Пример #1
0
        T GetUXAttribute <T>(XElement elm, string name, T defaultValue)
        {
            var v = elm.Attributes()
                    .Where(x => x.Name.NamespaceName == Configuration.UXNamespace)
                    .Where(x => x.Name.LocalName == name).FirstOrDefault();

            if (v != null)
            {
                return((T)ValueMarshal.Parse(v.Value, typeof(T)));
            }
            else
            {
                return(defaultValue);
            }
        }
Пример #2
0
        object Parse(IXmlLineInfo attr, string value, DataType dt)
        {
            var cilType = UnoTypeToCilType(attr, dt);

            if (cilType == null)
            {
                Error(attr, "A value of type '" + dt.FullName + "' cannot be parsed");
            }

            try
            {
                return(ValueMarshal.Parse(value, cilType));
            }
            catch (Exception e)
            {
                Error(attr, "Failed to parse value of type '" + dt.FullName + "': " + e.Message);
            }

            return(null);
        }