当前位置: 首页>>代码示例>>C#>>正文


C# CmdletProviderContext.GetAccumulatedObjects方法代码示例

本文整理汇总了C#中System.Management.Automation.CmdletProviderContext.GetAccumulatedObjects方法的典型用法代码示例。如果您正苦于以下问题:C# CmdletProviderContext.GetAccumulatedObjects方法的具体用法?C# CmdletProviderContext.GetAccumulatedObjects怎么用?C# CmdletProviderContext.GetAccumulatedObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.Automation.CmdletProviderContext的用法示例。


在下文中一共展示了CmdletProviderContext.GetAccumulatedObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProperty

        /// <summary>
        /// Gets the specified properties from the specified item.
        /// </summary>
        /// 
        /// <param name="paths">
        /// The path(s) to the item(s) to get the properties from.
        /// </param>
        /// 
        /// <param name="providerSpecificPickList">
        /// A list of the properties that the provider should return.
        /// </param>
        /// 
        /// <param name="literalPath">
        /// If true, globbing is not done on paths.
        /// </param>
        /// 
        /// <returns>
        /// A property table container the properties and their values.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> is null.
        /// </exception>
        /// 
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// 
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        internal Collection<PSObject> GetProperty(
            string[] paths,
            Collection<string> providerSpecificPickList,
            bool literalPath)
        {
            if (paths == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);
            context.SuppressWildcardExpansion = literalPath;

            GetProperty(paths, providerSpecificPickList, context);

            context.ThrowFirstErrorOrDoNothing();

            Collection<PSObject> results = context.GetAccumulatedObjects();

            return results;
        } // GetProperties
开发者ID:40a,项目名称:PowerShell,代码行数:62,代码来源:SessionStateProperty.cs

示例2: GetItem

        /// <summary>
        /// Gets the specified object
        /// </summary>
        /// 
        /// <param name="paths">
        /// The path(s) to the object(s). They can be either a relative (most common)
        /// or absolute path.
        /// </param>
        /// 
        /// <param name="force">
        /// Passed on to providers to force operations.
        /// </param>
        /// 
        /// <param name="literalPath">
        /// If true, globbing is not done on paths.
        /// </param>
        /// 
        /// <returns>
        /// The item at the specified path.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> is null.
        /// </exception>
        /// 
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// 
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        internal Collection<PSObject> GetItem(string[] paths, bool force, bool literalPath)
        {
            if (paths == null)
            {
                throw PSTraceSource.NewArgumentNullException("paths");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);
            context.Force = force;
            context.SuppressWildcardExpansion = literalPath;

            GetItem(paths, context);

            context.ThrowFirstErrorOrDoNothing();

            // Since there was not errors return the accumulated objects

            Collection<PSObject> results = context.GetAccumulatedObjects();

            return results;
        } // GetItem
开发者ID:40a,项目名称:PowerShell,代码行数:63,代码来源:SessionStateItem.cs

示例3: DoGetChildNamesManually

 private void DoGetChildNamesManually(CmdletProvider providerInstance, string providerPath, string relativePath, ReturnContainers returnContainers, Collection<WildcardPattern> includeMatcher, Collection<WildcardPattern> excludeMatcher, CmdletProviderContext context, bool recurse)
 {
     string path = this.MakePath(providerInstance, providerPath, relativePath, context);
     CmdletProviderContext context2 = new CmdletProviderContext(context);
     try
     {
         this.GetChildNames(providerInstance, path, ReturnContainers.ReturnMatchingContainers, context2);
         foreach (PSObject obj2 in context2.GetAccumulatedObjects())
         {
             if (context.Stopping)
             {
                 return;
             }
             string baseObject = obj2.BaseObject as string;
             if (((baseObject != null) && SessionStateUtilities.MatchesAnyWildcardPattern(baseObject, includeMatcher, true)) && !SessionStateUtilities.MatchesAnyWildcardPattern(baseObject, excludeMatcher, false))
             {
                 string str3 = this.MakePath(providerInstance, relativePath, baseObject, context);
                 context.WriteObject(str3);
             }
         }
         if (recurse)
         {
             this.GetChildNames(providerInstance, path, ReturnContainers.ReturnAllContainers, context2);
             foreach (PSObject obj3 in context2.GetAccumulatedObjects())
             {
                 if (context.Stopping)
                 {
                     return;
                 }
                 string child = obj3.BaseObject as string;
                 if (child != null)
                 {
                     string str5 = this.MakePath(providerInstance, relativePath, child, context);
                     string str6 = this.MakePath(providerInstance, providerPath, str5, context);
                     if (this.IsItemContainer(providerInstance, str6, context))
                     {
                         this.DoGetChildNamesManually(providerInstance, providerPath, str5, returnContainers, includeMatcher, excludeMatcher, context, true);
                     }
                 }
             }
         }
     }
     finally
     {
         context2.RemoveStopReferral();
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:47,代码来源:SessionStateInternal.cs

示例4: ClearItem

        } // SetItemDynamicParameters

        #endregion SetItem

        #region ClearItem

        /// <summary>
        /// Clears the specified object. Depending on the provider that the path
        /// maps to, this could mean the properties and/or content and/or value is
        /// cleared.
        /// </summary>
        /// 
        /// <param name="paths">
        /// The path(s) to the object. It can be either a relative (most common)
        /// or absolute path.
        /// </param>
        /// 
        /// <param name="force">
        /// Passed on to providers to force operations.
        /// </param>
        /// 
        /// <param name="literalPath">
        /// If true, globbing is not done on paths.
        /// </param>
        /// 
        /// <returns>
        /// The items that were cleared.
        /// </returns>
        /// 
        /// <remarks>
        /// If an error occurs that error will be thrown.
        /// </remarks>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> is null.
        /// </exception>
        /// 
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// 
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        internal Collection<PSObject> ClearItem(string[] paths, bool force, bool literalPath)
        {
            if (paths == null)
            {
                throw PSTraceSource.NewArgumentNullException("paths");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);
            context.Force = force;
            context.SuppressWildcardExpansion = literalPath;

            ClearItem(paths, context);

            context.ThrowFirstErrorOrDoNothing();

            return context.GetAccumulatedObjects();
        } // ClearItem
开发者ID:40a,项目名称:PowerShell,代码行数:71,代码来源:SessionStateItem.cs

示例5: GetChildNamesInDir


//.........这里部分代码省略.........
            getChildNamesContext.SetFilters(
                new Collection<string>(),
                new Collection<string>(),
                context.Filter);

            try
            {
                // Use the provider to get the children
                string unescapedDir = null;
                modifiedDirPath = null;

                if (dirIsProviderPath)
                {
                    modifiedDirPath = unescapedDir = context.SuppressWildcardExpansion ? dir : RemoveGlobEscaping(dir);
                }
                else
                {
                    Dbg.Diagnostics.Assert(
                        drive != null,
                        "Caller should verify that drive is not null when dirIsProviderPath is false");

                    // If the directory is an MSH path we must resolve it before calling GetChildNames()
                    // -- If the path is passed in by LiteralPath (context.SuppressWildcardExpansion == false), we surely should use 'dir' unchanged.
                    // -- If the path is passed in by Path (context.SuppressWildcardExpansion == true), we still should use 'dir' unchanged, in case that the special character
                    //    in 'dir' is escaped
                    modifiedDirPath = GetMshQualifiedPath(dir, drive);

                    ProviderInfo providerIgnored = null;
                    CmdletProvider providerInstanceIgnored = null;
                    Collection<string> resolvedPaths =
                        GetGlobbedProviderPathsFromMonadPath(
                            modifiedDirPath,
                            false,
                            getChildNamesContext,
                            out providerIgnored,
                            out providerInstanceIgnored);

                    // After resolving the path, we unescape the modifiedDirPath if necessary.
                    modifiedDirPath = context.SuppressWildcardExpansion
                                          ? modifiedDirPath
                                          : RemoveGlobEscaping(modifiedDirPath);
                    if (resolvedPaths.Count > 0)
                    {
                        unescapedDir = resolvedPaths[0];
                    }
                    else
                    {
                        // If there were no results from globbing but no
                        // exception was thrown, that means there was filtering.
                        // So return an empty collection and let the caller deal
                        // with it.

                        if (changedPathOrFilter)
                        {
                            context.Filter = originalFilter;
                        }

                        return new Collection<PSObject>();
                    }
                }

                if (provider.HasChildItems(unescapedDir, getChildNamesContext))
                {
                    provider.GetChildNames(
                        unescapedDir,
                        returnContainers,
                        getChildNamesContext);
                }

                // First check to see if there were any errors, and write them
                // to the real context if there are.

                if (getChildNamesContext.HasErrors())
                {
                    Collection<ErrorRecord> errors = getChildNamesContext.GetAccumulatedErrorObjects();

                    if (errors != null &&
                        errors.Count > 0)
                    {
                        foreach (ErrorRecord errorRecord in errors)
                        {
                            context.WriteError(errorRecord);
                        }
                    }
                }

                Collection<PSObject> childNamesObjectArray = getChildNamesContext.GetAccumulatedObjects();

                if (changedPathOrFilter)
                {
                    context.Filter = originalFilter;
                }

                return childNamesObjectArray;
            }
            finally
            {
                getChildNamesContext.RemoveStopReferral();
            }
        } // GetChildNamesInDir
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:LocationGlobber.cs

示例6: CopyItem

 internal Collection<PSObject> CopyItem(string[] paths, string copyPath, bool recurse, CopyContainers copyContainers, bool force, bool literalPath)
 {
     if (paths == null)
     {
         throw PSTraceSource.NewArgumentNullException("paths");
     }
     if (copyPath == null)
     {
         copyPath = string.Empty;
     }
     CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext) {
         Force = force,
         SuppressWildcardExpansion = literalPath
     };
     this.CopyItem(paths, copyPath, recurse, copyContainers, context);
     context.ThrowFirstErrorOrDoNothing();
     return context.GetAccumulatedObjects();
 }
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:SessionStateInternal.cs

示例7: SetProperty

 internal Collection<PSObject> SetProperty(string[] paths, PSObject property, bool force, bool literalPath)
 {
     if (paths == null)
     {
         throw PSTraceSource.NewArgumentNullException("paths");
     }
     if (property == null)
     {
         throw PSTraceSource.NewArgumentNullException("properties");
     }
     CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext) {
         Force = force,
         SuppressWildcardExpansion = literalPath
     };
     this.SetProperty(paths, property, context);
     context.ThrowFirstErrorOrDoNothing();
     return context.GetAccumulatedObjects();
 }
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:SessionStateInternal.cs

示例8: NewItem

 internal Collection<PSObject> NewItem(string[] paths, string name, string type, object content, bool force)
 {
     if (paths == null)
     {
         throw PSTraceSource.NewArgumentNullException("paths");
     }
     CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext) {
         Force = force
     };
     this.NewItem(paths, name, type, content, context);
     context.ThrowFirstErrorOrDoNothing();
     return context.GetAccumulatedObjects();
 }
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:SessionStateInternal.cs

示例9: GetChildNames

 internal Collection<string> GetChildNames(string[] paths, ReturnContainers returnContainers, bool recurse, bool force, bool literalPath)
 {
     if (paths == null)
     {
         throw PSTraceSource.NewArgumentNullException("paths");
     }
     CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext) {
         Force = force,
         SuppressWildcardExpansion = literalPath
     };
     foreach (string str in paths)
     {
         if (str == null)
         {
             throw PSTraceSource.NewArgumentNullException("paths");
         }
         this.GetChildNames(str, returnContainers, recurse, context);
     }
     context.ThrowFirstErrorOrDoNothing();
     Collection<PSObject> accumulatedObjects = context.GetAccumulatedObjects();
     Collection<string> collection2 = new Collection<string>();
     foreach (PSObject obj2 in accumulatedObjects)
     {
         collection2.Add(obj2.BaseObject as string);
     }
     return collection2;
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:SessionStateInternal.cs

示例10: ProcessPathItems


//.........这里部分代码省略.........
            Collection<WildcardPattern> includeMatcher =
                SessionStateUtilities.CreateWildcardsFromStrings(
                    context.Include,
                    WildcardOptions.IgnoreCase);


            // Construct the exclude filter

            Collection<WildcardPattern> excludeMatcher =
                SessionStateUtilities.CreateWildcardsFromStrings(
                    context.Exclude,
                    WildcardOptions.IgnoreCase);

            // If the item is a container we have to filter its children
            // Use a hint + lazy evaluation to skip a container check

            if (skipIsItemContainerCheck || IsItemContainer(providerInstance, path, context))
            {
                CmdletProviderContext newContext =
                    new CmdletProviderContext(context);

                Collection<PSObject> childNameObjects = null;
                System.Collections.Generic.Dictionary<string, bool> filteredChildNameDictionary = null;

                try
                {
                    // Get all the child names
                    GetChildNames(
                        providerInstance,
                        path,
                        (recurse) ? ReturnContainers.ReturnAllContainers : ReturnContainers.ReturnMatchingContainers,
                        newContext);
                    newContext.WriteErrorsToContext(context);
                    childNameObjects = newContext.GetAccumulatedObjects();


                    // The code above initially retrieves all of the containers so that it doesn't limit the recursion,
                    // but then emits the non-matching container further down. The public API doesn't support a way to
                    // differentiate the two, so we need to do a diff.
                    // So if there was a filter, do it again to get the fully filtered items.
                    if (recurse && (providerInstance.IsFilterSet()))
                    {
                        newContext.RemoveStopReferral();
                        newContext = new CmdletProviderContext(context);
                        filteredChildNameDictionary = new System.Collections.Generic.Dictionary<string, bool>();

                        GetChildNames(
                            providerInstance,
                            path,
                            ReturnContainers.ReturnMatchingContainers,
                            newContext);
                        var filteredChildNameObjects = newContext.GetAccumulatedObjects();

                        foreach (PSObject filteredChildName in filteredChildNameObjects)
                        {
                            string filteredName = filteredChildName.BaseObject as string;
                            if (filteredName != null)
                            {
                                filteredChildNameDictionary[filteredName] = true;
                            }
                        }
                    }
                }
                finally
                {
                    newContext.RemoveStopReferral();
开发者ID:dfinke,项目名称:powershell,代码行数:67,代码来源:SessionStateContainer.cs

示例11: GetVariableValueAtScope


//.........这里部分代码省略.........
                            argException);
                    }

                    IContentReader reader = readers[0];

                    try
                    {
                        // Read all the content
                        IList resultList = reader.Read(-1);

                        if (resultList != null)
                        {
                            if (resultList.Count == 0)
                            {
                                resultItem = null;
                            }
                            else if (resultList.Count == 1)
                            {
                                resultItem = resultList[0];
                            }
                            else
                            {
                                resultItem = resultList;
                            }
                        }
                    }
                    catch (Exception e) // Third-party callout, catch-all OK
                    {
                        // First get the provider for the path.

                        ProviderInfo providerInfo = null;
                        string unused =
                            this.Globber.GetProviderPath(variablePath.QualifiedName, out providerInfo);

                        CommandProcessorBase.CheckForSevereException(e);

                        ProviderInvocationException providerException =
                            new ProviderInvocationException(
                                "ProviderContentReadError",
                                SessionStateStrings.ProviderContentReadError,
                                providerInfo,
                                variablePath.QualifiedName,
                                e);

                        throw providerException;
                    }
                    finally
                    {
                        reader.Close();
                    }
#else
                        GetItem (variablePath.LookupPath.ToString (), context);

                        Collection<PSObject> results = context.GetAccumulatedObjects ();

                        if (results != null &
                            results.Count > 0)
                        {
                            // Only return the first value. If the caller wants globbing
                            // they need to call the GetItem method directly.

                            if (!results[0].basObjectIsEmpty)
                            {
                                resultItem = results[0].BaseObject;
                            }
                            else
                            {
                                resultItem = results[0];
                            }
                        }
#endif
                }
            }

            // If we get a PSVariable or DictionaryEntry returned then we have to 
            // grab the value from it and return that instead.

            if (resultItem != null)
            {
                PSVariable variable = resultItem as PSVariable;

                if (variable != null)
                {
                    resultItem = variable.Value;
                }
                else
                {
                    try
                    {
                        DictionaryEntry entry = (DictionaryEntry)resultItem;
                        resultItem = entry.Value;
                    }
                    catch (InvalidCastException)
                    {
                    }
                }
            } // if resultItem != null

            return resultItem;
        } // GetVariableValueAtScope
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:SessionStateVariableAPIs.cs

示例12: GetVariableValueFromProvider


//.........这里部分代码省略.........
                    ProviderInfo providerInfo = null;
                    string unused =
                        this.Globber.GetProviderPath(variablePath.QualifiedName, out providerInfo);

                    throw NewProviderInvocationException(
                        "ProviderVariableSyntaxInvalid",
                        SessionStateStrings.ProviderVariableSyntaxInvalid,
                        providerInfo,
                        variablePath.QualifiedName,
                        argException);
                }

                IContentReader reader = readers[0];

                try
                {
                    // Read all the content
                    IList resultList = reader.Read(-1);

                    if (resultList != null)
                    {
                        if (resultList.Count == 0)
                        {
                            result = null;
                        }
                        else if (resultList.Count == 1)
                        {
                            result = resultList[0];
                        }
                        else
                        {
                            result = resultList;
                        }
                    }
                }
                catch (Exception e) // Third-party callout, catch-all OK
                {
                    // First get the provider for the path.
                    ProviderInfo providerInfo = null;
                    string unused =
                        this.Globber.GetProviderPath(variablePath.QualifiedName, out providerInfo);

                    CommandProcessorBase.CheckForSevereException(e);

                    ProviderInvocationException providerException =
                        new ProviderInvocationException(
                            "ProviderContentReadError",
                            SessionStateStrings.ProviderContentReadError,
                            providerInfo,
                            variablePath.QualifiedName,
                            e);

                    throw providerException;
                }
                finally
                {
                    reader.Close();
                }

#else
                    try
                    {
                        GetItem(variablePath.LookupPath.ToString(), context);
                    }
                    catch (ItemNotFoundException)
                    {
                        break;
                    }

                    Collection<PSObject> items = context.GetAccumulatedObjects ();

                    if (items != null &&
                        items.Count > 0)
                    {
                        result = items[0];

                        if (!items[0].basObjectIsEmpty)
                        {
                            result = items[0].BaseObject;
                        }

                        try
                        {
                            DictionaryEntry entry = (DictionaryEntry)result;
                            result = entry.Value;
                        }
                            // Since DictionaryEntry is a value type we have to
                            // try the cast and catch the exception to determine
                            // if it is a DictionaryEntry type.
                        catch (InvalidCastException)
                        {
                        }
                    }

#endif
                break;
            } while (false);

            return result;
        } // GetVariableFromProvider
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:SessionStateVariableAPIs.cs

示例13: GetSecurityDescriptor

        } // GetPermissionProviderInstance

        #endregion private methods

        #region GetSecurityDescriptor


        /// <summary>
        /// Gets the security descriptor from the specified item.
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the item to retrieve the security descriptor from.
        /// </param>
        /// 
        /// <param name="sections">
        /// Specifies the parts of a security descriptor to retrieve.
        /// </param>
        /// 
        /// <returns>
        /// The security descriptor for the item at the specified path.
        /// </returns>
        /// 
        internal Collection<PSObject> GetSecurityDescriptor(string path,
                                                             AccessControlSections sections)
        {
            if (path == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);

            GetSecurityDescriptor(path, sections, context);

            context.ThrowFirstErrorOrDoNothing();

            Collection<PSObject> contextResults = context.GetAccumulatedObjects() ?? new Collection<PSObject>();

            return contextResults;
        } // GetSecurityDescriptor
开发者ID:40a,项目名称:PowerShell,代码行数:41,代码来源:SessionStateSecurityDescriptorInterface.cs

示例14: SetSecurityDescriptor

        } // GetSecurityDescriptor

        #endregion GetSecurityDescriptor

        #region SetSecurityDescriptor

        /// <summary>
        /// Sets the security descriptor on the specified item.
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the item to set the security descriptor on.
        /// </param>
        /// 
        /// <param name="securityDescriptor">
        /// The security descriptor to set on the item at the specified path.
        /// </param>
        /// 
        /// <returns>
        /// The security descriptor that was set on the item at the specified path.
        /// </returns>
        /// 
        internal Collection<PSObject> SetSecurityDescriptor(string path, ObjectSecurity securityDescriptor)
        {
            if (path == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            if (securityDescriptor == null)
            {
                throw PSTraceSource.NewArgumentNullException("securityDescriptor");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);

            SetSecurityDescriptor(path, securityDescriptor, context);

            context.ThrowFirstErrorOrDoNothing();

            // Return an empty array instead of null
            Collection<PSObject> contextResults = context.GetAccumulatedObjects() ?? new Collection<PSObject>();

            return contextResults;
        } // SetSecurityDescriptor
开发者ID:40a,项目名称:PowerShell,代码行数:45,代码来源:SessionStateSecurityDescriptorInterface.cs

示例15: DoManualGetChildItems

 private void DoManualGetChildItems(CmdletProvider providerInstance, string path, bool recurse, CmdletProviderContext context, bool skipIsItemContainerCheck = false)
 {
     Collection<WildcardPattern> patterns = SessionStateUtilities.CreateWildcardsFromStrings(context.Include, WildcardOptions.IgnoreCase);
     Collection<WildcardPattern> collection2 = SessionStateUtilities.CreateWildcardsFromStrings(context.Exclude, WildcardOptions.IgnoreCase);
     if (skipIsItemContainerCheck || this.IsItemContainer(providerInstance, path, context))
     {
         CmdletProviderContext context2 = new CmdletProviderContext(context);
         Collection<PSObject> accumulatedObjects = null;
         Dictionary<string, bool> dictionary = null;
         try
         {
             this.GetChildNames(providerInstance, path, recurse ? ReturnContainers.ReturnAllContainers : ReturnContainers.ReturnMatchingContainers, context2);
             context2.WriteErrorsToContext(context);
             accumulatedObjects = context2.GetAccumulatedObjects();
             if (recurse && providerInstance.IsFilterSet())
             {
                 context2.RemoveStopReferral();
                 context2 = new CmdletProviderContext(context);
                 Collection<PSObject> collection4 = new Collection<PSObject>();
                 dictionary = new Dictionary<string, bool>();
                 this.GetChildNames(providerInstance, path, ReturnContainers.ReturnMatchingContainers, context2);
                 foreach (PSObject obj2 in context2.GetAccumulatedObjects())
                 {
                     string baseObject = obj2.BaseObject as string;
                     if (baseObject != null)
                     {
                         dictionary[baseObject] = true;
                     }
                 }
             }
         }
         finally
         {
             context2.RemoveStopReferral();
         }
         for (int i = 0; i < accumulatedObjects.Count; i++)
         {
             if (context.Stopping)
             {
                 return;
             }
             string child = accumulatedObjects[i].BaseObject as string;
             if (child != null)
             {
                 string str3 = this.MakePath(providerInstance, path, child, context);
                 if (str3 != null)
                 {
                     if (SessionStateUtilities.MatchesAnyWildcardPattern(child, patterns, true) && !SessionStateUtilities.MatchesAnyWildcardPattern(child, collection2, false))
                     {
                         bool flag2 = true;
                         if (dictionary != null)
                         {
                             bool flag3 = false;
                             flag2 = dictionary.TryGetValue(child, out flag3);
                         }
                         if (flag2)
                         {
                             this.GetItemPrivate(providerInstance, str3, context);
                         }
                     }
                     if (this.IsItemContainer(providerInstance, str3, context) && recurse)
                     {
                         if (context.Stopping)
                         {
                             return;
                         }
                         this.DoManualGetChildItems(providerInstance, str3, recurse, context, true);
                     }
                 }
             }
         }
     }
     else
     {
         string text = path;
         text = this.GetChildName(providerInstance, path, context, true);
         if (SessionStateUtilities.MatchesAnyWildcardPattern(text, patterns, true) && !SessionStateUtilities.MatchesAnyWildcardPattern(text, collection2, false))
         {
             this.GetItemPrivate(providerInstance, path, context);
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:82,代码来源:SessionStateInternal.cs


注:本文中的System.Management.Automation.CmdletProviderContext.GetAccumulatedObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。