/// <summary> /// Creates a new ServiceObject. /// </summary> /// <param name="service">The service object that is used to invoke methods on</param> /// <param name="serviceAttribute">MDSService attribute of service object's class</param> public ServiceObject(MDSService service, MDSServiceAttribute serviceAttribute) { Service = service; ServiceAttribute = serviceAttribute; _serviceClassName = service.GetType().Name; //Find all methods _methods = new SortedList <string, bool>(); foreach (var methodInfo in Service.GetType().GetMethods()) { var attributes = methodInfo.GetCustomAttributes(typeof(MDSServiceMethodAttribute), true); _methods.Add(methodInfo.Name, attributes.Length > 0); } }
/// <summary> /// Removes a MDSService from this service application. /// </summary> /// <param name="service">Service to add</param> public void RemoveService(MDSService service) { if (service == null) { throw new ArgumentNullException("service"); } var type = service.GetType(); if (!_serviceObjects.ContainsKey(type.Name)) { return; } _serviceObjects.Remove(type.Name); }
/// <summary> /// Adds a new MDSService for this service application. /// </summary> /// <param name="service">Service to add</param> public void AddService(MDSService service) { if (service == null) { throw new ArgumentNullException("service"); } var type = service.GetType(); var attributes = type.GetCustomAttributes(typeof(MDSServiceAttribute), true); if (attributes.Length <= 0) { throw new MDSException("Service class must has MDSService attribute to be added."); } if (_serviceObjects.ContainsKey(type.Name)) { throw new MDSException("Service '" + type.Name + "' is already added."); } _serviceObjects.Add(type.Name, new ServiceObject(service, (MDSServiceAttribute)attributes[0])); }
/// <summary> /// Creates a new ServiceObject. /// </summary> /// <param name="service">The service object that is used to invoke methods on</param> /// <param name="serviceAttribute">MDSService attribute of service object's class</param> public ServiceObject(MDSService service, MDSServiceAttribute serviceAttribute) { Service = service; ServiceAttribute = serviceAttribute; _serviceClassName = service.GetType().Name; //Find all methods _methods = new SortedList<string, bool>(); foreach (var methodInfo in Service.GetType().GetMethods()) { var attributes = methodInfo.GetCustomAttributes(typeof(MDSServiceMethodAttribute), true); _methods.Add(methodInfo.Name, attributes.Length > 0); } }
/// <summary> /// Adds a new MDSService for this service application. /// </summary> /// <param name="service">Service to add</param> public void AddService(MDSService service) { if (service == null) { throw new ArgumentNullException("service"); } var type = service.GetType(); var attributes = type.GetCustomAttributes(typeof (MDSServiceAttribute), true); if(attributes.Length <= 0) { throw new MDSException("Service class must has MDSService attribute to be added."); } if (_serviceObjects.ContainsKey(type.Name)) { throw new MDSException("Service '" + type.Name + "' is already added."); } _serviceObjects.Add(type.Name, new ServiceObject(service, (MDSServiceAttribute)attributes[0])); }