Ejemplo n.º 1
0
        public override void OnExecuting(object context)
        {
            MS.ServiceContext realContext = context as MS.ServiceContext;

            base.OnExecuting(realContext);

            var paList = realContext.MethodInfo.GetCustomAttributes <PermissionAuthAttribute>().ToList();

            if (paList != null && paList.Count() != 0)
            {
                Auth(paList);
            }
        }
Ejemplo n.º 2
0
        public static object[] RestoreParams(this MS.ServiceContext context)
        {
            Type inputType1 = typeof(IDTO_GRPC <>);
            Type inputType2 = typeof(IDTO_Input);

            var methodParamArray = context.MethodInfo.GetParameters().ToList();
            var reqParamArray    = new List <object>();

            var reqContent = context.GetRawRequest();

            if (methodParamArray.Count() == 1)
            {
                if (reqContent != null && reqContent.Length != 0)
                {
                    reqParamArray.Add(MessagePackSerializer.Deserialize <object>(reqContent.AsMemory()));
                }
            }
            else if (methodParamArray.Count() > 1)
            {
                if (reqContent != null && reqContent.Length != 0)
                {
                    reqParamArray.AddRange(MessagePackSerializer.Deserialize <object[]>(reqContent.AsMemory()));
                }
            }

            if (methodParamArray.Count() != reqParamArray.Count())
            {
                return(reqParamArray.ToArray());
            }

            for (int i = 0; i < methodParamArray.Count(); i++)
            {
                var mpType = methodParamArray[i].ParameterType;

                if (mpType.IsImplementedNExtendGenericType(inputType1))
                {
                    reqParamArray[i] = reqParamArray[i].ToJson().ToObject(mpType);
                }
                else if (mpType.IsExtendType(inputType2))
                {
                    reqParamArray[i] = reqParamArray[i].ToJson().ToObject(mpType);
                }
            }

            return(reqParamArray.ToArray());
        }
 protected static void SetStatusCode(ServiceContext context, Grpc.Core.StatusCode statusCode, string detail)
 {
     context.CallContext.Status = new Grpc.Core.Status(statusCode, detail);
 }
 public abstract Task Invoke(ServiceContext context);
Ejemplo n.º 5
0
 internal ServiceBase(ServiceContext context)
 {
     this.Context = context;
 }
Ejemplo n.º 6
0
 public ServerStreamingContext(ServiceContext context)
 {
     this.context = context;
     this.inner   = context.ResponseStream;
     this.logger  = context.MagicOnionLogger;
 }
Ejemplo n.º 7
0
 public ClientStreamingContext(ServiceContext context)
 {
     this.context = context;
     this.inner   = context.RequestStream;
     this.logger  = context.MagicOnionLogger;
 }