示例#1
0
 private void AddCastIfNeeded(Expression useExpression, VariableReference variable)
 {
     V_0          = new TypeInferer.u003cu003ec__DisplayClass8_0();
     V_0.variable = variable;
     V_4          = useExpression.get_CodeNodeType();
     if (V_4 == 19)
     {
         V_1 = useExpression as MethodInvocationExpression;
         V_2 = V_1.get_Arguments().FirstOrDefault <Expression>(new Func <Expression, bool>(V_0.u003cAddCastIfNeededu003eb__0));
         if (V_2 == null)
         {
             V_7 = V_1.get_MethodExpression().get_Target();
             if (V_7.get_CodeNodeType() != 26 || (object)(V_7 as VariableReferenceExpression).get_Variable() != (object)V_0.variable)
             {
                 this.AddCastIfNeeded(V_7, V_0.variable);
                 return;
             }
             V_8 = V_1.get_MethodExpression().get_Method().get_DeclaringType();
             if (!this.IsSubtype(V_8, V_0.variable.get_VariableType()))
             {
                 V_1.get_MethodExpression().set_Target(new ExplicitCastExpression(V_7, V_8, null));
                 return;
             }
         }
         else
         {
             V_5 = V_1.get_Arguments().IndexOf(V_2);
             V_6 = V_1.get_MethodExpression().get_Method().get_Parameters().get_Item(V_5).ResolveParameterType(V_1.get_MethodExpression().get_Method());
             if (!this.IsSubtype(V_6, V_0.variable.get_VariableType()))
             {
                 if (V_6.get_IsPrimitive() && V_0.variable.get_VariableType().get_IsPrimitive() && String.op_Equality(ExpressionTypeInferer.GetContainingType(V_6.Resolve(), V_0.variable.get_VariableType().Resolve()).get_FullName(), V_6.get_FullName()))
                 {
                     return;
                 }
                 V_1.get_Arguments().set_Item(V_5, new ExplicitCastExpression(V_2, V_6, null));
                 return;
             }
         }
     }
     else
     {
         if (V_4 != 24)
         {
             return;
         }
         V_3 = useExpression as BinaryExpression;
         if (V_3.get_Operator() == 26 && V_3.get_Right().get_CodeNodeType() == 26 && (object)(V_3.get_Right() as VariableReferenceExpression).get_Variable() == (object)V_0.variable)
         {
             V_9 = V_3.get_Left().get_ExpressionType();
             if (!this.IsSubtype(V_9, V_0.variable.get_VariableType()))
             {
                 V_3.set_Right(new ExplicitCastExpression(V_3.get_Right(), V_9, null));
             }
         }
     }
     return;
 }
 private LinqQueryExpression RemoveTransparentIdentifiers(LinqQueryExpression originalQuery)
 {
     V_0 = (LinqQueryExpression)originalQuery.Clone();
     V_1 = new List <VariableReference>();
     V_2 = new RebuildLinqQueriesStep.LinqQueriesRebuilder.TransparentIdentifierCleaner();
     V_3 = new HashSet <VariableReference>();
     V_4 = 0;
     while (V_4 < V_0.get_Clauses().get_Count())
     {
         V_0.get_Clauses().set_Item(V_4, (QueryClause)V_2.Visit(V_0.get_Clauses().get_Item(V_4)));
         V_5 = V_0.get_Clauses().get_Item(V_4);
         if (V_5.get_CodeNodeType() != 73)
         {
             if (V_5.get_CodeNodeType() != 78)
             {
                 if (V_5.get_CodeNodeType() != 74 || V_4 == V_0.get_Clauses().get_Count() - 1)
                 {
                     if (V_5.get_CodeNodeType() == 80)
                     {
                         V_1.Clear();
                         V_1.Add(((IntoClause)V_5).get_Identifier().get_Variable());
                     }
                 }
                 else
                 {
                     V_6 = ((IntoClause)V_0.get_Clauses().get_Item(V_4 + 1)).get_Identifier().get_Variable();
                     if (this.IsTransparentIdentifier(V_6))
                     {
                         V_7 = this.GetPropertyToValueMap((V_5 as SelectClause).get_Expression());
                         if (V_7 == null)
                         {
                             return(originalQuery);
                         }
                         if (V_1.get_Count() != 2)
                         {
                             if (V_1.get_Count() != 1)
                             {
                                 return(originalQuery);
                             }
                             V_8 = this.GenerateLetClause(V_7, V_1.get_Item(0));
                             if (V_8 == null)
                             {
                                 return(originalQuery);
                             }
                             V_0.get_Clauses().set_Item(V_4, V_8);
                             V_0.get_Clauses().RemoveAt(V_4 + 1);
                         }
                         else
                         {
                             if (!this.RemoveIdentifier(V_7, V_1))
                             {
                                 return(originalQuery);
                             }
                             V_0.get_Clauses().RemoveAt(V_4);
                             V_0.get_Clauses().RemoveAt(V_4);
                             V_4 = V_4 - 1;
                         }
                         dummyVar0 = this.methodContext.get_VariablesToRename().Add(V_6.Resolve());
                         dummyVar1 = V_3.Add(V_6);
                         V_1.Clear();
                         V_1.Add(V_6);
                         this.UpdateCleaner(V_2, V_6, V_7);
                     }
                 }
             }
             else
             {
                 if (V_0.get_Clauses().get_Item(V_4 + 1).get_CodeNodeType() == 80)
                 {
                     V_1.Add(((IntoClause)V_0.get_Clauses().get_Item(V_4 + 1)).get_Identifier().get_Variable());
                     V_4 = V_4 + 1;
                 }
                 else
                 {
                     V_1.Add(this.GetVariableReference((V_5 as JoinClause).get_InnerIdentifier()));
                 }
             }
         }
         else
         {
             V_1.Add(this.GetVariableReference((V_5 as FromClause).get_Identifier()));
         }
         V_4 = V_4 + 1;
     }
     if ((new RebuildLinqQueriesStep.LinqQueriesRebuilder.TransparentIdentifierFinder(V_3)).ContainsTransparentIdentifiers(V_0))
     {
         return(originalQuery);
     }
     return(V_0);
 }
示例#3
0
		private List<TypeDefinition> GetInheritanceChain(TypeDefinition targetType, string definingTypeFullName)
		{
			V_0 = new List<TypeDefinition>();
			V_1 = new List<int>();
			V_0.Add(targetType);
			V_1.Add(-1);
			V_2 = -1;
			V_4 = 0;
			while (V_4 < V_0.get_Count())
			{
				V_5 = V_0.get_Item(V_4);
				if (V_5 == null || String.op_Equality(V_5.get_FullName(), definingTypeFullName))
				{
					V_2 = V_4;
					break;
				}
				else
				{
					V_6 = V_5.get_BaseType();
					if (V_6 != null)
					{
						V_7 = V_6.Resolve();
						if (V_7 != null)
						{
							V_0.Add(V_7);
							V_1.Add(V_4);
						}
					}
					V_8 = V_5.get_Interfaces().GetEnumerator();
					try
					{
						while (V_8.MoveNext())
						{
							V_9 = V_8.get_Current();
							if (V_9 == null)
							{
								continue;
							}
							V_10 = V_9.Resolve();
							if (V_10 == null)
							{
								continue;
							}
							V_0.Add(V_10);
							V_1.Add(V_4);
						}
					}
					finally
					{
						V_8.Dispose();
					}
					V_4 = V_4 + 1;
				}
			}
			V_3 = new List<TypeDefinition>();
			while (V_2 != -1)
			{
				V_3.Add(V_0.get_Item(V_2));
				V_2 = V_1.get_Item(V_2);
			}
			return V_3;
		}