コード例 #1
0
        public Expression Parse(CsExpression pStatement, FactoryExpressionCreator pCreator)
        {
            //embedded-type "." identifier
            CsPredefinedTypeMemberAccess ex = pStatement as CsPredefinedTypeMemberAccess;
            string name;
            bool   renamed = Helpers.GetRealName(ex, ex.identifier.identifier, out name);

            if (renamed)
            {
                return(new Expression(name, pStatement.entity_typeref));
            }

            CsEntityProperty p = ex.entity as CsEntityProperty;

            if (p != null)
            {
                //getter, rename
                name = "get_" + name + "()";
            }
            else if (ex.ec == expression_classification.ec_event_access)                //remove eventhandler name
            {
                name = string.Empty;
            }
            //FactoryExpressionCreator.Parse(ex.expression).Value
            return(new Expression(
                       "nose" + "." + name,
                       pStatement.entity_typeref
                       ));
        }
コード例 #2
0
        public static bool GetRealName(object pExpression, string pName, out string pRealName)
        {
            if (pExpression == null)
            {
                pRealName = pName;
                return(false);
            }

            CsEntityClass csEntityClass = pExpression as CsEntityClass;

            if (csEntityClass != null)
            {
                return(getRealName(csEntityClass.attributes, pName, out pRealName));
            }

            CsEntityEnum csEntityEnum = pExpression as CsEntityEnum;

            if (csEntityEnum != null)
            {
                return(getRealName(csEntityEnum.attributes, pName, out pRealName));
            }

            CsEntityStruct csEntityStruct = pExpression as CsEntityStruct;

            if (csEntityStruct != null)
            {
                return(getRealName(csEntityStruct.attributes, pName, out pRealName));
            }

            CsEntityInterface csEntityInterface = pExpression as CsEntityInterface;

            if (csEntityInterface != null)
            {
                return(getRealName(csEntityInterface.attributes, pName, out pRealName));
            }

            CsPrimaryExpressionMemberAccess csPrimaryExpressionMemberAccess = pExpression as CsPrimaryExpressionMemberAccess;

            if (csPrimaryExpressionMemberAccess != null)
            {
                return(GetRealName(csPrimaryExpressionMemberAccess.expression.entity, pName, out pRealName));
            }

            CsEntityLocalVariable csEntityLocalVariable = pExpression as CsEntityLocalVariable;

            if (csEntityLocalVariable != null)
            {
                CsLocalVariableDeclaration v = (csEntityLocalVariable.decl.parent) as CsLocalVariableDeclaration;
                if (v != null)
                {
                    GetRealName(v.type.entity_typeref.u, pName, out pRealName);
                    //get new name but do not replace expression, as this is a local accessor...
                    return(false);
                }
            }

            CsEntityVariable csEntityVariable = pExpression as CsEntityVariable;

            if (csEntityVariable != null)
            {
                return(GetRealName(csEntityVariable.type.u, pName, out pRealName));
            }

            CsEntityConstant csEntityConstant = pExpression as CsEntityConstant;

            if (csEntityConstant != null)
            {
                return(GetRealName(csEntityConstant.type.u, pName, out pRealName));
            }

            CsEntityMethod csEntityMethod = pExpression as CsEntityMethod;

            if (csEntityMethod != null)
            {
                return(GetRealName(csEntityMethod.parent, pName, out pRealName));
            }

            CsSimpleName csSimpleName = pExpression as CsSimpleName;

            if (csSimpleName != null)
            {
                return(GetRealName(csSimpleName.entity_typeref == null ? csSimpleName.entity : csSimpleName.entity_typeref.u,
                                   pName,
                                   out pRealName));
            }

            CsPredefinedTypeMemberAccess csPredefinedTypeMemberAccess = pExpression as CsPredefinedTypeMemberAccess;

            if (csPredefinedTypeMemberAccess != null)
            {
                return
                    (GetRealName(
                         csPredefinedTypeMemberAccess.entity_typeref == null
                                                        ? csPredefinedTypeMemberAccess.entity
                                                        : csPredefinedTypeMemberAccess.entity_typeref.u,
                         pName,
                         out pRealName));
            }

            CsEntityInstanceSpecifier csEntityInstanceSpecifier = pExpression as CsEntityInstanceSpecifier;

            if (csEntityInstanceSpecifier != null)
            {
                return(GetRealName(csEntityInstanceSpecifier.type.u, pName, out pRealName));
            }


            pRealName = pName;
            return(false);

            //CsEntityDelegate csEntityDelegate = pExpression as CsEntityDelegate;
            //if (csEntityDelegate != null) {
            //    pRealName = pName;
            //    return false;
            //}

            //throw new NotImplementedException();
        }