csharp/1100100/Uragano/src/Uragano.DynamicProxy/DynamicProxyAbstract.cs

DynamicProxyAbstract.cs
using System.Collections.Generic;
using System.Threading.Tasks;
using Uragano.Abstractions;

namespace Uragano.DynamicProxy
{
    public abstract clast DynamicProxyAbstract
    {
        private Dictionary Meta { get; set; }

        private IRemotingInvoke RemotingInvoke { get; }

        protected DynamicProxyAbstract(IRemotingInvoke remotingInvoke)
        {
            RemotingInvoke = remotingInvoke;
        }

        public void SetMeta(string key, string value)
        {
            if (Meta == null)
                Meta = new Dictionary();
            Meta.Add(key, value);
        }


        //protected void Invoke(object[] args, string route, string serviceName)
        //{
        //    RemotingInvoke.InvokeAsync(args, route, serviceName, Meta).ConfigureAwait(false).GetAwaiter().GetResult();
        //}

        //protected T Invoke(object[] args, string route, string serviceName)
        //{
        //    return RemotingInvoke.InvokeAsync(args, route, serviceName, Meta).ConfigureAwait(false).GetAwaiter().GetResult();
        //}


        protected async Task InvokeAsync(object[] args, string route, string serviceName)
        {
            await RemotingInvoke.InvokeAsync(args, route, serviceName, Meta);
            Meta?.Clear();
        }

        protected async Task InvokeAsync(object[] args, string route, string serviceName)
        {
            var result = await RemotingInvoke.InvokeAsync(args, route, serviceName, Meta);
            Meta?.Clear();
            return result;
        }
    }
}