|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using bsn.GoldParser.Semantic;
using System.CodeDom;
namespace EntityMapper.Semantic
{
public class MemberAccess : Expression
{
private readonly Expression _entity;
private readonly Identifier _member;
private readonly Identifier _ownerId;
[Rule(@"<Member Access> ::= <SourceTarget> ~'.' Identifier")]
public MemberAccess(Expression entity, Identifier member)
{
_entity = entity;
_member = member;
}
[Rule(@"<Member Access> ::= Identifier ~'.' Identifier")]
public MemberAccess(Identifier ownerId, Identifier member)
{
_ownerId = ownerId;
_member = member;
}
[Rule(@"<Member Access> ::= <Value> ~'.' Identifier")]
public MemberAccess(ValueToken val, Identifier member)
{
_entity = val;
_member = member;
}
public override CodeExpression GetValue(ExecutionContext ctx)
{
if (_entity != null)
{
return new CodePropertyReferenceExpression(_entity.GetValue(ctx), _member.GetName(ctx));
}
else
{
// Type.Property
return new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(_ownerId.GetName(ctx)), _member.GetName(ctx));
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am always interested in finding innovative ways for building better applications and founded a technology company since 2003. Welcome to exchange any idea with you and if I am not too busy before deadline of projects, I will reply your emails. Also, if you willing to pay for consulting works and customized software development, you can leave me message.