Beispiel #1
0
        public IList <EndpointDefinition> GetEndpointDefinitions(string address)
        {
            var appDataDirectory  = _pathHelper.GetWcfPadAppDataDirectory();
            var endpointGuid      = Guid.NewGuid().ToString();
            var endpointDirectory = Path.Combine(appDataDirectory, endpointGuid);
            var configPath        = Path.Combine(endpointDirectory, $"{endpointGuid}.dll.config");
            var clientPath        = Path.Combine(endpointDirectory, $"{endpointGuid}.cs");

            var assemblyPath = _wcfClientBuilder.BuildAssembly(endpointDirectory, address, configPath, clientPath, $"{endpointGuid}.dll");

            var sectionGroup = _configHelper.GetSectionGroup(configPath);

            if (sectionGroup == null)
            {
                return(null);
            }

            var endpointDefinitions = new List <EndpointDefinition>();

            foreach (ChannelEndpointElement endpoint in sectionGroup.Client.Endpoints)
            {
                endpointDefinitions.Add(new EndpointDefinition
                {
                    AssemblyPath      = assemblyPath,
                    ConfigPath        = configPath,
                    EndpointDirectory = endpointDirectory,
                    ClientPath        = clientPath,
                    Address           = endpoint.Address.AbsoluteUri,
                    GeneratedName     = endpoint.Name,
                    DisplayName       = endpoint.Name,
                    Contract          = endpoint.Contract
                });
            }

            return(endpointDefinitions);
        }