/// <summary> /// Creates a new ServiceObject. /// /// </summary> /// <param name="serviceInterfaceType">Type of service interface</param><param name="service">The service object that is used to invoke methods on</param> public ServiceObject(Type serviceInterfaceType, ScsService service) { this.Service = service; object[] customAttributes = serviceInterfaceType.GetCustomAttributes(typeof(ScsServiceAttribute), true); if (customAttributes.Length <= 0) { throw new Exception("Service interface (" + serviceInterfaceType.Name + ") must has ScsService attribute."); } this.ServiceAttribute = customAttributes[0] as ScsServiceAttribute; this._methods = new SortedList <string, MethodInfo>(); foreach (MethodInfo methodInfo in serviceInterfaceType.GetMethods()) { this._methods.Add(methodInfo.Name, methodInfo); } }
/// <summary> /// Creates a new ServiceObject. /// </summary> /// <param name="serviceInterfaceType">Type of service interface</param> /// <param name="service">The service object that is used to invoke methods on</param> public ServiceObject(Type serviceInterfaceType, object service) { Service = service; var classAttributes = serviceInterfaceType.GetCustomAttributes(typeof(ScsServiceAttribute), true); if (classAttributes.Length <= 0) { ServiceAttribute = new ScsServiceAttribute(); } else { ServiceAttribute = classAttributes[0] as ScsServiceAttribute; } _methods = new SortedList <string, MethodInfo>(); foreach (var methodInfo in serviceInterfaceType.GetMethods()) { _methods.Add(methodInfo.Name, methodInfo); } }