Пример #1
0
        private static int GetEndpointPort(
            ICodePackageActivationContext codePackageActivationContext,
            Type serviceContactType,
            string endpointResourceName)
        {
            var port = 0;

            var endpointName = endpointResourceName;

            if (string.IsNullOrEmpty(endpointName) && (serviceContactType != null))
            {
                endpointName = ServiceNameFormat.GetEndpointName(serviceContactType);
            }

            var endpoints = codePackageActivationContext.GetEndpoints();

            foreach (var endpoint in endpoints)
            {
                if (string.Compare(endpoint.Name, endpointName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    port = endpoint.Port;
                    break;
                }
            }

            return(port);
        }
        public void GetServiceNameFormat_NoServiceNameProvided_ReturnEndpointName()
        {
            // Arrange
            string serviceName = "ObjectServiceEndpoint";

            // Act
            var result = ServiceNameFormat.GetEndpointName(typeof(object));

            // Assert
            result.Should().Be(serviceName);
        }