本文整理汇总了C#中System.Management.Automation.SessionState类的典型用法代码示例。如果您正苦于以下问题:C# SessionState类的具体用法?C# SessionState怎么用?C# SessionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SessionState类属于System.Management.Automation命名空间,在下文中一共展示了SessionState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: UnresolvedPscxPathImpl
/// <summary>
///
/// </summary>
/// <param name="literalPath"></param>
/// <param name="session"></param>
internal UnresolvedPscxPathImpl(string literalPath, SessionState session)
{
PscxArgumentException.ThrowIfIsNullOrEmpty(literalPath);
PscxArgumentException.ThrowIfIsNull(session);
_providerPath = session.Path.GetUnresolvedProviderPathFromPSPath(literalPath, out _providerInfo, out _driveInfo);
_isUnresolved = true;
_sourcePath = literalPath;
}
开发者ID:razaraz,项目名称:Pscx,代码行数:14,代码来源:PscxPathInfo.UnresolvedPscxPathImpl.cs
示例17: Create
public IAzureHDInsightConnectionSessionManager Create(SessionState sessionState)
{
if (singleton == null)
{
singleton = new AzureHDInsightConnectionSessionManagerSimulator();
}
return singleton;
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:9,代码来源:AzureHDInsightConnectionSessionManagerSimulatorFactory.cs
示例18: ResolveKeyPath
/// <summary>
/// Gets an provider path for the given component key path.
/// </summary>
/// <param name="session">The <see cref="SessionState"/> for resolving key paths.</param>
/// <param name="path">The component key path to resolve.</param>
/// <returns>A provider path for the given component path.</returns>
public static string ResolveKeyPath(SessionState session, string path)
{
if (session != null)
{
return session.Path.GetUnresolvedPSPathFromKeyPath(path);
}
return null;
}
开发者ID:heaths,项目名称:psmsi,代码行数:15,代码来源:ComponentProvider.cs
示例19: GetCurrentDriveSessionInfo
internal static ADSessionInfo GetCurrentDriveSessionInfo(SessionState sessionState)
{
ADSessionInfo aDSessionInfo = null;
ADDriveInfo current = sessionState.Drive.Current as ADDriveInfo;
if (current != null)
{
aDSessionInfo = current.SessionInfo.Copy();
}
return aDSessionInfo;
}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:ProviderUtils.cs
示例20: ProviderInfo
internal ProviderInfo(SessionState sessionState, Type implementingType, string name, string description, string home, string helpFile, PSSnapInInfo psSnapIn)
{
_sessionState = sessionState;
PSSnapIn = psSnapIn;
Name = name;
Description = description;
Home = home;
ImplementingType = implementingType;
Capabilities = GetCapabilities(implementingType);
HelpFile = helpFile;
}
开发者ID:b333z,项目名称:Pash,代码行数:11,代码来源:ProviderInfo.cs
注:本文中的System.Management.Automation.SessionState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论