/// <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) { Service = service; object[] classAttributes = serviceInterfaceType.GetCustomAttributes(typeof(ScsServiceAttribute), true); if (classAttributes.Length <= 0) { throw new Exception("Service interface (" + serviceInterfaceType.Name + ") must has ScsService attribute."); } ServiceAttribute = classAttributes[0] as ScsServiceAttribute; _methods = new SortedList <string, MethodInfo>(); foreach (MethodInfo methodInfo in serviceInterfaceType.GetMethods()) { _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, ScsService service) { Service = service; object[] classAttributes = serviceInterfaceType.GetCustomAttributes(typeof(ScsServiceAttribute), true); ServiceAttribute = classAttributes.Length > 0 ? classAttributes[0] as ScsServiceAttribute : new ScsServiceAttribute { Version = serviceInterfaceType.Assembly.GetName().Version.ToString() }; _methods = new SortedList <string, MethodInfo>(); foreach (Type serviceInterface in serviceInterfaceType.GetInterfaces().Union(new[] { serviceInterfaceType })) { foreach (MethodInfo methodInfo in serviceInterface.GetMethods()) { _methods[methodInfo.Name] = methodInfo; } } }