Example #1
0
        public void RegisterService(HttpListenerHost appHost, Type serviceType)
        {
            var processedReqs = new HashSet <Type>();

            var actions = ServiceExecGeneral.Reset(serviceType);

            foreach (var mi in serviceType.GetActions())
            {
                var requestType = mi.GetParameters()[0].ParameterType;
                if (processedReqs.Contains(requestType))
                {
                    continue;
                }
                processedReqs.Add(requestType);

                ServiceExecGeneral.CreateServiceRunnersFor(requestType, actions);

                //var returnMarker = GetTypeWithGenericTypeDefinitionOf(requestType, typeof(IReturn<>));
                //var responseType = returnMarker != null ?
                //      GetGenericArguments(returnMarker)[0]
                //    : mi.ReturnType != typeof(object) && mi.ReturnType != typeof(void) ?
                //      mi.ReturnType
                //    : Type.GetType(requestType.FullName + "Response");

                RegisterRestPaths(appHost, requestType);

                appHost.AddServiceInfo(serviceType, requestType);
            }
        }
Example #2
0
        public void RegisterService(HttpListenerHost appHost, Type serviceType)
        {
            // Make sure the provided type implements IService
            if (!typeof(IService).IsAssignableFrom(serviceType))
            {
                _logger.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType);
                return;
            }

            var processedReqs = new HashSet <Type>();

            var actions = ServiceExecGeneral.Reset(serviceType);

            foreach (var mi in serviceType.GetActions())
            {
                var requestType = mi.GetParameters()[0].ParameterType;
                if (processedReqs.Contains(requestType))
                {
                    continue;
                }

                processedReqs.Add(requestType);

                ServiceExecGeneral.CreateServiceRunnersFor(requestType, actions);

                //var returnMarker = GetTypeWithGenericTypeDefinitionOf(requestType, typeof(IReturn<>));
                //var responseType = returnMarker != null ?
                //      GetGenericArguments(returnMarker)[0]
                //    : mi.ReturnType != typeof(object) && mi.ReturnType != typeof(void) ?
                //      mi.ReturnType
                //    : Type.GetType(requestType.FullName + "Response");

                RegisterRestPaths(appHost, requestType, serviceType);

                appHost.AddServiceInfo(serviceType, requestType);
            }
        }