Esempio n. 1
0
 public override string Generate(Expressions.DeleteDefaultConstraintExpression expression)
 {
     return string.Format(
         "ALTER TABLE {0} ALTER COLUMN {1} DROP DEFAULT",
         this.QuoteSchemaAndTable(expression.SchemaName, expression.TableName),
         Quoter.QuoteColumnName(expression.ColumnName));
 }
Esempio n. 2
0
 public override string Generate(Expressions.RenameTableExpression expression)
 {
     return string.Format(
         "RENAME TABLE {0} TO {1}",
         this.QuoteSchemaAndTable(expression.SchemaName, expression.OldName),
         Quoter.QuoteTableName(expression.NewName));
 }
Esempio n. 3
0
        public override string Generate(Expressions.CreateForeignKeyExpression expression)
        {
            if (expression.ForeignKey.PrimaryColumns.Count != expression.ForeignKey.ForeignColumns.Count)
            {
                throw new ArgumentException("Number of primary columns and secondary columns must be equal");
            }

            var keyName = string.IsNullOrEmpty(expression.ForeignKey.Name)
                ? Column.GenerateForeignKeyName(expression.ForeignKey)
                : expression.ForeignKey.Name;
            var keyWithSchema = string.IsNullOrEmpty(expression.ForeignKey.ForeignTableSchema)
                ? Quoter.QuoteConstraintName(keyName)
                : Quoter.QuoteSchemaName(expression.ForeignKey.ForeignTableSchema) + "." + Quoter.QuoteConstraintName(keyName);

            var primaryColumns = expression.ForeignKey.PrimaryColumns.Aggregate(new StringBuilder(), (acc, col) =>
            {
                var separator = acc.Length == 0 ? string.Empty : ", ";
                return acc.AppendFormat("{0}{1}", separator, Quoter.QuoteColumnName(col));
            });

            var foreignColumns = expression.ForeignKey.ForeignColumns.Aggregate(new StringBuilder(), (acc, col) =>
            {
                var separator = acc.Length == 0 ? string.Empty : ", ";
                return acc.AppendFormat("{0}{1}", separator, Quoter.QuoteColumnName(col));
            });

            return string.Format(
                "ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4}){5}",
                this.QuoteSchemaAndTable(expression.ForeignKey.ForeignTableSchema, expression.ForeignKey.ForeignTable),
                keyWithSchema,
                foreignColumns,
                this.QuoteSchemaAndTable(expression.ForeignKey.PrimaryTableSchema, expression.ForeignKey.PrimaryTable),
                primaryColumns,
                Column.FormatCascade("DELETE", expression.ForeignKey.OnDelete));
        }
Esempio n. 4
0
        protected override Expression VisitMethodDefinitionExpression(Expressions.MethodDefinitionExpression method)
        {
            this.containsDateConversion = false;

            var retval = (MethodDefinitionExpression)base.VisitMethodDefinitionExpression(method);

            if (this.containsDateConversion && retval.Body is BlockExpression)
            {
                var block = (BlockExpression)retval.Body;
                var variables = new List<ParameterExpression>(block.Variables);
                var dateFormatter = Expression.Variable(new FickleType("NSDateFormatter"), "dateFormatter");
                variables.Add(dateFormatter);
                var expressions = new List<Expression>();

                // dateFormatter = [[NSDateFormatter alloc]init]
                expressions.Add(Expression.Assign(dateFormatter, Expression.New(new FickleType("NSDateFormatter"))).ToStatement());
                // [dateFormatter setTimeZone: [NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
                expressions.Add(FickleExpression.Call(dateFormatter, "setTimeZone", FickleExpression.StaticCall("NSTimeZone", "NSTimeZone", "timeZoneWithAbbreviation", "UTC")).ToStatement());
                // [dateFormatter setDateFormat: @"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];
                expressions.Add(FickleExpression.Call(dateFormatter, "setDateFormat", "yyyy-MM-dd'T'HH:mm:ssZZZZZ").ToStatement());

                expressions.AddRange(block.Expressions);

                var newBody = Expression.Block(variables, expressions);

                return new MethodDefinitionExpression(retval.Name, retval.Parameters, retval.ReturnType, newBody, retval.IsPredeclaration, retval.RawAttributes);
            }

            return retval;
        }
Esempio n. 5
0
        protected override void VisitAndAlso(Expressions.AndAlsoExpression expression)
        {
            string leftClause = "";
            if (!(expression.Left is TrueExpression))
            {
                leftClause = VisitInner(expression.Left).ClauseText;
            }

            string rightClause = "";
            if (!(expression.Right is TrueExpression))
            {
                rightClause = VisitInner(expression.Right).ClauseText;
            }

            if (!string.IsNullOrEmpty(leftClause) && !string.IsNullOrEmpty(rightClause))
            {
                clauseText.AppendFormat("(({0}) AND ({1}))", leftClause, rightClause);
            }
            else if (!string.IsNullOrEmpty(leftClause))
            {
                clauseText.Append(leftClause);
            }
            else if (!string.IsNullOrEmpty(rightClause))
            {
                clauseText.Append(rightClause);
            }
        }
        public override string Generate(Expressions.DeleteSequenceExpression expression)
        {
            var result = new StringBuilder(string.Format("DROP SEQUENCE "));
            result.AppendFormat("{0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteSequenceName(expression.SequenceName));

            return result.ToString();
        }
Esempio n. 7
0
 protected override void VisitWhere(Expressions.IWhereExpression expression)
 {
     if (clauseText.Length != 0)
     {
         clauseText.Append("AND ");
     }
     base.VisitWhere(expression);
 }
Esempio n. 8
0
 public override string Generate(Expressions.AlterDefaultConstraintExpression expression)
 {
     return string.Format(
         "ALTER TABLE {0} ALTER COLUMN {1} SET DEFAULT {2}",
         this.QuoteSchemaAndTable(expression.SchemaName, expression.TableName),
         Quoter.QuoteColumnName(expression.ColumnName),
         ((Db2Column)Column).FormatAlterDefaultValue(expression.ColumnName, expression.DefaultValue));
 }
Esempio n. 9
0
        public override string Generate(Expressions.CreateColumnExpression expression)
        {
            expression.Column.AdditionalFeatures.Add(new KeyValuePair<string, object>("IsCreateColumn", true));

            return string.Format(
                "ALTER TABLE {0} ADD COLUMN {1}",
                this.QuoteSchemaAndTable(expression.SchemaName, expression.TableName),
                Column.Generate(expression.Column));
        }
Esempio n. 10
0
        public override void Visite(Expressions.IExpression expression)
        {
            selectText = "*";
            clauseText = new StringBuilder();
            sortText = new StringBuilder();

            base.Visite(expression);

            query.SelectText = selectText.ToString();
            query.ClauseText = clauseText.ToString();
            query.SortText = sortText.ToString();
        }
Esempio n. 11
0
        /// <summary>
        /// Converts the expression to constant.
        /// </summary>
        private string ConvertExpressionToConstant(Expressions.BindingPathExpression expression, string propertyName)
        {
            if (expression is BindingConstantExpression)
            {
                return ((BindingConstantExpression)expression).Value;
            }

            if (!(expression is BindingGetPropertyExpression) || ((BindingGetPropertyExpression)expression).NextExpression != null)
            {
                ThrowParserError(string.Format("The value of property '{0}' must be one word and must not contain other characters than letters, numbers or underscore. Otherwise the value must be in enclosed in double quotes.", propertyName));
            }

            return ((BindingGetPropertyExpression)expression).PropertyName;
        }
Esempio n. 12
0
        public override string Generate(Expressions.DeleteColumnExpression expression)
        {
            var builder = new StringBuilder();
            if (expression.ColumnNames.Count == 0 || string.IsNullOrEmpty(expression.ColumnNames.First()))
            {
                return string.Empty;
            }

            builder.AppendFormat("ALTER TABLE {0}", this.QuoteSchemaAndTable(expression.SchemaName, expression.TableName));
            foreach (var column in expression.ColumnNames)
            {
                builder.AppendFormat(" DROP COLUMN {0}", this.Quoter.QuoteColumnName(column));
            }

            return builder.ToString();
        }
        public override Expression Bind(Expressions.ProjectionExpression projection, ProjectionBindingContext context, System.Linq.Expressions.MethodCallExpression node, IEnumerable<System.Linq.Expressions.Expression> arguments)
        {
            var aggregatorName = "Single";
            var returnType = node.Method.ReturnType;
            if (node.Method.Name.EndsWith("Async"))
            {
                aggregatorName += "Async";
                returnType = returnType.GetGenericArguments()[0];
            }

            var aggregator = CreateAggregator(aggregatorName, returnType);

            var source = projection.Source;
            var argument = arguments.FirstOrDefault();
            if (argument != null && ExtensionExpressionVisitor.IsLambda(argument))
            {
                var lambda = ExtensionExpressionVisitor.GetLambda(argument);
                var binder = new AccumulatorBinder(context.GroupMap, context.SerializerRegistry);
                binder.RegisterParameterReplacement(lambda.Parameters[0], projection.Projector);
                argument = binder.Bind(lambda.Body);
            }
            else
            {
                argument = projection.Projector;
                var select = source as SelectExpression;
                if (select != null)
                {
                    source = select.Source;
                }
            }

            var serializer = context.SerializerRegistry.GetSerializer(returnType);
            var accumulator = new AccumulatorExpression(returnType, AccumulatorType, argument);
            var serializationAccumulator = new SerializationExpression(
                accumulator,
                new BsonSerializationInfo("__agg0", serializer, serializer.ValueType));

            var rootAccumulator = new RootAccumulatorExpression(source, serializationAccumulator);

            return new ProjectionExpression(
                rootAccumulator,
                serializationAccumulator,
                aggregator);
        }
        public void Test1()
        {
            var exps = new Expressions();

            var query = Db<DB>.Sql(db =>
                Select(Asterisk(db.tbl_staff)).
                From(db.tbl_staff).
                Where(exps.Condition1 || exps.Condition2));

            var datas = _connection.Query(query).ToList();
            Assert.IsTrue(0 < datas.Count);
            AssertEx.AreEqual(query, _connection,
@"SELECT *
FROM tbl_staff
WHERE ((@val1) = (@p_0)) OR ((@val1) = (@p_1))", 
new Params()
{
    { "@val1", 1 },
    { "@p_0", 1 },
    { "@p_1", 2 },
});
        }
        public override string Generate(Expressions.CreateSequenceExpression expression)
        {
            var result = new StringBuilder(string.Format("CREATE SEQUENCE "));
            var seq = expression.Sequence;
            result.AppendFormat("{0}.{1}", Quoter.QuoteSchemaName(seq.SchemaName), Quoter.QuoteSequenceName(seq.Name));

            if (seq.Increment.HasValue)
            {
                result.AppendFormat(" INCREMENT BY {0}", seq.Increment);
            }

            if (seq.MinValue.HasValue)
            {
                result.AppendFormat(" MINVALUE {0}", seq.MinValue);
            }

            if (seq.MaxValue.HasValue)
            {
                result.AppendFormat(" MAXVALUE {0}", seq.MaxValue);
            }

            if (seq.StartWith.HasValue)
            {
                result.AppendFormat(" START WITH {0}", seq.StartWith);
            }

            if (seq.Cache.HasValue)
            {
                result.AppendFormat(" CACHE {0}", seq.Cache);
            }

            if (seq.Cycle)
            {
                result.Append(" CYCLE");
            }

            return result.ToString();
        }
		public virtual void Visit(Expressions.ArrayInitializer x)
		{
			Visit((AssocArrayExpression)x);
		}
		public virtual void Visit(Expressions.SurroundingParenthesesExpression x)
		{
			if (x.Expression != null)
				x.Expression.Accept(this);
		}
Esempio n. 18
0
 public bool IsInconsistentWith(DecisionRule rule)
 {
     //do two rules have same background rule but different outputs?
     return(Expressions.AreEqual(rule.Expressions) && Output != rule.Output);
 }
Esempio n. 19
0
        public void TestLikeRegexStringAndNull_OM()
        {
            String stmtText = "select p00 like p01 as r1, " +
                              "p00 like p01 escape \"!\" as r2, " +
                              "p02 regexp p03 as r3 " +
                              "from " + typeof(SupportBean_S0).FullName;

            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.Create()
                                 .Add(Expressions.Like(Expressions.Property("p00"), Expressions.Property("p01")), "r1")
                                 .Add(Expressions.Like(Expressions.Property("p00"), Expressions.Property("p01"), Expressions.Constant("!")), "r2")
                                 .Add(Expressions.Regexp(Expressions.Property("p02"), Expressions.Property("p03")), "r3");
            model.FromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean_S0).FullName));
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);
            Assert.AreEqual(stmtText, model.ToEPL());

            EPStatement selectTestCase = _epService.EPAdministrator.Create(model);

            selectTestCase.Events += _testListener.Update;

            RunLikeRegexStringAndNull();

            String epl = "select * from " + typeof(SupportBean).FullName + "(TheString not like \"foo%\")";
            EPPreparedStatement eps       = _epService.EPAdministrator.PrepareEPL(epl);
            EPStatement         statement = _epService.EPAdministrator.Create(eps);

            Assert.AreEqual(epl, statement.Text);

            epl       = "select * from " + typeof(SupportBean).FullName + "(TheString not regexp \"foo\")";
            eps       = _epService.EPAdministrator.PrepareEPL(epl);
            statement = _epService.EPAdministrator.Create(eps);
            Assert.AreEqual(epl, statement.Text);
        }
Esempio n. 20
0
        private static void ProcessCure(Event e, Expressions exp)
        {
            var line = new Line(e.ChatLogItem)
            {
                EventDirection = e.Direction,
                EventSubject   = e.Subject,
                EventType      = e.Type
            };

            LineHelper.SetTimelineTypes(ref line);
            if (LineHelper.IsIgnored(line))
            {
                return;
            }

            Match cure = Regex.Match("ph", @"^\.$");

            switch (e.Subject)
            {
            case EventSubject.You:
                switch (e.Direction)
                {
                case EventDirection.Self:
                    line.Target = You;
                    break;
                }

                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = You;
                    UpdateHealing(cure, line, exp, FilterType.You);
                }

                break;

            case EventSubject.Pet:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNamePet;
                    UpdateHealing(cure, line, exp, FilterType.Pet);
                }

                break;

            case EventSubject.Party:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNamePartyHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.Party);
                }

                break;

            case EventSubject.PetParty:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNamePetPartyHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.PetParty);
                }

                break;

            case EventSubject.Alliance:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNameAllianceHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.Alliance);
                }

                break;

            case EventSubject.PetAlliance:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNamePetAllianceHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.PetAlliance);
                }

                break;

            case EventSubject.Other:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNameOtherHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.Other);
                }

                break;

            case EventSubject.PetOther:
                cure = exp.pCure;
                if (cure.Success)
                {
                    line.Source = _lastNamePetOtherHealingFrom;
                    UpdateHealing(cure, line, exp, FilterType.PetOther);
                }

                break;
            }

            if (cure.Success)
            {
                return;
            }

            ParsingLogHelper.Log(Logger, "Cure", e, exp);
        }
Esempio n. 21
0
 static Issue2468Tests()
 {
     MapEnumToString <ColorEnum>();
     MapEnumToString <CMYKEnum>();
     Expressions.MapMember((StatusEnum v) => v.ToString(), v => MyExtensions.StatusEnumToString(v));
 }
Esempio n. 22
0
        private void RunAssertionOp(EPServiceProvider epService)
        {
            EventCollection     events       = EventCollectionFactory.GetEventSetOne(0, 1000);
            var                 testCaseList = new CaseList();
            EventExpressionCase testCase     = null;

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B1\") where timer:within(2 sec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B1\") where timer:within(2001 msec)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B1\") where timer:within(1999 msec)");
            testCaseList.AddTest(testCase);

            string text  = "select * from pattern [b=" + EVENT_B_CLASS + "(id=\"B3\") where timer:within(10.001)]";
            var    model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);
            Expression  filter  = Expressions.Eq("id", "B3");
            PatternExpr pattern = Patterns.TimerWithin(10.001, Patterns.Filter(Filter.Create(EVENT_B_CLASS, filter), "b"));

            model.FromClause = FromClause.Create(PatternStream.Create(pattern));
            Assert.AreEqual(text, model.ToEPL());
            testCase = new EventExpressionCase(model);
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B3\") where timer:within(10001 msec)");
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B3\") where timer:within(10 sec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "(id=\"B3\") where timer:within(9.999)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=" + EVENT_B_CLASS + ") where timer:within(2.001)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=" + EVENT_B_CLASS + ") where timer:within(4.001)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + " where timer:within(2.001)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " where timer:within(2001 msec))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every ((every b=" + EVENT_B_CLASS + ") where timer:within(2.001))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every ((every b=" + EVENT_B_CLASS + ") where timer:within(6.001))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=" + EVENT_B_CLASS + ") where timer:within(11.001)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=" + EVENT_B_CLASS + ") where timer:within(4001 milliseconds)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + ") where timer:within(6.001)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + " where timer:within(4001 milliseconds)");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() -> d=" + EVENT_D_CLASS + "() where timer:within(4 sec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + "() where timer:within (4.001) and d=" + EVENT_D_CLASS + "() where timer:within(6.001))");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2001 msec) and d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2001 msec) and d=" + EVENT_D_CLASS + "() where timer:within(6000 msec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2000 msec) and d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + " where timer:within(4000 msec)");
            testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + "() -> every d=" + EVENT_D_CLASS + " where timer:within(4000 msec)");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
            testCase.Add("D2", "b", events.GetEvent("B1"), "d", events.GetEvent("D2"));
            testCase.Add("D2", "b", events.GetEvent("B2"), "d", events.GetEvent("D2"));
            testCase.Add("D3", "b", events.GetEvent("B1"), "d", events.GetEvent("D3"));
            testCase.Add("D3", "b", events.GetEvent("B2"), "d", events.GetEvent("D3"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() -> d=" + EVENT_D_CLASS + "() where timer:within(3999 msec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + "() -> (every d=" + EVENT_D_CLASS + ") where timer:within(2001 msec)");
            testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + "() -> d=" + EVENT_D_CLASS + "()) where timer:within(6001 msec)");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2000 msec) or d=" + EVENT_D_CLASS + "() where timer:within(6000 msec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(b=" + EVENT_B_CLASS + "() where timer:within (2000 msec) or d=" + EVENT_D_CLASS + "() where timer:within(6000 msec)) where timer:within (1999 msec)");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + "() where timer:within (2001 msec) and d=" + EVENT_D_CLASS + "() where timer:within(6001 msec))");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2001 msec) or d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + "() where timer:within (2000 msec) or d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCase.Add("D1", "d", events.GetEvent("D1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + "() where timer:within (2001 msec) and every d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
            testCase.Add("D2", "b", events.GetEvent("B1"), "d", events.GetEvent("D2"));
            testCase.Add("D2", "b", events.GetEvent("B2"), "d", events.GetEvent("D2"));
            testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D1"));
            testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
            testCase.Add("D3", "b", events.GetEvent("B1"), "d", events.GetEvent("D3"));
            testCase.Add("D3", "b", events.GetEvent("B2"), "d", events.GetEvent("D3"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=" + EVENT_B_CLASS + ") where timer:within (2000 msec) and every d=" + EVENT_D_CLASS + "() where timer:within(6001 msec)");
            testCaseList.AddTest(testCase);

            var util = new PatternTestHarness(events, testCaseList, this.GetType());

            util.RunTest(epService);
        }
Esempio n. 23
0
        public void TestOutputWhenThenExpression()
        {
            SendTimeEvent(1, 8, 0, 0, 0);
            _epService.EPAdministrator.Configuration.AddVariable("myvar", typeof(int), 0);
            _epService.EPAdministrator.Configuration.AddVariable("count_insert_var", typeof(int), 0);
            _epService.EPAdministrator.CreateEPL("on SupportBean set myvar = IntPrimitive");

            String      expression = "select symbol from MarketData.win:length(2) output when myvar=1 then set myvar=0, count_insert_var=count_insert";
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(expression);

            RunAssertion(1, stmt);

            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause      = SelectClause.Create("symbol");
            model.FromClause        = FromClause.Create(FilterStream.Create("MarketData").AddView("win", "length", Expressions.Constant(2)));
            model.OutputLimitClause = OutputLimitClause.Create(Expressions.Eq("myvar", 1))
                                      .AddThenAssignment(Expressions.Eq(Expressions.Property("myvar"), Expressions.Constant(0)))
                                      .AddThenAssignment(Expressions.Eq(Expressions.Property("count_insert_var"), Expressions.Property("count_insert")));

            String epl = model.ToEPL();

            Assert.AreEqual(expression, epl);
            stmt = _epService.EPAdministrator.Create(model);
            RunAssertion(2, stmt);

            model = _epService.EPAdministrator.CompileEPL(expression);
            Assert.AreEqual(expression, model.ToEPL());
            stmt = _epService.EPAdministrator.Create(model);
            RunAssertion(3, stmt);

            String outputLast = "select symbol from MarketData.win:length(2) output last when myvar=1 ";

            model = _epService.EPAdministrator.CompileEPL(outputLast);
            Assert.AreEqual(outputLast.Trim(), model.ToEPL().Trim());

            // test same variable referenced multiple times JIRA-386
            SendTimer(0);
            SupportUpdateListener listenerOne = new SupportUpdateListener();
            SupportUpdateListener listenerTwo = new SupportUpdateListener();
            EPStatement           stmtOne     = _epService.EPAdministrator.CreateEPL("select * from MarketData output last when myvar=100");

            stmtOne.Events += listenerOne.Update;
            EPStatement stmtTwo = _epService.EPAdministrator.CreateEPL("select * from MarketData output last when myvar=100");

            stmtTwo.Events += listenerTwo.Update;
            _epService.EPRuntime.SendEvent(new SupportMarketDataBean("ABC", "E1", 100));
            _epService.EPRuntime.SendEvent(new SupportMarketDataBean("ABC", "E2", 100));

            SendTimer(1000);
            Assert.IsFalse(listenerOne.IsInvoked);
            Assert.IsFalse(listenerTwo.IsInvoked);

            _epService.EPRuntime.SetVariableValue("myvar", 100);
            SendTimer(2000);
            Assert.IsTrue(listenerTwo.IsInvoked);
            Assert.IsTrue(listenerOne.IsInvoked);

            stmtOne.Dispose();
            stmtTwo.Dispose();

            // test when-then with condition triggered by output events
            SendTimeEvent(2, 8, 0, 0, 0);
            String eplToDeploy = "create variable bool varOutputTriggered = false\n;" +
                                 "@Audit @Name('out') select * from SupportBean.std:lastevent() output snapshot when (count_insert > 1 and varOutputTriggered = false) then set varOutputTriggered = true;";

            _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(eplToDeploy);
            _epService.EPAdministrator.GetStatement("out").Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            Assert.AreEqual("E2", _listener.AssertOneGetNewAndReset().Get("TheString"));

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SetVariableValue("varOutputTriggered", false); // turns true right away as triggering output

            _epService.EPRuntime.SendEvent(new SupportBean("E5", 5));
            SendTimeEvent(2, 8, 0, 1, 0);
            Assert.AreEqual("E5", _listener.AssertOneGetNewAndReset().Get("TheString"));

            _epService.EPRuntime.SendEvent(new SupportBean("E6", 6));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPAdministrator.DestroyAllStatements();

            // test count_total for insert and remove
            _epService.EPAdministrator.CreateEPL("create variable int var_cnt_total = 3");
            String      expressionTotal = "select TheString from SupportBean.win:length(2) output when count_insert_total = var_cnt_total or count_remove_total > 2";
            EPStatement stmtTotal       = _epService.EPAdministrator.CreateEPL(expressionTotal);

            stmtTotal.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 1));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), "TheString".Split(','), new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } });

            _epService.EPRuntime.SetVariableValue("var_cnt_total", -1);

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 1));
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            _epService.EPRuntime.SendEvent(new SupportBean("E5", 1));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), "TheString".Split(','), new Object[][] { new Object[] { "E4" }, new Object[] { "E5" } });
            _epService.EPAdministrator.DestroyAllStatements();
        }
        public override IEnumerable <System.Linq.Expressions.MemberBinding> FinalSelectBindings(Type selectType, System.Linq.Expressions.ParameterExpression sourceTypeParameter)
        {
            if (!HasStratifications)
            {
                Expression prop = Expressions.ChildPropertyExpression(sourceTypeParameter, "Key", "AdmittedOn");

                return(new[] {
                    Expression.Bind(selectType.GetProperty("AdmittedOn"), prop)
                });
            }

            DTO.Enums.PeriodStratification stratification;
            if (!Enum.TryParse <DTO.Enums.PeriodStratification>(Stratifications.First().ToString(), out stratification))
            {
                throw new ArgumentException("Unable to parse the specified stratification value as an PeriodStratification: " + Stratifications.First().ToString());
            }

            List <MemberAssignment> bindings = new List <MemberAssignment>();

            bindings.Add(Expression.Bind(selectType.GetProperty("AdmittedOnYear"), Expressions.ChildPropertyExpression(sourceTypeParameter, "Key", "AdmittedOnYear")));

            if (stratification == DTO.Enums.PeriodStratification.Monthly)
            {
                bindings.Add(Expression.Bind(selectType.GetProperty("AdmittedOnMonth"), Expressions.ChildPropertyExpression(sourceTypeParameter, "Key", "AdmittedOnMonth")));
            }

            return(bindings);
        }
Esempio n. 25
0
 private AssignmentExpressionSyntax Assign(PropertyInfo property, object value)
 {
     return(Expressions.AssignExpression(property.Name, ValueToSyntax(value)));
 }
Esempio n. 26
0
        public static void magix_execute_execute_script(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.execute-script-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.execute-script-sample]");
                return;
            }

            Node dp = Dp(e.Params);

            if (!ip.ContainsValue("file") && !ip.ContainsValue("script"))
            {
                throw new ArgumentException("[execute-script] needs either a [file] or a [script] parameter");
            }

            if (ip.ContainsValue("file") && ip.ContainsValue("script"))
            {
                throw new ArgumentException("you cannot supply both [file] and [script] to [execute-script]");
            }

            string script = null;

            if (ip.ContainsValue("script"))
            {
                script = Expressions.GetExpressionValue <string>(ip["script"].Get <string>(), dp, ip, false);
            }
            else
            {
                try
                {
                    RaiseActiveEvent(
                        "magix.file.load",
                        e.Params);

                    script = ip["value"].Get <string>();
                }
                finally
                {
                    ip["value"].UnTie();
                }
            }

            Node conversionNode = new Node();

            conversionNode["code"].Value = script;

            RaiseActiveEvent(
                "magix.execute.code-2-node",
                conversionNode);

            conversionNode["node"]["inspect"].UnTie();

            Node exe = conversionNode["node"].Clone();

            if (ip.ContainsValue("file"))
            {
                string file      = Expressions.GetFormattedExpression("file", e.Params, "");
                string directory = file;
                if (directory.Contains("/"))
                {
                    directory = directory.Substring(0, directory.LastIndexOf('/'));
                }
                exe["$"]["script-file"].Value      = file;
                exe["$"]["script-directory"].Value = directory;
            }
            ExecuteScript(exe, ip);
        }
Esempio n. 27
0
        private void RunAssertionAliasesAggregationOM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause      = SelectClause.Create("symbol", "volume").Add(Expressions.Sum("price"), "mySum");
            model.FromClause        = FromClause.Create(FilterStream.Create(typeof(SupportMarketDataBean).FullName).AddView(View.Create("length", Expressions.Constant(20))));
            model.GroupByClause     = GroupByClause.Create("symbol");
            model.OutputLimitClause = OutputLimitClause.Create(6);
            model.OrderByClause     = OrderByClause.Create(Expressions.Sum("price")).Add("symbol", false);
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string statementString = "select symbol, volume, sum(price) as mySum from " +
                                     typeof(SupportMarketDataBean).FullName + "#length(20) " +
                                     "group by symbol " +
                                     "output every 6 events " +
                                     "order by sum(price), symbol";

            Assert.AreEqual(statementString, model.ToEPL());

            var         testListener = new SupportUpdateListener();
            EPStatement statement    = epService.EPAdministrator.Create(model);

            statement.Events += testListener.Update;

            TryAssertionDefault(epService, testListener);

            statement.Dispose();
        }
Esempio n. 28
0
        /// <summary>
        /// Initializes character renderers with selected sprites.
        /// </summary>
        private void TryInitialize()
        {
            if (Expressions.All(i => i.Name != "Default") || Expressions.All(i => i.Name != "Angry") || Expressions.All(i => i.Name != "Dead"))
            {
                throw new Exception("Character must have at least 3 basic expressions: Default, Angry and Dead.");
            }

            HeadRenderer.sprite          = Head;
            HairRenderer.sprite          = Hair;
            HairRenderer.maskInteraction = Helmet == null || Helmet.name.Contains("[FullHair]") ? SpriteMaskInteraction.None : SpriteMaskInteraction.VisibleInsideMask;
            EarsRenderer.sprite          = Ears;
            SetExpression(Expression);
            BeardRenderer.sprite = Beard;
            EarsRenderer.sprite  = Ears;
            MapSprites(BodyRenderers, Body);
            HelmetRenderer.sprite   = Helmet;
            GlassesRenderer.sprite  = Glasses;
            MaskRenderer.sprite     = Mask;
            EarringsRenderer.sprite = Earrings;
            MapSprites(ArmorRenderers, Armor);
            CapeRenderer.sprite = Cape;
            BackRenderer.sprite = Back;
            PrimaryMeleeWeaponRenderer.sprite       = PrimaryMeleeWeapon;
            SecondaryMeleeWeaponRenderer.sprite     = SecondaryMeleeWeapon;
            BowRenderers.ForEach(i => i.sprite      = Bow.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            FirearmsRenderers.ForEach(i => i.sprite = Firearms.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            ShieldRenderer.sprite = Shield;

            PrimaryMeleeWeaponRenderer.enabled   = WeaponType != WeaponType.Bow;
            SecondaryMeleeWeaponRenderer.enabled = WeaponType == WeaponType.MeleePaired;
            BowRenderers.ForEach(i => i.enabled  = WeaponType == WeaponType.Bow);

            if (Hair != null && Hair.name.Contains("[HideEars]") && HairRenderer.maskInteraction == SpriteMaskInteraction.None)
            {
                EarsRenderer.sprite = null;
            }

            switch (WeaponType)
            {
            case WeaponType.Firearms1H:
            case WeaponType.Firearms2H:
                Firearm.AmmoShooted = 0;
                BuildFirearms(Firearm.Params);
                break;
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateIndexColumn"/> class.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="type">The index type.</param>
 public CreateIndexColumn(String columnName, CreateIndexColumnType type)
 {
     this.columns = Collections.SingletonList<Expression>(Expressions.Property(columnName));
     this.indexType = type.GetName();
 }
Esempio n. 30
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            var Position = Code.Length - 1;

            if (Position >= 0 && Code[Position] == ']')
            {
                var State = Container.State;
                var ZPos  = Code.GetBracketPos(State, true, Options.EnableMessages);
                if (ZPos == -1)
                {
                    return(SimpleRecResult.Failed);
                }

                var Left = Code.TrimmedSubstring(State, 0, ZPos, Options.EnableMessages);
                if (!Left.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                var TOptions = Options;
                TOptions.Func = x => x.RealId is Type;

                var TypeOfVals = Identifiers.Recognize(Container, Left, TOptions);
                if (TypeOfVals == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var RTypeOfVals = TypeOfVals.RealId as Type;
                if (RTypeOfVals == null || (RTypeOfVals.TypeFlags & TypeFlags.CanBeArrayType) == 0)
                {
                    if (Options.EnableMessages)
                    {
                        State.Messages.Add(MessageId.UnknownId, Code);
                    }

                    return(SimpleRecResult.Failed);
                }

                var StrParams = Code.Substring(ZPos + 1, Position - ZPos - 1).Trim();
                if (StrParams.IsEqual("?"))
                {
                    Ret = new NonrefArrayType(Container, TypeOfVals, null);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
                else if (StrParams.IsEqual("*"))
                {
                    if ((RTypeOfVals.TypeFlags & TypeFlags.CanBePointer) == 0)
                    {
                        if (Options.EnableMessages)
                        {
                            State.Messages.Add(MessageId.UnknownId, Code);
                        }

                        return(SimpleRecResult.Failed);
                    }

                    Ret = new PointerAndLength(Container, TypeOfVals);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }

                var SplParams = RecognizerHelper.SplitToParameters(State, StrParams,
                                                                   ',', Options.EnableMessages, true);

                if (SplParams == null)
                {
                    return(SimpleRecResult.Failed);
                }

                if (SplParams.Length == 0 || SplParams[0].Length == 0)
                {
                    for (var i = 0; i < SplParams.Length; i++)
                    {
                        if (SplParams[i].Length > 0)
                        {
                            State.Messages.Add(MessageId.NotExpected, SplParams[i]);
                            return(SimpleRecResult.Failed);
                        }
                    }

                    var IndexCount = SplParams.Length == 0 ? 1 : SplParams.Length;
                    Ret = new RefArrayType(Container, TypeOfVals, IndexCount);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
                else
                {
                    var Plugin = Container.GetPlugin();
                    Plugin.GetPlugin <EvaluatorPlugin>().MustBeConst = true;

                    var Lengths = new int[SplParams.Length];
                    for (var i = 0; i < SplParams.Length; i++)
                    {
                        var Node    = Expressions.CreateExpression(SplParams[i], Plugin);
                        var ConstCh = Node as ConstExpressionNode;
                        if (ConstCh == null)
                        {
                            return(SimpleRecResult.Failed);
                        }

                        if (!(ConstCh.Type is NonFloatType))
                        {
                            if (Options.EnableMessages)
                            {
                                State.Messages.Add(MessageId.MustBeInteger, StrParams);
                            }

                            return(SimpleRecResult.Failed);
                        }

                        if (!VerifyArrayLength(State, ConstCh, StrParams, Options.EnableMessages))
                        {
                            return(SimpleRecResult.Failed);
                        }

                        Lengths[i] = (int)ConstCh.Integer;
                    }

                    Ret = new NonrefArrayType(Container, TypeOfVals, Lengths);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
            }

            return(SimpleRecResult.Unknown);
        }
Esempio n. 31
0
        private static void UpdateDamageMonster(Match damage, Line line, Expressions exp, FilterType type)
        {
            _type = type;
            try {
                line.Hit       = true;
                line.DirectHit = damage.Groups["direct"].Success;

                if (string.IsNullOrWhiteSpace(line.Source))
                {
                    line.Source = Convert.ToString(damage.Groups["source"].Value);
                }

                if (string.IsNullOrWhiteSpace(line.Target))
                {
                    line.Target = Convert.ToString(damage.Groups["target"].Value);
                }

                var lastActionIsAttack = false;

                switch (damage.Groups["source"].Success)
                {
                case true:
                    switch (type)
                    {
                    case FilterType.You:
                        lastActionIsAttack = _lastActionYouIsAttack;
                        break;

                    case FilterType.Pet:
                        lastActionIsAttack = _lastActionPetIsAttack;
                        break;

                    case FilterType.Party:
                        lastActionIsAttack = _lastActionPartyIsAttack;
                        break;

                    case FilterType.PetParty:
                        lastActionIsAttack = _lastActionPetPartyIsAttack;
                        break;

                    case FilterType.Alliance:
                        lastActionIsAttack = _lastActionAllianceIsAttack;
                        break;

                    case FilterType.PetAlliance:
                        lastActionIsAttack = _lastActionPetAllianceIsAttack;
                        break;

                    case FilterType.Other:
                        lastActionIsAttack = _lastActionOtherIsAttack;
                        break;

                    case FilterType.PetOther:
                        lastActionIsAttack = _lastActionPetOtherIsAttack;
                        break;
                    }

                    break;

                case false:
                    line.Action = _lastActionMonster;
                    break;
                }

                line.Action = lastActionIsAttack
                                  ? $"{exp.Attack} [+]"
                                  : exp.Attack;
                line.Action = line.DirectHit
                                  ? $"{line.Action} [→]"
                                  : line.Action;

                line.Amount = damage.Groups["amount"].Success
                                  ? Convert.ToDouble(damage.Groups["amount"].Value)
                                  : 0;
                line.Block    = damage.Groups["block"].Success;
                line.Crit     = damage.Groups["crit"].Success;
                line.Modifier = damage.Groups["modifier"].Success
                                    ? Convert.ToDouble(damage.Groups["modifier"].Value) / 100
                                    : 0;
                line.Parry = damage.Groups["parry"].Success;
                switch (type)
                {
                case FilterType.Pet:
                    _lastNamePet = line.Target;
                    break;

                case FilterType.Party:
                    _lastNamePartyTo = line.Target;
                    break;

                case FilterType.PetParty:
                    _lastNamePetPartyTo = line.Target;
                    break;

                case FilterType.Alliance:
                    _lastNameAllianceTo = line.Target;
                    break;

                case FilterType.PetAlliance:
                    _lastNamePetAllianceTo = line.Target;
                    break;

                case FilterType.Other:
                    _lastNameOtherTo = line.Target;
                    break;

                case FilterType.PetOther:
                    _lastNamePetOtherTo = line.Target;
                    break;
                }

                if (line.IsEmpty())
                {
                    return;
                }

                switch (type)
                {
                default:
                    ParseControl.Instance.Timeline.PublishTimelineEvent(TimelineEventType.PartyMonsterFighting, line.Source);
                    break;
                }

                ParseControl.Instance.Timeline.GetSetPlayer(line.Target).SetDamageTaken(line);
                ParseControl.Instance.Timeline.GetSetMonster(line.Source).SetDamage(line);
            }
            catch (Exception ex) {
                ParsingLogHelper.Error(Logger, "Damage", exp.Event, ex);
            }
        }
Esempio n. 32
0
 public IOrderExpression GetOrder()
 {
     return(_order ?? (_order = Expressions.First(exp => exp.ExpressionType == ExpressionType.Order)));
 }
Esempio n. 33
0
        private static void ProcessActions(Event e, Expressions exp)
        {
            var line = new Line(e.ChatLogItem)
            {
                EventDirection = e.Direction,
                EventSubject   = e.Subject,
                EventType      = e.Type
            };

            LineHelper.SetTimelineTypes(ref line);
            if (LineHelper.IsIgnored(line))
            {
                return;
            }

            Match actions = Regex.Match("ph", @"^\.$");

            switch (e.Subject)
            {
            case EventSubject.You:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        line.Source = You;
                        UpdateActions(actions, line, exp, FilterType.You);
                    }

                    break;
                }

                break;

            case EventSubject.Pet:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.Pet);
                    }

                    break;
                }

                break;

            case EventSubject.Party:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.Party);
                    }

                    break;
                }

                break;

            case EventSubject.PetParty:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.PetParty);
                    }

                    break;
                }

                break;

            case EventSubject.Alliance:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.Alliance);
                    }

                    break;
                }

                break;

            case EventSubject.PetAlliance:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.PetAlliance);
                    }

                    break;
                }

                break;

            case EventSubject.Other:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.Other);
                    }

                    break;
                }

                break;

            case EventSubject.PetOther:
                switch (e.Direction)
                {
                // casts/uses
                case EventDirection.Self:
                    actions = exp.pActions;
                    if (actions.Success)
                    {
                        UpdateActions(actions, line, exp, FilterType.PetOther);
                    }

                    break;
                }

                break;

            case EventSubject.Engaged:
            case EventSubject.UnEngaged:
                switch (e.Direction)
                {
                case EventDirection.Self:
                    actions = exp.mActions;
                    if (actions.Success)
                    {
                        _lastNameMonster   = Convert.ToString(actions.Groups["source"].Value).ToTitleCase();
                        _lastActionMonster = Convert.ToString(actions.Groups["action"].Value).ToTitleCase();
                        UpdateActionsMonster(actions, line, exp, FilterType.MonsterParty);
                    }

                    break;
                }

                break;
            }

            if (actions.Success)
            {
                return;
            }

            ParsingLogHelper.Log(Logger, "Action", e, exp);
        }
Esempio n. 34
0
        public static void magix_execute_tunnel(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (ShouldInspect(ip))
            {
                AppendInspectFromResource(
                    ip["inspect"],
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.tunnel-dox].value");
                AppendCodeFromResource(
                    ip,
                    "Magix.execute",
                    "Magix.execute.hyperlisp.inspect.hl",
                    "[magix.execute.tunnel-sample]");
                return;
            }

            if (!ip.ContainsValue("name"))
            {
                throw new ArgumentException(
                          @"[tunnel] needs [name], being active event name, to know which event to override to go externally");
            }

            Node dp = Dp(e.Params);

            string activeEvent = Expressions.GetExpressionValue <string>(ip["name"].Get <string>(), dp, ip, false);
            string url         = ip.Contains("url") ? Expressions.GetExpressionValue <string>(ip["url"].Get <string>(), dp, ip, false) : null;

            if (string.IsNullOrEmpty(url))
            {
                if (!ip.Contains("persist") || ip["persist"].Get <bool>())
                {
                    DataBaseRemoval.Remove(activeEvent, "magix.execute.tunnel", e.Params);
                }

                ActiveEvents.Instance.RemoveRemoteOverride(activeEvent);

                string originalName    = "";
                string origActiveEvent = ActiveEvents.Instance.GetEventMappingValue(activeEvent, ref originalName);
                if (origActiveEvent == "magix.execute._mumbo-jumbo")
                {
                    ActiveEvents.Instance.RemoveMapping(activeEvent);
                }
            }
            else
            {
                if (!ip.Contains("persist") || ip["persist"].Get <bool>())
                {
                    DataBaseRemoval.Remove(activeEvent, "magix.execute.tunnel", e.Params);

                    Node saveNode = new Node("magix.data.save");
                    saveNode["id"].Value             = Guid.NewGuid();
                    saveNode["value"]["event"].Value = activeEvent;
                    saveNode["value"]["type"].Value  = "magix.execute.tunnel";
                    saveNode["value"]["url"].Value   = url;
                    BypassExecuteActiveEvent(saveNode, e.Params);
                }
                ActiveEvents.Instance.OverrideRemotely(activeEvent, url);
                if (!ActiveEvents.Instance.IsOverride(activeEvent))
                {
                    // to make sure the local system actually has an active event with that name
                    ActiveEvents.Instance.CreateEventMapping(
                        activeEvent,
                        "magix.execute._mumbo-jumbo");
                }
            }
        }
Esempio n. 35
0
        private static void UpdateActions(Match actions, Line line, Expressions exp, FilterType type)
        {
            _type = type;
            _lastActionYouIsAttack         = false;
            _lastActionPetIsAttack         = false;
            _lastActionPartyIsAttack       = false;
            _lastActionPetPartyIsAttack    = false;
            _lastActionAllianceIsAttack    = false;
            _lastActionPetAllianceIsAttack = false;
            try {
                if (string.IsNullOrWhiteSpace(line.Source))
                {
                    line.Source = Convert.ToString(actions.Groups["source"].Value);
                }

                var    isHealingSkill = false;
                Player player         = ParseControl.Instance.Timeline.GetSetPlayer(line.Source);
                var    action         = Convert.ToString(actions.Groups["action"].Value).ToTitleCase();
                foreach (var healingAction in ParseHelper.HealingActions.Where(healingAction => string.Equals(healingAction, action, Constants.InvariantComparer)))
                {
                    isHealingSkill = true;
                }

                switch (type)
                {
                case FilterType.You:
                    _lastActionYou = action;
                    break;

                case FilterType.Pet:
                    _lastActionPet = action;
                    _lastNamePet   = line.Source;
                    break;

                case FilterType.Party:
                    if (isHealingSkill)
                    {
                        _lastActionPartyHealingFrom = action;
                        _lastNamePartyHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPartyFrom = action;
                        _lastNamePartyFrom   = line.Source;
                    }

                    break;

                case FilterType.PetParty:
                    if (isHealingSkill)
                    {
                        _lastActionPetPartyHealingFrom = action;
                        _lastNamePetPartyHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetPartyFrom = action;
                        _lastNamePetPartyFrom   = line.Source;
                    }

                    break;

                case FilterType.Alliance:
                    if (isHealingSkill)
                    {
                        _lastActionAllianceHealingFrom = action;
                        _lastNameAllianceHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionAllianceFrom = action;
                        _lastNameAllianceFrom   = line.Source;
                    }

                    break;

                case FilterType.PetAlliance:
                    if (isHealingSkill)
                    {
                        _lastActionPetAllianceHealingFrom = action;
                        _lastNamePetAllianceHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetAllianceFrom = action;
                        _lastNamePetAllianceFrom   = line.Source;
                    }

                    break;

                case FilterType.Other:
                    if (isHealingSkill)
                    {
                        _lastActionOtherHealingFrom = action;
                        _lastNameOtherHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionOtherFrom = action;
                        _lastNameOtherFrom   = line.Source;
                    }

                    break;

                case FilterType.PetOther:
                    if (isHealingSkill)
                    {
                        _lastActionPetOtherHealingFrom = action;
                        _lastNamePetOtherHealingFrom   = line.Source;
                    }
                    else
                    {
                        _lastActionPetOtherFrom = action;
                        _lastNamePetOtherFrom   = line.Source;
                    }

                    break;
                }

                player.LastActionTime = DateTime.Now;
                try {
                    List <ActorItem> players = XIVInfoViewModel.Instance.CurrentPCs.Select(entity => entity.Value).ToList();
                    if (!players.Any())
                    {
                        return;
                    }

                    foreach (ActorItem actorEntity in players)
                    {
                        var playerName = actorEntity.Name;
                        ParseControl.Instance.Timeline.TrySetPlayerCurable(playerName, actorEntity.HPMax - actorEntity.HPCurrent);
                    }
                }
                catch (Exception ex) {
                    Logging.Log(Logger, new LogItem(ex, true));
                }
            }
            catch (Exception ex) {
                ParsingLogHelper.Error(Logger, "Action", exp.Event, ex);
            }
        }
		public virtual void Visit(Expressions.ImportExpression x)
		{
			if (x.AssignExpression != null)
				x.AssignExpression.Accept(this);
		}
Esempio n. 37
0
        private static void UpdateHealing(Match cure, Line line, Expressions exp, FilterType type)
        {
            _type = type;
            try {
                if (string.IsNullOrWhiteSpace(line.Source))
                {
                    line.Source = Convert.ToString(cure.Groups["source"].Value);
                }

                if (string.IsNullOrWhiteSpace(line.Target))
                {
                    line.Target = Convert.ToString(cure.Groups["target"].Value);
                }

                switch (type)
                {
                case FilterType.You:
                    line.Action = _lastActionYou;
                    break;

                case FilterType.Pet:
                    line.Action = _lastActionPet;
                    break;

                case FilterType.Party:
                    line.Action = _lastActionPartyHealingFrom;
                    break;

                case FilterType.PetParty:
                    line.Action = _lastActionPetPartyHealingFrom;
                    break;

                case FilterType.Alliance:
                    line.Action = _lastActionAllianceHealingFrom;
                    break;

                case FilterType.PetAlliance:
                    line.Action = _lastActionPetAllianceHealingFrom;
                    break;

                case FilterType.Other:
                    line.Action = _lastActionOtherHealingFrom;
                    break;

                case FilterType.PetOther:
                    line.Action = _lastActionPetOtherHealingFrom;
                    break;
                }

                line.Amount = cure.Groups["amount"].Success
                                  ? Convert.ToDouble(cure.Groups["amount"].Value)
                                  : 0;
                line.Crit     = cure.Groups["crit"].Success;
                line.Modifier = cure.Groups["modifier"].Success
                                    ? Convert.ToDouble(cure.Groups["modifier"].Value) / 100
                                    : 0;
                switch (line.EventDirection)
                {
                case EventDirection.You:
                    line.Target = You;
                    break;
                }

                line.RecLossType = Convert.ToString(cure.Groups["type"].Value.ToUpperInvariant());
                if (line.IsEmpty())
                {
                    return;
                }

                if (line.RecLossType == exp.HealingType)
                {
                    ParseControl.Instance.Timeline.GetSetPlayer(line.Source).SetHealing(line);
                }
            }
            catch (Exception ex) {
                ParsingLogHelper.Error(Logger, "Cure", exp.Event, ex);
            }
        }
		public virtual void Visit(Expressions.IsExpression x)
		{
			if (x.TestedType != null)
				x.TestedType.Accept(this);

			// Do not visit the artificial param..it's not existing

			if (x.TypeSpecialization != null)
				x.TypeSpecialization.Accept(this);

			if (x.TemplateParameterList != null)
				foreach (var p in x.TemplateParameterList)
					p.Accept(this);
		}
		public virtual void Visit(Expressions.TokenExpression x)
		{
			
		}
Esempio n. 40
0
            public void Run(RegressionEnvironment env)
            {
                var stmtText = "@Name('s0') select P00 like P01 as r1, " +
                               "P00 like P01 escape \"!\" as r2, " +
                               "P02 regexp P03 as r3 " +
                               "from SupportBean_S0";

                var model = new EPStatementObjectModel();

                model.Annotations  = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                model.SelectClause = SelectClause.Create()
                                     .Add(Expressions.Like(Expressions.Property("P00"), Expressions.Property("P01")), "r1")
                                     .Add(Expressions.Like(Expressions.Property("P00"), Expressions.Property("P01"), Expressions.Constant("!")), "r2")
                                     .Add(Expressions.Regexp(Expressions.Property("P02"), Expressions.Property("P03")), "r3");

                model.FromClause = FromClause.Create(FilterStream.Create("SupportBean_S0"));
                model            = SerializableObjectCopier.GetInstance(env.Container).Copy(model);
                Assert.AreEqual(stmtText, model.ToEPL());

                var compiled = env.Compile(model, new CompilerArguments(env.Configuration));

                env.Deploy(compiled).AddListener("s0").Milestone(0);

                RunLikeRegexStringAndNull(env);

                env.UndeployAll();
            }
		public virtual void Visit(Expressions.ArrayLiteralExpression x)
		{
			foreach (var e in x.Elements)
				if(e!=null)
					e.Accept(this);
		}
		public virtual void Visit(Expressions.FunctionLiteral x)
		{
			x.AnonymousMethod.Accept(this);
		}
        public override IEnumerable <System.Linq.Expressions.MemberBinding> InnerSelectBindings(Type selectType, System.Linq.Expressions.ParameterExpression sourceTypeParameter)
        {
            //the earliest  encounter date that satisfies the query critieria

            ParameterExpression pe_sourceQueryType = sourceTypeParameter;

            Expression encountersProp = Expressions.AsQueryable(Expression.Property(pe_sourceQueryType, "Encounters"));

            ParameterExpression pe_encountersQueryType = Expression.Parameter(typeof(PCORIQueryBuilder.Model.Encounter), "enc");

            Expression admittedOnSelector = Expression.Property(pe_encountersQueryType, "AdmittedOn");

            BinaryExpression be_encounterPatient = Expression.Equal(Expression.Property(pe_sourceQueryType, "ID"), Expression.Property(pe_encountersQueryType, "PatientID"));

            BinaryExpression predicate = be_encounterPatient;

            if (Criteria.Any(c => c.Terms.Any(t => t.Type == ModelTermsFactory.ObservationPeriodID)))
            {
                var observationPeriodCriteria = Criteria.SelectMany(c => c.Terms.Where(t => t.Type == ModelTermsFactory.ObservationPeriodID));
                foreach (var obpTerm in observationPeriodCriteria)
                {
                    DateTime dateValue;
                    var      range = AdapterHelpers.ParseDateRangeValues(obpTerm);
                    if (range.StartDate.HasValue)
                    {
                        dateValue = range.StartDate.Value.DateTime.Date;
                        predicate = Expression.AndAlso(predicate, Expression.GreaterThanOrEqual(admittedOnSelector, Expression.Constant(dateValue)));
                    }
                    if (range.EndDate.HasValue)
                    {
                        dateValue = range.EndDate.Value.DateTime.Date;
                        predicate = Expression.AndAlso(predicate, Expression.LessThanOrEqual(admittedOnSelector, Expression.Constant(dateValue)));
                    }
                }
            }

            MethodCallExpression admittedOnWhere = Expressions.Where(encountersProp, Expression.Lambda(predicate, pe_encountersQueryType));

            MethodCallExpression orderByAdmittedOn = Expressions.OrderByAscending(admittedOnWhere, Expression.Lambda(admittedOnSelector, pe_encountersQueryType));

            //need to cast the return type of the select to a nullable datetime so that the FirstOrDefault will be null as the default
            MethodCallExpression admittedOnSelect = Expressions.Select(pe_encountersQueryType.Type, typeof(DateTime?), orderByAdmittedOn, Expression.Lambda(Expression.Convert(admittedOnSelector, typeof(DateTime?)), pe_encountersQueryType));

            MethodCallExpression firstOrDefaultAdmittedOn = Expressions.FirstOrDefault <DateTime?>(admittedOnSelect);

            if (!HasStratifications)
            {
                return(new[] {
                    Expression.Bind(selectType.GetProperty("AdmittedOn"), firstOrDefaultAdmittedOn)
                });
            }

            //if stratified by Month -> return as string in format yyyy-MM
            //if stratified by Year -> return as string in format yyyy

            DTO.Enums.PeriodStratification stratification;
            if (!Enum.TryParse <DTO.Enums.PeriodStratification>(Stratifications.First().ToString(), out stratification))
            {
                throw new ArgumentException("Unable to parse the specified stratification value as an PeriodStratification: " + Stratifications.First().ToString());
            }

            Expression prop = Expression.Property(firstOrDefaultAdmittedOn, "Value");
            //Expression yearPartString = Expressions.CallToString<int>(Expression.Property(prop, "Year"));
            //if (stratification == DTO.Enums.PeriodStratification.Monthly)
            //{
            //    //if stratified by Month -> return as string in format yyyy-MM
            //    Expression monthPartString = Expressions.CallToString<int>(Expression.Property(prop, "Month"));

            //    prop = Expressions.ConcatStrings(yearPartString, Expression.Constant("-"), monthPartString);
            //}
            //else if (stratification == DTO.Enums.PeriodStratification.Yearly)
            //{
            //    //if stratified by Year -> return as string in format yyyy
            //    prop = yearPartString;
            //}
            //else
            //{
            //    throw new NotSupportedException("The specified period stratifcation is not currently supported; stratification value: " + Stratifications.First().ToString());
            //}

            //Expression stratificationModifier = Expression.Condition(Expression.NotEqual(firstOrDefaultAdmittedOn, Expression.Constant(null)), prop, Expression.Constant("", typeof(string)));
            //return new[] {
            //        Expression.Bind(selectType.GetProperty("AdmittedOn"), stratificationModifier)
            //    };

            Expression yearProp  = Expression.Property(prop, "Year");
            Expression monthProp = Expression.Property(prop, "Month");

            return(new[] {
                Expression.Bind(selectType.GetProperty("AdmittedOn"), firstOrDefaultAdmittedOn),
                Expression.Bind(selectType.GetProperty("AdmittedOnYear"), yearProp),
                Expression.Bind(selectType.GetProperty("AdmittedOnMonth"), monthProp)
            });
        }
Esempio n. 44
0
 public override object Evaluate()
 {
     return((Complex)NumberTheory.LCM(Expressions.Select(x => x.EvaluateAsInt64()).ToArray()));
 }
		public virtual void Visit(Expressions.IdentifierExpression x)
		{
			
		}
Esempio n. 46
0
 public void SpotCheckEnumElementAccess()
 {
     Assert.AreEqual(Weapons.Blowgun, Expressions.Get("Blowgun"));
     Assert.AreEqual(Weapons.Blowgun | Weapons.Club, Expressions.Get("Blowgun | Club"));
     Assert.AreEqual(DamageType.Fire | DamageType.Acid | DamageType.Bludgeoning, Expressions.Get("Fire | Acid | Bludgeoning"));
     Assert.AreEqual(Conditions.Deafened, Expressions.Get("Deafened"));
 }
		public virtual void Visit(Expressions.TypeDeclarationExpression x)
		{
			x.Declaration.Accept(this);
		}
Esempio n. 48
0
        public void TestArrayWithArg()
        {
            var joinStatement = "select irstream id, theString from " +
                                typeof(SupportBean).Name + "().win:length(3) as s1, " +
                                " method:com.espertech.esper.support.epl.SupportStaticMethodLib.FetchArrayGen(intPrimitive)";
            var stmt = _epService.EPAdministrator.CreateEPL(joinStatement);

            TryArrayWithArg(stmt);

            joinStatement = "select irstream id, theString from " +
                            "method:com.espertech.esper.support.epl.SupportStaticMethodLib.FetchArrayGen(intPrimitive) as s0, " +
                            typeof(SupportBean).Name + ".win:length(3)";
            stmt = _epService.EPAdministrator.CreateEPL(joinStatement);
            TryArrayWithArg(stmt);

            var model = _epService.EPAdministrator.CompileEPL(joinStatement);

            Assert.AreEqual(joinStatement, model.ToEPL());
            stmt = _epService.EPAdministrator.Create(model);
            TryArrayWithArg(stmt);

            model = new EPStatementObjectModel();
            model.SelectClause = SelectClause.Create("id", "theString").SetStreamSelector(StreamSelector.RSTREAM_ISTREAM_BOTH);
            model.FromClause   = FromClause.Create()
                                 .Add(MethodInvocationStream.Create(typeof(SupportStaticMethodLib).FullName, "FetchArrayGen", "s0")
                                      .AddParameter(Expressions.Property("intPrimitive")))
                                 .Add(FilterStream.Create(typeof(SupportBean).Name).AddView("win", "length", Expressions.Constant(3)));

            stmt = _epService.EPAdministrator.Create(model);
            Assert.AreEqual(joinStatement, model.ToEPL());

            TryArrayWithArg(stmt);
        }
		public virtual void Visit(Expressions.AssocArrayExpression x)
		{
			foreach (var kv in x.Elements)
			{
				kv.Key.Accept(this);
				kv.Value.Accept(this);
			}
		}
Esempio n. 50
0
        private static void ProcessFailed(Event e, Expressions exp)
        {
            var line = new Line(e.ChatLogItem)
            {
                EventDirection = e.Direction,
                EventSubject   = e.Subject,
                EventType      = e.Type,
            };

            LineHelper.SetTimelineTypes(ref line);
            if (LineHelper.IsIgnored(line))
            {
                return;
            }

            Match failed = Regex.Match("ph", @"^\.$");

            switch (e.Subject)
            {
            case EventSubject.You:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = You;
                        UpdateFailed(failed, line, exp, FilterType.You);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            line.Source = You;
                            UpdateFailed(failed, line, exp, FilterType.You);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Pet:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNamePet;
                        UpdateFailed(failed, line, exp, FilterType.Pet);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.Pet);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Party:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNamePartyFrom;
                        UpdateFailed(failed, line, exp, FilterType.Party);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.Party);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetParty:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNamePetPartyFrom;
                        UpdateFailed(failed, line, exp, FilterType.PetParty);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.PetParty);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Alliance:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameAllianceFrom;
                        UpdateFailed(failed, line, exp, FilterType.Alliance);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.Alliance);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetAlliance:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNamePetAllianceFrom;
                        UpdateFailed(failed, line, exp, FilterType.PetAlliance);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.PetAlliance);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Other:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameOtherFrom;
                        UpdateFailed(failed, line, exp, FilterType.Other);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.Other);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetOther:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    failed = exp.pFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNamePetOtherFrom;
                        UpdateFailed(failed, line, exp, FilterType.PetOther);
                        break;

                    case false:
                        failed = exp.pFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailed(failed, line, exp, FilterType.PetOther);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Engaged:
            case EventSubject.UnEngaged:
                switch (e.Direction)
                {
                case EventDirection.You:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = You;
                        UpdateFailedMonster(failed, line, exp, FilterType.You);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            line.Target = You;
                            UpdateFailedMonster(failed, line, exp, FilterType.You);
                        }

                        break;
                    }

                    break;

                case EventDirection.Pet:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePet;
                        UpdateFailedMonster(failed, line, exp, FilterType.Pet);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.Pet);
                        }

                        break;
                    }

                    break;

                case EventDirection.Party:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePartyTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.Party);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.Party);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetParty:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetPartyTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.PetParty);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.PetParty);
                        }

                        break;
                    }

                    break;

                case EventDirection.Alliance:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNameAllianceTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.Alliance);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.Alliance);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetAlliance:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetAllianceTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.PetAlliance);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.PetAlliance);
                        }

                        break;
                    }

                    break;

                case EventDirection.Other:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNameOtherTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.Other);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.Other);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetOther:
                    failed = exp.mFailed;
                    switch (failed.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetOtherTo;
                        UpdateFailedMonster(failed, line, exp, FilterType.PetOther);
                        break;

                    case false:
                        failed = exp.mFailedAuto;
                        if (failed.Success)
                        {
                            UpdateFailedMonster(failed, line, exp, FilterType.PetOther);
                        }

                        break;
                    }

                    break;
                }

                break;
            }

            if (failed.Success)
            {
                return;
            }

            ParsingLogHelper.Log(Logger, "Failed", e, exp);
        }
		public virtual void Visit(Expressions.AssertExpression x)
		{
			VisitChildren(x);
		}
Esempio n. 52
0
        private static void UpdateFailedMonster(Match failed, Line line, Expressions exp, FilterType type)
        {
            _type = type;
            try {
                line.Miss = true;
                if (string.IsNullOrWhiteSpace(line.Source))
                {
                    line.Source = Convert.ToString(failed.Groups["source"].Value);
                }

                if (string.IsNullOrWhiteSpace(line.Target))
                {
                    line.Target = Convert.ToString(failed.Groups["target"].Value);
                }

                switch (failed.Groups["source"].Success)
                {
                case true:
                    line.Action = exp.Attack;
                    break;

                case false:
                    line.Action = _lastActionMonster;
                    break;
                }

                switch (type)
                {
                case FilterType.Pet:
                    _lastNamePet = line.Target;
                    break;

                case FilterType.Party:
                    _lastNamePartyTo = line.Target;
                    break;

                case FilterType.PetParty:
                    _lastNamePetPartyTo = line.Target;
                    break;

                case FilterType.Alliance:
                    _lastNameAllianceTo = line.Target;
                    break;

                case FilterType.PetAlliance:
                    _lastNamePetAllianceTo = line.Target;
                    break;

                case FilterType.Other:
                    _lastNameOtherTo = line.Target;
                    break;

                case FilterType.PetOther:
                    _lastNamePetOtherTo = line.Target;
                    break;
                }

                if (line.IsEmpty())
                {
                    return;
                }

                switch (type)
                {
                default:
                    ParseControl.Instance.Timeline.PublishTimelineEvent(TimelineEventType.PartyMonsterFighting, line.Source);
                    break;
                }

                ParseControl.Instance.Timeline.GetSetPlayer(line.Target).SetDamageTaken(line);
                ParseControl.Instance.Timeline.GetSetMonster(line.Source).SetDamage(line);
            }
            catch (Exception ex) {
                ParsingLogHelper.Error(Logger, "Failed", exp.Event, ex);
            }
        }
		public virtual void Visit(Expressions.TypeidExpression x)
		{
			if (x.Type != null)
				x.Type.Accept(this);
			else if (x.Expression != null)
				x.Expression.Accept(this);
		}
        TransformInfo TransformExpression(IBuildContext context, Expression expr, bool enforceServerSide, string alias)
        {
            if (_skippedExpressions.Contains(expr))
            {
                return(new TransformInfo(expr, true));
            }

            if (HasNoneSqlMember(expr))
            {
                return(new TransformInfo(expr));
            }

            alias = alias ?? GetExpressionAlias(expr);

            switch (expr.NodeType)
            {
            case ExpressionType.Convert:
            case ExpressionType.ConvertChecked:
            {
                if (expr.Type == typeof(object))
                {
                    break;
                }

                var cex = (UnaryExpression)expr;

                _convertedExpressions.Add(cex.Operand, cex);

                var nex = BuildExpression(context, cex.Operand, enforceServerSide);

                if (nex.Type != cex.Type)
                {
                    nex = cex.Update(nex);
                }

                var ret = new TransformInfo(nex, true);

                RemoveConvertedExpression(cex.Operand);

                return(ret);
            }

            case ExpressionType.MemberAccess:
            {
                if (IsServerSideOnly(expr) || PreferServerSide(expr, enforceServerSide))
                {
                    return(new TransformInfo(BuildSql(context, expr, alias)));
                }

                var ma = (MemberExpression)expr;

                var l = Expressions.ConvertMember(MappingSchema, ma.Expression?.Type, ma.Member);
                if (l != null)
                {
                    // In Grouping KeyContext we have to perform calculation on server side
                    if (Contexts.Any(c => c is GroupByBuilder.KeyContext))
                    {
                        return(new TransformInfo(BuildSql(context, expr, alias)));
                    }
                    break;
                }

                if (ma.Member.IsNullableValueMember())
                {
                    break;
                }

                var ctx = GetContext(context, ma);

                if (ctx != null)
                {
                    if (ma.Type.IsGenericTypeEx() && typeof(IEnumerable <>).IsSameOrParentOf(ma.Type))
                    {
                        var res = ctx.IsExpression(ma, 0, RequestFor.Association);

                        if (res.Result)
                        {
                            var table = (TableBuilder.AssociatedTableContext)res.Context;
                            if (table.IsList)
                            {
                                var mexpr = GetMultipleQueryExpression(context, MappingSchema, ma, new HashSet <ParameterExpression>());
                                return(new TransformInfo(BuildExpression(context, mexpr, enforceServerSide)));
                            }
                        }
                    }

                    var prevCount  = ctx.SelectQuery.Select.Columns.Count;
                    var expression = ctx.BuildExpression(ma, 0, enforceServerSide);
                    if (!alias.IsNullOrEmpty() && (ctx.SelectQuery.Select.Columns.Count - prevCount) == 1)
                    {
                        ctx.SelectQuery.Select.Columns[ctx.SelectQuery.Select.Columns.Count - 1].Alias = alias;
                    }
                    return(new TransformInfo(expression));
                }

                var ex = ma.Expression;

                while (ex is MemberExpression)
                {
                    ex = ((MemberExpression)ex).Expression;
                }

                if (ex is MethodCallExpression ce)
                {
                    if (IsSubQuery(context, ce))
                    {
                        if (!IsMultipleQuery(ce))
                        {
                            var info = GetSubQueryContext(context, ce);
                            if (alias != null)
                            {
                                info.Context.SetAlias(alias);
                            }
                            var par = Expression.Parameter(ex.Type);
                            var bex = info.Context.BuildExpression(ma.Transform(e => e == ex ? par : e), 0, enforceServerSide);

                            if (bex != null)
                            {
                                return(new TransformInfo(bex));
                            }
                        }
                    }
                }

                ex = ma.Expression;

                if (ex != null && ex.NodeType == ExpressionType.Constant)
                {
                    // field = localVariable
                    //
                    if (!_expressionAccessors.TryGetValue(ex, out var c))
                    {
                        return(new TransformInfo(ma));
                    }
                    return(new TransformInfo(Expression.MakeMemberAccess(Expression.Convert(c, ex.Type), ma.Member)));
                }

                break;
            }

            case ExpressionType.Parameter:
            {
                if (expr == ParametersParam)
                {
                    break;
                }

                var ctx = GetContext(context, expr);

                if (ctx != null)
                {
                    var buildExpr = ctx.BuildExpression(expr, 0, enforceServerSide);
                    if (buildExpr.Type != expr.Type)
                    {
                        buildExpr = Expression.Convert(buildExpr, expr.Type);
                    }
                    return(new TransformInfo(buildExpr));
                }

                break;
            }

            case ExpressionType.Constant:
            {
                if (expr.Type.IsConstantable())
                {
                    break;
                }

                if (_expressionAccessors.TryGetValue(expr, out var accessor))
                {
                    return(new TransformInfo(Expression.Convert(accessor, expr.Type)));
                }

                break;
            }

            case ExpressionType.Coalesce:

                if (expr.Type == typeof(string) && MappingSchema.GetDefaultValue(typeof(string)) != null)
                {
                    return(new TransformInfo(BuildSql(context, expr, alias)));
                }

                if (CanBeTranslatedToSql(context, ConvertExpression(expr), true))
                {
                    return(new TransformInfo(BuildSql(context, expr, alias)));
                }

                break;

            case ExpressionType.Call:
            {
                var ce = (MethodCallExpression)expr;

                if (IsGroupJoinSource(context, ce))
                {
                    foreach (var arg in ce.Arguments.Skip(1))
                    {
                        if (!_skippedExpressions.Contains(arg))
                        {
                            _skippedExpressions.Add(arg);
                        }
                    }

                    if (IsSubQuery(context, ce))
                    {
                        if (ce.IsQueryable())
                        //if (!typeof(IEnumerable).IsSameOrParentOf(expr.Type) || expr.Type == typeof(string) || expr.Type.IsArray)
                        {
                            var ctx = GetContext(context, expr);

                            if (ctx != null)
                            {
                                return(new TransformInfo(ctx.BuildExpression(expr, 0, enforceServerSide)));
                            }
                        }
                    }

                    break;
                }

                if (ce.IsAssociation(MappingSchema))
                {
                    var ctx = GetContext(context, ce);
                    if (ctx == null)
                    {
                        throw new InvalidOperationException();
                    }

                    return(new TransformInfo(ctx.BuildExpression(ce, 0, enforceServerSide)));
                }

                if ((_buildMultipleQueryExpressions == null || !_buildMultipleQueryExpressions.Contains(ce)) && IsSubQuery(context, ce))
                {
                    if (IsMultipleQuery(ce))
                    {
                        return(new TransformInfo(BuildMultipleQuery(context, ce, enforceServerSide)));
                    }

                    return(new TransformInfo(GetSubQueryExpression(context, ce, enforceServerSide, alias)));
                }

                if (IsServerSideOnly(expr) || PreferServerSide(expr, enforceServerSide) || ce.Method.IsSqlPropertyMethodEx())
                {
                    return(new TransformInfo(BuildSql(context, expr, alias)));
                }
            }

            break;

            case ExpressionType.New:
            {
                var ne = (NewExpression)expr;

                List <Expression> arguments = null;
                for (var i = 0; i < ne.Arguments.Count; i++)
                {
                    var argument    = ne.Arguments[i];
                    var memberAlias = ne.Members?[i].Name;

                    var newArgument = ConvertAssignmentArgument(context, argument, ne.Members?[i], enforceServerSide, memberAlias);
                    if (newArgument != argument)
                    {
                        if (arguments == null)
                        {
                            arguments = ne.Arguments.Take(i).ToList();
                        }
                    }
                    arguments?.Add(newArgument);
                }

                if (arguments != null)
                {
                    ne = ne.Update(arguments);
                }

                return(new TransformInfo(ne, true));
            }

            case ExpressionType.MemberInit:
            {
                var mi      = (MemberInitExpression)expr;
                var newPart = (NewExpression)BuildExpression(context, mi.NewExpression, enforceServerSide);
                List <MemberBinding> bindings = null;
                for (var i = 0; i < mi.Bindings.Count; i++)
                {
                    var binding    = mi.Bindings[i];
                    var newBinding = binding;
                    if (binding is MemberAssignment assignment)
                    {
                        var argument = ConvertAssignmentArgument(context, assignment.Expression,
                                                                 assignment.Member, enforceServerSide, assignment.Member.Name);
                        if (argument != assignment.Expression)
                        {
                            newBinding = Expression.Bind(assignment.Member, argument);
                        }
                    }

                    if (newBinding != binding)
                    {
                        if (bindings == null)
                        {
                            bindings = mi.Bindings.Take(i).ToList();
                        }
                    }

                    bindings?.Add(newBinding);
                }

                if (mi.NewExpression != newPart || bindings != null)
                {
                    mi = mi.Update(newPart, bindings ?? mi.Bindings.AsEnumerable());
                }

                return(new TransformInfo(mi, true));
            }
            }

            if (EnforceServerSide(context))
            {
                switch (expr.NodeType)
                {
                case ExpressionType.MemberInit:
                case ExpressionType.Convert:
                    break;

                default:
                    if (CanBeCompiled(expr))
                    {
                        break;
                    }
                    return(new TransformInfo(BuildSql(context, expr, alias)));
                }
            }

            return(new TransformInfo(expr));
        }
		public virtual void Visit(Expressions.TraitsExpression x)
		{
			if (x.Arguments != null)
				foreach (var arg in x.Arguments)
					arg.Accept(this);
		}
        bool PreferServerSide(Expression expr, bool enforceServerSide)
        {
            switch (expr.NodeType)
            {
            case ExpressionType.MemberAccess:
            {
                var pi = (MemberExpression)expr;
                var l  = Expressions.ConvertMember(MappingSchema, pi.Expression?.Type, pi.Member);

                if (l != null)
                {
                    var info = l.Body.Unwrap();

                    if (l.Parameters.Count == 1 && pi.Expression != null)
                    {
                        info = info.Transform(wpi => wpi == l.Parameters[0] ? pi.Expression : wpi);
                    }

                    return(info.Find(e => PreferServerSide(e, enforceServerSide)) != null);
                }

                var attr = GetExpressionAttribute(pi.Member);
                return(attr != null && (attr.PreferServerSide || enforceServerSide) && !CanBeCompiled(expr));
            }

            case ExpressionType.Call:
            {
                var pi = (MethodCallExpression)expr;
                var l  = Expressions.ConvertMember(MappingSchema, pi.Object?.Type, pi.Method);

                if (l != null)
                {
                    return(l.Body.Unwrap().Find(e => PreferServerSide(e, enforceServerSide)) != null);
                }

                var attr = GetExpressionAttribute(pi.Method);
                return(attr != null && (attr.PreferServerSide || enforceServerSide) && !CanBeCompiled(expr));
            }

            default:
            {
                if (expr is BinaryExpression binary)
                {
                    var l = Expressions.ConvertBinary(MappingSchema, binary);
                    if (l != null)
                    {
                        var body    = l.Body.Unwrap();
                        var newExpr = body.Transform(wpi =>
                            {
                                if (wpi.NodeType == ExpressionType.Parameter)
                                {
                                    if (l.Parameters[0] == wpi)
                                    {
                                        return(binary.Left);
                                    }
                                    if (l.Parameters[1] == wpi)
                                    {
                                        return(binary.Right);
                                    }
                                }

                                return(wpi);
                            });

                        return(PreferServerSide(newExpr, enforceServerSide));
                    }
                }
                break;
            }
            }

            return(false);
        }
		public virtual void Visit(Expressions.VoidInitializer x)
		{
			
		}
Esempio n. 58
0
 public ImmutableArray <ExpressionSyntax> .Enumerator GetEnumerator()
 {
     return(Expressions.GetEnumerator());
 }
		public virtual void Visit(Expressions.StructInitializer x)
		{
			if (x.MemberInitializers != null)
				foreach (var i in x.MemberInitializers)
					i.Accept(this);
		}
Esempio n. 60
0
        private static void ProcessDamage(Event e, Expressions exp)
        {
            var line = new Line(e.ChatLogItem)
            {
                EventDirection = e.Direction,
                EventSubject   = e.Subject,
                EventType      = e.Type
            };

            LineHelper.SetTimelineTypes(ref line);
            if (LineHelper.IsIgnored(line))
            {
                return;
            }

            Match damage = Regex.Match("ph", @"^\.$");

            switch (e.Subject)
            {
            case EventSubject.You:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = You;
                        UpdateDamage(damage, line, exp, FilterType.You);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionYouIsAttack = true;
                            line.Source            = You;
                            UpdateDamage(damage, line, exp, FilterType.You);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Pet:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNamePet;
                        UpdateDamage(damage, line, exp, FilterType.Pet);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.Pet);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Party:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNamePartyFrom;
                        UpdateDamage(damage, line, exp, FilterType.Party);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPartyIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.Party);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetParty:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNamePetPartyFrom;
                        UpdateDamage(damage, line, exp, FilterType.PetParty);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetPartyIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.PetParty);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Alliance:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameAllianceFrom;
                        UpdateDamage(damage, line, exp, FilterType.Alliance);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionAllianceIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.Alliance);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetAlliance:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNamePetAllianceFrom;
                        UpdateDamage(damage, line, exp, FilterType.PetAlliance);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetAllianceIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.PetAlliance);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Other:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameOtherFrom;
                        UpdateDamage(damage, line, exp, FilterType.Other);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionOtherIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.Other);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.PetOther:
                switch (e.Direction)
                {
                case EventDirection.Engaged:
                case EventDirection.UnEngaged:
                    damage = exp.pDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNamePetOtherFrom;
                        UpdateDamage(damage, line, exp, FilterType.PetOther);
                        break;

                    case false:
                        damage = exp.pDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetOtherIsAttack = true;
                            UpdateDamage(damage, line, exp, FilterType.PetOther);
                        }

                        break;
                    }

                    break;
                }

                break;

            case EventSubject.Engaged:
            case EventSubject.UnEngaged:
                switch (e.Direction)
                {
                case EventDirection.You:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = You;
                        UpdateDamageMonster(damage, line, exp, FilterType.You);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionYouIsAttack = true;
                            line.Target            = You;
                            UpdateDamageMonster(damage, line, exp, FilterType.You);
                        }

                        break;
                    }

                    break;

                case EventDirection.Pet:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePet;
                        UpdateDamageMonster(damage, line, exp, FilterType.Pet);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.Pet);
                        }

                        break;
                    }

                    break;

                case EventDirection.Party:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePartyTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.Party);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPartyIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.Party);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetParty:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetPartyTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.PetParty);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetPartyIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.PetParty);
                        }

                        break;
                    }

                    break;

                case EventDirection.Alliance:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNameAllianceTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.Alliance);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionAllianceIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.Alliance);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetAlliance:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetAllianceTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.PetAlliance);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetAllianceIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.PetAlliance);
                        }

                        break;
                    }

                    break;

                case EventDirection.Other:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNameOtherTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.Other);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionOtherIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.Other);
                        }

                        break;
                    }

                    break;

                case EventDirection.PetOther:
                    damage = exp.mDamage;
                    switch (damage.Success)
                    {
                    case true:
                        line.Source = _lastNameMonster;
                        line.Target = _lastNamePetOtherTo;
                        UpdateDamageMonster(damage, line, exp, FilterType.PetOther);
                        break;

                    case false:
                        damage = exp.mDamageAuto;
                        if (damage.Success)
                        {
                            _lastActionPetOtherIsAttack = true;
                            UpdateDamageMonster(damage, line, exp, FilterType.PetOther);
                        }

                        break;
                    }

                    break;
                }

                break;
            }

            if (damage.Success)
            {
                return;
            }

            ParsingLogHelper.Log(Logger, "Damage", e, exp);
        }