Exemple #1
0
        public static IBUEstimateType GetXmlIbuEstimateType(string ibuString, string name, IBUMethodType defaultIbuMethod)
        {
            string str = ibuString.Replace("IBU", null);

            decimal decVal;

            string strUnit = str.ParseOffUnits();
            IBUMethodType method = defaultIbuMethod;
            try
            {
                //	Rager, Tinseth, Garetz, Other
                if (!strUnit.IsNullOrEmpty())
                    method = (IBUMethodType) Enum.Parse(typeof (IBUMethodType), strUnit);
            }
            catch
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid IBUEstimateType '{0}' value or units is missing.", name)
                              	});
                return null;
            }
            if (!strUnit.IsNullOrEmpty())
                str = str.Replace(strUnit, null).Trim();

            if (str.IsNullOrEmpty() || !Decimal.TryParse(str, out decVal))
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid IBUEstimateType '{0}' value or units is missing.", name)
                              	});
                return null;
            }

            return new IBUEstimateType {method = method, Value = decVal};
        }
Exemple #2
0
 private static IBUEstimateType NewIBUEstimateType(decimal value, IBUMethodType ibuMethod)
 {
     return new IBUEstimateType
     {
         Value = value,
         method = ibuMethod
     };
 }
Exemple #3
0
        public static IBUEstimateType GetXmlIbuEstimateType(XElement xmlElement, string name, bool required,
            IBUMethodType defaultIbuMethod)
        {
            if (xmlElement.Element(name) == null)
            {
                if (required)
                    Messages.Add(new Message
                                  	{
                                  		Type = MessageType.Error,
                                  		Text = String.Format("Required IBUEstimateType element '{0}' is missing.", name)
                                  	});
                return null;
            }

            string str = xmlElement.Element(name).Value ?? String.Empty;
            if (str.IsNullOrEmpty())
            {
                Messages.Add(new Message
                              	{
                              		Type = MessageType.Error,
                              		Text = String.Format("Invalid IBUEstimateType '{0}' value or units is missing.", name)
                              	});
                return null;
            }

            return GetXmlIbuEstimateType(str, name, defaultIbuMethod);
        }