public void SetServiceProvider(IAssetAdministrationShellRepositoryServiceProvider repositoryServiceProvider)
 {
     WebHostBuilder.ConfigureServices(services =>
     {
         services.AddSingleton <IAssetAdministrationShellRepositoryServiceProvider>(repositoryServiceProvider);
     });
 }
        public static void UseAutoEndpointRegistration(this IAssetAdministrationShellRepositoryServiceProvider serviceProvider, ServerConfiguration serverConfiguration)
        {
            string multiUrl = serverConfiguration.Hosting.Urls.Find(u => u.Contains("+"));

            if (!string.IsNullOrEmpty(multiUrl))
            {
                Uri uri = new Uri(multiUrl.Replace("+", "localhost"));
                List <IEndpoint> endpoints = GetNetworkInterfaceBasedEndpoints(uri.Scheme, uri.Port);
                serviceProvider.UseDefaultEndpointRegistration(endpoints);
            }
            else
            {
                List <IEndpoint> endpoints = serverConfiguration.Hosting.Urls.ConvertAll(EndpointConverter);
                serviceProvider.UseDefaultEndpointRegistration(endpoints);
            }
        }
        public static void UseDefaultEndpointRegistration(this IAssetAdministrationShellRepositoryServiceProvider serviceProvider, IEnumerable <IEndpoint> endpoints)
        {
            List <IEndpoint> repositoryEndpoints = new List <IEndpoint>();

            foreach (var endpoint in endpoints)
            {
                string epAddress = endpoint.Address;
                if (!epAddress.EndsWith("/shells"))
                {
                    epAddress = epAddress + (epAddress.EndsWith("/") ? "" : "/") + "shells";
                }

                repositoryEndpoints.Add(EndpointFactory.CreateEndpoint(endpoint.Type, epAddress, endpoint.Security));
            }

            serviceProvider.ServiceDescriptor.AddEndpoints(repositoryEndpoints);
            var aasRepositoryDescriptor = serviceProvider.ServiceDescriptor;

            foreach (var aasDescriptor in aasRepositoryDescriptor.AssetAdministrationShellDescriptors)
            {
                List <IEndpoint> aasEndpoints = new List <IEndpoint>();
                foreach (var endpoint in repositoryEndpoints)
                {
                    var ep = EndpointFactory.CreateEndpoint(endpoint.Type, GetAssetAdministrationShellEndpoint(endpoint, aasDescriptor.IdShort), endpoint.Security);
                    aasEndpoints.Add(ep);
                }
                aasDescriptor.AddEndpoints(aasEndpoints);

                foreach (var submodelDescriptor in aasDescriptor.SubmodelDescriptors)
                {
                    List <IEndpoint> submodelEndpoints = new List <IEndpoint>();
                    foreach (var endpoint in aasEndpoints)
                    {
                        var ep = EndpointFactory.CreateEndpoint(endpoint.Type, GetSubmodelEndpoint(endpoint, submodelDescriptor.IdShort), endpoint.Security);
                        submodelEndpoints.Add(ep);
                    }
                    submodelDescriptor.AddEndpoints(submodelEndpoints);
                }
            }
        }
示例#4
0
 public MultiIndexModel(IAssetAdministrationShellRepositoryServiceProvider provider, ServerSettings serverSettings)
 {
     ServiceProvider = provider;
     Settings        = serverSettings;
 }
示例#5
0
 public AssetAdministrationShellRepositoryServices(IAssetAdministrationShellRepositoryServiceProvider assetAdministrationShellRepositoryServiceProvider)
 {
     repository        = assetAdministrationShellRepositoryServiceProvider;
     ServiceDescriptor = assetAdministrationShellRepositoryServiceProvider.ServiceDescriptor;
 }