當前位置: 首頁>>代碼示例>>C#>>正文


C# Automation.SessionState類代碼示例

本文整理匯總了C#中System.Management.Automation.SessionState的典型用法代碼示例。如果您正苦於以下問題:C# SessionState類的具體用法?C# SessionState怎麽用?C# SessionState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SessionState類屬於System.Management.Automation命名空間,在下文中一共展示了SessionState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsCurrentDriveAD

		internal static bool IsCurrentDriveAD(SessionState sessionState)
		{
			PSDriveInfo current = sessionState.Drive.Current;
			ProviderInfo provider = current.Provider;
			bool flag = string.Compare(provider.Name, "ActiveDirectory", StringComparison.OrdinalIgnoreCase) == 0;
			return flag;
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:7,代碼來源:ProviderUtils.cs

示例2: ProcessRecord

        //private string _projectCollectionUri;
        //[AllowNull]
        //[Parameter(ParameterSetName = "ParamByUri")]
        //public string ProjectCollectionUri
        //{
        //    get { return _projectCollectionUri; }
        //    set
        //    {
        //        if (Uri.IsWellFormedUriString(value, UriKind.Absolute))
        //        {
        //            _projectCollectionUri = value;
        //        }
        //    }
        //}
        protected override void ProcessRecord()
        {
            PendingChange[] pc;
            try
            {
                //if (_projectCollectionUri != null)
                //{
                //var uri = new Uri(_projectCollectionUri);
                //var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);
                //var vcs = tpc.GetService<VersionControlServer>();
                //tpc.ConfigurationServer.Connect(ConnectOptions.IncludeServices);
                //tpc.ConfigurationServer.Authenticate();

                ///builds = buildserver.QueryBuilds(ProjectName);
                //}

                var x = new SessionState();
                var currentDirectory = x.Path.CurrentLocation.Path;
                var wk = Core.GetWorkspaceByLocalPath(currentDirectory);
                pc = wk.GetPendingChanges();
                if (pc == null)
                {
                    throw new Exception("No mapped workspace could be found at this path");
                }
                WriteObject(pc, true);
            }
            catch (Exception ex)
            {
                WriteObject(ex, true);
            }
            base.ProcessRecord();
        }
開發者ID:smartersolutionRepo,項目名稱:TfsManager,代碼行數:46,代碼來源:GetTfsPendingChangesCommand.cs

示例3: GetSessionState

		private static InitialSessionState GetSessionState(SessionState sessionState)
		{
			var initialSessionState = InitialSessionState.CreateDefault2();
			CaptureVariables(sessionState, initialSessionState);
			CaptureFunctions(sessionState, initialSessionState);
			return initialSessionState;
		}
開發者ID:powercode,項目名稱:PSParallel,代碼行數:7,代碼來源:InvokeParallelCommand.cs

示例4: GetCurrentPartitionPath

		internal static string GetCurrentPartitionPath(SessionState sessionState)
		{
			ADRootDSE rootDSE;
			string str = null;
			ADDriveInfo current = sessionState.Drive.Current as ADDriveInfo;
			if (current != null)
			{
				using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(current.SessionInfo))
				{
					rootDSE = aDObjectSearcher.GetRootDSE();
					rootDSE.SessionInfo = current.SessionInfo;
				}
				string currentDriveLocation = ProviderUtils.GetCurrentDriveLocation(sessionState, current.SessionInfo);
				if (currentDriveLocation != string.Empty)
				{
					try
					{
						str = ADForestPartitionInfo.ExtractAndValidatePartitionInfo(rootDSE, currentDriveLocation);
					}
					catch (ArgumentException argumentException1)
					{
						ArgumentException argumentException = argumentException1;
						object[] objArray = new object[1];
						objArray[0] = currentDriveLocation;
						throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ProviderUtilInvalidDrivePath, objArray), argumentException);
					}
				}
				else
				{
					return string.Empty;
				}
			}
			return str;
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:34,代碼來源:ProviderUtils.cs

示例5: ProcessRecord

 protected override void ProcessRecord()
 {
     IBuildDefinition[] builddefinitions;
     try
     {
         if (_projectCollectionUri != null)
         {
             var uri = new Uri(_projectCollectionUri);
             var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);
             var buildserver = tpc.GetService<IBuildServer>();
             builddefinitions = buildserver.QueryBuildDefinitions(ProjectName);
         }
         else
         {
             var x = new SessionState();
             var currentDirectory = x.Path.CurrentLocation.Path;
             builddefinitions = Core.GetBuildDefinitionsByLocalPath(currentDirectory);
             if (builddefinitions == null)
             {
                 throw new Exception("No mapped workspace could be found at this path");
             }
         }
         WriteObject(builddefinitions, true);
     }
     catch (Exception ex)
     {
         WriteObject(ex, true);
     }
     base.ProcessRecord();
 }
開發者ID:smartersolutionRepo,項目名稱:TfsManager,代碼行數:30,代碼來源:GetTfsBuildDefinitionCommand.cs

示例6: ProviderInfo

 internal ProviderInfo(SessionState sessionState, Type implementingType, string name, string description, string home, string helpFile, PSSnapInInfo psSnapIn)
 {
     this.helpFile = "";
     if (sessionState == null)
     {
         throw PSTraceSource.NewArgumentNullException("sessionState");
     }
     if (implementingType == null)
     {
         throw PSTraceSource.NewArgumentNullException("implementingType");
     }
     if (string.IsNullOrEmpty(name))
     {
         throw PSTraceSource.NewArgumentException("name");
     }
     if (string.IsNullOrEmpty(name))
     {
         throw PSTraceSource.NewArgumentException("name");
     }
     this.sessionState = sessionState;
     this.name = name;
     this.description = description;
     this.home = home;
     this.implementingType = implementingType;
     this.helpFile = helpFile;
     this.pssnapin = psSnapIn;
     this.hiddenDrive = new PSDriveInfo(this.FullName, this, "", "", null);
     this.hiddenDrive.Hidden = true;
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:29,代碼來源:ProviderInfo.cs

示例7: ProviderRuntime

 internal ProviderRuntime(SessionState sessionState, bool force, bool avoidWildcardExpansion)
     : this()
 {
     SessionState = sessionState;
     AvoidGlobbing = avoidWildcardExpansion;
     Force = force;
 }
開發者ID:bitwiseman,項目名稱:Pash,代碼行數:7,代碼來源:ProviderRuntime.cs

示例8: PathInfo

 internal PathInfo(PSDriveInfo drive, ProviderInfo provider, Path path, SessionState sessionState)
 {
     Drive = drive;
     Provider = provider;
     _path = path;
     _sessionState = sessionState;
 }
開發者ID:Ventero,項目名稱:Pash,代碼行數:7,代碼來源:PathInfo.cs

示例9: AddToSshSessionCollection

        public static SshSession AddToSshSessionCollection(SshClient sshclient, SessionState pssession)
        {
            //Set initial variables
            var obj = new SshSession();
            var sshSessions = new List<SshSession>();
            var index = 0;

            // Retrieve existing sessions from the global variable.
            var sessionvar = pssession.PSVariable.GetValue("Global:SshSessions") as List<SshSession>;

            // If sessions exist we set the proper index number for them.
            if (sessionvar != null && sessionvar.Count > 0)
            {
                sshSessions.AddRange(sessionvar);

                // Get the SessionId of the last item and count + 1
                SshSession lastSession = sshSessions[sshSessions.Count - 1];
                index = lastSession.SessionId + 1;
            }

            // Create the object that will be saved
            obj.SessionId = index;
            obj.Host = sshclient.ConnectionInfo.Host;
            obj.Session = sshclient;
            sshSessions.Add(obj);

            // Set the Global Variable for the sessions.
            pssession.PSVariable.Set((new PSVariable("Global:SshSessions", sshSessions, ScopedItemOptions.AllScope)));

            return obj;
        }
開發者ID:darkoperator,項目名稱:Posh-SSH,代碼行數:31,代碼來源:SshModHelper.cs

示例10: AddToSftpSessionCollection

        public static SftpSession AddToSftpSessionCollection(SftpClient sftpclient, SessionState pssession)
        {
            //Set initial variables
            var obj = new SftpSession();
            var sftpSessions = new List<SftpSession>();
            var index = 0;

            // Retrive existing sessions from the globla variable.
            var sessionvar = pssession.PSVariable.GetValue("Global:SFTPSessions") as List<SftpSession>;

            // If sessions exist we set the proper index number for them.
            if (sessionvar != null)
            {
                sftpSessions.AddRange(sessionvar);
                index = sftpSessions.Count;
            }

            // Create the object that will be saved
            obj.SessionId = index;
            obj.Host = sftpclient.ConnectionInfo.Host;
            obj.Session = sftpclient;
            sftpSessions.Add(obj);

            // Set the Global Variable for the sessions.
            pssession.PSVariable.Set((new PSVariable("Global:SFTPSessions", sftpSessions, ScopedItemOptions.AllScope)));
            return obj;
        }
開發者ID:sangfo,項目名稱:Posh-SSH,代碼行數:27,代碼來源:SshModHelper.cs

示例11: CreatePsPath

        public static Stream CreatePsPath(SessionState session, string filePath)
        {
            string parentPath = session.Path.ParseParent(filePath, null);
            string childName = session.Path.ParseChildName(filePath);
            var parentItems = session.InvokeProvider.Item.Get(parentPath);
            if (parentItems.Count > 1)
            {
                throw new IOException(string.Format(CultureInfo.InvariantCulture, "PowerShell path {0} is ambiguous", parentPath));
            }
            else if (parentItems.Count < 1)
            {
                throw new DirectoryNotFoundException("No such directory");
            }

            DirectoryInfo parentAsDir = parentItems[0].BaseObject as DirectoryInfo;
            if (parentAsDir != null)
            {
                return File.Create(Path.Combine(parentAsDir.FullName, childName));
            }

            DiscDirectoryInfo parentAsDiscDir = parentItems[0].BaseObject as DiscDirectoryInfo;
            if (parentAsDiscDir != null)
            {
                return parentAsDiscDir.FileSystem.OpenFile(Path.Combine(parentAsDiscDir.FullName, childName), FileMode.Create, FileAccess.ReadWrite);
            }

            throw new FileNotFoundException("Path is not a directory", parentPath);
        }
開發者ID:JGTM2016,項目名稱:discutils,代碼行數:28,代碼來源:Utilities.cs

示例12: GetPsObject

        internal static PSObject GetPsObject(SessionState provider, Notification notification)
        {
            var psobj = PSObject.AsPSObject(notification);

            psobj.Properties.Add(new PSNoteProperty("Type", notification.GetType().Name));

            return psobj;
        }
開發者ID:mikaelnet,項目名稱:Console,代碼行數:8,代碼來源:CloneNotificationCommand.cs

示例13: ExecutionContext

 public ExecutionContext(PSHost host, RunspaceConfiguration config)
     : this()
 {
     RunspaceConfiguration = config;
     LocalHost = host;
     SessionStateGlobal = new SessionStateGlobal(this);
     SessionState = new SessionState(SessionStateGlobal);
 }
開發者ID:Pash-Project,項目名稱:Pash,代碼行數:8,代碼來源:ExecutionContext.cs

示例14: SessionState

 internal SessionState(SessionState sessionState)
 {
     SessionStateGlobal = sessionState.SessionStateGlobal;
     Drive = sessionState.Drive;
     Path = sessionState.Path;
     Provider = sessionState.Provider;
     PSVariable = sessionState.PSVariable;
 }
開發者ID:b333z,項目名稱:Pash,代碼行數:8,代碼來源:SessionState.cs

示例15: LocationGlobber

 internal LocationGlobber(SessionState sessionState)
 {
     if (sessionState == null)
     {
         throw PSTraceSource.NewArgumentNullException("sessionState");
     }
     this.sessionState = sessionState;
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:8,代碼來源:LocationGlobber.cs


注:本文中的System.Management.Automation.SessionState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。