Beispiel #1
0
        /// <summary>
        /// Registers ServiceConfigSection.ServiceHandlersSet event
        /// </summary>
        static void OnServiceHandlersSet(object sender, EventArgs e)
        {
            ServiceConfigSection config = (ServiceConfigSection)sender;

            foreach (ServiceHandlerMapping handler in config.serviceHandlers)
            {
                Type type = Type.GetType(handler.type);
                Uri  uri  = new Uri(handler.uri);
                DictionaryServiceFactory.RegisterServiceType(type, uri);
                Logger.WriteLineIf(LogLevel.Info, _log_props, string.Format("{0} service at {1} registered", type.Name, uri.ToString()));
            }
        }
Beispiel #2
0
        public void TestSerializationAndDeserialization()
        {
            FushareConfig        cfg      = new FushareConfig();
            ServiceConfigSection svc      = new ServiceConfigSection();
            ServiceHandler       handler1 = new ServiceHandler();

            handler1.type       = typeof(BrunetDht).FullName;
            handler1.uri        = new Uri("http://localhost:15151/xd.rem").ToString();
            svc.serviceHandlers = new ServiceHandler[] { handler1 };
            cfg.serviceConfig   = svc;
            MemoryStream ms = new MemoryStream();

            FushareConfigHandler.Write(ms, cfg);
            Logger.WriteLineIf(LogLevel.Verbose, _log_props, Encoding.UTF8.GetString(ms.ToArray()));
            ms.Flush();
            ms.Position = 0;
            FushareConfig acutal = FushareConfigHandler.Read(ms);

            Assert.AreEqual("http://localhost:15151/xd.rem", acutal.serviceConfig.serviceHandlers[0].uri);
        }
 public void TestSerializationAndDeserialization()
 {
     FushareConfig cfg = new FushareConfig();
       ServiceConfigSection svc = new ServiceConfigSection();
       ServiceHandler handler1 = new ServiceHandler();
       handler1.type = typeof(BrunetDht).FullName;
       handler1.uri = new Uri("http://localhost:15151/xd.rem").ToString();
       svc.serviceHandlers = new ServiceHandler[] { handler1 };
       cfg.serviceConfig = svc;
       MemoryStream ms = new MemoryStream();
       FushareConfigHandler.Write(ms, cfg);
       Logger.WriteLineIf(LogLevel.Verbose, _log_props, Encoding.UTF8.GetString(ms.ToArray()));
       ms.Flush();
       ms.Position = 0;
       FushareConfig acutal = FushareConfigHandler.Read(ms);
       Assert.AreEqual("http://localhost:15151/xd.rem", acutal.serviceConfig.serviceHandlers[0].uri);
 }