• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Automation.CmdletProviderContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CmdletProviderContext

 internal CmdletProviderContext(CmdletProviderContext contextToCopyFrom)
 {
     this.credentials = PSCredential.Empty;
     this._origin = CommandOrigin.Internal;
     this.accumulatedObjects = new Collection<PSObject>();
     this.accumulatedErrorObjects = new Collection<ErrorRecord>();
     this.stopReferrals = new Collection<CmdletProviderContext>();
     if (contextToCopyFrom == null)
     {
         throw PSTraceSource.NewArgumentNullException("contextToCopyFrom");
     }
     this.executionContext = contextToCopyFrom.ExecutionContext;
     this.command = contextToCopyFrom.command;
     if (contextToCopyFrom.Credential != null)
     {
         this.credentials = contextToCopyFrom.Credential;
     }
     this.drive = contextToCopyFrom.Drive;
     this.force = (bool) contextToCopyFrom.Force;
     this.CopyFilters(contextToCopyFrom);
     this.suppressWildcardExpansion = contextToCopyFrom.SuppressWildcardExpansion;
     this.dynamicParameters = contextToCopyFrom.DynamicParameters;
     this._origin = contextToCopyFrom._origin;
     this.stopping = contextToCopyFrom.Stopping;
     contextToCopyFrom.StopReferrals.Add(this);
     this.copiedContext = contextToCopyFrom;
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:CmdletProviderContext.cs


示例2: GetProviderSpecificHelpInfo

 internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
 {
     ProviderInfo info = null;
     PSDriveInfo drive = null;
     string str = null;
     CmdletProviderContext context = new CmdletProviderContext(this._executionContext);
     try
     {
         string str2 = this._requestedPath;
         if (string.IsNullOrEmpty(this._requestedPath))
         {
             str2 = this._pathIntrinsics.CurrentLocation.Path;
         }
         str = this._executionContext.LocationGlobber.GetProviderPath(str2, context, out info, out drive);
     }
     catch (ArgumentNullException)
     {
     }
     catch (ProviderNotFoundException)
     {
     }
     catch (DriveNotFoundException)
     {
     }
     catch (ProviderInvocationException)
     {
     }
     catch (NotSupportedException)
     {
     }
     catch (InvalidOperationException)
     {
     }
     catch (ItemNotFoundException)
     {
     }
     if (info == null)
     {
         return null;
     }
     CmdletProvider provider = info.CreateInstance();
     ICmdletProviderSupportsHelp help = provider as ICmdletProviderSupportsHelp;
     if (help == null)
     {
         return null;
     }
     if (str == null)
     {
         throw new ItemNotFoundException(this._requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
     }
     provider.Start(info, context);
     string path = str;
     string helpMaml = help.GetHelpMaml(helpItemName, path);
     if (string.IsNullOrEmpty(helpMaml))
     {
         return null;
     }
     return MamlCommandHelpInfo.Load(InternalDeserializer.LoadUnsafeXmlDocument(helpMaml, false, null).DocumentElement, HelpCategory.Provider);
 }
开发者ID:nickchal,项目名称:pash,代码行数:59,代码来源:ProviderContext.cs


示例3: NewDrive

 internal PSDriveInfo NewDrive(PSDriveInfo drive, CmdletProviderContext context)
 {
     base.Context = context;
     if (((drive.Credential != null) && (drive.Credential != PSCredential.Empty)) && !CmdletProviderManagementIntrinsics.CheckProviderCapabilities(ProviderCapabilities.Credentials, base.ProviderInfo))
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "NewDriveCredentials_NotSupported", new object[0]);
     }
     return this.NewDrive(drive);
 }
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:DriveCmdletProvider.cs


示例4: CopyProperty

 internal void CopyProperty(string sourcePath, string sourceProperty, string destinationPath, string destinationProperty, CmdletProviderContext cmdletProviderContext)
 {
     this.Context = cmdletProviderContext;
     IDynamicPropertyCmdletProvider provider = this as IDynamicPropertyCmdletProvider;
     if (provider == null)
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "IDynamicPropertyCmdletProvider_NotSupported", new object[0]);
     }
     provider.CopyProperty(sourcePath, sourceProperty, destinationPath, destinationProperty);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CmdletProvider.cs


示例5: ClearPropertyDynamicParameters

 internal object ClearPropertyDynamicParameters(string path, Collection<string> providerSpecificPickList, CmdletProviderContext cmdletProviderContext)
 {
     this.Context = cmdletProviderContext;
     IPropertyCmdletProvider provider = this as IPropertyCmdletProvider;
     if (provider == null)
     {
         return null;
     }
     return provider.ClearPropertyDynamicParameters(path, providerSpecificPickList);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CmdletProvider.cs


示例6: ClearProperty

 internal void ClearProperty(string path, Collection<string> propertyName, CmdletProviderContext cmdletProviderContext)
 {
     this.Context = cmdletProviderContext;
     IPropertyCmdletProvider provider = this as IPropertyCmdletProvider;
     if (provider == null)
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "IPropertyCmdletProvider_NotSupported", new object[0]);
     }
     provider.ClearProperty(path, propertyName);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CmdletProvider.cs


示例7: ClearContentDynamicParameters

 internal object ClearContentDynamicParameters(string path, CmdletProviderContext cmdletProviderContext)
 {
     this.Context = cmdletProviderContext;
     IContentCmdletProvider provider = this as IContentCmdletProvider;
     if (provider == null)
     {
         return null;
     }
     return provider.ClearContentDynamicParameters(path);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CmdletProvider.cs


示例8: ClearContent

 internal void ClearContent(string path, CmdletProviderContext cmdletProviderContext)
 {
     this.Context = cmdletProviderContext;
     IContentCmdletProvider provider = this as IContentCmdletProvider;
     if (provider == null)
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "IContentCmdletProvider_NotSupported", new object[0]);
     }
     provider.ClearContent(path);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:CmdletProvider.cs


示例9: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			if (!(this.Path != null & (int)this.Path.Length > 0))
			{
				return base.InvokeProvider.Property.CopyPropertyDynamicParameters(".", this.property, this.Destination, this.property, context);
			}
			else
			{
				return base.InvokeProvider.Property.CopyPropertyDynamicParameters(this.Path[0], this.property, this.Destination, this.property, context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:CopyItemPropertyCommand.cs


示例10: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			if (this.Path == null)
			{
				return base.InvokeProvider.Property.RenamePropertyDynamicParameters(".", this.Name, this.NewName, context);
			}
			else
			{
				return base.InvokeProvider.Property.RenamePropertyDynamicParameters(this.Path, this.Name, this.NewName, context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:RenameItemPropertyCommand.cs


示例11: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			if (this.Path == null || (int)this.Path.Length <= 0)
			{
				return base.InvokeProvider.Property.GetPropertyDynamicParameters(".", SessionStateUtilities.ConvertArrayToCollection<string>(this.property), context);
			}
			else
			{
				return base.InvokeProvider.Property.GetPropertyDynamicParameters(this.Path[0], SessionStateUtilities.ConvertArrayToCollection<string>(this.property), context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:GetItemPropertyCommand.cs


示例12: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			if (base.Path == null || (int)base.Path.Length <= 0)
			{
				return base.InvokeProvider.Content.GetContentReaderDynamicParameters(".", context);
			}
			else
			{
				return base.InvokeProvider.Content.GetContentReaderDynamicParameters(base.Path[0], context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:GetContentCommand.cs


示例13: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			Collection<string> strs = new Collection<string>();
			strs.Add(this.property);
			if (this.Path == null || (int)this.Path.Length <= 0)
			{
				return base.InvokeProvider.Property.ClearPropertyDynamicParameters(".", strs, context);
			}
			else
			{
				return base.InvokeProvider.Property.ClearPropertyDynamicParameters(this.Path[0], strs, context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:ClearItemPropertyCommand.cs


示例14: GetAcceptedPaths

		private string[] GetAcceptedPaths(string[] unfilteredPaths, CmdletProviderContext currentContext)
		{
			Collection<PathInfo> pathInfos = base.ResolvePaths(unfilteredPaths, true, false, currentContext);
			ArrayList arrayLists = new ArrayList();
			foreach (PathInfo pathInfo in pathInfos)
			{
				if (!this.CallShouldProcess(pathInfo.Path))
				{
					continue;
				}
				arrayLists.Add(pathInfo.Path);
			}
			return (string[])arrayLists.ToArray(typeof(string));
		}
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:WriteContentCommandBase.cs


示例15: GetParentPath

        /// <summary>
        /// Gets the path to the parent object for the given object
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the object to get the parent path from
        /// </param>
        /// 
        /// <param name="root">
        /// The root of the drive.
        /// </param>
        /// 
        /// <returns>
        /// The path to the parent object
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> is null.
        /// </exception>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the <paramref name="providerInstance"/> does not support this operation.
        /// </exception>
        /// 
        /// <exception cref="PipelineStoppedException">
        /// If the pipeline is being stopped while executing the command.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        internal string GetParentPath(string path, string root)
        {
            if (path == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);

            string result = GetParentPath(path, root, context);

            context.ThrowFirstErrorOrDoNothing();

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


示例16: ResolvePath

 private PathInfo ResolvePath(string pathToResolve, bool isLiteralPath, bool allowNonexistingPaths, PSCmdlet cmdlet)
 {
     CmdletProviderContext context = new CmdletProviderContext(cmdlet) {
         SuppressWildcardExpansion = isLiteralPath
     };
     Collection<PathInfo> targetObject = new Collection<PathInfo>();
     try
     {
         foreach (PathInfo info in cmdlet.SessionState.Path.GetResolvedPSPathFromPSPath(pathToResolve, context))
         {
             targetObject.Add(info);
         }
     }
     catch (PSNotSupportedException exception)
     {
         cmdlet.ThrowTerminatingError(new ErrorRecord(exception.ErrorRecord, exception));
     }
     catch (DriveNotFoundException exception2)
     {
         cmdlet.ThrowTerminatingError(new ErrorRecord(exception2.ErrorRecord, exception2));
     }
     catch (ProviderNotFoundException exception3)
     {
         cmdlet.ThrowTerminatingError(new ErrorRecord(exception3.ErrorRecord, exception3));
     }
     catch (ItemNotFoundException exception4)
     {
         if (allowNonexistingPaths)
         {
             ProviderInfo provider = null;
             PSDriveInfo drive = null;
             string path = cmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath(pathToResolve, context, out provider, out drive);
             PathInfo item = new PathInfo(drive, provider, path, cmdlet.SessionState);
             targetObject.Add(item);
         }
         else
         {
             cmdlet.ThrowTerminatingError(new ErrorRecord(exception4.ErrorRecord, exception4));
         }
     }
     if (targetObject.Count == 1)
     {
         return targetObject[0];
     }
     Exception exception5 = PSTraceSource.NewNotSupportedException();
     cmdlet.ThrowTerminatingError(new ErrorRecord(exception5, "NotSupported", ErrorCategory.NotImplemented, targetObject));
     return null;
 }
开发者ID:nickchal,项目名称:pash,代码行数:48,代码来源:PathResolver.cs


示例17: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			string empty = string.Empty;
			if (this.Name != null && (int)this.Name.Length > 0)
			{
				empty = this.Name[0];
			}
			if (this.Path == null || (int)this.Path.Length <= 0)
			{
				return base.InvokeProvider.Property.MovePropertyDynamicParameters(".", empty, this.Destination, empty, context);
			}
			else
			{
				return base.InvokeProvider.Property.MovePropertyDynamicParameters(this.Path[0], empty, this.Destination, empty, context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:MoveItemPropertyCommand.cs


示例18: GetDynamicParameters

		internal override object GetDynamicParameters(CmdletProviderContext context)
		{
			string name = null;
			if (this.Name != null && (int)this.Name.Length > 0)
			{
				name = this.Name[0];
			}
			if (this.Path == null || (int)this.Path.Length <= 0)
			{
				return base.InvokeProvider.Property.RemovePropertyDynamicParameters(".", name, context);
			}
			else
			{
				return base.InvokeProvider.Property.RemovePropertyDynamicParameters(this.Path[0], name, context);
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:RemoveItemPropertyCommand.cs


示例19: GetContentReader

        /// <summary>
        /// Gets the content reader for the specified item.
        /// </summary>
        /// 
        /// <param name="paths">
        /// The path(s) to the item(s) to get the content reader for.
        /// </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 content readers for all items that the path resolves to.
        /// </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<IContentReader> GetContentReader(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;

            Collection<IContentReader> results = GetContentReader(paths, context);

            context.ThrowFirstErrorOrDoNothing();

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


示例20: BeforeOpenStreams

        /// <summary>
        /// Called by the base class before the streams are open for the path.
        /// This override clears the content from the item. 
        /// </summary>
        /// 
        /// <param name="paths">
        /// The path to the items that will be opened for writing content.
        /// </param>
        /// 
        internal override void BeforeOpenStreams(string[] paths)
        {
            if (paths == null ||
                (paths != null && paths.Length == 0))
            {
                throw PSTraceSource.NewArgumentNullException("paths");
            }

            CmdletProviderContext context = new CmdletProviderContext(GetCurrentContext());

            foreach (string path in paths)
            {
                try
                {
                    InvokeProvider.Content.Clear(path, context);
                    context.ThrowFirstErrorOrDoNothing(true);
                }
                catch (PSNotSupportedException)
                {
                    // If the provider doesn't support clear, that is fine. Continue
                    // on with the setting of the content.
                    continue;
                }
                catch (DriveNotFoundException driveNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            driveNotFound.ErrorRecord,
                            driveNotFound));
                    continue;
                }
                catch (ProviderNotFoundException providerNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            providerNotFound.ErrorRecord,
                            providerNotFound));
                    continue;
                }
                catch (ItemNotFoundException)
                {
                    //If the item is not found then there is nothing to clear so ignore this exception.
                    continue;
                }
            }
        } // BeforeOpenStreams
开发者ID:dfinke,项目名称:powershell,代码行数:55,代码来源:SetContentCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Automation.ErrorRecord类代码示例发布时间:2022-05-26
下一篇:
C# Management.SelectQuery类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap