/// <summary> /// Initializes the contents of the expression. /// </summary> private void Initialize() { this.target.Value = null; Expression firstExpression = this.FindFirstChildExpression(); if (firstExpression == null) { throw new SyntaxException(this.Document, this.LineNumber); } if (firstExpression.ExpressionType == ExpressionType.Literal) { AttributeColonToken colon = firstExpression.FindNextSibling <AttributeColonToken>(); if (colon != null) { this.target.Value = (LiteralExpression)firstExpression; } } if (this.target.Value == null) { this.initialization.Value = firstExpression; } else { this.initialization.Value = firstExpression.FindNextSiblingExpression(); if (this.initialization.Value == null) { throw new SyntaxException(this.Document, this.LineNumber); } } }
/// <summary> /// Initializes the contents of the expression. /// </summary> private void Initialize() { Expression firstExpression = this.FindFirstChildExpression(); if (firstExpression == null || (firstExpression.ExpressionType != ExpressionType.Literal && firstExpression.ExpressionType != ExpressionType.MemberAccess && firstExpression.ExpressionType != ExpressionType.QualifiedAlias && firstExpression.ExpressionType != ExpressionType.MethodInvocation)) { throw new SyntaxException(this.Document, this.LineNumber); } this.typeCreationExpression.Value = firstExpression; Expression nextExpression = firstExpression.FindNextSiblingExpression(); if (nextExpression != null && (nextExpression.ExpressionType == ExpressionType.ObjectInitializer || nextExpression.ExpressionType == ExpressionType.CollectionInitializer)) { this.initializerExpression.Value = nextExpression; } else { this.initializerExpression.Value = null; } }