/// <summary>更新全局玩家扩展数据</summary> public static int GetEntityUpdate(tg_user_extend model) { var exp = new ConcatExpression(); exp &= _.daySalary == model.daySalary; exp &= _.donate == model.donate; exp &= _.shot_count == model.shot_count; exp &= _.task_role_refresh == model.task_role_refresh; exp &= _.task_vocation_refresh == model.task_vocation_refresh; exp &= _.bargain_count == model.bargain_count; exp &= _.npc_refresh_count == model.npc_refresh_count; exp &= _.challenge_count == model.challenge_count; exp &= _.power_buy_count == model.power_buy_count; exp &= _.salary_state == model.salary_state; exp &= _.task_vocation_isgo == model.task_vocation_isgo; exp &= _.eloquence_count == model.eloquence_count; exp &= _.tea_count == model.tea_count; exp &= _.calculate_count == model.calculate_count; exp &= _.ninjutsu_count == model.ninjutsu_count; exp &= _.ball_count == model.ball_count; exp &= _.game_finish_count == model.game_finish_count; exp &= _.game_receive == model.game_receive; exp &= _.refresh_count == model.refresh_count; exp &= _.steal_fail_count == model.steal_fail_count; exp &= _.fight_count == model.fight_count; exp &= _.fight_buy == model.fight_buy; return(Update(exp, null)); }
public static void SerializeConcatExpression() { var v = new StringLiteral("Hello"); var a = new ConcatExpression(v, v); var b = SerializationUtil.Reserialize(a); Assert.AreEqual(a, b); }
public static T Parse <T>(this string input, string pattern) { var expression = Expression.Parse(pattern); if (typeof(T).Namespace is string ns) { expression = new ConcatExpression(new UsingExpression(ns), expression); } return(expression.Parse <T>(input)); }
public static IEnumerable <T> Parse <T>(this IEnumerable <string> input, string pattern) { var expression = Expression.Parse(pattern); if (typeof(T).Namespace is string ns) { expression = new ConcatExpression(new UsingExpression(ns), expression); } return(input.Select(expression.Parse <T>)); }
private BsonValue TranslateConcat(ConcatExpression node) { var first = TranslateValue(node.Source); var second = TranslateValue(node.Other); return(new BsonDocument("$concatArrays", new BsonArray { first, second })); }
public void BackreferenceExistenceUndefined() { // Given var expression = new ConcatExpression(new Expression[] { new SubExpression(new BackreferenceExpression("foo")) }); // When var result = expression.Transform(""); // Then Assert.Null(result); }
public void Undefined() { // Given var expression = new ConcatExpression( new FunctionExpression("foo", new TextExpression("x")), new CallExpression("bar") ); // When var result = expression.Transform("x"); // Then Assert.Null(result); }
public void BackreferenceExistence() { // Given var expression = new ConcatExpression(new Expression[] { new AssignmentExpression("foo", "x"), new SubExpression(new BackreferenceExpression("foo")) }); // When var result = expression.Transform(""); // Then Assert.Equal("", result); }
public void BackreferenceMismatch() { // Given var expression = new ConcatExpression( new AssignmentExpression("foo", "x"), new SubExpression(new BackreferenceExpression("foo"), new TextExpression("y")) ); // When var result = expression.Transform(""); // Then Assert.Null(result); }
public void Backtrack() { // Given var expression = new ConcatExpression( new OptExpression(new TextExpression("x")), new TextExpression("x") ); // When var result = expression.Transform("x"); // Then Assert.Equal("x", result); }
public void PartialMatchLong() { // Given var expression = new ConcatExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform("xyz"); // Then Assert.Null(result); }
public void MatchFirst() { // Given var expression = new ConcatExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform("xy"); // Then Assert.Equal("xy", result); }
public void Mismatch() { // Given var expression = new ConcatExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform("yx"); // Then Assert.Null(result); }
public void Match() { // Given var expression = new ConcatExpression( new FunctionExpression("foo", new TextExpression("x")), new CallExpression("foo") ); // When var result = expression.Transform("x"); // Then Assert.Equal("x", result); }
public void Ancestor() { // Given var expression = new ConcatExpression( new AssignmentExpression("foo", "x"), new CaptureExpression("bar", new BackreferenceExpression("foo")) ); // When var result = expression.Transform("x"); // Then Assert.Equal("x", result); }
public void Nested() { // Given var expression = new ConcatExpression( new CaptureExpression("foo", new CaptureExpression("bar", new TextExpression("x"))), new BackreferenceExpression("foo.bar") ); // When var result = expression.Transform("xx"); // Then Assert.Equal("xx", result); }
public void Undefined() { // Given var expression = new ConcatExpression( new CaptureExpression("foo", new TextExpression("x")), new BackreferenceExpression("bar") ); // When var result = expression.Transform("xx"); // Then Assert.Null(result); }
public void BlockDescendants() { // Given var expression = new ConcatExpression( new CaptureExpression("foo", new AssignmentExpression("bar", "x")), new BackreferenceExpression("bar") ); // When var result = expression.Transform("x"); // Then Assert.Null(result); }
public void Shadow() { // Given var expression = new ConcatExpression( new CaptureExpression("foo", new TextExpression("x")), new CaptureExpression("foo", new TextExpression("y")), new BackreferenceExpression("foo") ); // When var result = expression.Transform("xyy"); // Then Assert.Equal("xyy", result); }
/// <summary>更新全局玩家扩展数据</summary> public static int GetUpdateByLevel(tg_user_vip model) { var exp = new ConcatExpression(); exp &= _.power == model.power; exp &= _.bargain == model.bargain; exp &= _.buy == model.buy; exp &= _.arena_buy == model.arena_buy; exp &= _.arena_cd == model.arena_cd; exp &= _.train_home == model.train_home; var _where = string.Format("[vip_level]={0}", model.vip_level); return(Update(exp, _where)); }
public void BlockOuterCaptureWithCallCapture() { // Given var expression = new ConcatExpression( new AssignmentExpression("bar", "x"), new FunctionExpression("foo", new BackreferenceExpression("bar")), new CallExpression("foo", "baz") ); // When var result = expression.Transform("x"); // Then Assert.Null(result); }
public void Subcapture() { // Given var expression = new ConcatExpression( new FunctionExpression("foo", new AssignmentExpression("baz", "x")), new CallExpression("foo", "bar"), new BackreferenceExpression("bar.baz") ); // When var result = expression.Transform("x"); // Then Assert.Equal("x", result); }
/// <summary> /// Parses a text expression, or a block of unquoted strings, that are /// prefixed with <paramref name="prefix"/> which will return a /// <see cref="StringValue"/> when evaluated. /// </summary> /// <param name="prefix"> /// The prefix parser to use at the beginning of each line, or null for /// no prefix parsing. /// </param> public static Parser <Expression> PrefixText <T> (Parser <T> prefix) { return(state => { using (var transaction = new Transaction(state)) { // Parse each line of the text var lines = Parse.PrefixBlock1( prefix, TextLine, Parse.Indented )(state); // Combine each line of the text into a single expression Expression result = null; foreach (var line in lines) { if (result != null) { var s = new StringValue(" "); result = new ConcatExpression( new ConcatExpression(result, new StringLiteral(s)), line ); } else { result = line; } } transaction.CommitIndex(); return result.Simplify(); } }); }
public static EntityList <Online> GetList(Int32 forumid = 0, String order = null, Boolean isdesc = false, Int32 start = 0, Int32 max = 200) { if (Meta.Count < CacheCount) { var list = Online.FindAllWithCache().Clone(); if (forumid > 0) { list = list.FindAll(__.ForumID, forumid); } // 如果隐藏游客 if (GeneralConfigInfo.Current.WhosOnlineContract) { list = list.FindAll(e => e.UserID > 0); } // 排序 if (!String.IsNullOrEmpty(order)) { FieldItem fi = Meta.Table.FindByName(order); if (fi != null) { list = list.Sort(fi.Name, isdesc); } } return(list.Page(start, max)); } else { // 最多返回1000行 var exp = new WhereExpression(); if (forumid > 0) { exp &= _.ForumID == forumid; } if (GeneralConfigInfo.Current.WhosOnlineContract) { exp &= _.UserID > 0; } // 排序 ConcatExpression dexp = null; if (!String.IsNullOrEmpty(order)) { FieldItem fi = Meta.Table.FindByName(order); if (fi != null) { if (isdesc) { dexp = fi.Desc(); } else { dexp = fi.Asc(); } } } return(FindAll(null, dexp, null, start, max)); } }
public SingleExpression(TextReader reader) { while (reader.Peek() != -1) { char c = (char)reader.Peek(); if (c == '(') { reader.Read(); Expression = new SingleExpression(reader); if ((char)reader.Read() != ')') { throw new Exception("Expected )"); } } else if (c == ')') { return; } else if (c == '[') { reader.Read(); Expression = new RangeExpression(reader); if ((char)reader.Read() != ']') { throw new Exception("Expected ]"); } } else if (c == '{') { reader.Read(); Expression = new RepeatExpression(reader) { Expression = Expression }; if ((char)reader.Read() != '}') { throw new Exception("Expected }"); } } else if (c == '|') { reader.Read(); Expression = new OrExpression { Left = Expression, Right = new SingleExpression(reader) }; } else if (c == '.') { reader.Read(); Expression = new ConcatExpression { Left = Expression, Right = new SingleExpression(reader).Expression }; } else if (c == '*') { reader.Read(); Expression = new StarExpression { Expression = Expression }; } else if (c == '+') { reader.Read(); Expression = new PlusExpression { Expression = Expression }; } else { throw new Exception("Unexpected " + c); } } }
public SingleExpression(TextReader reader) { while (reader.Peek() != -1) { char c = (char)reader.Peek(); if (c == '(') { reader.Read(); Expression = new SingleExpression(reader); if ((char)reader.Read() != ')') throw new Exception("Expected )"); } else if (c == ')') { return; } else if (c == '[') { reader.Read(); Expression = new RangeExpression(reader); if ((char)reader.Read() != ']') throw new Exception("Expected ]"); } else if (c == '{') { reader.Read(); Expression = new RepeatExpression(reader) { Expression = Expression }; if ((char)reader.Read() != '}') throw new Exception("Expected }"); } else if (c == '|') { reader.Read(); Expression = new OrExpression { Left = Expression, Right = new SingleExpression(reader) }; } else if (c == '.') { reader.Read(); Expression = new ConcatExpression { Left = Expression, Right = new SingleExpression(reader).Expression }; } else if (c == '*') { reader.Read(); Expression = new StarExpression { Expression = Expression }; } else if (c == '+') { reader.Read(); Expression = new PlusExpression { Expression = Expression }; } else { throw new Exception("Unexpected " + c); } } }