public ExpandableMemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible) { if (buffer == null) { throw new ArgumentNullException("buffer", MyEnvironment.GetResourceString("ArgumentNull_Buffer")); } if (index < 0) { throw new ArgumentOutOfRangeException("index", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if ((buffer.Length - index) < count) { throw new ArgumentException(MyEnvironment.GetResourceString("Argument_InvalidOffLen")); } this._buffer = buffer; this._origin = this._position = index; this._length = this._capacity = index + count; this._writable = writable; this._exposable = publiclyVisible; this._isOpen = true; }
/// <summary> /// Throw ObjectDisposedException if the MRES is disposed /// </summary> private void ThrowIfDisposed() { if ((m_combinedState & Dispose_BitMask) != 0) { throw new ObjectDisposedException(MyEnvironment.GetResourceString("ManualResetEventSlim_Disposed")); } }
public virtual byte[] GetBuffer() { if (!this._exposable) { throw new UnauthorizedAccessException(MyEnvironment.GetResourceString("UnauthorizedAccess_MemStreamBuffer")); } return(this._buffer); }
public override void Write(byte[] buffer, int offset, int count) { if (buffer == null) { throw new ArgumentNullException("buffer", MyEnvironment.GetResourceString("ArgumentNull_Buffer")); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if ((buffer.Length - offset) < count) { throw new ArgumentException(MyEnvironment.GetResourceString("Argument_InvalidOffLen")); } if (!this._isOpen) { // __Error.StreamIsClosed(); throw new NotImplementedException(""); } this.EnsureWriteable(); int num = this._position + count; if (num < 0) { throw new IOException(MyEnvironment.GetResourceString("IO.IO_StreamTooLong")); } if (num > this._length) { bool flag = this._position > this._length; if ((num > this._capacity) && this.EnsureCapacity(num)) { flag = false; } if (flag) { Array.Clear(this._buffer, this._length, num - this._length); } this._length = num; } if ((count <= 8) && (buffer != this._buffer)) { int num2 = count; while (--num2 >= 0) { this._buffer[this._position + num2] = buffer[offset + num2]; } } else { Buffer.BlockCopy(buffer, offset, this._buffer, this._position, count); } this._position = num; }
public Interpreter() { this.globals.define("clock", new Clock()); this.globals.define("print", new Print()); this.globals.define("println", new Println()); this.environment = this.globals; this.AddTypeScriptGlobals(); }
object Stmt.Visitor <object> .visitClassStmt(Class stmt) { //Console.WriteLine("visitClassStmt"); Object superclass = null; if (stmt.superclass != null) { superclass = evaluate(stmt.superclass); if (!(superclass is TypeScriptNativeClass)) { throw new RuntimeError(stmt.superclass.name, "Superclass must be a class."); } } environment.define(stmt.name.lexeme, null); if (stmt.superclass != null) { environment = new MyEnvironment(environment); environment.define("super", superclass); } Dictionary <String, TypeScriptNativeFunction> methods = new Dictionary <String, TypeScriptNativeFunction>(); foreach (Function method in stmt.methods) { TypeScriptNativeFunction function = new TypeScriptNativeFunction( method, environment, method.name.lexeme.Equals("constructor") ); methods.Add(method.name.lexeme, function); } TypeScriptNativeClass klass = new TypeScriptNativeClass( stmt.name.lexeme, (TypeScriptNativeClass)superclass, methods ); if (superclass != null) { environment = environment.enclosing; } environment.assign(stmt.name, klass); return(null); }
public ExpandableMemoryStream(int capacity) { if (capacity < 0) { throw new ArgumentOutOfRangeException("capacity", MyEnvironment.GetResourceString("ArgumentOutOfRange_NegativeCapacity")); } this._buffer = new byte[capacity]; this._capacity = capacity; this._writable = true; this._exposable = true; this._origin = 0; this._isOpen = true; }
public ExpandableMemoryStream(byte[] buffer, bool writable) { if (buffer == null) { throw new ArgumentNullException("buffer", MyEnvironment.GetResourceString("ArgumentNull_Buffer")); } this._buffer = buffer; this._length = this._capacity = buffer.Length; this._writable = writable; this._exposable = false; this._origin = 0; this._isOpen = true; }
public virtual void WriteTo(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream", MyEnvironment.GetResourceString("ArgumentNull_Stream")); } if (!this._isOpen) { //__Error.StreamIsClosed(); throw new NotImplementedException(""); } stream.Write(this._buffer, this._origin, this._length - this._origin); }
public override long Seek(long offset, SeekOrigin loc) { if (!this._isOpen) { // __Error.StreamIsClosed(); throw new NotImplementedException(""); } if (offset > 2147483647L) { throw new ArgumentOutOfRangeException("offset", MyEnvironment.GetResourceString("ArgumentOutOfRange_StreamLength")); } switch (loc) { case SeekOrigin.Begin: { int num = this._origin + ((int)offset); if ((offset < 0L) || (num < this._origin)) { throw new IOException(MyEnvironment.GetResourceString("IO.IO_SeekBeforeBegin")); } this._position = num; break; } case SeekOrigin.Current: { int num2 = this._position + ((int)offset); if (((this._position + offset) < this._origin) || (num2 < this._origin)) { throw new IOException(MyEnvironment.GetResourceString("IO.IO_SeekBeforeBegin")); } this._position = num2; break; } case SeekOrigin.End: { int num3 = this._length + ((int)offset); if (((this._length + offset) < this._origin) || (num3 < this._origin)) { throw new IOException(MyEnvironment.GetResourceString("IO.IO_SeekBeforeBegin")); } this._position = num3; break; } default: throw new ArgumentException(MyEnvironment.GetResourceString("Argument_InvalidSeekOrigin")); } return((long)this._position); }
public override int Read(byte[] buffer, int offset, int count) { if (buffer == null) { throw new ArgumentNullException("buffer", MyEnvironment.GetResourceString("ArgumentNull_Buffer")); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", MyEnvironment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if ((buffer.Length - offset) < count) { throw new ArgumentException(MyEnvironment.GetResourceString("Argument_InvalidOffLen")); } if (!this._isOpen) { //__Error.StreamIsClosed(); throw new NotImplementedException(""); } int byteCount = this._length - this._position; if (byteCount > count) { byteCount = count; } if (byteCount <= 0) { return(0); } if (byteCount <= 8) { int num2 = byteCount; while (--num2 >= 0) { buffer[offset + num2] = this._buffer[this._position + num2]; } } else { Buffer.BlockCopy(this._buffer, this._position, buffer, offset, byteCount); } this._position += byteCount; return(byteCount); }
private void ListenConnect() { try { while (true) { Socket client = _socket.Accept(); _env = new MyEnvironment(); Thread thread = new Thread(this.ReceiveMessage); thread.Start(client); } } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="ManualResetEventSlim"/> /// class with a Boolen value indicating whether to set the intial state to signaled and a specified /// spin count. /// </summary> /// <param name="initialState">true to set the initial state to signaled; false to set the initial state /// to nonsignaled.</param> /// <param name="spinCount">The number of spin waits that will occur before falling back to a true /// wait.</param> /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="spinCount"/> is less than /// 0.</exception> public ManualResetEventSlim(bool initialState, int spinCount) { if (spinCount < 0) { throw new ArgumentOutOfRangeException("spinCount"); } if (spinCount > SpinCountState_MaxValue) { throw new ArgumentOutOfRangeException( "spinCount", String.Format(MyEnvironment.GetResourceString("ManualResetEventSlim_ctor_SpinCountOutOfRange"), SpinCountState_MaxValue)); } // We will suppress default spin because the user specified a count. Initialize(initialState, spinCount); }
public void Execute() { string myDocumentsPath = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments); MyEnvironment env = new MyEnvironment(); string binariesPath = Path.Combine(env.BOSSS_BIN.FullName, "Release"); foreach (var entry in toolVersionFilesMap) { string tool = entry.Key; foreach (var versionFilesPair in entry.Value) { DirectoryInfo dest = new DirectoryInfo(Path.Combine( myDocumentsPath, "Visual Studio " + versionFilesPair.Key, "Visualizers")); if (!dest.Exists) { // VS version not installed continue; } Console.WriteLine( "Installing visualizer '{0}' to '{1}'", tool, dest.FullName); foreach (string fileName in versionFilesPair.Value) { FileInfo file = new FileInfo(Path.Combine( binariesPath, fileName)); if (!file.Exists) { throw new Exception(String.Format( "Could not find required file '{0}' in directory '{1}'.", fileName, binariesPath)); } file.CopyTo(Path.Combine(dest.FullName, fileName), true); } } } }
public void executeBlock(List <Stmt> statements, MyEnvironment environment) { //Console.WriteLine("executeBlock"); MyEnvironment previous = this.environment; try { this.environment = environment; foreach (Stmt statement in statements) { execute(statement); } } finally { this.environment = previous; } }
private bool EnsureCapacity(int value) { if (value < 0) { throw new IOException(MyEnvironment.GetResourceString("IO.IO_StreamTooLong")); } if (value <= this._capacity) { return(false); } int num = value; if (num < 256) { num = 256; } if (num < (this._capacity * 2)) { num = this._capacity * 2; } this.Capacity = num; return(true); }
public override void SetLength(long value) { if ((value < 0L) || (value > 2147483647L)) { throw new ArgumentOutOfRangeException("value", MyEnvironment.GetResourceString("ArgumentOutOfRange_StreamLength")); } this.EnsureWriteable(); if (value > (2147483647 - this._origin)) { throw new ArgumentOutOfRangeException("value", MyEnvironment.GetResourceString("ArgumentOutOfRange_StreamLength")); } int num = this._origin + ((int)value); if (!this.EnsureCapacity(num) && (num > this._length)) { Array.Clear(this._buffer, this._length, num - this._length); } this._length = num; if (this._position > num) { this._position = num; } }
static void Try() { var b = new MyEnvironment(); List <Vector3[]> positions = new List <Vector3[]>(); for (var i = 1; i <= 8000; i++) { var z = b.StepMove(0.01f); positions.Add(new Vector3[] { z[0][0], z[0][1], z[0][2] }); //Console.WriteLine("{0},{1}",z[0][0],z[0][1]); } //写入txt存档一下 string filename = @"position.txt"; StreamWriter sw = new StreamWriter(filename); foreach (var i in positions) { sw.WriteLine(string.Format("{0}\t{1}\t{2}", i[0], i[1], i[2])); } Console.WriteLine("success!"); Console.ReadKey(); }
public static ApiResponse GetExceptionApiResponse(this ApiResponse response, Exception error, MyEnvironment enviroment) { response.StatusCode = (int)HttpStatusCode.InternalServerError; response.Status = "Internal Server Error"; if (enviroment == MyEnvironment.Development || enviroment == MyEnvironment.Staging) { response.Errors.Add(error); } if (error is InvalidDataException) { response.StatusCode = (int)HttpStatusCode.BadRequest; response.Status = $"Bad Request"; } response.Success = false; return(response); }
public static ApiResponse GetExceptionApiResponse(this ApiResponse response, Exception error, MyEnvironment enviroment, string fromBody) { response.StatusCode = (int)HttpStatusCode.InternalServerError; response.Status = "Internal Server Error"; if (enviroment == MyEnvironment.Development || enviroment == MyEnvironment.Staging) { response.Errors.Add(error); } if (error is InvalidDataException) { response.StatusCode = (int)HttpStatusCode.BadRequest; response.Status = $"Bad Request"; } if (string.IsNullOrEmpty(fromBody)) { response.Errors.Add(new Exception("We Didn't Recieve An Object From The Body Of Your Request")); } response.Success = false; return(response); }
static public List <Dictionary <int, Vector3> > ParseInputJson(string paramsJson, MyEnvironment env) { ReceiveJson param = JsonConvert.DeserializeObject <ReceiveJson>(paramsJson); List <Dictionary <int, Vector3> > Result = env.StepsMove(param.steps, param.steps_pic, param.step_time, param.G); //进行投影校正 var corrected = MyDataFormat.Projection(Result, param); return(corrected); }
public MyService(MyEnvironment env) { _env = env; }
public HomeController(MyEnvironment env) { _env = env; }