Пример #1
0
            /// <summary>
            /// Creates a new ServiceObject.
            /// </summary>
            /// <param name="service">The service object that is used to invoke methods on</param>
            /// <param name="serviceAttribute">NGRIDService attribute of service object's class</param>
            public ServiceObject(NGRIDService service, NGRIDServiceAttribute 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(NGRIDServiceMethodAttribute), true);
                    _methods.Add(methodInfo.Name, attributes.Length > 0);
                }
            }
Пример #2
0
        /// <summary>
        /// Removes a NGRIDService from this service application.
        /// </summary>
        /// <param name="service">Service to add</param>
        public void RemoveService(NGRIDService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            var type = service.GetType();

            if (!_serviceObjects.ContainsKey(type.Name))
            {
                return;
            }

            _serviceObjects.Remove(type.Name);
        }
Пример #3
0
        /// <summary>
        /// Adds a new NGRIDService for this service application.
        /// </summary>
        /// <param name="service">Service to add</param>
        public void AddService(NGRIDService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            var type       = service.GetType();
            var attributes = type.GetCustomAttributes(typeof(NGRIDServiceAttribute), true);

            if (attributes.Length <= 0)
            {
                throw new NGRIDException("Service class must has NGRIDService attribute to be added.");
            }

            if (_serviceObjects.ContainsKey(type.Name))
            {
                throw new NGRIDException("Service '" + type.Name + "' is already added.");
            }

            _serviceObjects.Add(type.Name, new ServiceObject(service, (NGRIDServiceAttribute)attributes[0]));
        }
Пример #4
0
        /// <summary>
        /// Adds a new NGRIDService for this service application.
        /// </summary>
        /// <param name="service">Service to add</param>
        public void AddService(NGRIDService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            var type = service.GetType();
            var attributes = type.GetCustomAttributes(typeof (NGRIDServiceAttribute), true);
            if(attributes.Length <= 0)
            {
                throw new NGRIDException("Service class must has NGRIDService attribute to be added.");
            }

            if (_serviceObjects.ContainsKey(type.Name))
            {
                throw new NGRIDException("Service '" + type.Name + "' is already added.");
            }

            _serviceObjects.Add(type.Name, new ServiceObject(service, (NGRIDServiceAttribute)attributes[0]));
        }
Пример #5
0
            /// <summary>
            /// Creates a new ServiceObject.
            /// </summary>
            /// <param name="service">The service object that is used to invoke methods on</param>
            /// <param name="serviceAttribute">NGRIDService attribute of service object's class</param>
            public ServiceObject(NGRIDService service, NGRIDServiceAttribute 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(NGRIDServiceMethodAttribute), true);
                    _methods.Add(methodInfo.Name, attributes.Length > 0);
                }
            }
Пример #6
0
        /// <summary>
        /// Removes a NGRIDService from this service application.
        /// </summary>
        /// <param name="service">Service to add</param>
        public void RemoveService(NGRIDService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            var type = service.GetType();
            if (!_serviceObjects.ContainsKey(type.Name))
            {
                return;
            }

            _serviceObjects.Remove(type.Name);
        }