예제 #1
0
        private void AnalyzeServiceAndInterfaces(Type serviceType)
        {
            var tree = new InterfaceTree(serviceType);

            for (var i = 0; i < tree.Services.Count; i++)
            {
                var service = tree.Services[i];
                var interfaceDescription = new InterfaceDescription(service.ServiceType);
                Services.Add(interfaceDescription);

                foreach (var method in ReflectionTools.GetMethods(service.ServiceType))
                {
                    if (!ServiceContract.IsServiceOperation(method))
                    {
                        interfaceDescription.Methods.Add(CreateNonServiceOperation(service.ServiceType, method));
                        continue;
                    }

                    if (TryCreateMessage(method, out var message, out var error))
                    {
                        interfaceDescription.Operations.Add(new OperationDescription(
                                                                service.ServiceName,
                                                                ServiceContract.GetServiceOperationName(method),
                                                                message));
                    }
예제 #2
0
        private void AnalyzeServiceAndInterfaces(Type serviceType)
        {
            foreach (var interfaceType in ReflectionTools.ExpandInterface(serviceType))
            {
                var interfaceDescription = new InterfaceDescription(interfaceType);

                string?serviceName = null;
                if (ServiceContract.IsServiceContractInterface(interfaceType))
                {
                    serviceName = ServiceContract.GetServiceName(interfaceType);
                    Services.Add(interfaceDescription);
                }
                else
                {
                    Interfaces.Add(interfaceDescription);
                }

                foreach (var method in ReflectionTools.GetMethods(interfaceType))
                {
                    string?error;

                    if (serviceName == null || !ServiceContract.IsServiceOperation(method))
                    {
                        error = "Method {0}.{1}.{2} is not service operation.".FormatWith(
                            ReflectionTools.GetNamespace(interfaceType),
                            interfaceType.Name,
                            method.Name);

                        interfaceDescription.Methods.Add(new MethodDescription(method, error));
                        continue;
                    }

                    if (TryCreateMessage(method, out var message, out error))
                    {
                        interfaceDescription.Operations.Add(new OperationDescription(
                                                                serviceName,
                                                                ServiceContract.GetServiceOperationName(method),
                                                                message));
                    }