Esempio n. 1
0
 /// <summary>
 /// Updates the current config and writes it to the file.
 /// </summary>
 public static void Write(string configFile,
     FushareConfig config)
 {
     _config = config;
       using (FileStream fs = new FileStream(configFile, FileMode.Create,
     FileAccess.Write)) {
     Write(fs, config);
       }
 }
Esempio n. 2
0
 /// <summary>
 /// Updates the current config and writes it to the file.
 /// </summary>
 public static void Write(string configFile,
                          FushareConfig config)
 {
     _config = config;
     using (FileStream fs = new FileStream(configFile, FileMode.Create,
                                           FileAccess.Write)) {
         Write(fs, config);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Read config from file and updateds the current config object.
        /// </summary>
        private static FushareConfig Read(Stream configStream)
        {
            //Register event handler
            ServiceConfigSection.ServiceHandlersSet += new EventHandler(OnServiceHandlersSet);
            XmlSerializer serializer = new XmlSerializer(typeof(FushareConfig));
            FushareConfig config     = (FushareConfig)serializer.Deserialize(configStream);

            _config = config;
            return(config);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
 }
Esempio n. 6
0
 private static void Write(Stream configStream, FushareConfig config)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(FushareConfig));
       serializer.Serialize(configStream, config);
 }
Esempio n. 7
0
 /// <summary>
 /// Read config from file and updateds the current config object.
 /// </summary>
 private static FushareConfig Read(Stream configStream)
 {
     //Register event handler
       ServiceConfigSection.ServiceHandlersSet += new EventHandler(OnServiceHandlersSet);
       XmlSerializer serializer = new XmlSerializer(typeof(FushareConfig));
       FushareConfig config = (FushareConfig)serializer.Deserialize(configStream);
       _config = config;
       return config;
 }
Esempio n. 8
0
        private static void Write(Stream configStream, FushareConfig config)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(FushareConfig));

            serializer.Serialize(configStream, config);
        }