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


C# Provider.CmdletProvider类代码示例

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


CmdletProvider类属于System.Management.Automation.Provider命名空间,在下文中一共展示了CmdletProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Context

 public Context(CmdletProvider provider, string path, PSDriveInfo drive, IPathNodeProcessor pathProcessor, object dynamicParameters, Version topology, bool recurse)
 {
     _pathProcessor = pathProcessor;
     DynamicParameters = dynamicParameters;
     _provider = provider;
     _path = path;
     _drive = drive;
     _recurse = recurse;
     PathTopologyVersion = topology;
 }
开发者ID:beefarino,项目名称:bips,代码行数:10,代码来源:Context.cs

示例2: ProviderContext

 public ProviderContext(CmdletProvider provider, string path, PSDriveInfo drive, IPathResolver pathProcessor, object dynamicParameters, Version topology, bool recurse)
 {
     this.pathProcessor = pathProcessor;
     DynamicParameters = dynamicParameters;
     this.provider = provider;
     this.path = path;
     this.drive = drive;
     this.recurse = recurse;
     PathTopologyVersion = topology;
 }
开发者ID:viciousviper,项目名称:p2f,代码行数:10,代码来源:ProviderContext.cs

示例3: ItemContentReaderWriterBase

        protected ItemContentReaderWriterBase(CmdletProvider provider, Item item,
            FileSystemCmdletProviderEncoding encoding, bool raw)
        {
            Item = item;
            Provider = provider;
            Raw = raw;

            if (encoding == FileSystemCmdletProviderEncoding.Unknown)
            {
                encoding = FileSystemCmdletProviderEncoding.Byte;
            }
            Encoding = new FileSystemContentWriterDynamicParameters() {Encoding = encoding}.EncodingType;
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:13,代码来源:ItemContentReaderWriterBase.cs

示例4: ItemContentWriter

 public ItemContentWriter(CmdletProvider provider, Item item, string path,  FileSystemCmdletProviderEncoding encoding, string extension, bool raw, bool fileBased, bool versioned, string language)
     : base(provider, item, encoding, raw)
 {
     if (Encoding != null && !Raw)
     {
         encoder = Encoding.GetEncoder();
     }
     if (!string.IsNullOrEmpty(extension))
     {
         this.extension = extension.StartsWith(".") ? extension : "." + extension;
     }
     this.fileBased = fileBased;
     this.path = path;
     this.versioned = versioned;
     this.language = language ?? Item?.Language?.Name;
     database = Item?.Database?.Name ?? PathUtilities.GetDrive(path, "master");
 }
开发者ID:GuitarRich,项目名称:Console,代码行数:17,代码来源:ItemContentWriter.cs

示例5: GetGlobbedProviderPaths

        internal Collection<string> GetGlobbedProviderPaths(string path, ProviderRuntime runtime, bool itemMustExist,
                                                            out CmdletProvider provider)
        {
            var results = new Collection<string>();
            ProviderInfo providerInfo;

            // get internal path, resolve home path and set provider info and drive info (if resolved)
            path = GetProviderSpecificPath(path, runtime, out providerInfo);
            provider = _sessionState.Provider.GetInstance(providerInfo);

            if (!ShouldGlob(path, runtime))
            {
                // Although even ItemCmdletProvider supports ItemExists, PS doesn't seem
                // to throw errors when resolving paths with ItemProviders, only for ContainerProviders or higher
                // this behavior can be seen in the tests
                var containerProvider = provider as ContainerCmdletProvider;
                if (itemMustExist && containerProvider != null && !containerProvider.ItemExists(path, runtime))
                {
                    var msg = String.Format("An item with path {0} doesn't exist", path);
                    runtime.WriteError(new ItemNotFoundException(msg).ErrorRecord);
                    return results;
                }
                results.Add(path);
                return results;
            }

            if (providerInfo.Capabilities.HasFlag(ProviderCapabilities.ExpandWildcards))
            {
                var filter = new IncludeExcludeFilter(runtime.Include, runtime.Exclude, runtime.IgnoreFiltersForGlobbing);
                foreach (var expanded in CmdletProvider.As<ItemCmdletProvider>(provider).ExpandPath(path, runtime))
                {
                    if (filter.Accepts(expanded))
                    {
                        results.Add(expanded);
                    }
                }
            }
            else
            {
                results = BuiltInGlobbing(provider, path, runtime);
            }

            return results;
        }
开发者ID:mauve,项目名称:Pash,代码行数:44,代码来源:PathGlobber.cs

示例6: GetPermissionProviderInstance

        /// <summary>
        /// Gets an instance of an ISecurityDescriptorCmdletProvider given the provider ID.
        /// </summary>
        /// 
        /// <param name="providerInstance">
        /// An instance of a CmdletProvider.
        /// </param>
        /// 
        /// <returns>
        /// An instance of a ISecurityDescriptorCmdletProvider for the specified provider ID.
        /// </returns>
        /// 
        /// <throws>
        /// ArgumentNullException if providerId is null.
        /// NotSupportedException if the providerId is not for a provider
        /// that is derived from ISecurityDescriptorCmdletProvider.
        /// </throws>
        /// 
        internal static ISecurityDescriptorCmdletProvider GetPermissionProviderInstance(CmdletProvider providerInstance)
        {
            if (providerInstance == null)
            {
                throw PSTraceSource.NewArgumentNullException("providerInstance");
            }

            ISecurityDescriptorCmdletProvider permissionCmdletProvider =
                providerInstance as ISecurityDescriptorCmdletProvider;

            if (permissionCmdletProvider == null)
            {
                throw
                    PSTraceSource.NewNotSupportedException(
                        ProviderBaseSecurity.ISecurityDescriptorCmdletProvider_NotSupported);
            }

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

示例7: FileSystemContentReaderWriter

 public FileSystemContentReaderWriter(string path, string streamName, FileMode mode, FileAccess access, FileShare share, Encoding encoding, bool usingByteEncoding, bool waitForChanges, CmdletProvider provider, bool isRawStream)
 {
     this.delimiter = "\n";
     if (string.IsNullOrEmpty(path))
     {
         throw PSTraceSource.NewArgumentNullException("path");
     }
     tracer.WriteLine("path = {0}", new object[] { path });
     tracer.WriteLine("mode = {0}", new object[] { mode });
     tracer.WriteLine("access = {0}", new object[] { access });
     this.path = path;
     this.streamName = streamName;
     this.mode = mode;
     this.access = access;
     this.share = share;
     this.encoding = encoding;
     this.usingByteEncoding = usingByteEncoding;
     this.waitForChanges = waitForChanges;
     this.provider = provider;
     this.isRawStream = isRawStream;
     this.CreateStreams(path, streamName, mode, access, share, encoding);
 }
开发者ID:nickchal,项目名称:pash,代码行数:22,代码来源:FileSystemContentReaderWriter.cs

示例8: IsItemContainer

        private bool IsItemContainer(CmdletProvider provider, string path, ProviderRuntime providerRuntime)
        {
            NavigationCmdletProvider navigationProvider = provider as NavigationCmdletProvider;

            if (navigationProvider == null)
                return false;

            return navigationProvider.IsItemContainer(path, providerRuntime);
        }
开发者ID:staxmanade,项目名称:Pash,代码行数:9,代码来源:SessionStateGlobal.cs

示例9: GetGlobbedProviderPathsFromMonadPath

 internal Collection<string> GetGlobbedProviderPathsFromMonadPath(string path, bool allowNonexistingPaths, out ProviderInfo provider, out CmdletProvider providerInstance)
 {
     providerInstance = null;
     if (path == null)
     {
         throw PSTraceSource.NewArgumentNullException("path");
     }
     CmdletProviderContext context = new CmdletProviderContext(this.sessionState.Internal.ExecutionContext);
     return this.GetGlobbedProviderPathsFromMonadPath(path, allowNonexistingPaths, context, out provider, out providerInstance);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:LocationGlobber.cs

示例10: GetGlobbedMonadPathsFromMonadPath

 internal Collection<PathInfo> GetGlobbedMonadPathsFromMonadPath(string path, bool allowNonexistingPaths, out CmdletProvider providerInstance)
 {
     CmdletProviderContext context = new CmdletProviderContext(this.sessionState.Internal.ExecutionContext);
     return this.GetGlobbedMonadPathsFromMonadPath(path, allowNonexistingPaths, context, out providerInstance);
 }
开发者ID:nickchal,项目名称:pash,代码行数:5,代码来源:LocationGlobber.cs

示例11: FileSystemContentReaderWriter

        /// <summary>
        /// Constructor for the content stream
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the file to get the content from.
        /// </param>
        /// 
        /// <param name="streamName">
        /// The name of the Alternate Data Stream to get the content from. If null or empty, returns
        /// the file's primary content.
        /// </param>
        /// 
        /// <param name="mode">
        /// The file mode to open the file with.
        /// </param>
        /// 
        /// <param name="access">
        /// The file access requested in the file.
        /// </param>
        /// 
        /// <param name="share">
        /// The file share to open the file with
        /// </param>
        ///
        /// <param name="encoding">
        /// The encoding of the file to be read or written.
        /// </param>
        /// 
        /// <param name="usingByteEncoding">
        /// If true, bytes will be read from the file. If false, the specified encoding
        /// will be used to read the file.
        /// </param>
        /// 
        /// <param name="waitForChanges">
        /// If true, we will perform blocking reads on the file, waiting for new content to be appended
        /// </param>
        /// 
        /// <param name="provider">
        /// The CmdletProvider invoking this stream
        /// </param>
        /// 
        /// <param name="isRawStream">
        /// Indicates raw stream.
        /// </param>
        /// 
        public FileSystemContentReaderWriter(
            string path, string streamName, FileMode mode, FileAccess access, FileShare share,
            Encoding encoding, bool usingByteEncoding, bool waitForChanges, CmdletProvider provider,
            bool isRawStream)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            if (s_tracer.IsEnabled)
            {
                s_tracer.WriteLine("path = {0}", path);
                s_tracer.WriteLine("mode = {0}", mode);
                s_tracer.WriteLine("access = {0}", access);
            }

            _path = path;
            _streamName = streamName;
            _mode = mode;
            _access = access;
            _share = share;
            _encoding = encoding;
            _usingByteEncoding = usingByteEncoding;
            _waitForChanges = waitForChanges;
            _provider = provider;
            _isRawStream = isRawStream;

            CreateStreams(path, streamName, mode, access, share, encoding);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:76,代码来源:FileSystemContentStream.cs

示例12: GenerateRelativePath

        internal string GenerateRelativePath(PSDriveInfo drive, string path, bool escapeCurrentLocation, CmdletProvider providerInstance, CmdletProviderContext context)
        {
            if (path == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }
            if (drive == null)
            {
                throw PSTraceSource.NewArgumentNullException("drive");
            }
            string currentLocation = drive.CurrentLocation;
			bool flag1 = OSHelper.IsUnix && drive.Root.StartsWith ("/");
			if (!flag1 && !string.IsNullOrEmpty(currentLocation) && currentLocation.StartsWith(drive.Root, StringComparison.Ordinal))
            {
                currentLocation = currentLocation.Substring(drive.Root.Length);
            }
            if (escapeCurrentLocation)
            {
                currentLocation = WildcardPattern.Escape(currentLocation);
            }
            if (!string.IsNullOrEmpty(path))
            {
				var flag6 = OSHelper.IsUnix;
				var flag7 = flag6;
				if (!flag6) flag6 = (path[0] != '/');
                if ((path[0] != '\\') && flag6)
                {
                Label_024B:
                    if ((path.Length > 0) && this.HasRelativePathTokens(path))
                    {
                        if (context.Stopping)
                        {
                            throw new PipelineStoppedException();
                        }
                        bool flag = false;
                        bool flag2 = path.StartsWith("..", StringComparison.Ordinal);
                        bool flag3 = path.Length == 2;
                        bool flag4 = (path.Length > 2) && ((path[2] == '\\') || (path[2] == '/'));
						if (flag7) flag4 = flag7;
                        if (flag2 && (flag3 || flag4))
                        {
                            if (!string.IsNullOrEmpty(currentLocation))
                            {
                                currentLocation = this.sessionState.Internal.GetParentPath(providerInstance, currentLocation, drive.Root, context);
                            }
                            tracer.WriteLine("Parent path = {0}", new object[] { currentLocation });
                            path = path.Substring(2);
                            tracer.WriteLine("path = {0}", new object[] { path });
                            flag = true;
                            if (path.Length != 0)
                            {
								if (!flag7) {
	                                if ((path[0] == '\\') || (path[0] == '/'))
	                                {
	                                    path = path.Substring(1);
	                                }
								}
                                tracer.WriteLine("path = {0}", new object[] { path });
                                if (path.Length != 0)
                                {
                                    goto Label_024B;
                                }
                            }
                            goto Label_0260;
                        }
                        if (path.Equals(".", StringComparison.OrdinalIgnoreCase))
                        {
                            flag = true;
                            path = string.Empty;
                            goto Label_0260;
                        }
                        if (path.StartsWith(@".\", StringComparison.Ordinal) || path.StartsWith("./", StringComparison.Ordinal))
                        {
                            path = path.Substring(@".\".Length);
                            flag = true;
                            tracer.WriteLine("path = {0}", new object[] { path });
                            if (path.Length == 0)
                            {
                                goto Label_0260;
                            }
                        }
                        if ((path.Length == 0) || !flag)
                        {
                            goto Label_0260;
                        }
                        goto Label_024B;
                    }
                }
                else
                {
                    currentLocation = string.Empty;
                    path = path.Substring(1);
                    tracer.WriteLine("path = {0}", new object[] { path });
                }
            }
        Label_0260:
            if (!string.IsNullOrEmpty(path))
            {
                currentLocation = this.sessionState.Internal.MakePath(providerInstance, currentLocation, path, context);
            }
//.........这里部分代码省略.........
开发者ID:nickchal,项目名称:pash,代码行数:101,代码来源:LocationGlobber.cs

示例13: GetDriveRootRelativePathFromPSPath

        internal string GetDriveRootRelativePathFromPSPath (string path, CmdletProviderContext context, bool escapeCurrentLocation, out PSDriveInfo workingDriveForPath, out CmdletProvider providerInstance)
		{
			if (path == null) {
				throw PSTraceSource.NewArgumentNullException ("path");
			}
			if (OSHelper.IsUnix) {
				int index = path.IndexOf ("::");
				if (index != -1)
				{
					path = path.Substring (index + 2);
				}
			}
            workingDriveForPath = null;
            string driveName = null;
            if (this.sessionState.Drive.Current != null)
            {
                driveName = this.sessionState.Drive.Current.Name;
            }
            bool flag = false;
            if (this.IsAbsolutePath(path, out driveName))
            {
                tracer.WriteLine("Drive Name: {0}", new object[] { driveName });
                try
                {
                    workingDriveForPath = this.sessionState.Drive.Get(driveName);
                }
                catch (DriveNotFoundException)
                {
                    if (this.sessionState.Drive.Current == null)
                    {
                        throw;
                    }
					if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix)
					{
						flag = path.StartsWith ("/", StringComparison.OrdinalIgnoreCase);
						workingDriveForPath = this.sessionState.Drive.Current;
					}
					else
					{
						string str2 = OSHelper.IsUnix ? this.sessionState.Drive.Current.Root : this.sessionState.Drive.Current.Root.Replace('/', '\\');
						string tempPath = OSHelper.IsUnix ? path : path.Replace('/', '\\');
	                    if ((str2.IndexOf(":", StringComparison.CurrentCulture) >= 0) && tempPath.StartsWith(str2, StringComparison.OrdinalIgnoreCase))
	                    {
	                        flag = true;
							if (!OSHelper.IsUnix) {
		                        path = path.Substring(str2.Length);
		                        path = path.TrimStart(new char[] { '\\' });
		                        path = '\\' + path;
							}
	                        workingDriveForPath = this.sessionState.Drive.Current;
	                    }
	                    if (!flag)
	                    {
	                        throw;
	                    }
					}
                }
				if (!flag) /* && !OSHelper.IsUnix */
                {
                    path = path.Substring(driveName.Length + 1);
                }
            }
            else
            {
                workingDriveForPath = this.sessionState.Drive.Current;
            }
            if (workingDriveForPath == null)
            {
                ItemNotFoundException exception = new ItemNotFoundException(path, "PathNotFound", SessionStateStrings.PathNotFound);
                pathResolutionTracer.TraceError("Item does not exist: {0}", new object[] { path });
                throw exception;
            }
            try
            {
                providerInstance = this.sessionState.Internal.GetContainerProviderInstance(workingDriveForPath.Provider);
                context.Drive = workingDriveForPath;
                return this.GenerateRelativePath(workingDriveForPath, path, escapeCurrentLocation, providerInstance, context);
            }
            catch (PSNotSupportedException)
            {
                providerInstance = null;
                return "";
            }
        }
开发者ID:nickchal,项目名称:pash,代码行数:84,代码来源:LocationGlobber.cs

示例14: GetGlobbedProviderPathsFromProviderPath

 internal Collection<string> GetGlobbedProviderPathsFromProviderPath(string path, bool allowNonexistingPaths, string providerId, out CmdletProvider providerInstance)
 {
     providerInstance = null;
     if (path == null)
     {
         throw PSTraceSource.NewArgumentNullException("path");
     }
     CmdletProviderContext context = new CmdletProviderContext(this.sessionState.Internal.ExecutionContext);
     Collection<string> collection = this.GetGlobbedProviderPathsFromProviderPath(path, allowNonexistingPaths, providerId, context, out providerInstance);
     if (context.HasErrors())
     {
         ErrorRecord record = context.GetAccumulatedErrorObjects()[0];
         if (record != null)
         {
             throw record.Exception;
         }
     }
     return collection;
 }
开发者ID:nickchal,项目名称:pash,代码行数:19,代码来源:LocationGlobber.cs

示例15: ResolveDriveQualifiedPath

 private Collection<PathInfo> ResolveDriveQualifiedPath(string path, CmdletProviderContext context, bool allowNonexistingPaths, out CmdletProvider providerInstance)
 {
     providerInstance = null;
     PSDriveInfo workingDriveForPath = null;
     Collection<PathInfo> collection = new Collection<PathInfo>();
     pathResolutionTracer.WriteLine("Path is DRIVE-QUALIFIED", new object[0]);
     string str = this.GetDriveRootRelativePathFromPSPath(path, context, true, out workingDriveForPath, out providerInstance);
     pathResolutionTracer.WriteLine("DRIVE-RELATIVE path: {0}", new object[] { str });
     pathResolutionTracer.WriteLine("Drive: {0}", new object[] { workingDriveForPath.Name });
     pathResolutionTracer.WriteLine("Provider: {0}", new object[] { workingDriveForPath.Provider });
     context.Drive = workingDriveForPath;
     providerInstance = this.sessionState.Internal.GetContainerProviderInstance(workingDriveForPath.Provider);
     ContainerCmdletProvider provider = providerInstance as ContainerCmdletProvider;
     ItemCmdletProvider provider2 = providerInstance as ItemCmdletProvider;
     ProviderInfo providerInfo = providerInstance.ProviderInfo;
     string item = null;
     string providerPath = null;
     if (workingDriveForPath.Hidden)
     {
         item = GetProviderQualifiedPath(str, providerInfo);
         providerPath = str;
     }
     else
     {
         item = GetDriveQualifiedPath(str, workingDriveForPath);
         providerPath = this.GetProviderPath(path, context);
     }
     pathResolutionTracer.WriteLine("PROVIDER path: {0}", new object[] { providerPath });
     Collection<string> collection2 = new Collection<string>();
     if (!context.SuppressWildcardExpansion)
     {
         if (CmdletProviderManagementIntrinsics.CheckProviderCapabilities(ProviderCapabilities.ExpandWildcards, providerInfo))
         {
             pathResolutionTracer.WriteLine("Wildcard matching is being performed by the provider.", new object[0]);
             if ((provider2 != null) && WildcardPattern.ContainsWildcardCharacters(str))
             {
                 foreach (string str4 in provider2.ExpandPath(providerPath, context))
                 {
                     collection2.Add(this.GetDriveRootRelativePathFromProviderPath(str4, workingDriveForPath, context));
                 }
             }
             else
             {
                 collection2.Add(this.GetDriveRootRelativePathFromProviderPath(providerPath, workingDriveForPath, context));
             }
         }
         else
         {
             pathResolutionTracer.WriteLine("Wildcard matching is being performed by the engine.", new object[0]);
             collection2 = this.ExpandMshGlobPath(str, allowNonexistingPaths, workingDriveForPath, provider, context);
         }
     }
     else if (provider2 != null)
     {
         if (allowNonexistingPaths || provider2.ItemExists(providerPath, context))
         {
             collection2.Add(item);
         }
     }
     else
     {
         collection2.Add(item);
     }
     if ((((!allowNonexistingPaths && (collection2.Count < 1)) && !WildcardPattern.ContainsWildcardCharacters(path)) && ((context.Include == null) || (context.Include.Count == 0))) && ((context.Exclude == null) || (context.Exclude.Count == 0)))
     {
         ItemNotFoundException exception = new ItemNotFoundException(path, "PathNotFound", SessionStateStrings.PathNotFound);
         pathResolutionTracer.TraceError("Item does not exist: {0}", new object[] { path });
         throw exception;
     }
     foreach (string str5 in collection2)
     {
         if (context.Stopping)
         {
             throw new PipelineStoppedException();
         }
         item = null;
         if (workingDriveForPath.Hidden)
         {
             if (IsProviderDirectPath(str5))
             {
                 item = str5;
             }
             else
             {
                 item = GetProviderQualifiedPath(str5, providerInfo);
             }
         }
         else
         {
             item = GetDriveQualifiedPath(str5, workingDriveForPath);
         }
         collection.Add(new PathInfo(workingDriveForPath, providerInfo, item, this.sessionState));
         pathResolutionTracer.WriteLine("RESOLVED PATH: {0}", new object[] { item });
     }
     return collection;
 }
开发者ID:nickchal,项目名称:pash,代码行数:96,代码来源:LocationGlobber.cs


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