public virtual string GetData() { return(data.GetData()); }
// //Methods // internal string GetPassword() { return(password.GetData()); }
/// <summary> /// Functionn to get ManagementClass object for the given class /// </summary> /// <param name="cls"> Management class object returned </param> /// <returns>bool value indicating the success of the method</returns> private static bool InitializeClassObject(out ManagementClass cls) { cls = null; //First try to connect to WMI and get the class object. // If it fails then no point in continuing try { ConnectionOptions ConOps = null; ManagementPath thePath = null; if (Username != string.Empty) { ConOps = new ConnectionOptions(); ConOps.Username = Username; ConOps.Password = password.GetData(); ConOps.Authority = Authority; } thePath = new ManagementPath(); thePath.Path = ClassName; if (thePath.NamespacePath == string.Empty || thePath.NamespacePath == "") { bool bRet = true; try { thePath.NamespacePath = WMINamespace; if (thePath.NamespacePath == "") { bRet = false; } } catch { bRet = false; } if (bRet == false) { Console.WriteLine(resMgr.GetString("invalidNamespace", curCulture) + " " + WMINamespace); return(false); } } else { WMINamespace = thePath.NamespacePath; } if (Server != String.Empty) { thePath.Server = Server; } ObjectGetOptions mgmtOptions = new ObjectGetOptions(); mgmtOptions.UseAmendedQualifiers = true; if (ConOps != null) { ManagementScope MgScope = new ManagementScope(thePath, ConOps); cls = new ManagementClass(MgScope, thePath, mgmtOptions); } else { cls = new ManagementClass(thePath, mgmtOptions); } // Get the object to check if the object is valid cls.Get(); // get the className if the path of the class is passed as argument ClassName = thePath.ClassName; return(true); } catch (ManagementException e) { if (e.ErrorCode == ManagementStatus.NotFound) { Console.WriteLine(resMgr.GetString("classNotFoundErr", curCulture)); return(false); } throw; } }