Ejemplo n.º 1
0
        public override Object GetValue(Object component)
        {
            CimType CimType = prop.Type;

            if (prop == null)
            {
                return(null);
            }


            //handle embedded objects and array of embedded objects
            if (CimType == CimType.Object)
            {
                return(null);                   //disabled for Beta1: too many problems
                //throw new Exception("Displaying embedded objects is not supported in Beta1");
            }


            if (prop.Value == null)
            {
                if (prop.IsArray)
                {
                    return(Array.CreateInstance(CimTypeMapper.ToType(CimType, false, prop), 0));
                }
                return(null);
            }

            //handle datetimes, intervals and arrays of datetimes and intervals
            if (CimType == CimType.DateTime)
            {
                if (WmiHelper.IsInterval(prop))
                {
                    if (prop.IsArray)
                    {
                        string[]   strAr = (string[])prop.Value;
                        TimeSpan[] retAr = new TimeSpan[strAr.Length];
                        for (int i = 0; i < strAr.Length; i++)
                        {
                            retAr[i] = WmiHelper.ToTimeSpan(strAr[i]);
                        }
                        return(retAr);
                    }
                    else
                    {
                        return(WmiHelper.ToTimeSpan(prop.Value.ToString()));
                    }
                }
                else
                {
                    if (prop.IsArray)
                    {
                        string[]   strAr = (string[])prop.Value;
                        DateTime[] retAr = new DateTime[strAr.Length];
                        for (int i = 0; i < strAr.Length; i++)
                        {
                            retAr[i] = WmiHelper.ToDateTime(strAr[i]);
                        }
                        return(retAr);
                    }
                    else
                    {
                        return(WmiHelper.ToDateTime(prop.Value.ToString()));
                    }
                }
            }

            return(prop.Value);
        }