ModifyPoolResourcesByPath(
            ManagementScope scope,
            ManagementObject rPConfigurationService,
            string resourceType,
            string resourceSubType,
            string poolPath,
            string[] parentPoolIdArray,
            string[][] parentHostResourcesArray)
        {
            if (parentPoolIdArray.Length == 0)
            {
                throw new ManagementException(string.Format(
                                                  CultureInfo.CurrentCulture,
                                                  @"At least one parent pool must be specified when modifying a 
                    resource pool's host resources (poolPath ""{0}"")", poolPath));
            }

            if (parentPoolIdArray.Length != parentHostResourcesArray.Length)
            {
                throw new ManagementException(string.Format(
                                                  CultureInfo.CurrentCulture,
                                                  @"When modifying a child resource pool's host resources, a host 
                    resource must be specified for each parent pool. Shared allocations 
                    are not supported (poolPath ""{0}"")",
                                                  poolPath));
            }

            string[] parentPoolPathArray =
                ResourcePoolUtilities.GetParentPoolArrayFromPoolIds(
                    scope,
                    resourceType,
                    resourceSubType,
                    parentPoolIdArray);

            string[] resourceAllocationSettingDataArray =
                MsvmResourceAllocationSettingData.GetNewPoolAllocationSettingsArray(
                    scope,
                    resourceType,
                    resourceSubType,
                    parentPoolIdArray,
                    parentHostResourcesArray);

            using (ManagementBaseObject inParams =
                       rPConfigurationService.GetMethodParameters(
                           "ModifyPoolResources"))
            {
                inParams["ChildPool"]          = poolPath;
                inParams["ParentPools"]        = parentPoolPathArray;
                inParams["AllocationSettings"] = resourceAllocationSettingDataArray;

                using (ManagementBaseObject outParams =
                           rPConfigurationService.InvokeMethod(
                               "ModifyPoolResources",
                               inParams,
                               null))
                {
                    WmiUtilities.ValidateOutput(outParams, scope, true, true);
                }
            }
        }
        CreatePoolHelper(
            ManagementScope scope,
            ManagementObject rPConfigurationService,
            string resourceType,
            string resourceSubType,
            string childPoolId,
            string childPoolName,
            string[] parentPoolIdArray,
            string[][] parentHostResourcesArray)
        {
            if (parentPoolIdArray.Length == 0)
            {
                throw new ManagementException(string.Format(
                                                  CultureInfo.CurrentCulture,
                                                  @"At least one parent pool must be specified when creating a 
                    child resource pool (PoolId ""{0}"")", childPoolId));
            }

            if (parentPoolIdArray.Length != parentHostResourcesArray.Length)
            {
                throw new ManagementException(string.Format(
                                                  CultureInfo.CurrentCulture,
                                                  @"When creating a child resource pool, a host resource must be 
                    specified for each parent pool. Shared allocations are not 
                    supported (PoolId ""{0}"")", childPoolId));
            }

            string resourcePoolSettingData =
                MsvmResourcePoolSettingData.GetSettingsForPool(
                    scope,
                    resourceType,
                    resourceSubType,
                    childPoolId,
                    childPoolName);

            string[] parentPoolPathArray =
                ResourcePoolUtilities.GetParentPoolArrayFromPoolIds(
                    scope,
                    resourceType,
                    resourceSubType,
                    parentPoolIdArray);

            string[] resourceAllocationSettingDataArray =
                MsvmResourceAllocationSettingData.GetNewPoolAllocationSettingsArray(
                    scope,
                    resourceType,
                    resourceSubType,
                    parentPoolIdArray,
                    parentHostResourcesArray);

            using (ManagementBaseObject inParams =
                       rPConfigurationService.GetMethodParameters(
                           "CreatePool"))
            {
                inParams["PoolSettings"]       = resourcePoolSettingData;
                inParams["ParentPools"]        = parentPoolPathArray;
                inParams["AllocationSettings"] = resourceAllocationSettingDataArray;

                using (ManagementBaseObject outParams =
                           rPConfigurationService.InvokeMethod(
                               "CreatePool",
                               inParams,
                               null))
                {
                    if (WmiUtilities.ValidateOutput(outParams, scope, true, true))
                    {
                        string poolPath = outParams["Pool"].ToString();

                        return(new ManagementObject(
                                   scope,
                                   new ManagementPath(poolPath),
                                   null));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }