示例#1
0
        internal static T GetField <T>(t_field_type accessor, string fieldName, int field_name_idx)
        {
            uint member_id;

            int field_divider_idx = fieldName.IndexOf('.', field_name_idx);

            if (-1 != field_divider_idx)
            {
                string member_name_string = fieldName.Substring(field_name_idx, field_divider_idx - field_name_idx);
                if (!FieldLookupTable_t_field_name.TryGetValue(member_name_string, out member_id))
                {
                    Throw.undefined_field();
                }
                switch (member_id)
                {
                /*FOREACH*/
                /*USE_LIST("t_member")*/
                /*  IF("$t_member_type->is_struct()")*/
                case t_uint:
                    return(GenericFieldAccessor.GetField <T>(accessor.t_member_name, fieldName, field_divider_idx + 1));

                /*  END*/
                /*END*/
                default:
                    // @note   We cannot go further unless it's a struct.
                    //         Throw exception now.
                    Throw.member_access_on_non_struct__field(member_name_string);
                    break;
                }
            }

            fieldName = fieldName.Substring(field_name_idx);
            if (!FieldLookupTable_t_field_name.TryGetValue(fieldName, out member_id))
            {
                Throw.undefined_field();
            }
            switch (member_id)
            {
            /*FOREACH*/
            /*USE_LIST("t_member")*/
            case t_uint:
                return(TypeConverter <T> .ConvertFrom_t_field_type_2_display(accessor.t_member_name));

                break;
                /*END*/
            }

            /* Should not reach here */
            throw new Exception("Internal error T5008");
        }