示例#1
0
 private static IWithParameters GetDeclaration(ScopeResolveResult resolveResult, IElement parent)
 {
     IWithParameters declaration = null;
       if (resolveResult != null)
       {
     ReferenceDeclarationMapping mapping = resolveResult.GetReferenceDeclarationMapping();
     if (mapping != null)
     {
       declaration = mapping[parent] as IWithParameters;
       if (declaration == null)
     declaration = parent.GetDeclaration(false) as IWithParameters;
     }
       }
       else
     declaration = parent.GetDeclaration(false) as IWithParameters;
       return declaration;
 }
示例#2
0
        private static bool ComponentsInstancePassedIntoConstructor(ScopeResolveResult resolveResult, IElement parent)
        {
            IAssignmentStatement assignment = parent as IAssignmentStatement;
              if (assignment == null)
            return false;

              IObjectCreationExpression objectCreationExp = assignment.Expression as IObjectCreationExpression;
              if (objectCreationExp == null)
            return false;

              if (objectCreationExp.Arguments.Count != 1)
            return false;

              IElementReferenceExpression referenceExp = objectCreationExp.Arguments[0] as IElementReferenceExpression;
              if (referenceExp == null)
            return false;

              if (referenceExp.Name != "components")
            return false;

              if (resolveResult != null)
              {
            ReferenceDeclarationMapping mapping = resolveResult.GetReferenceDeclarationMapping();
            if (mapping != null)
            {
              IHasType declaration = mapping[referenceExp] as IHasType;
              if (declaration != null && declaration.Type != null)
              {
            IElement typeDeclaration = mapping[declaration.Type];
            if (typeDeclaration != null)
              return typeDeclaration.FullName == "System.ComponentModel.IContainer";
              }
            }
              }

              // NOTE: true by default, assuming that components is the corrent reference...
              return true;
        }