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


C# StringScanner.Match方法代码示例

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


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

示例1: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col = this.ReadCollection(db, s);
            var query = s.Match("{") ? Query.Query.All() : this.ReadQuery(s);
            var code = DynamicCode.GetCode(s);

            var docs = col.Find(query).ToArray();

            try
            {
                db.BeginTrans();

                foreach (var doc in docs)
                {
                    code(doc["_id"], doc, col, db);
                }

                db.Commit();

                return docs.Length;
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw ex;
            }
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:27,代码来源:Exec.cs

示例2: ReadQuery

        public Query ReadQuery(StringScanner s)
        {
            if (s.HasTerminated || s.Match(@"skip\s+\d") || s.Match(@"limit\s+\d"))
            {
                return Query.All();
            }

            return this.ReadInlineQuery(s);
        }
开发者ID:jaked122,项目名称:LiteDB,代码行数:9,代码来源:BaseCollection.cs

示例3: Execute

        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var result = new StringBuilder();

            if (s.HasTerminated || s.Match("mem$"))
            {
                var mem = s.Match("mem$");

                result = DumpDatabase.Pages(db, mem);
            }
            else
            {
                var col = s.Scan(@"[\w-]+");
                var field = s.Scan(@"\s+\w+").Trim();

                result = DumpDatabase.Index(db, col, field);
            }

            return result.ToString();
        }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:20,代码来源:Dump.cs

示例4: ReadSkipLimit

        public KeyValuePair<int, int> ReadSkipLimit(StringScanner s)
        {
            var skip = 0;
            var limit = int.MaxValue;

            if (s.Match(@"\s*skip\s+\d+"))
            {
                skip = Convert.ToInt32(s.Scan(@"\s*skip\s+(\d+)\s*", 1));
            }

            if (s.Match(@"\s*limit\s+\d+"))
            {
                limit = Convert.ToInt32(s.Scan(@"\s*limit\s+(\d+)\s*", 1));
            }

            // skip can be before or after limit command
            if (s.Match(@"\s*skip\s+\d+"))
            {
                skip = Convert.ToInt32(s.Scan(@"\s*skip\s+(\d+)\s*", 1));
            }

            return new KeyValuePair<int, int>(skip, limit);
        }
开发者ID:jaked122,项目名称:LiteDB,代码行数:23,代码来源:BaseCollection.cs

示例5: ReadInlineQuery

        private Query ReadInlineQuery(StringScanner s)
        {
            var left = this.ReadOneQuery(s);

            if (s.Match(@"\s+(and|or)\s+") == false)
            {
                return left;
            }

            var oper = s.Scan(@"\s+(and|or)\s+").Trim();

            if(oper.Length == 0) throw new ApplicationException("Invalid query operator");

            return oper == "and" ?
                Query.And(left, this.ReadInlineQuery(s)) :
                Query.Or(left, this.ReadInlineQuery(s));
        }
开发者ID:ktaranov,项目名称:LiteDB,代码行数:17,代码来源:BaseCollection.cs

示例6: Execute

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            if (s.HasTerminated || s.Match(@"\d+"))
            {
                var start = s.Scan(@"\d*").Trim();
                var end = s.Scan(@"\s*\d*").Trim();

                if (start.Length > 0 && end.Length == 0) end = start;

                return engine.DumpPages(
                    start.Length == 0 ? 0 : Convert.ToUInt32(start),
                    end.Length == 0 ? uint.MaxValue : Convert.ToUInt32(end)).ToString();
            }
            else
            {
                var col = s.Scan(@"[\w-]+");
                var field = s.Scan(@"\s+\w+").Trim();

                return engine.DumpIndex(col, field).ToString();
            }
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:21,代码来源:DiskDump.cs

示例7: IsCommand

 public bool IsCommand(StringScanner s)
 {
     return s.Match(@"timer$");
 }
开发者ID:apkd,项目名称:LiteDB,代码行数:4,代码来源:Timer.cs

示例8: IsCollectionCommand

 public bool IsCollectionCommand(StringScanner s, string command)
 {
     return s.Match(@"db\.[\w-]+\." + command);
 }
开发者ID:jaked122,项目名称:LiteDB,代码行数:4,代码来源:BaseCollection.cs

示例9: IsCommand

 public override bool IsCommand(StringScanner s)
 {
     return s.Match(@"ver(sion)?$");
 }
开发者ID:azraelrabbit,项目名称:LiteDB,代码行数:4,代码来源:Version.cs

示例10: Execute

        public override void Execute(ref IShellEngine engine, StringScanner s, Display d, InputCommand input)
        {
            var sb = new StringBuilder();
            var full = s.Match("full");

            if (!full)
            {
                d.WriteHelp("Basic Shell Commands - try `help full` for all commands");
                d.WriteHelp("=======================================================");

                d.WriteHelp("> show collections", "List all collections inside database");
                d.WriteHelp("> db.<collection>.insert <jsonDoc>", "Insert a new document into collection");
                d.WriteHelp("> db.<collection>.update <jsonDoc>", "Update a document inside collection");
                d.WriteHelp("> db.<collection>.delete <filter>", "Delete documents using a filter clausule (see find)");
                d.WriteHelp("> db.<collection>.find <filter> [skip N][limit N]", "Show filtered documents based on index search");
                d.WriteHelp("> db.<collection>.count <filter>", "Show count rows according query filter");
                d.WriteHelp("> db.<collection>.ensureIndex <field> [true|{options}]", "Create a new index document field. For unique key, use true");
                d.WriteHelp("> db.<collection>.indexes", "List all indexes in this collection");
                d.WriteHelp("<filter> = <field> [=|>|>=|<|<=|!=|like|between] <jsonValue>", "Filter query syntax");
                d.WriteHelp("<filter> = (<filter> [and|or] <filter> [and|or] ...)", "Multi queries syntax");

                d.WriteHelp("Try:");
                d.WriteHelp(" > db.customers.insert { _id:1, name:\"John Doe\", age: 37 }");
                d.WriteHelp(" > db.customers.ensureIndex name");
                d.WriteHelp(" > db.customers.find name like \"John\"");
                d.WriteHelp(" > db.customers.find name like \"John\" and _id between [0, 100] limit 10");
            }
            else
            {
                d.WriteHelp("Shell commands");
                d.WriteHelp("==============");

                d.WriteHelp("> open <filename>", "Open a new database");
                d.WriteHelp("> close", "Close current database");
                d.WriteHelp("> run <filename>", "Run commands inside filename");
                d.WriteHelp("> pretty on|off", "Turns on/off pretty json format");
                d.WriteHelp("> dump > <filename.dmp>", "Export all documents to an external file script");
                d.WriteHelp("> dump < <filename.dmp>", "Import all documents inside a script dump file");
                d.WriteHelp("> timer", "Show timer before prompt");
                d.WriteHelp("> ed", "Open nodepad with last command to edit and execute");
                d.WriteHelp("> spool on|off", "Spool all output in a spool file");
                d.WriteHelp("> -- comment", "Do nothing, its just a comment");
                d.WriteHelp("> /<command>/", "Support for multi line command");
                d.WriteHelp("> debug on|off", "Enabled debug messages from dbengine");
                d.WriteHelp("> version", "Show LiteDB version");
                d.WriteHelp("> exit", "Close LiteDB shell");

                d.WriteHelp();
                d.WriteHelp("Collections commands");
                d.WriteHelp("====================");

                d.WriteHelp("> show collections", "List all collections inside database");
                d.WriteHelp("> db.<collection>.insert <jsonDoc>", "Insert a new document into collection");
                d.WriteHelp("> db.<collection>.update <jsonDoc>", "Update a document inside collection");
                d.WriteHelp("> db.<collection>.delete <filter>", "Delete documents using a filter clausule (see find)");
                d.WriteHelp("> db.<collection>.bulk <filename>", "Bulk insert a json file as documents");
                d.WriteHelp("> db.<collection>.find [skip N][limit N]", "Show all documents. Can limit/skip results");
                d.WriteHelp("> db.<collection>.find <filter> [skip N][limit N]", "Show filtered documents based on index search. See <filter> syntax below");
                d.WriteHelp("> db.<collection>.count <filter>", "Show count rows according query filter");
                d.WriteHelp("> db.<collection>.ensureIndex <field> [unique]", "Create a new index document field");
                d.WriteHelp("> db.<collection>.indexes", "List all indexes in this collection");
                d.WriteHelp("> db.<collection>.drop", "Drop collection and destroy all documents inside");
                d.WriteHelp("> db.<collection>.dropIndex <field>", "Drop a index and make index area free to use with another index");
                d.WriteHelp("> db.<collection>.rename <newCollectionName>", "Rename a collection");
                d.WriteHelp("> db.<collection>.min <field>", "Returns min/first value from collection using index field");
                d.WriteHelp("> db.<collection>.max <field>", "Returns max/last value from collection using index field");
                d.WriteHelp("> db.<collection>.stats", "Display statistics about a collection");
                d.WriteHelp("<filter> = <field> [=|>|>=|<|<=|!=|like|contains|in|between] <jsonValue>", "Filter query syntax");
                d.WriteHelp("<filter> = (<filter> [and|or] <filter> [and|or] ...)", "Multi queries syntax");
                d.WriteHelp("<jsonDoc> = {_id: ... , key: value, key1: value1 }", "Represent a json (extended version) for a BsonDocument. See special data types");
                d.WriteHelp("Json Date", "{ field: { $date :\"2015-01-01T23:59:59Z\"} }");
                d.WriteHelp("Json Guid", "{ field: { $guid :\"3a1c34b3-9f66-4d8e-975a-d545d898a4ba\"} }");
                d.WriteHelp("Json Binary", "{ field: { $binary :\"base64 byte array\"} }");

                d.WriteHelp();
                d.WriteHelp("File storage commands");
                d.WriteHelp("=====================");

                d.WriteHelp("> fs.find", "List all files on database");
                d.WriteHelp("> fs.find <fileId>", "List file info from a key. Supports * for starts with key");
                d.WriteHelp("> fs.upload <fileId> <filename>", "Insert a new file inside database");
                d.WriteHelp("> fs.download <fileId> <filename>", "Save a file to disk passing a file key and filename");
                d.WriteHelp("> fs.update <fileId> {key:value}", "Update metadata file");
                d.WriteHelp("> fs.delete <fileId>", "Remove a file inside database");

                d.WriteHelp();
                d.WriteHelp("Other commands");
                d.WriteHelp("==============");

                d.WriteHelp("> shrink", "Reduce database removing empty pages");
                d.WriteHelp("> diskdump [n m]", "Display database disk pages strucutre (from N page to M page)");
            }
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:93,代码来源:Help.cs


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