当前位置: 首页>>代码示例>>C#>>正文


C# Serializer.Put方法代码示例

本文整理汇总了C#中Serializer.Put方法的典型用法代码示例。如果您正苦于以下问题:C# Serializer.Put方法的具体用法?C# Serializer.Put怎么用?C# Serializer.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Serializer的用法示例。


在下文中一共展示了Serializer.Put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CookiesToArray

 public byte[] CookiesToArray()
 {
     Serializer serializer = new Serializer();
     serializer.Put(_cookies.Count);
     foreach (Cookie cookie in _cookies.GetCookies(_uri))
     {
         serializer.Put(cookie.Name);
         serializer.Put(cookie.Value);
         serializer.Put(cookie.Path);
         serializer.Put(cookie.Domain);
     }
     return serializer.ToArray();
 }
开发者ID:Claymore,项目名称:SharpMediaWiki,代码行数:13,代码来源:Wiki.cs

示例2: NamespacesToArray

 public byte[] NamespacesToArray()
 {
     Serializer serializer = new Serializer();
     serializer.Put(_namespaces.Count);
     foreach (var pair in _namespaces)
     {
         serializer.Put(pair.Key);
         serializer.Put(pair.Value);
     }
     return serializer.ToArray();
 }
开发者ID:Claymore,项目名称:SharpMediaWiki,代码行数:11,代码来源:Wiki.cs

示例3: SwitchToLanguage

        private void SwitchToLanguage(string language)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            path += @"\WikiLive\" + language;
            Directory.CreateDirectory(path);

            _baseName = path + @"\WikiLive.db";
            if (!File.Exists(_baseName))
            {
                SQLiteConnection.CreateFile(_baseName);
            }

            if (_connection != null && _connection.State != ConnectionState.Closed)
            {
                _connection.Close();
            }

            SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
            _connection = (SQLiteConnection)factory.CreateConnection();
            _connection.ConnectionString = "Data Source = " + _baseName;
            _connection.Open();

            using (SQLiteCommand command = new SQLiteCommand(_connection))
            {
                command.CommandText = @"CREATE TABLE IF NOT EXISTS [edits] (
                        [id] integer PRIMARY KEY NOT NULL,
                        [timestamp] TEXT NOT NULL,
                        [user] TEXT NOT NULL,
                        [page] TEXT NOT NULL,
                        [namespace] INTEGER NOT NULL,
                        [flags] INTEGER NOT NULL,
                        [oldid] INTEGER NOT NULL,
                        [size] INTEGER NOT NULL,
                        [summary] TEXT NOT NULL
                    );";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();
            }

            using (SQLiteCommand command = new SQLiteCommand(_connection))
            {
                command.CommandText = @"CREATE TABLE IF NOT EXISTS [watched_pages] (
                        [id] integer PRIMARY KEY AUTOINCREMENT NOT NULL,
                        [page] TEXT NOT NULL,
                        [namespace] INTEGER NOT NULL
                    );";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();
            }

            if (!File.Exists(path + @"\namespaces.dat"))
            {
                Wiki wiki = new Wiki("http://" + language + ".wikipedia.org");
                ParameterCollection parameters = new ParameterCollection();
                parameters.Add("meta", "siteinfo");
                parameters.Add("siprop", "namespaces");
                XmlDocument xml = wiki.Enumerate(parameters, true);
                XmlNodeList nodes = xml.SelectNodes("//ns[@id > 0]");
                Serializer serializer = new Serializer();
                serializer.Put(nodes.Count);
                foreach (XmlNode node in nodes)
                {
                    serializer.Put(node.Attributes["id"].Value);
                    serializer.Put(node.FirstChild.Value);
                }

                using (FileStream fs = new FileStream(path + @"\namespaces.dat", FileMode.CreateNew))
                using (BinaryWriter streamWriter = new BinaryWriter(fs))
                {
                    streamWriter.Write(serializer.ToArray());
                }
            }
        }
开发者ID:Claymore,项目名称:WikiLive,代码行数:73,代码来源:MainForm.cs


注:本文中的Serializer.Put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。