public static void DecodeTextureDataToWriter(byte[] data, int width, int height, TextureFormat format, PipelineWriter writer) { if (!format.IsSupported()) throw new FormatException("Unsupported format: " + format.ToString()); PipelineReader reader = null; switch (format) { case TextureFormat.DXT1: reader = new DXT1Reader(data, format, width, height); break; case TextureFormat.DXT2: case TextureFormat.DXT3: reader = new DXT3Reader(data, format, width, height); break; case TextureFormat.DXT4: case TextureFormat.DXT5: reader = new DXT5Reader(data, format, width, height); break; case TextureFormat.BC4: reader = new BC4Reader(data, format, width, height); break; case TextureFormat.BC5: reader = new BC5Reader(data, format, width, height); break; default: reader = new DefaultReader(data, format, width, height); break; } reader.Read(writer); }
internal FileOutputWriter(PipelineWriter inner, PSRuleOption option, Encoding encoding, string path, ShouldProcess shouldProcess) : base(inner, option) { _Encoding = encoding; _Path = path; _ShouldProcess = shouldProcess; }
private void WriteErrorCreateRemoteRunspaceFailed(Exception e, Uri uri) { PipelineWriter objectWriter = this.stream.ObjectWriter; ErrorRecord errorRecord = new ErrorRecord(e, "CreateRemoteRunspaceFailed", ErrorCategory.InvalidArgument, uri); Action <Cmdlet> action = cmdlet => cmdlet.WriteError(errorRecord); objectWriter.Write(action); }
internal ProcessStreamReader(StreamReader streamReader, string processPath, bool isOutput, PipelineWriter writer, ProcessOutputReader processOutputReader) { this.streamReader = streamReader; this.processPath = processPath; this.isOutput = isOutput; this.writer = writer; this.processOutputReader = processOutputReader; }
private List <RemoteRunspace> CreateRunspacesWhenRunspaceParameterSpecified() { List <RemoteRunspace> list = new List <RemoteRunspace>(); base.ValidateRemoteRunspacesSpecified(); int rsIndex = 0; foreach (PSSession session in this.remoteRunspaceInfos) { if ((session == null) || (session.Runspace == null)) { base.ThrowTerminatingError(new ErrorRecord(new ArgumentNullException("PSSession"), "PSSessionArgumentNull", ErrorCategory.InvalidArgument, null)); } else { try { int num2; RemoteRunspace runspace = (RemoteRunspace)session.Runspace; WSManConnectionInfo connectionInfo = runspace.ConnectionInfo as WSManConnectionInfo; WSManConnectionInfo info2 = null; if (connectionInfo != null) { info2 = connectionInfo.Copy(); info2.EnableNetworkAccess = info2.EnableNetworkAccess || (this.EnableNetworkAccess != false); } else { Uri uri = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <Uri>(runspace.ConnectionInfo, "ConnectionUri", null); string shellUri = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <string>(runspace.ConnectionInfo, "ShellUri", string.Empty); info2 = new WSManConnectionInfo(uri, shellUri, runspace.ConnectionInfo.Credential); base.UpdateConnectionInfo(info2); info2.EnableNetworkAccess = (bool)this.EnableNetworkAccess; } RemoteRunspacePoolInternal remoteRunspacePoolInternal = runspace.RunspacePool.RemoteRunspacePoolInternal; TypeTable typeTable = null; if (((remoteRunspacePoolInternal != null) && (remoteRunspacePoolInternal.DataStructureHandler != null)) && (remoteRunspacePoolInternal.DataStructureHandler.TransportManager != null)) { typeTable = remoteRunspacePoolInternal.DataStructureHandler.TransportManager.Fragmentor.TypeTable; } string runspaceName = this.GetRunspaceName(rsIndex, out num2); RemoteRunspace item = new RemoteRunspace(typeTable, info2, base.Host, this.SessionOption.ApplicationArguments, runspaceName, num2); list.Add(item); } catch (UriFormatException exception) { PipelineWriter objectWriter = this.stream.ObjectWriter; ErrorRecord errorRecord = new ErrorRecord(exception, "CreateRemoteRunspaceFailed", ErrorCategory.InvalidArgument, session); Action <Cmdlet> action = delegate(Cmdlet cmdlet) { cmdlet.WriteError(errorRecord); }; objectWriter.Write(action); } } rsIndex++; } return(list); }
public override void Read(PipelineWriter output) { using (SimpleBinaryStream stream = new SimpleBinaryStream(dataSource)) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { output.Write(ReadPixel(stream)); } } } }
internal ProcessStreamReader( StreamReader streamReader, string processPath, bool isOutput, PipelineWriter writer, ProcessOutputReader processOutputReader) { using (ProcessStreamReader.tracer.TraceConstructor((object)this, " isOutput {0}", (object)isOutput)) { this.streamReader = streamReader; this.processPath = processPath; this.isOutput = isOutput; this.writer = writer; this.processOutputReader = processOutputReader; } }
private List <RemoteRunspace> CreateRunspacesWhenComputerNameParameterSpecified() { string[] strArray; List <RemoteRunspace> list = new List <RemoteRunspace>(); base.ResolveComputerNames(this.ComputerName, out strArray); base.ValidateComputerName(strArray); for (int i = 0; i < strArray.Length; i++) { try { int num2; WSManConnectionInfo connectionInfo = null; connectionInfo = new WSManConnectionInfo(); string str = this.UseSSL.IsPresent ? "https" : "http"; connectionInfo.ComputerName = strArray[i]; connectionInfo.Port = this.Port; connectionInfo.AppName = this.ApplicationName; connectionInfo.ShellUri = this.ConfigurationName; connectionInfo.Scheme = str; if (this.CertificateThumbprint != null) { connectionInfo.CertificateThumbprint = this.CertificateThumbprint; } else { connectionInfo.Credential = this.Credential; } connectionInfo.AuthenticationMechanism = this.Authentication; base.UpdateConnectionInfo(connectionInfo); connectionInfo.EnableNetworkAccess = (bool)this.EnableNetworkAccess; string runspaceName = this.GetRunspaceName(i, out num2); RemoteRunspace item = new RemoteRunspace(Utils.GetTypeTableFromExecutionContextTLS(), connectionInfo, base.Host, this.SessionOption.ApplicationArguments, runspaceName, num2); list.Add(item); } catch (UriFormatException exception) { PipelineWriter objectWriter = this.stream.ObjectWriter; ErrorRecord errorRecord = new ErrorRecord(exception, "CreateRemoteRunspaceFailed", ErrorCategory.InvalidArgument, strArray[i]); Action <Cmdlet> action = delegate(Cmdlet cmdlet) { cmdlet.WriteError(errorRecord); }; objectWriter.Write(action); } } return(list); }
private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { this.DisposeCommands(); this.localPipeline = null; this.externalSuccessOutput = null; this.externalErrorOutput = null; this.executionScope = null; this.SecurityContext.Dispose(); this.SecurityContext = null; this.logBuffer = null; } this.disposed = true; } }
internal JsonOutputWriter(PipelineWriter inner, PSRuleOption option) : base(inner, option) { }
private void HandleRunspaceStateChanged(object sender, OperationStateEventArgs stateEventArgs) { ErrorRecord errorRecord; PSRemotingTransportException exception2; string str; if (sender == null) { throw PSTraceSource.NewArgumentNullException("sender"); } if (stateEventArgs == null) { throw PSTraceSource.NewArgumentNullException("stateEventArgs"); } RunspaceStateEventArgs baseEvent = stateEventArgs.BaseEvent as RunspaceStateEventArgs; RunspaceState state = baseEvent.RunspaceStateInfo.State; OpenRunspaceOperation operation = sender as OpenRunspaceOperation; RemoteRunspace operatedRunspace = operation.OperatedRunspace; if (operatedRunspace != null) { operatedRunspace.URIRedirectionReported -= new EventHandler <RemoteDataEventArgs <Uri> >(this.HandleURIDirectionReported); } PipelineWriter objectWriter = this.stream.ObjectWriter; Exception reason = baseEvent.RunspaceStateInfo.Reason; switch (state) { case RunspaceState.Opened: { PSSession remoteRunspaceInfo = new PSSession(operatedRunspace); base.RunspaceRepository.Add(remoteRunspaceInfo); Action <Cmdlet> action = cmdlet => cmdlet.WriteObject(remoteRunspaceInfo); if (objectWriter.IsOpen) { objectWriter.Write(action); } return; } case RunspaceState.Closed: { Uri uri = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <Uri>(operatedRunspace.ConnectionInfo, "ConnectionUri", null); string message = base.GetMessage(RemotingErrorIdStrings.RemoteRunspaceClosed, new object[] { (uri != null) ? uri.AbsoluteUri : string.Empty }); Action <Cmdlet> action3 = cmdlet => cmdlet.WriteVerbose(message); if (objectWriter.IsOpen) { objectWriter.Write(action3); } if (reason != null) { ErrorRecord errorRecord2 = new ErrorRecord(reason, "PSSessionStateClosed", ErrorCategory.OpenError, operatedRunspace); Action <Cmdlet> action4 = cmdlet => cmdlet.WriteError(errorRecord2); if (objectWriter.IsOpen) { objectWriter.Write(action4); } } return; } case RunspaceState.Closing: return; case RunspaceState.Broken: exception2 = reason as PSRemotingTransportException; str = null; if (exception2 != null) { OpenRunspaceOperation operation2 = sender as OpenRunspaceOperation; if (operation2 != null) { string computerName = operation2.OperatedRunspace.ConnectionInfo.ComputerName; if (exception2.ErrorCode != -2144108135) { str = "[" + computerName + "] "; if (!string.IsNullOrEmpty(exception2.Message)) { str = str + exception2.Message; } else if (!string.IsNullOrEmpty(exception2.TransportMessage)) { str = str + exception2.TransportMessage; } break; } string str3 = PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.URIRedirectionReported, new object[] { exception2.Message, "MaximumConnectionRedirectionCount", "PSSessionOption", "AllowRedirection" }); str = "[" + computerName + "] " + str3; } } break; default: return; } PSRemotingDataStructureException exception3 = reason as PSRemotingDataStructureException; if (exception3 != null) { OpenRunspaceOperation operation3 = sender as OpenRunspaceOperation; if (operation3 != null) { string str4 = operation3.OperatedRunspace.ConnectionInfo.ComputerName; str = "[" + str4 + "] " + exception3.Message; } } if (reason == null) { reason = new RuntimeException(base.GetMessage(RemotingErrorIdStrings.RemoteRunspaceOpenUnknownState, new object[] { state })); } string fQEIDFromTransportError = WSManTransportManagerUtils.GetFQEIDFromTransportError((exception2 != null) ? exception2.ErrorCode : 0, this._defaultFQEID); errorRecord = new ErrorRecord(reason, operatedRunspace, fQEIDFromTransportError, ErrorCategory.OpenError, null, null, null, null, null, str, null); Action <Cmdlet> action2 = cmdlet => cmdlet.WriteError(errorRecord); if (objectWriter.IsOpen) { objectWriter.Write(action2); } this.toDispose.Add(operatedRunspace); }
internal CsvOutputWriter(PipelineWriter inner, PSRuleOption option) : base(inner, option) { _Builder = new StringBuilder(); }
public override void Read(PipelineWriter output) { int blockWidth = Math.Max((width + 3) / 4, 1); int blockHeight = Math.Max((height + 3) / 4, 1); PixelColor[,] cache0 = new PixelColor[4, blockWidth * 4]; PixelColor[,] cache1 = new PixelColor[4, blockWidth * 4]; bool isPingPong = false; #if !NET40 System.Threading.Tasks.Task task = null; #endif using (SimpleBinaryStream stream = new SimpleBinaryStream(dataSource)) { for (int y = 0; y < blockHeight; y++) { if (isPingPong) { for (int x = 0; x < blockWidth; x++) ReadBlock(stream, ref cache1, x); } else { for (int x = 0; x < blockWidth; x++) ReadBlock(stream, ref cache0, x); } #if !NET40 if (task != null) task.Wait(); #endif bool pingPoing = isPingPong; int baseY = y; #if !NET40 task = System.Threading.Tasks.Task.Run((() => { #endif for (int y2 = 0; y2 < 4; y2++) { int currentY = baseY * 4 + y2; if (currentY < height) { if (pingPoing) { for (int x = 0; x < width; x++) output.Write(cache1[y2, x]); } else { for (int x = 0; x < width; x++) output.Write(cache0[y2, x]); } } } #if !NET40 })); #endif isPingPong = !isPingPong; } #if !NET40 task.Wait(); #endif } }
public abstract void Read(PipelineWriter output);