Ejemplo n.º 1
0
 public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name)
 {
     Debug.Assert(
         name.IsSimpleMemberAccessExpressionName() ||
         name.IsMemberBindingExpressionName() ||
         name.IsRightSideOfQualifiedName() ||
         name.IsParentKind(SyntaxKind.NameMemberCref)
         );
     if (name.IsSimpleMemberAccessExpressionName())
     {
         return(((MemberAccessExpressionSyntax)name.Parent).Expression);
     }
     else if (name.IsMemberBindingExpressionName())
     {
         return(name.GetParentConditionalAccessExpression().Expression);
     }
     else if (name.IsRightSideOfQualifiedName())
     {
         return(((QualifiedNameSyntax)name.Parent).Left);
     }
     else
     {
         return(((QualifiedCrefSyntax)name.Parent.Parent).Container);
     }
 }
Ejemplo n.º 2
0
 public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name)
 {
     Contract.Requires(name.IsMemberAccessExpressionName() || name.IsRightSideOfQualifiedName() || name.IsParentKind(SyntaxKind.NameMemberCref));
     if (name.IsMemberAccessExpressionName())
     {
         var conditionalAccess = name.GetParentConditionalAccessExpression();
         if (conditionalAccess != null)
         {
             return(conditionalAccess.Expression);
         }
         else
         {
             return(((MemberAccessExpressionSyntax)name.Parent).Expression);
         }
     }
     else if (name.IsRightSideOfQualifiedName())
     {
         return(((QualifiedNameSyntax)name.Parent).Left);
     }
     else
     {
         return(((QualifiedCrefSyntax)name.Parent.Parent).Container);
     }
 }