예제 #1
0
 public object GetPropertyFromManager(ServiceType type, string data)
 {
     try
     {
         if (data != null && !data.Equals(String.Empty))
         {
             var          temp       = _proxy.GetPropertyData(type, data);
             DataBoundary serialized = JsonConvert.DeserializeObject <DataBoundary>(temp.ToString());
             var          vals       = serialized.Attributes.FirstOrDefault();
             object       reflected;
             if (Type.GetType(vals.Key.ToString()).IsEnum)
             {
                 reflected = Enum.Parse(Type.GetType(vals.Key.ToString()), vals.Value.ToString());
             }
             else
             {
                 reflected = ((Newtonsoft.Json.Linq.JArray)vals.Value).ToObject(Type.GetType(vals.Key.ToString()));
             }
             return(reflected);
         }
         return(null);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #2
0
        protected override void ExecuteBefore(IInvocation invocation)
        {
            Console.WriteLine("Start");

            DataBoundary data = new DataBoundary()
            {
                CommandName = invocation.Method.Name,
                Attributes  = new Dictionary <object, object>()
            };

            invocation.Arguments.ToList().ForEach(arg => data.Attributes.Add(arg.GetType(), arg));
            if (data.CommandName.Contains("get_") || data.CommandName.Contains("set_"))
            {
                data.CommandName       = data.CommandName.Remove(0, 4);
                invocation.ReturnValue = _reflectionClientManager.GetPropertyFromManager(GetServiceType(invocation.Proxy.ToString()), JsonConvert.SerializeObject(data));
            }
            else
            {
                invocation.ReturnValue = _reflectionClientManager.GetFromManager(GetServiceType(invocation.Proxy.ToString()), JsonConvert.SerializeObject(data));
            }
        }