コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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()));
        }