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


C# SelectStatement.AsText方法代码示例

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


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

示例1: Initialize

        /// <summary>
        /// If configured, this function reads from a SQLite database caching previously known hashes.
        /// The motivation for this is that the most expensive operation would be the MD5 hash calculation;
        /// That means that on a second run of DetectDuplicates, we may want to reuse existing known MD5 hashes.
        /// </summary>
        public bool Initialize(string database_filename, Dictionary<long, Dictionary<string, string>> cache)
        {
            if (string.IsNullOrEmpty(database_filename))
                return false;

            Filename = database_filename;

            try
            {
                // connect to database
                Trace.TraceInformation("About to read cache from \"{0}\"", Filename);
                Database = new Database("Data Source=" + Filename);

                // make sure lookup table exists
                Database.ExecuteNonQuery(@"CREATE TABLE IF NOT EXISTS hashes (hash TEXT, filename TEXT);");

                DateTime cacheStartTime = DateTime.Now;

                // read known hashes from lookup table
                int CachedHashesRead = 0;
                using (SelectStatement ss = new SelectStatement(Database, "SELECT hash, filename FROM hashes", null))
                {
                    while (ss.Next())
                    {
                        string hash = ss.AsText(0);
                        string filename = ss.AsText(1);
                        CacheValues[filename.ToLower()] = hash;
                        ++CachedHashesRead;
                    }
                }
                if (CachedHashesRead == 0)
                {
                    Console.WriteLine("Cache is empty as of yet...");
                }
                else
                {
                    TimeSpan elapsed = DateTime.Now - cacheStartTime;
                    Console.WriteLine("Read {0} hashes from the cache in {1}...", CachedHashesRead, elapsed);
                }
                return true;
            }
            catch (Exception e)
            {
                Tools.DumpException(e, "ReadCache() caught an exception while reading \"{0}\"", Filename);
                return false;
            }
        }
开发者ID:zippy1981,项目名称:GTools,代码行数:52,代码来源:CachedHashes.cs


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