public RpcServiceDecorator(T serviceObj) : base(string.Empty) { Type intf = typeof(T); if (!intf.IsInterface) { throw new NotSupportedException(); } RpcServiceAttribute serviceAttr = AttributeHelper.GetAttribute <RpcServiceAttribute>(intf); p_serviceName = serviceAttr.ServiceName; _serviceObj = serviceObj; IICPerformanceCounterCategory category = new IICPerformanceCounterCategory("rpc:" + p_serviceName, PerformanceCounterCategoryType.MultiInstance); foreach (MethodInfo method in intf.GetMethods()) { RpcServiceMethodAttribute methodAttr = AttributeHelper.GetAttribute <RpcServiceMethodAttribute>(method); string methodName = method.Name; RpcServiceMethod m = new RpcServiceDecorator <T> .RpcServiceMethod(); m.RatePerSecond = category.CreateCounter(methodName + " /sec.", PerformanceCounterType.RateOfCountsPerSecond32); m.TotalCount = category.CreateCounter(methodName + " Total.", PerformanceCounterType.NumberOfItems32); m.TotalFailed = category.CreateCounter(methodName + " Failed.", PerformanceCounterType.NumberOfItems32); m.Concurrent = category.CreateCounter(methodName + " Concurrent.", PerformanceCounterType.NumberOfItems32); m.Method = method; _methods.Add(methodName, m); } IICPerformanceCounterFactory.GetCounters(category); }
public RpcServiceDecorator(T serviceObj, string serviceName) : base(string.Empty) { Type intf = typeof(T); if (!intf.IsInterface) { throw new NotSupportedException(); } RpcServiceAttribute serviceAttr = AttributeHelper.GetAttribute <RpcServiceAttribute>(intf); if (!string.IsNullOrEmpty(serviceName)) { p_serviceName = serviceName; } else { p_serviceName = serviceAttr.ServiceName; } _serviceObj = serviceObj; _methods = new HybridDictionary <string, RpcServiceMethod>(); bool enableCounter = serviceAttr.EnableCounters == RpcPerformanceCounterMode.Both || serviceAttr.EnableCounters == RpcPerformanceCounterMode.Server; IICPerformanceCounterCategory category = new IICPerformanceCounterCategory("rpc:" + p_serviceName, PerformanceCounterCategoryType.MultiInstance); foreach (MethodInfo method in intf.GetMethods()) { string methodName = method.Name; RpcServiceMethod m; RpcServiceBatchMethodAttribute battr = AttributeHelper.TryGetAttribute <RpcServiceBatchMethodAttribute>(method); if (battr != null) { if (!string.IsNullOrEmpty(battr.MethodName)) { methodName = battr.MethodName; } m = new RpcServiceBatchMethod(serviceObj, category, methodName, method, enableCounter); } else { RpcServiceMethodAttribute attr = AttributeHelper.GetAttribute <RpcServiceMethodAttribute>(method); if (!string.IsNullOrEmpty(attr.MethodName)) { methodName = attr.MethodName; } m = new RpcServiceMethod(serviceObj, category, methodName, method, enableCounter); } _methods.Add(methodName, m); } IICPerformanceCounterFactory.GetCounters(category); }
internal RpcTransparentService(T serviceObj, string serviceUrl) : base(string.Empty) { Type intf = typeof(T); if (!intf.IsInterface) { throw new NotSupportedException(); } RpcServiceAttribute serviceAttr = AttributeHelper.GetAttribute <RpcServiceAttribute>(intf); p_serviceName = serviceAttr.ServiceName; _serviceObj = serviceObj; _serviceUrl = serviceUrl; IICPerformanceCounterCategory category = new IICPerformanceCounterCategory("rpc:" + p_serviceName, PerformanceCounterCategoryType.MultiInstance); foreach (MethodInfo method in intf.GetMethods()) { string methodName = method.Name; DynamicMethod dm = new DynamicMethod("fun", typeof(object[]), new[] { typeof(RpcServerContext) }); RpcServiceMethod m = new RpcServiceMethod(); m.RatePerSecond = category.CreateCounter(methodName + " /sec.", PerformanceCounterType.RateOfCountsPerSecond32); m.TotalCount = category.CreateCounter(methodName + " Total.", PerformanceCounterType.NumberOfItems32); m.TotalFailed = category.CreateCounter(methodName + " Failed.", PerformanceCounterType.NumberOfItems32); m.Concurrent = category.CreateCounter(methodName + " Concurrent.", PerformanceCounterType.NumberOfItems32); m.Method = method; RpcGetArgsHelper.RegisterMethod(p_serviceName, m); _methods.Add(methodName, m); } IICPerformanceCounterFactory.GetCounters(category); }
public static void RegisterService <T>(T service) { RpcServiceAttribute serviceAttr = AttributeHelper.GetAttribute <RpcServiceAttribute>(typeof(T)); RegisterService <T>(serviceAttr.ServiceName, service); }