private ServiceHost StartNetTcpAndHttpService(ModelManager modelManager, Boolean onlyNetTcp) { Uri[] baseAddresses; if (onlyNetTcp) { baseAddresses = new Uri[] { new Uri($"net.tcp://localhost:{OpusCatMTEngineSettings.Default.MtServicePort}/") }; } else { baseAddresses = new Uri[] { new Uri($"net.tcp://localhost:{OpusCatMTEngineSettings.Default.MtServicePort}/"), new Uri($"http://localhost:{OpusCatMTEngineSettings.Default.HttpMtServicePort}/") }; }; var mtService = new MTService(modelManager); Log.Information($"Creating service host with following URIs: {String.Join(",",baseAddresses.Select(x => x.ToString()))}"); var selfHost = new ServiceHost(mtService, baseAddresses); var nettcpBinding = new NetTcpBinding(); //Use default net.tcp security, which is based on Windows authentication: //using the service is only possible from other computers in the same domain. //TODO: add a checkbox (with warning) in the UI for using security mode None, //to allow connections from IP range (also add same checkbox to clients). //nettcpBinding.Security.Mode = SecurityMode.None; /*nettcpBinding.Security.Mode = SecurityMode.Transport; * nettcpBinding.Security.Transport.ClientCredentialType = * TcpClientCredentialType.Windows;*/ //Customization tuning sets tend to be big nettcpBinding.MaxReceivedMessageSize = 20000000; selfHost.AddServiceEndpoint(typeof(IMTService), nettcpBinding, "MTService"); if (!onlyNetTcp) { selfHost.AddServiceEndpoint(typeof(IMTService), new WebHttpBinding(), "MTRestService"); WebHttpBehavior helpBehavior = new WebHttpBehavior(); helpBehavior.HelpEnabled = true; selfHost.Description.Endpoints[1].Behaviors.Add(helpBehavior); } /* * // Check to see if the service host already has a ServiceMetadataBehavior * ServiceMetadataBehavior smb = selfHost.Description.Behaviors.Find<ServiceMetadataBehavior>(); * // If not, add one * if (smb == null) * smb = new ServiceMetadataBehavior(); * //smb.HttpGetEnabled = true; * smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; * selfHost.Description.Behaviors.Add(smb); * * // Add MEX endpoint * selfHost.AddServiceEndpoint( * ServiceMetadataBehavior.MexContractName, * MetadataExchangeBindings.CreateMexTcpBinding(), * "mex" * ); */ Log.Information($"Opening the service host"); selfHost.Open(); return(selfHost); }
public MTService(ModelManager modelManager) { this.ModelManager = modelManager; }
private void dataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { this.modelManager = ((ModelManager)this.DataContext); }
public LocalModelListView(ModelManager modelManager) { this.DataContext = modelManager; InitializeComponent(); }