// Encode outgoing data. // // Warning: not all type are supported (see below). protected override bool OnBeforeOutgoing(IHubOutgoingInvokerContext context) { _log.Debug(""); var args = context.Invocation.Args; for (int argI = 0; argI < args.Length; argI++) { if (typeof(IEncodable).IsAssignableFrom(args[argI].GetType())) { IEncodable model = (IEncodable)args[argI]; model.Encode(); } else if (args[argI].GetType() == typeof(string)) { args[argI] = HttpUtility.HtmlEncode(args[argI].ToString()); } else if (args[argI].GetType() == typeof(List <string>)) { var items = (List <string>)args[argI]; for (int itemI = 0; itemI < items.Count; itemI++) { items[itemI] = HttpUtility.HtmlEncode(items[itemI]); } //} else { // Won't get encoded! } } return(base.OnBeforeOutgoing(context)); }
public void Encode(IEncodable value) { bool hasValue = value != null; this.Encode(hasValue); if (hasValue) { value.Encode(this); } }
public void Write(IAction t) { BinaryOutput stream = _stream as BinaryOutput; int i = 0; if (t is SetTileAction) { i = 1; } if (t is MultiAction) { i = 2; } if (t is FillAction) { i = 3; } if (t is RectangleAction) { i = 4; } if (t is AddEntityAction) { i = 5; } if (t is RemoveEntityAction) { i = 6; } stream.Write(i); IEncodable encodable = t as IEncodable; if (encodable != null) { encodable.Encode(stream); } }
public static void Encode(BinaryOutput output, IEncodable value) { value.Encode(output); }
public static void Encode(Stream stream, IEncodable value) { BinaryOutput output = new BinaryOutput(stream); value.Encode(output); }
private static void CheckEncoded(string expected, IEncodable expression) => Assert.Equal(expected, expression.Encode());
public void Write(IEncodable value) { value.Encode(this); }
public async static Task SendSecretMessage(Stream s, byte[] key, IEncodable message, CancellationToken token = default) { await SendSecretMessage(s, key, message.Encode(), token); }
public static string Encode(IEncodable encodable) { return(Encode(encodable.Encode())); }
public static void DecodeCopy(IEncodable encodable, IEncodable toCopy) { Decode(encodable, Encode(toCopy.Encode())); }
/// <summary> /// Encode an encodable object. /// </summary> /// <param name="encodable"></param> public void Encode(IEncodable encodable) { encodable.Encode(encoder); }
public static string Encode(IEncodable encodable) { return Encode(encodable.Encode()); }