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


C# ProviderRuntime.WriteObject方法代码示例

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


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

示例1: ManuallyGetChildNames

 private void ManuallyGetChildNames(ContainerCmdletProvider provider, string providerPath, string relativePath,
     ReturnContainers returnContainers, bool recurse, IncludeExcludeFilter filter, ProviderRuntime runtime)
 {
     // Affected by #trailingSeparatorAmbiguity
     // Sometimes, PS removes or appends a trailing slash to the providerPath
     // E.g. when the recurse == true, there is a trailing slash, but not when recurse == false.
     // As it calls the method with the slash being appended and not appended, PS doesn't seem to make
     // promises to the provider implementation whether or not the path has a trailing slash
     var childNames = GetValidChildNames(provider, providerPath, returnContainers, runtime);
     foreach (var childName in childNames)
     {
         // add the child only if the filter accepts it
         if (!filter.Accepts(childName))
         {
             continue;
         }
         var path = Path.Combine(provider, relativePath, childName, runtime);
         runtime.WriteObject(path);
     }
     // check if we need to handle this recursively
     if (!recurse)
     {
         return;
     }
     // okay, we should use recursion, so get all child containers and call this function again
     childNames = GetValidChildNames(provider, providerPath, ReturnContainers.ReturnAllContainers, runtime);
     foreach (var childName in childNames)
     {
         var providerChildPath = Path.Combine(provider, providerPath, childName, runtime);
         if (Item.IsContainer(providerChildPath, runtime))
         {
             // recursive call wirth child's provider path and relative path
             var relativeChildPath = Path.Combine(provider, relativePath, childName, runtime);
             ManuallyGetChildNames(provider, providerChildPath, relativeChildPath, returnContainers,
                 true, filter, runtime);
         }
     }
 }
开发者ID:mauve,项目名称:Pash,代码行数:38,代码来源:ChildItemCmdletProviderIntrinsics.cs

示例2: GetNames

        internal void GetNames(string[] path, ReturnContainers returnContainers, bool recurse, ProviderRuntime runtime)
        {
            // the include/exclude filters apply to the results, not to the globbing process. Make this sure
            runtime.IgnoreFiltersForGlobbing = true;
            // compile here, not in every recursive iteration
            var filter = new IncludeExcludeFilter(runtime.Include, runtime.Exclude, false);

            // do the globbing manually, because the behavior depends on it...
            foreach (var p in path)
            {
                CmdletProvider provider;
                var doGlob = Globber.ShouldGlob(p, runtime);
                // even if we don't actually glob, the next method will return the resolved path & provider
                var resolved = Globber.GetGlobbedProviderPaths(p, runtime, out provider);
                var contProvider = CmdletProvider.As<ContainerCmdletProvider>(provider);
                foreach (var curPath in resolved)
                {
                    if (!doGlob && filter.CanBeIgnored && !recurse)
                    {
                        contProvider.GetChildNames(curPath, returnContainers, runtime);
                        continue;
                    }
                    if ((recurse || !doGlob) && Item.IsContainer(contProvider, curPath, runtime))
                    {
                        ManuallyGetChildNames(contProvider, curPath, "", returnContainers, recurse, filter, runtime);
                        continue;
                    }
                    var cn = Path.ParseChildName(contProvider, curPath, runtime);
                    if (filter.Accepts(cn))
                    {
                        runtime.WriteObject(cn);
                    }
                }
            }
        }
开发者ID:mauve,项目名称:Pash,代码行数:35,代码来源:ChildItemCmdletProviderIntrinsics.cs


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