public void Invalid_Untyped_Expression_Returns_False()
        {
            var actual = ExpressionExt.TryGetMemberInfo <TestClass>(c => "string", out var member);

            Assert.IsFalse(actual);
            Assert.IsNull(member);
        }
        public void Valid_Untyped_Unary_Field_Expressions_Return_Expected_Values()
        {
            var actual = ExpressionExt.TryGetMemberInfo <TestClass>(c => (string)c.Field, out var member);

            Assert.IsTrue(actual);
            Assert.AreEqual(TestClass.FieldInfo, member);
        }
        public void Valid_Untyped_Property_Expressions_Return_Expected_Values()
        {
            var actual = ExpressionExt.TryGetMemberInfo <TestClass>(c => c.Property, out var member);

            Assert.IsTrue(actual);
            Assert.AreEqual(TestClass.PropertyInfo, member);
        }
示例#4
0
        public void Valid_Untyped_Property_Expressions_Returns_Null()
        {
            var actual = ExpressionExt.TryGetFieldInfo <TestClass>(c => c.Property, out var member);

            Assert.IsFalse(actual);
            Assert.IsNull(member);
        }
        public void Method_Expression_Returns_Null()
        {
            var actual = ExpressionExt.TryGetMemberInfo <TestClass>(c => c.Method(), out var member);

            Assert.IsFalse(actual);
            Assert.IsNull(member);
        }
示例#6
0
        public List <StudentEval> GetPageData(SearchModel <StudentEval> search, out int count)
        {
            GetPageListParameter <StudentEval, string> parameter = new GetPageListParameter <StudentEval, string>();

            parameter.isAsc         = true;
            parameter.orderByLambda = t => t.StudentNo;
            parameter.pageIndex     = search.PageIndex;
            parameter.pageSize      = search.PageSize;
            parameter.whereLambda   = t => !string.IsNullOrEmpty(t.StudentNo);
            //查询数据
            if (!string.IsNullOrEmpty(search.Entity.PEM))
            {
                Expression <Func <StudentEval, bool> > Where = item => item.PEM == search.Entity.PEM;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <StudentEval>(parameter.whereLambda, Where);
            }

            if (!string.IsNullOrEmpty(search.Entity.PRM))
            {
                Expression <Func <StudentEval, bool> > Where = item => item.PRM == search.Entity.PRM;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <StudentEval>(parameter.whereLambda, Where);
            }
            DBBaseService      baseService = new DBBaseService(SurveyContext.Instance);
            List <StudentEval> list        = baseService.GetSimplePagedData <StudentEval, string>(parameter, out count);

            return(list);
        }
        public void Valid_Untyped_Unary_Field_Expressions_Returns_Null()
        {
            var actual = ExpressionExt.TryGetPropertyInfo <TestClass>(c => (string)c.Field, out var member);

            Assert.IsFalse(actual);
            Assert.IsNull(member);
        }
示例#8
0
        /// <summary>
        /// 分页查询,代码
        /// </summary>
        /// <param name="search"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <SurveyModel> GetPageData(SearchModel <SurveyModel> search, out int count)
        {
            GetPageListParameter <SurveyModel, int> parameter = new GetPageListParameter <SurveyModel, int>();

            parameter.isAsc         = true;
            parameter.orderByLambda = t => t.SurveyID;
            parameter.pageIndex     = search.PageIndex;
            parameter.pageSize      = search.PageSize;
            if (search.RoleName == "学生" || search.RoleName == "项目组组长" || search.RoleName == "技术主管" || search.RoleName == "项目主管" || search.RoleName == "人事主管")
            {
                Expression <Func <SurveyModel, bool> > lambda0 = item => item.Status != 1;
                Expression <Func <SurveyModel, bool> > lambda1 = item => item.StuName == search.UserName;
                //合并表达式
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(lambda0, lambda1);
            }
            else if (search.RoleName == "人事经理")
            {
                Expression <Func <SurveyModel, bool> > lambda0 = item => item.Status != 1;
                Expression <Func <SurveyModel, bool> > lambda1 = item => item.PEM == search.UserName && (item.AuditName == item.PEM || string.IsNullOrEmpty(item.AuditName) || item.AuditStatus == 3);
                //合并表达式
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(lambda0, lambda1);
            }
            else if (search.RoleName == "项目经理")
            {
                Expression <Func <SurveyModel, bool> > lambda0 = item => item.Status != 1;
                Expression <Func <SurveyModel, bool> > lambda1 = item => item.PRM == search.UserName;
                //合并表达式
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(lambda0, lambda1);
            }
            else
            {
                Expression <Func <SurveyModel, bool> > lambda0 = item => item.Status != 1;
                Expression <Func <SurveyModel, bool> > lambda1 = item => item.AuditName == search.UserName || item.AuditStatus == 3;
                //合并表达式
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(lambda0, lambda1);
            }
            if (!string.IsNullOrEmpty(search.Entity.Batch))
            {
                Expression <Func <SurveyModel, bool> > batchWhere = item => item.Batch == search.Entity.Batch;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(parameter.whereLambda, batchWhere);
            }
            if (!string.IsNullOrEmpty(search.Entity.ProjectName))
            {
                Expression <Func <SurveyModel, bool> > projectNameWhere = item => item.ProjectName == search.Entity.ProjectName;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(parameter.whereLambda, projectNameWhere);
            }
            if (!string.IsNullOrEmpty(search.Entity.Direction))
            {
                Expression <Func <SurveyModel, bool> > directionWhere = item => item.Direction == search.Entity.Direction;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SurveyModel>(parameter.whereLambda, directionWhere);
            }
            //查询数据
            DBBaseService      baseService = new DBBaseService(SurveyContext.Instance);
            List <SurveyModel> list        = baseService.GetSimplePagedData <SurveyModel, int>(parameter, out count);

            return(list);
        }
示例#9
0
 private static void Sample5()
 {
     IDictionary <string, string> dictionary = ExpressionExt.ToDictionary(Name => "Arek",
                                                                          Age => "23",
                                                                          LastCheck => DateTime.Now.ToShortDateString());
     var dictionaryName = dictionary["Name"];  //
     var anonPerson     =
         dictionary.ToAnonymousType(
             new
     {
         Name      = default(string),
         Age       = default(int),
         LastCheck = default(DateTime)
     });         //Anonymous Type
 }
示例#10
0
        private static ILineObject GenerateNormalSkill(PlayerExporter exporter, bool isFirst, NormalSkill skill, string name)
        {
            var u         = ThisExpr.Instance.MakeIndex("u");
            var condition = ExpressionExt.AndAll(
                KeyCondition(skill.Key),
                CancelLevelCondition(skill.CancelLevel),
                AirCondition(skill.AirState),
                XCondition(skill.X),
                YCondition(skill.Y),
                MagicCondition(skill.MagicUse),
                RushCondition(exporter, skill));

            return(new ControlBlock(isFirst ? ControlBlockType.If : ControlBlockType.ElseIf,
                                    condition, new ILineObject[] {
                u.MakeIndex("InputReset").MakeIndex("call").Call(ThisExpr.Instance).Statement(),
                u.MakeIndex(name).MakeIndex("call").Call(ThisExpr.Instance).Statement(),
            }).Statement());
        }
示例#11
0
 private static Expression RushCondition(PlayerExporter exporter, NormalSkill skill)
 {
     if (skill.IsRushSkill)
     {
         var skillActionID = skill.ActionID;
         var indexes       = exporter.Skills
                             .Where(s => s is NormalSkill)
                             .Select(s => (NormalSkill)s)
                             .Where(s => s.RushCancel == skillActionID)
                             .Select(s =>
                                     new BiOpExpr(ThisExpr.Instance.MakeIndex("motion"),
                                                  new BiOpExpr(ThisExpr.Instance.MakeIndex("u").MakeIndex("CA"),
                                                               new ConstNumberExpr(exporter.GetActionID(s.ActionID)), BiOpExpr.Op.Add),
                                                  BiOpExpr.Op.Equal))
                             .ToArray();
         return(ExpressionExt.OrAll(indexes));
     }
     return(new ConstNumberExpr(1));
 }
示例#12
0
        public object GetPageData(SearchModel <SkillTag> search, out int count)
        {
            GetPageListParameter <SkillTag, string> parameter = new GetPageListParameter <SkillTag, string>();

            parameter.isAsc         = true;
            parameter.orderByLambda = t => t.TagID;
            parameter.pageIndex     = search.PageIndex;
            parameter.pageSize      = search.PageSize;
            parameter.whereLambda   = t => t.TagID != "";
            if (!string.IsNullOrEmpty(search.Entity.Direction))
            {
                Expression <Func <SkillTag, bool> > Where = item => item.Direction == search.Entity.Direction;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SkillTag>(parameter.whereLambda, Where);
            }
            if (!string.IsNullOrEmpty(search.Entity.TagType))
            {
                Expression <Func <SkillTag, bool> > Where = item => item.TagType == search.Entity.TagType;
                parameter.whereLambda = ExpressionExt.ReBuildExpression <SkillTag>(parameter.whereLambda, Where);
            }
            DBBaseService   baseService = new DBBaseService(SurveyContext.Instance);
            List <SkillTag> list        = baseService.GetSimplePagedData <SkillTag, string>(parameter, out count);

            return(list);
        }
示例#13
0
 public override Expression Generate(GenerationEnvironment env)
 {
     return(ExpressionExt.AndAll(Filters.Select(f => f.Generate(env)).ToArray()));
 }