protected Planner() { this.move = new Move(); this.pull = new Pull(); this.push = new Push(); this.noOp = new NoOp(); }
public void FindPartialType() { Qubit qubit = new TestQubit(); QArray <Qubit> qubits = new QArray <Qubit>(); IUnitary <TestTuple> op = new NoOp(null); var _ = AbstractCallable._; TestOnePartialType(typeof(QVoid), typeof(long), 1L); TestOnePartialType(typeof(long), typeof(long), _); TestOnePartialType(typeof(IUnitary), typeof(IUnitary <TestTuple>), _); TestOnePartialType(typeof(Qubit), typeof(TestQubit), _); TestOnePartialType(typeof(QVoid), typeof(QVoid), _); TestOnePartialType(typeof(IUnitary), (1, op).GetType(), (1, _)); TestOnePartialType(typeof(Qubit), (qubit, op).GetType(), (_, op)); TestOnePartialType(typeof(ValueTuple <Qubit, IUnitary>), (qubit, op).GetType(), (_, _)); TestOnePartialType(typeof(IUnitary), (qubit, op).GetType(), (qubit, _)); TestOnePartialType(typeof(Qubit), (qubit, 1L, op).GetType(), (_, 1L, op)); TestOnePartialType(typeof(ValueTuple <Int64, IUnitary>), (Result.One, 2.0, 3L, qubit, op).GetType(), (Result.One, 2.0, _, qubit, _)); var original = (Result.One, (1L, 2.0), (3L, (op, qubits))); TestOnePartialType(typeof(QVoid), original.GetType(), (Result.One, (1L, 2.0), (3L, (op, qubits)))); TestOnePartialType(typeof(Result), original.GetType(), (_, (1L, 2.0), (3L, (op, qubits)))); TestOnePartialType(typeof(ValueTuple <Result, long, long>), original.GetType(), (_, (_, 2.0), (_, (op, qubits)))); TestOnePartialType(typeof(ValueTuple <long, double>), original.GetType(), (Result.One, _, (3L, (op, qubits)))); TestOnePartialType(typeof(ValueTuple <long, double>), original.GetType(), (Result.One, (_, _), (3L, (op, qubits)))); TestOnePartialType(typeof(ValueTuple <long, QArray <Qubit> >), original.GetType(), (Result.One, (1L, 2.0), (_, (op, _)))); TestOnePartialType(typeof(ValueTuple <Result, ValueTuple <long, IUnitary> >), original.GetType(), (_, (1L, 2.0), (_, (_, qubits)))); }
public override void Begin(ref Statement s) { switch (s.StatementType) { case StatementType.VariableDeclaration: { var e = s as VariableDeclaration; if (e.Variable.IsConstant) { s = new NoOp(e.Source); } } break; case StatementType.TryCatchFinally: case StatementType.Throw: case StatementType.Switch: case StatementType.Draw: case StatementType.DrawDispose: case StatementType.ExternScope: Log.Error(s.Source, ErrorCode.E5014, "<" + s.StatementType + "> is not supported in shader (in " + Generator.Path.Quote() + ")"); break; } Parent = s is Expression ? null : s; }
public override void End(ref Statement e) { if (e is LoadLocal && (e as LoadLocal).Variable.IsIndirection) { e = new NoOp(e.Source); } }
public void PartialMappingErrors() { Qubit qubit = null; QArray <Qubit> qubits = new QArray <Qubit>(); NoOp op = new NoOp(null); var _ = AbstractCallable._; var expected = (Result.One, (1, 2.0), (3, (op, qubits)), qubit); OperationsTestHelper.IgnoreDebugAssert(() => { // If too many parameters, are ignored: TestOneMapping(expected, Result.One, (Result.One, (1, 2.0), (3, (op, qubits)), qubit)); // Parameters mismatch TestOneMappingError <TestTuple, (double, double), MissingMethodException>((2.0, 3.0), (Result.One, _, (3, (op, qubits)), qubit)); TestOneMappingError <TestTuple, int, MissingMethodException>(1, (_, (1, 2.0), (3, (op, qubits)), qubit)); TestOneMappingError <TestTuple, int, MissingMethodException>(1, (Result.One, _, (3, (op, qubits)), qubit)); //TestOneMapping((1, 2, (3, 4)), (2, 4), (1, new MissingParameter(typeof((int,int))), (3, _))); // Too little parameters TestOneMappingError <TestTuple, Result, InvalidOperationException>(Result.One, (_, _, (3, (op, qubits)), qubit)); // Both, parameters mismatch and too little parameters TestOneMappingError <TestTuple, int, InvalidOperationException>(1, (_, _, (3, (op, qubits)), qubit)); }); }
public void TupleNoSubstitutions() // substitutes nothing { Qubit qubit = null; QArray <Qubit> qubits = new QArray <Qubit>(); IUnitary <TestTuple> op = new NoOp(null); TestOneTupleNoSubstitution(QVoid.Instance); TestOneTupleNoSubstitution(1L, 1L); TestOneTupleNoSubstitution(qubit, qubit); TestOneTupleNoSubstitution(qubits, qubits); TestOneTupleNoSubstitution((1L, 2.0), 1L, 2.0); TestOneTupleNoSubstitution((1L, 2.0, Result.Zero), 1L, 2.0, Result.Zero); TestOneTupleNoSubstitution(((1L, 2.0), Result.Zero), 1L, 2.0, Result.Zero); TestOneTupleNoSubstitution(((1L, 2.0), (Result.Zero, qubit, qubits)), 1L, 2.0, Result.Zero, qubit, qubits); TestOneTupleNoSubstitution(((op, 4L, (1L, 2.0)), (Result.Zero, (op, qubits, qubit))), op, 4L, 1L, 2.0, Result.Zero, op, qubits, qubit); }
protected dynamic Visit(AST node) { return(node switch { Program program => VisitProgram(program), Block block => VisitBlock(block), VarDecl decl => VisitDecl(decl), Compound compound => VisitCompound(compound), Assign assign => VisitAssign(assign), NoOp noOp => VisitNoOp(noOp), Var var => VisitVar(var), Num num => VisitNum(num), BinOp binOp => VisitBinOp(binOp), UnaryOp unaryOp => VisitUnaryOp(unaryOp), _ => throw new NotImplementedException() });
public override string ToString() { s = (NoOp)base.Tag; Binding descbinding = new Binding("Description"); descbinding.Mode = BindingMode.TwoWay; descbinding.Source = s; txtdesc.SetBinding(TextBox.TextProperty, descbinding); Binding varbinding = new Binding("variable"); varbinding.Mode = BindingMode.TwoWay; varbinding.Source = s; txtvar.SetBinding(TextBox.TextProperty, varbinding); return base.ToString(); }
public override void End(ref Statement s) { switch (s.StatementType) { case StatementType.VariableDeclaration: { var vd = s as VariableDeclaration; for (var var = vd.Variable; var != null; var = var.Next) { if (InlineVariables.Contains(var)) { s = new NoOp(vd.Source); } } } break; } }
public override string ToString() { s = (NoOp)base.Tag; Binding descbinding = new Binding("Description"); descbinding.Mode = BindingMode.TwoWay; descbinding.Source = s; txtdesc.SetBinding(TextBox.TextProperty, descbinding); Binding varbinding = new Binding("variable"); varbinding.Mode = BindingMode.TwoWay; varbinding.Source = s; txtvar.SetBinding(TextBox.TextProperty, varbinding); return(base.ToString()); }
public override void End(ref Statement e) { if (e.Tag is InvalidExpression) { e = new NoOp(e.Source); } switch (e.StatementType) { case StatementType.DrawDispose: { if (!Backend.CanExportDontExports) { e = ILFactory.CallMethod(e.Source, new This(e.Source, Type).Address, "free_DrawCalls"); } break; } } }
public void performAction() { IAction action = null; if (actionQueue.Count > 0) { action = actionQueue.Dequeue(); } if (action == null) { action = new NoOp(); } action.ProcessAction(this); if (debug) { Debug.Log(roundManager.tickCount + ": " + action.DebugSerialize()); } }
public IRpcMethodResult NextAction(Me me, Meta meta, List <Entity> entities) { _logger.LogInformation("Next action requested."); _logger.LogInformation(JsonSerializer.Serialize(me)); _logger.LogInformation(JsonSerializer.Serialize(meta)); _logger.LogInformation(JsonSerializer.Serialize(entities)); var rnd = new Random(); var noop = new NoOp(); var walk = new WalkOp(Direction.North); var throww = new ThrowOp(rnd.Next(0, 50), rnd.Next(0, 50)); var look = new LookOp(rnd.Next(0, 50)); var actions = new IOperation[] { noop, walk, throww, look }; var result = actions[rnd.Next(0, actions.Length)]; _logger.LogInformation("Sending reply: {Result}", JsonSerializer.Serialize(result)); return(this.Ok(result)); }
private void AssignSecondary() { ICommand assign = new NoOp(); if (_cursorPosition == BoomerangPosition && _agent.Player.Inventory.HasBoomerang) { assign = new LinkSecondaryAddAndAssign(_agent.Player, Secondary.Boomerang); _selectedItem = Boomerang; } if (_cursorPosition == BombPosition && _agent.Player.Inventory.BombCount >= 1) { assign = new LinkSecondaryAddAndAssign(_agent.Player, Secondary.Bomb); _selectedItem = Bomb; } if (_cursorPosition == BowPosition && _agent.Player.Inventory.HasBow && _agent.Player.Inventory.HasArrow) { assign = new LinkSecondaryAddAndAssign(_agent.Player, Secondary.Bow); _selectedItem = Arrow; } assign.Execute(); }
public void PartialMapping() { Qubit qubit = null; QArray <Qubit> qubits = new QArray <Qubit>(); NoOp op = new NoOp(null); var _ = AbstractCallable._; TestOneMapping(1, 1, _); TestOneMapping(op, op, _); TestOneMapping(qubit, qubit, _); TestOneMapping(QVoid.Instance, QVoid.Instance, _); TestOneMapping(1, QVoid.Instance, 1); TestOneMapping((1, op), op, (1, _)); TestOneMapping((qubit, op), qubit, (_, op)); TestOneMapping((qubit, op), (qubit, op), (_, _)); TestOneMapping((qubit, op), (qubit, op), _); TestOneMapping((Result.One, 2.0, 3, qubit, op), (3, op), (Result.One, 2.0, _, qubit, _)); var expected = (Result.One, (1, 2.0), (3, (op, qubits)), qubit); TestOneMapping(expected, QVoid.Instance, (Result.One, (1, 2.0), (3, (op, qubits)), qubit)); TestOneMapping(expected, Result.One, (_, (1, 2.0), (3, (op, qubits)), qubit)); TestOneMapping(expected, (Result.One, (1, 2.0)), (_, _, (3, (op, qubits)), qubit)); TestOneMapping(expected, (Result.One, (3, (op, qubits))), (_, (1, 2.0), _, qubit)); TestOneMapping(expected, (Result.One, qubit), (_, (1, 2.0), (3, (op, qubits)), _)); TestOneMapping(expected, qubit, (Result.One, (1, 2.0), (3, (op, qubits)), _)); TestOneMapping(expected, (1, 2.0), (Result.One, _, (3, (op, qubits)), qubit)); TestOneMapping(expected, ((1, 2.0), qubit), (Result.One, _, (3, (op, qubits)), _)); TestOneMapping(expected, (3, (op, qubits)), (Result.One, (1, 2.0), _, qubit)); TestOneMapping(expected, ((1, 2.0), (3, (op, qubits))), (Result.One, _, _, qubit)); TestOneMapping(expected, 2.0, (Result.One, (1, _), (3, (op, qubits)), qubit)); TestOneMapping(expected, (Result.One, 2.0, op), (_, (1, _), (3, (_, qubits)), qubit)); TestOneMapping(expected, ((1, 2.0), (3, qubits)), (Result.One, _, (_, (op, _)), qubit)); TestOneMapping(expected, expected, (_, _, _, _)); TestOneMapping((expected, expected), expected, (expected, _)); TestOneMapping((1, 2, (3, 4)), (2, 4), (1, _, (3, _))); TestOneMapping((1, (2.1, 2.2), (3, 4)), ((2.1, 2.2), 4), (1, _, (3, _))); TestOneMapping((1, (2.1, 2.2), (3, (4.1, 4.2))), ((2.1, 2.2), (4.1, 4.2)), (1, _, (3, _))); }
public void VisitNoOp(NoOp node) { }
public override string VisitNoOp(NoOp noOp) { return(""); }
public virtual void WriteNoOp(NoOp s, ExpressionUsage u) { }
public string visit(NoOp node) { throw new NotImplementedException(); }
public virtual T VisitNoOp(NoOp noOp) { throw new NotImplementedException(); }
public abstract void VisitNoOp(NoOp node);
public string VisitNoOp(NoOp noOp) { throw new NotImplementedException(); }
public EventLoopTests(ITestOutputHelper output) : base(output) { this.eventLoop = new EventLoop(null, null); this.noOp = new NoOp(); }
/// <summary> /// Process the web request. /// </summary> /// <param name="context">The context of this single web request.</param> public void ProcessRequest(HttpContext context) { UriTemplateMatch templateMatch = null; RestMethodInfo rmi = null; ArrayList finalParameters = null; Object result = null, p; // // Initialization phase, register all handlers and then find a match. // try { // // Register all handlers. // RegisterHandlers(); String baseUrl = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + context.Request.FilePath; rmi = FindHandler(context.Request.HttpMethod.ToUpper(), new Uri(baseUrl), context.Request.Url, ref templateMatch); if (rmi == null) { throw new MissingMethodException(); } } catch (Exception e) { context.Response.Write(String.Format("Exception occurred at init: {0}", e.Message + e.StackTrace)); return; } // // Parse out any parameters for the method call. // try { finalParameters = new ArrayList(); // // Walk each parameter in the method and see if we can convert // one of the query variables to the proper type. // foreach (ParameterInfo pi in rmi.methodInfo.GetParameters()) { try { p = null; if (typeof(Stream).IsAssignableFrom(pi.ParameterType)) { p = context.Request.InputStream; } else if (templateMatch.BoundVariables.AllKeys.Contains(pi.Name.ToUpper()) == true) { p = templateMatch.BoundVariables[pi.Name.ToUpper()]; if (p != null) { if (typeof(List <String>).IsAssignableFrom(pi.ParameterType)) { p = p.ToString().Split(new char[1] { ',' }).ToList <String>(); } else { p = Convert.ChangeType(p, pi.ParameterType); } } } } catch { p = null; } finalParameters.Add(p); } } catch (Exception e) { context.Response.Write(String.Format("Exception occurred at parameter parse: {0} at {1}", e.Message, e.StackTrace)); return; } // // Force the context to be anonymous, then authenticate if the user // is calling a non-anonymous method. // try { ArenaContext.Current.SetWebServiceProperties(ArenaContext.Current.CreatePrincipal(""), new Arena.Core.Person()); if (rmi.uriTemplate.ToString() != "/version" && rmi.uriTemplate.ToString() != "/login" && rmi.uriTemplate.ToString() != "/help" && rmi.methodInfo.GetCustomAttributes(typeof(RestApiAnonymous), true).Length == 0) { String PathAndQuery = context.Request.RawUrl.ToLower(); PathAndQuery = PathAndQuery.Substring(context.Request.FilePath.Length + 1); AuthenticationManager.SetupSessionForRequest(context.Request.QueryString["api_session"], false); AuthenticationManager.VerifySignature(context.Request.Url, PathAndQuery, context.Request.QueryString["api_session"]); } } catch (Exception e) { RESTException restEx = e as RESTException; if (restEx != null) { result = new RestErrorMessage(restEx); } else { result = new RestErrorMessage(System.Net.HttpStatusCode.InternalServerError, e.ToString(), string.Empty); } } // // Perform the actual method call. // if (result == null) { try { // // Set some default response information. // context.Response.ContentType = "application/xml; charset=utf-8"; if (TypeIsServiceContract(rmi.instance.GetType()) == true) { // // Run the request inside of a operation context so response information // can be set. This is a bit of a cheat, but it works. // WebChannelFactory <NoOp> factory = new WebChannelFactory <NoOp>(new Uri("http://localhost/")); NoOp channel = factory.CreateChannel(); using (new OperationContextScope((IContextChannel)channel)) { result = rmi.methodInfo.Invoke(rmi.instance, (object[])finalParameters.ToArray(typeof(object))); if (WebOperationContext.Current.OutgoingResponse.ContentType != null) { context.Response.ContentType = WebOperationContext.Current.OutgoingResponse.ContentType; } } } else { // // This is a standard method call, just call it. // result = rmi.methodInfo.Invoke(rmi.instance, (object[])finalParameters.ToArray(typeof(object))); } } catch (Exception e) { RESTException restEx; if (e.InnerException != null) { e = e.InnerException; } restEx = e as RESTException; if (restEx != null) { result = new RestErrorMessage(restEx); } else { result = new RestErrorMessage(System.Net.HttpStatusCode.InternalServerError, e.ToString(), string.Empty); } } } // // Deal with the response that was generated. // try { if (result != null) { // // There is probably a better way to do this, but this is the best // I can come up with. Somebody feel free to make this cleaner. // if (typeof(Stream).IsAssignableFrom(result.GetType()) == true) { Stream s = (Stream)result; int count; // // Response is a data stream, just copy it to the response // stream. // do { byte[] buf = new byte[8192]; count = s.Read(buf, 0, 8192); context.Response.BinaryWrite(buf); } while (count > 0); } else if (typeof(Message).IsAssignableFrom(result.GetType()) == true) { Message msg = (Message)result; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); XmlTextWriter xtw = new XmlTextWriter(sw); // // Response is a Message object. Write it out as an XML // stream. // msg.WriteMessage(xtw); context.Response.Write(sb.ToString()); } else { DataContractSerializer serializer = new DataContractSerializer(result.GetType()); // // Otherwise, use the DataContractSerializer to convert the object into // an XML stream. // serializer.WriteObject(context.Response.OutputStream, result); } } } catch (Exception e) { context.Response.Write(String.Format("Exception sending response: {0}", e.Message)); return; } }
public object VisitNoOp(NoOp node) { return(null); }
private int VisitNoOp(NoOp node) { return(0); }
void Eval_NoOp(NoOp node) { return; }
/// <summary> /// Process the web request. /// </summary> /// <param name="context">The context of this single web request.</param> public void ProcessRequest(HttpContext context) { UriTemplateMatch templateMatch = null; RestMethodInfo rmi = null; ArrayList finalParameters = null; Object result = null, p; // // Initialization phase, register all handlers and then find a match. // try { // // Register all handlers. // RegisterHandlers(); String baseUrl = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + context.Request.FilePath; rmi = FindHandler(context.Request.HttpMethod.ToUpper(), new Uri(baseUrl), context.Request.Url, ref templateMatch); if (rmi == null) { throw new MissingMethodException(); } } catch (Exception e) { context.Response.Write(String.Format("Exception occurred at init: {0}", e.Message + e.StackTrace)); return; } // // Parse out any parameters for the method call. // try { finalParameters = new ArrayList(); // // Walk each parameter in the method and see if we can convert // one of the query variables to the proper type. // foreach (ParameterInfo pi in rmi.methodInfo.GetParameters()) { try { p = null; if (typeof(Stream).IsAssignableFrom(pi.ParameterType)) { p = context.Request.InputStream; } else if (templateMatch.BoundVariables.AllKeys.Contains(pi.Name.ToUpper()) == true) { p = templateMatch.BoundVariables[pi.Name.ToUpper()]; if (p != null) { if (typeof(List <String>).IsAssignableFrom(pi.ParameterType)) { p = p.ToString().Split(new char[1] { ',' }).ToList <String>(); } else { p = Convert.ChangeType(p, pi.ParameterType); } } } } catch { p = null; } finalParameters.Add(p); } } catch (Exception e) { context.Response.Write(String.Format("Exception occurred at parameter parse: {0} at {1}", e.Message, e.StackTrace)); return; } // // Force the context to be anonymous, then authenticate if the user // is calling a non-anonymous method. // try { ArenaContext.Current.SetWebServiceProperties(ArenaContext.Current.CreatePrincipal(""), new Arena.Core.Person()); String PathAndQuery = String.Empty; if (rmi.uriTemplate.ToString() != "/version" && rmi.uriTemplate.ToString() != "/login" && rmi.uriTemplate.ToString() != "/help" && rmi.methodInfo.GetCustomAttributes(typeof(RestApiAnonymous), true).Length == 0 && rmi.methodInfo.GetCustomAttributes(typeof(RestApiCustom), true).Length == 0) { PathAndQuery = context.Request.Path + "?" + context.Server.UrlDecode(context.Request.QueryString.ToString()); PathAndQuery = PathAndQuery.Substring(context.Request.FilePath.Length + 1).ToLower(); PathAndQuery = PathAndQuery.Substring(0, PathAndQuery.IndexOf("api_sig") - 1); string apiSession = context.Request.Params["api_session"]; // Loop through non-production environments to determine where we are bool checkForExpiration = true; if (ConfigurationSettings.AppSettings["EnableAutomaticSessionExtension"] == "true") { foreach (String url in ConfigurationSettings.AppSettings["Environments"].Split(',')) { if (HttpContext.Current.Request.Url.ToString().IndexOf(url) > -1) { checkForExpiration = false; } } } if (!checkForExpiration) { CoreApiSessionService.ExtendExpiration(apiSession); } AuthenticationManager.SetupSessionForRequest(apiSession, false); AuthenticationManager.VerifySignature(context.Request.Url, PathAndQuery, apiSession); } else if (rmi.methodInfo.GetCustomAttributes(typeof(RestApiCustom), true).Length != 0) { PathAndQuery = context.Request.Path; PathAndQuery = PathAndQuery.Substring(context.Request.FilePath.Length + 1).ToLower(); string secret = String.Empty; foreach (String element in context.Request.Form.AllKeys) { if (element != "api_sig" && element.IndexOf("btn_") == -1) { PathAndQuery += (PathAndQuery.IndexOf("?") > 0 ? "&" : "?"); PathAndQuery += element.Trim() + "=" + context.Request.Form[element]; } if (element == "api_session") { CoreApiSessionService cass = new CoreApiSessionService(); secret = cass.GetSecretBySessionId(context.Request.Form[element]); } } if (!String.IsNullOrEmpty(secret)) { string sig = EncryptString(secret + "_" + PathAndQuery.ToLower()); if (sig.ToLower() != context.Request.Params["api_sig"].ToLower()) { throw new Exception("Invalid signature. " + "Path: " + context.Request.Path + "?" + context.Server.UrlDecode(context.Request.QueryString.ToString()) + "; Signatured string: " + secret + "_" + PathAndQuery.ToLower()); } } else { throw new Exception("Invalid session."); } } } catch (Exception e) { RESTException restEx = e as RESTException; if (restEx != null) { // result = new RestErrorMessage(System.Net.HttpStatusCode.Conflict, e.Message + " " + e.StackTrace, string.Empty); result = new RestErrorMessage(restEx); } else { result = new RestErrorMessage(System.Net.HttpStatusCode.OK, e.Message, string.Empty); } } // // Perform the actual method call. // if (result == null) { // NPM: Capture session and user id's for logging string sessionid = System.Web.HttpContext.Current.Request.Params["sessionid"]; int? personid = PersonId(); try { // // Set some default response information. // context.Response.ContentType = "application/xml; charset=utf-8"; if (TypeIsServiceContract(rmi.instance.GetType()) == true) { // // Run the request inside of a operation context so response information // can be set. This is a bit of a cheat, but it works. // WebChannelFactory <NoOp> factory = new WebChannelFactory <NoOp>(new Uri("http://localhost/")); NoOp channel = factory.CreateChannel(); using (new OperationContextScope((IContextChannel)channel)) { result = rmi.methodInfo.Invoke(rmi.instance, (object[])finalParameters.ToArray(typeof(object))); if (WebOperationContext.Current.OutgoingResponse.ContentType != null) { context.Response.ContentType = WebOperationContext.Current.OutgoingResponse.ContentType; } } } else { // // This is a standard method call, just call it. // result = rmi.methodInfo.Invoke(rmi.instance, (object[])finalParameters.ToArray(typeof(object))); } // NPM: Log the call as a SUCCESS ApiSessionLogService.Log(sessionid, personid, context.Request.PathInfo.ToLower(), "SUCCESS", ""); } catch (Exception e) { // NPM: Log the call as a FAILURE ApiSessionLogService.Log(sessionid, personid, context.Request.PathInfo.ToLower(), "FAILURE", e.InnerException.Message); RESTException restEx; if (e.InnerException != null) { e = e.InnerException; } restEx = e as RESTException; if (restEx != null) { result = new RestErrorMessage(restEx); } else { result = new RestErrorMessage(System.Net.HttpStatusCode.OK, e.Message, string.Empty); } } } // // Deal with the response that was generated. // try { if (result != null) { // // There is probably a better way to do this, but this is the best // I can come up with. Somebody feel free to make this cleaner. // if (typeof(Stream).IsAssignableFrom(result.GetType()) == true) { Stream s = (Stream)result; int count; // // Response is a data stream, just copy it to the response // stream. // do { byte[] buf = new byte[8192]; count = s.Read(buf, 0, 8192); context.Response.BinaryWrite(buf); } while (count > 0); } else if (typeof(Message).IsAssignableFrom(result.GetType()) == true) { Message msg = (Message)result; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); XmlTextWriter xtw = new XmlTextWriter(sw); // // Response is a Message object. Write it out as an XML // stream. // msg.WriteMessage(xtw); context.Response.Write(sb.ToString()); } else { DataContractSerializer serializer = new DataContractSerializer(result.GetType()); // // Otherwise, use the DataContractSerializer to convert the object into // an XML stream. // serializer.WriteObject(context.Response.OutputStream, result); } } } catch (Exception e) { context.Response.Write(String.Format("Exception sending response: {0}", e.Message)); return; } }
public override void VisitNoOp(NoOp node) { }
void Visit(NoOp noOp) { }