public override void SetValue(Object component, Object val) { try { if (val == null || val == string.Empty || ((val.GetType().IsArray || val.GetType() == typeof(System.Array)) && ((Array)val).Length == 0)) { prop.Value = val; //Object obj = null; //prop.set_Value(ref obj); } if (val != null && (val.GetType().IsArray || val.GetType() == typeof(System.Array))) { if (((Array)val).GetValue(0).GetType() == typeof(DateTime)) { Array arDT = (Array)val; string[] strVal = new string[arDT.Length]; for (int i = 0; i < strVal.Length; i++) { strVal[i] = WmiHelper.ToDMTFTime((DateTime)arDT.GetValue(i)); } prop.Value = strVal; } else if (((Array)val).GetValue(0).GetType() == typeof(TimeSpan)) { Array arTS = (Array)val; string[] strVal = new string[arTS.Length]; for (int i = 0; i < strVal.Length; i++) { strVal[i] = WmiHelper.ToDMTFInterval((TimeSpan)arTS.GetValue(i)); } prop.Value = strVal; } else { prop.Value = (Array)val; } } if (val != null && !val.GetType().IsArray&& val.GetType() != typeof(System.Array)) { if (val.GetType() == typeof(DateTime)) { string dmtf = WmiHelper.ToDMTFTime((DateTime)val); prop.Value = dmtf; } else if (val.GetType() == typeof(TimeSpan)) { string dmtf = WmiHelper.ToDMTFInterval((TimeSpan)val); prop.Value = dmtf; } else { prop.Value = val; } } if (CommitImmediately) { PutOptions putOpts = new PutOptions(null, true, //use amended qualifiers PutType.UpdateOrCreate); mgmtObj.Put(putOpts); } } catch (Exception exc) { throw (exc); } }