Beispiel #1
0
        internal static ManagementScope _Clone(ManagementScope scope, IdentifierChangedEventHandler handler)
        {
            ManagementScope scopeTmp = new ManagementScope(null, null, null, null);

            // Wire up change handler chain. Use supplied handler, if specified;
            // otherwise, default to that of the scope argument.
            if (handler != null)
            {
                scopeTmp.IdentifierChanged = handler;
            }
            else if (scope != null)
            {
                scopeTmp.IdentifierChanged = new IdentifierChangedEventHandler(scope.HandleIdentifierChange);
            }

            // Set scope path.
            if (scope == null)
            {
                // No path specified. Default.
                scopeTmp.prvpath     = ManagementPath._Clone(ManagementPath.DefaultPath, new IdentifierChangedEventHandler(scopeTmp.HandleIdentifierChange));
                scopeTmp.IsDefaulted = true;

                scopeTmp.wbemServices = null;
                scopeTmp.options      = null;
//				scopeTmp.securityHelper = null;					// BUGBUG : should this allocate a new object?
            }
            else
            {
                if (scope.prvpath == null)
                {
                    // No path specified. Default.
                    scopeTmp.prvpath     = ManagementPath._Clone(ManagementPath.DefaultPath, new IdentifierChangedEventHandler(scopeTmp.HandleIdentifierChange));
                    scopeTmp.IsDefaulted = true;
                }
                else
                {
                    // Use scope-supplied path.
                    scopeTmp.prvpath     = ManagementPath._Clone(scope.prvpath, new IdentifierChangedEventHandler(scopeTmp.HandleIdentifierChange));
                    scopeTmp.IsDefaulted = scope.IsDefaulted;
                }

                scopeTmp.wbemServices = scope.wbemServices;
                if (scope.options != null)
                {
                    scopeTmp.options = ConnectionOptions._Clone(scope.options, new IdentifierChangedEventHandler(scopeTmp.HandleIdentifierChange));
                }
//				scopeTmp.securityHelper = scope.securityHelper;	// BUGBUG : should this allocate a new one?
            }

            return(scopeTmp);
        }
Beispiel #2
0
        internal static ManagementScope _Clone(ManagementScope scope, IdentifierChangedEventHandler handler)
        {
            ManagementScope managementScope = new ManagementScope(null, null, null);

            if (handler == null)
            {
                if (scope != null)
                {
                    managementScope.IdentifierChanged = new IdentifierChangedEventHandler(scope.HandleIdentifierChange);
                }
            }
            else
            {
                managementScope.IdentifierChanged = handler;
            }
            if (scope != null)
            {
                if (scope.prvpath != null)
                {
                    managementScope.prvpath     = ManagementPath._Clone(scope.prvpath, new IdentifierChangedEventHandler(managementScope.HandleIdentifierChange));
                    managementScope.IsDefaulted = scope.IsDefaulted;
                }
                else
                {
                    managementScope.prvpath     = ManagementPath._Clone(ManagementPath.DefaultPath, new IdentifierChangedEventHandler(managementScope.HandleIdentifierChange));
                    managementScope.IsDefaulted = true;
                }
                managementScope.wbemServices = scope.wbemServices;
                if (scope.options != null)
                {
                    managementScope.options = ConnectionOptions._Clone(scope.options, new IdentifierChangedEventHandler(managementScope.HandleIdentifierChange));
                }
            }
            else
            {
                managementScope.prvpath      = ManagementPath._Clone(ManagementPath.DefaultPath, new IdentifierChangedEventHandler(managementScope.HandleIdentifierChange));
                managementScope.IsDefaulted  = true;
                managementScope.wbemServices = null;
                managementScope.options      = null;
            }
            return(managementScope);
        }
Beispiel #3
0
 public ManagementScope(ManagementPath path, ConnectionOptions options)
 {
     if (path != null)
     {
         this.prvpath = ManagementPath._Clone(path, new IdentifierChangedEventHandler(this.HandleIdentifierChange));
     }
     else
     {
         this.prvpath = ManagementPath._Clone(null);
     }
     if (options != null)
     {
         this.options = ConnectionOptions._Clone(options, new IdentifierChangedEventHandler(this.HandleIdentifierChange));
     }
     else
     {
         this.options = null;
     }
     this.IsDefaulted = false;
 }
Beispiel #4
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref='System.Management.ManagementScope'/> class representing the specified scope path,
        ///    with the specified options.</para>
        /// </summary>
        /// <param name='path'>A <see cref='System.Management.ManagementPath'/> containing the path to the server and namespace for the <see cref='System.Management.ManagementScope'/>.</param>
        /// <param name=' options'>The <see cref='System.Management.ConnectionOptions'/> containing options for the connection.</param>
        /// <example>
        ///    <code lang='C#'>ConnectionOptions opt = new ConnectionOptions();
        /// opt.Username = UserName;
        /// opt.Password = SecurelyStoredPassword;
        ///
        /// ManagementPath p = new ManagementPath("\\\\MyServer\\root\\default");
        /// ManagementScope = new ManagementScope(p, opt);
        ///    </code>
        ///    <code lang='VB'>Dim opt As New ConnectionOptions()
        /// opt.UserName = UserName
        /// opt.Password = SecurelyStoredPassword
        ///
        /// Dim p As New ManagementPath("\\MyServer\root\default")
        /// Dim s As New ManagementScope(p, opt)
        ///    </code>
        /// </example>
        public ManagementScope(ManagementPath path, ConnectionOptions options)
        {
            if (null != path)
            {
                this.prvpath = ManagementPath._Clone(path, new IdentifierChangedEventHandler(HandleIdentifierChange));
            }
            else
            {
                this.prvpath = ManagementPath._Clone(null);
            }

            if (null != options)
            {
                this.options = ConnectionOptions._Clone(options, new IdentifierChangedEventHandler(HandleIdentifierChange));
            }
            else
            {
                this.options = null;
            }

            IsDefaulted = false;             //assume that this scope is not initialized by the default path
        }
Beispiel #5
0
 internal static ConnectionOptions _Clone(ConnectionOptions options)
 {
     return(ConnectionOptions._Clone(options, null));
 }