public static bool GetYesOrNoAsBool(this ObjVerEx targetEx, MFIdentifier prop, out bool value) { value = false; // if the object doesn't have the property, return null if (!targetEx.HasProperty(prop)) { return(false); } // get the text version of the property var propText = targetEx.GetPropertyText(prop); // if the text version of the property is "Yes", return true if (propText.Equals("Yes")) { value = true; return(true); } // if the text version of the property is "No", return false if (propText.Equals("No")) { value = false; return(true); } // couldn't parse the text value, return null return(false); }
public static DateTime GetProperyDateTimeValue(this ObjVerEx objVerEx, int id) { if (objVerEx.HasProperty(id)) { PropertyValue pv = objVerEx.GetProperty(id); if (!pv.Value.IsNULL()) { return((DateTime)objVerEx.GetProperty(id).Value.Value); } } return(DateTime.MinValue); }
public static int GetPropertyIntValue(this ObjVerEx objVerEx, int id) { if (objVerEx.HasProperty(id)) { PropertyValue pv = objVerEx.GetProperty(id); if (!pv.Value.IsNULL()) { return((int)objVerEx.GetProperty(id).Value.Value); } } return(0); }
public static double GetPropertyDoubleValue(this ObjVerEx objVerEx, int id) { if (objVerEx.HasProperty(id)) { PropertyValue pv = objVerEx.GetProperty(id); if (!pv.Value.IsNULL()) { return((double)objVerEx.GetProperty(id).Value.Value); } } return(0.0); }
public static bool?GetPropertyBooleanValue(this ObjVerEx objVerEx, int id) { if (objVerEx.HasProperty(id)) { PropertyValue pv = objVerEx.GetProperty(id); if (!pv.Value.IsNULL()) { return((bool)objVerEx.GetProperty(id).Value.Value); } } return(null); }
public static bool GetDouble(this ObjVerEx targetEx, MFIdentifier prop, out double value) { // set default value value = 0.0; // check if the property exists on the target if (!targetEx.HasProperty(prop)) { return(false); } // attempt to get the text value of the property var text = targetEx.GetPropertyText(prop); // attempt to parse it return(double.TryParse(text, out value)); }
public static T?GetSingleSelectValueListForPropertyDef <T>(this ObjVerEx objVerEx, int id) where T : struct { if (!typeof(T).IsEnum || !objVerEx.HasProperty(id)) { return(default(T)); } PropertyValue prop = objVerEx.GetProperty(id); if (prop == null) { return(null); } Lookup lookup = prop.Value.GetValueAsLookup(); if (lookup == null || lookup.Deleted) { return(null); } return((T)Enum.Parse(typeof(T), lookup.Item.ToString())); }