コード例 #1
0
ファイル: PakSrvHost.cs プロジェクト: santedb/santedb-sdk
        /// <summary>
        /// Start the service host
        /// </summary>
        public void Start()
        {
            var configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "paksrv.config");

            if (!File.Exists(configFile))
            {
                m_configuration = new PakSrvConfiguration()
                {
                    Bindings = new List <string>()
                    {
                        "http://0.0.0.0:6039/paksrv"
                    }
                };

                using (var fs = File.Create(configFile))
                    m_configuration.Save(fs);
            }
            else
            {
                using (var fs = File.OpenRead(configFile))
                    m_configuration = PakSrvConfiguration.Load(fs);
            }

            this.m_serviceHost = new RestService(typeof(PakSrvBehavior));

            foreach (var bind in m_configuration.Bindings)
            {
                this.m_serviceHost.AddServiceEndpoint(new Uri(bind), typeof(IPakSrvContract), new RestHttpBinding());
            }
            this.m_serviceHost.AddServiceBehavior(new PakSrvAuthenticationBehavior(m_configuration));
            this.m_serviceHost.Start();
        }
コード例 #2
0
 /// <summary>
 /// Create a new package service auth behavior
 /// </summary>
 public PakSrvAuthenticationBehavior(PakSrvConfiguration config)
 {
     this.m_configuration = config;
 }
コード例 #3
0
 /// <summary>
 /// Configuration
 /// </summary>
 public PakSrvBehavior()
 {
     this.m_configuration = PakSrvHost.m_configuration;
 }