Exemplo n.º 1
0
        // 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));
        }
Exemplo n.º 2
0
        public void Encode(IEncodable value)
        {
            bool hasValue = value != null;

            this.Encode(hasValue);

            if (hasValue)
            {
                value.Encode(this);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 public static void Encode(BinaryOutput output, IEncodable value)
 {
     value.Encode(output);
 }
Exemplo n.º 5
0
        public static void Encode(Stream stream, IEncodable value)
        {
            BinaryOutput output = new BinaryOutput(stream);

            value.Encode(output);
        }
Exemplo n.º 6
0
 private static void CheckEncoded(string expected, IEncodable expression) =>
 Assert.Equal(expected, expression.Encode());
Exemplo n.º 7
0
 public void Write(IEncodable value)
 {
     value.Encode(this);
 }
Exemplo n.º 8
0
 public async static Task SendSecretMessage(Stream s, byte[] key, IEncodable message, CancellationToken token = default)
 {
     await SendSecretMessage(s, key, message.Encode(), token);
 }
Exemplo n.º 9
0
 public static string Encode(IEncodable encodable)
 {
     return(Encode(encodable.Encode()));
 }
Exemplo n.º 10
0
 public static void DecodeCopy(IEncodable encodable, IEncodable toCopy)
 {
     Decode(encodable, Encode(toCopy.Encode()));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Encode an encodable object.
 /// </summary>
 /// <param name="encodable"></param>
 public void Encode(IEncodable encodable)
 {
     encodable.Encode(encoder);
 }
Exemplo n.º 12
-1
	public static string Encode(IEncodable encodable)
	{
		return Encode(encodable.Encode());
	}
Exemplo n.º 13
-1
	public static void DecodeCopy(IEncodable encodable, IEncodable toCopy)
	{
		Decode(encodable, Encode(toCopy.Encode()));
	}