コード例 #1
0
        protected void ImplementValueHolderCode(PropertyInstance p_valueHolderContainerTemplate, PropertyInstance p_targetCache, PropertyInstance p_relationMembers)
        {
            RelationMember[] relationMembers = metaData.RelationMembers;
            NewType          owner           = State.NewType;

            for (int relationIndex = relationMembers.Length; relationIndex-- > 0;)
            {
                RelationMember relationMember = relationMembers[relationIndex];

                relationMember = (RelationMember)GetApplicableMember(relationMember);
                if (relationMember == null)
                {
                    // member is handled in another type
                    continue;
                }
                String           propertyName = relationMember.Name;
                IPropertyInfo    propertyInfo = propertyInfoProvider.GetProperty(relationMember.DeclaringType, propertyName);
                PropertyInstance prop         = PropertyInstance.FindByTemplate(propertyInfo, true);
                MethodInstance   m_get        = prop != null ? prop.Getter : new MethodInstance(((MethodPropertyInfo)propertyInfo).Getter);
                MethodInstance   m_set        = prop != null ? prop.Setter : new MethodInstance(((MethodPropertyInfo)propertyInfo).Setter);

                FieldInstance f_objRefs          = GetObjRefsFieldByPropertyName(propertyName);
                FieldInstance f_objRefs_existing = State.GetAlreadyImplementedField(f_objRefs.Name);

                FieldInstance f_initialized          = GetInitializedFieldByPropertyName(propertyName);
                FieldInstance f_initialized_existing = State.GetAlreadyImplementedField(f_initialized.Name);

                if (f_objRefs_existing == null)
                {
                    f_objRefs_existing = ImplementField(f_objRefs);
                    ImplementGetter(new MethodInstance(null, MethodAttributes.Public, f_objRefs_existing.Type, "get_" + f_objRefs_existing.Name),
                                    f_objRefs_existing);
                    ImplementSetter(
                        new MethodInstance(null, MethodAttributes.Public, NewType.VOID_TYPE, "set_" + f_objRefs_existing.Name, f_objRefs_existing.Type),
                        f_objRefs_existing);
                }
                if (f_initialized_existing == null)
                {
                    f_initialized_existing = ImplementField(f_initialized);
                    ImplementGetter(new MethodInstance(null, MethodAttributes.Public, f_initialized_existing.Type, "get_" + f_initialized_existing.Name),
                                    f_initialized_existing);
                    ImplementSetter(new MethodInstance(null, MethodAttributes.Public, NewType.VOID_TYPE, "set_" + f_initialized_existing.Name, f_initialized_existing.Type), f_initialized_existing);
                }

                ImplementRelationGetter(propertyName, m_get, m_set, relationIndex, p_valueHolderContainerTemplate, p_targetCache, p_relationMembers, f_initialized_existing, f_objRefs_existing);
                ImplementRelationSetter(propertyName, m_set, f_initialized_existing, f_objRefs_existing);
            }
        }
コード例 #2
0
ファイル: MemberTypeProvider.cs プロジェクト: vogelb/ambeth
        public static IPropertyInfo[] BuildPropertyPath(Type entityType, String memberName, IPropertyInfoProvider propertyInfoProvider)
        {
            String[] memberPath = EmbeddedMember.Split(memberName);
            Type     currType   = entityType;

            IPropertyInfo[] propertyPath = new IPropertyInfo[memberPath.Length];
            for (int a = 0, size = propertyPath.Length; a < size; a++)
            {
                IPropertyInfo property = propertyInfoProvider.GetProperty(currType, memberPath[a]);
                if (property == null)
                {
                    FieldInfo[] fields = ReflectUtil.GetDeclaredFieldInHierarchy(currType, memberPath[a]);
                    if (fields.Length == 0)
                    {
                        throw new Exception("Path illegal: " + memberName);
                    }
                    property = new FieldPropertyInfo(currType, memberPath[a], fields[a]);
                }
                propertyPath[a] = property;
                currType        = property.PropertyType;
            }
            return(propertyPath);
        }
コード例 #3
0
 public Object Invoke(string fieldName, Type enhancedType)
 {
     return(propertyInfoProvider.GetProperty(enhancedType, propertyName));
 }