public static Tuple GetServiceInterfaceAndClass()

in src/CTA.FeatureDetection.Common/WCFConfigUtils/WCFBindingAndTransportUtil.cs [307:358]


        public static Tuple<string, string> GetServiceInterfaceAndClass(ProjectWorkspace project)
        {
            Tuple<string, string> serviceInterfaceAndClass;

            var interfaces = project.GetAllInterfaceDeclarations()?.ToList();
            if (interfaces.IsNullOrEmpty()) { return null; }

            var interfacesWithServiceContract = interfaces
                .Where(i => i.HasAttribute(Constants.ServiceContractAttribute))
                ?.ToList();
            if (interfacesWithServiceContract.IsNullOrEmpty()) { return null; }

            var interfaceWithServiceContractMethods = interfacesWithServiceContract
                .SelectMany(i => i.GetMethodDeclarations())?.ToList();
            if (interfaceWithServiceContractMethods.IsNullOrEmpty()) { return null; }

            var serviceInterfaceMethodWithObjectContract = interfaceWithServiceContractMethods
                .Where(m => m.HasAttribute(Constants.OperationContractAttribute))
                ?.ToList();

            if (!serviceInterfaceMethodWithObjectContract.IsNullOrEmpty())
            {
                var classes = project.GetAllClassDeclarations()?.ToList();
                if (classes.IsNullOrEmpty()) { return null; }

                foreach (var interfaceWithServiceContract in interfacesWithServiceContract)
                {
                    foreach (var classDeclaration in classes)
                    {
                        if (classDeclaration.InheritsInterface(interfaceWithServiceContract.Identifier))
                        {
                            //Filter out generated Code
                            var IsGeneratedCode = classDeclaration.HasAnnotation(Constants.DebuggerStepThroughAttribute)
                                || classDeclaration.HasAnnotation(Constants.GeneratedCodeAttribute);

                            if(!IsGeneratedCode)
                            {
                                serviceInterfaceAndClass = new Tuple<string, string>(interfaceWithServiceContract.Identifier, 
                                    classDeclaration.Identifier);

                                return serviceInterfaceAndClass;
                            }
                        }
                    }
                }
                return null;
            }
            else
            {
                return null;
            }
        }