private void ProcessCtorInvocation()
 {
     V_3 = this.GetStatementsForInvocation(out V_1, out V_0, out V_2);
     if (V_3 == null)
     {
         return;
     }
     this.patternsContext = new CodePatternsContext(V_3);
     stackVariable10      = new ICodePattern[5];
     stackVariable10[0]   = new NullCoalescingPattern(this.patternsContext, this.methodContext);
     stackVariable10[1]   = new TernaryConditionPatternAgressive(this.patternsContext, this.typeSystem);
     stackVariable10[2]   = new ArrayInitialisationPattern(this.patternsContext, this.typeSystem);
     stackVariable10[3]   = new VariableInliningPatternAggressive(this.patternsContext, this.methodContext, this.context.get_Language().get_VariablesToNotInlineFinder());
     stackVariable10[4]   = new MultiAssignPattern(this.patternsContext, this.methodContext);
     V_4 = new List <ICodePattern>(stackVariable10);
     if (V_2)
     {
         V_4.Add(new InitializationPattern(this.patternsContext, this.context));
     }
     if (!this.ProcessStatementCollection(V_3, V_4))
     {
         return;
     }
     if (V_3.get_Item(0).get_CodeNodeType() != 5)
     {
         return;
     }
     V_5 = (V_3.get_Item(0) as ExpressionStatement).get_Expression() as MethodInvocationExpression;
     if (V_5.get_CodeNodeType() != 52 && V_5.get_CodeNodeType() != 53)
     {
         return;
     }
     this.methodContext.set_CtorInvokeExpression(V_5);
     return;
 }
Exemple #2
0
 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     this.context         = context;
     this.typeSystem      = context.MethodContext.Method.Module.TypeSystem;
     this.patternsContext = new CodePatternsContext(body);
     body = (BlockStatement)Visit(body);
     return(body);
 }
 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     this.context         = context;
     this.typeSystem      = context.get_MethodContext().get_Method().get_Module().get_TypeSystem();
     this.patternsContext = new CodePatternsContext(body);
     body = (BlockStatement)this.Visit(body);
     return(body);
 }
 private TernaryConditionPattern GetTernaryPattern(CodePatternsContext patternsContext)
 {
     if (!this.isAggressive && !this.isInFilter)
     {
         return(new TernaryConditionPattern(patternsContext, this.typeSystem));
     }
     return(new TernaryConditionPatternAgressive(patternsContext, this.typeSystem));
 }
 private VariableInliningPattern GetVariableInliningPattern(CodePatternsContext patternsContext)
 {
     if (!this.isAggressive)
     {
         return(new VariableInliningPattern(patternsContext, this.context.get_MethodContext(), this.context.get_Language().get_VariablesToNotInlineFinder()));
     }
     return(new VariableInliningPatternAggressive(patternsContext, this.context.get_MethodContext(), this.context.get_Language().get_VariablesToNotInlineFinder()));
 }
        public Country GetById(int id)
        {
            if (id == 0)
            {
                return(new Country());
            }

            using (var context = new CodePatternsContext())
            {
                var myTest = context.Countries.SingleOrDefault(c => c.Id == id);
                return(myTest);
            }
        }
Exemple #7
0
        public IEnumerable <Continent> Get()
        {
            using (var context = new CodePatternsContext())
            {
                var continents = new List <Continent>();

                foreach (var continent in context.Continents)
                {
                    continents.Add(new Continent
                    {
                        Id   = continent.Id,
                        Name = continent.Name
                    });
                }

                return(continents);
            }
        }
        public IEnumerable <Country> Get()
        {
            using (var context = new CodePatternsContext())
            {
                var countries = new List <Country>();

                foreach (var country in context.Countries)
                {
                    countries.Add(new Country
                    {
                        Id   = country.Id,
                        Name = country.Name
                    });
                }

                return(countries);
            }
        }
Exemple #9
0
        private void ProcessCtorInvocation()
        {
            int  startIndex, endIndex;
            bool isBaseCtor;
            StatementCollection statements = GetStatementsForInvocation(out endIndex, out startIndex, out isBaseCtor);

            if (statements == null)
            {
                return;
            }

            this.patternsContext = new CodePatternsContext(statements);

            List <ICodePattern> patternArray = new List <ICodePattern>(new ICodePattern[]
                                                                       { new NullCoalescingPattern(patternsContext, methodContext), new TernaryConditionPatternAgressive(patternsContext, typeSystem),
                                                                         new ArrayInitialisationPattern(patternsContext, typeSystem), new VariableInliningPatternAggressive(patternsContext, methodContext),
                                                                         new MultiAssignPattern(patternsContext, methodContext) });

            if (isBaseCtor)
            {
                patternArray.Add(new FieldInitializationPattern(patternsContext, context));
            }

            if (!ProcessStatementCollection(statements, patternArray))
            {
                return;
            }

            if (statements[0].CodeNodeType != CodeNodeType.ExpressionStatement)
            {
                return;
            }

            MethodInvocationExpression theCtorInvokeExpression = (statements[0] as ExpressionStatement).Expression as MethodInvocationExpression;

            if (theCtorInvokeExpression.CodeNodeType != CodeNodeType.BaseCtorExpression &&
                theCtorInvokeExpression.CodeNodeType != CodeNodeType.ThisCtorExpression)
            {
                return;
            }

            methodContext.CtorInvokeExpression = theCtorInvokeExpression;
        }
        public IEnumerable <Country> GetByContinent(int id)
        {
            if (id == 0)
            {
                return(this.Get());
            }

            using (var context = new CodePatternsContext())
            {
                var countries = new List <Country>();

                foreach (var country in context.Countries.Where(c => c.ContinentId == id))
                {
                    countries.Add(new Country
                    {
                        Id   = country.Id,
                        Name = country.Name
                    });
                }

                return(countries);
            }
        }
Exemple #11
0
 private TernaryConditionPattern GetTernaryPattern(CodePatternsContext patternsContext)
 {
     return(isAggressive || isInFilter ? new TernaryConditionPatternAgressive(patternsContext, typeSystem) : new TernaryConditionPattern(patternsContext, typeSystem));
 }
Exemple #12
0
 private VariableInliningPattern GetVariableInliningPattern(CodePatternsContext patternsContext)
 {
     return(isAggressive ? new VariableInliningPatternAggressive(patternsContext, context.MethodContext) : new VariableInliningPattern(patternsContext, context.MethodContext));
 }
 private VariableInliningPattern GetVariableInliningPattern(CodePatternsContext patternsContext)
 {
     return(isAggressive ? new VariableInliningPatternAggressive(patternsContext, context.MethodContext, this.context.Language.VariablesToNotInlineFinder) :
            new VariableInliningPattern(patternsContext, context.MethodContext, this.context.Language.VariablesToNotInlineFinder));
 }