protected void ImplementRelationSetter(String propertyName, MethodInstance m_set_template, FieldInstance f_initialized, FieldInstance f_objRefs)
        {
            // public void setPropertyName(String propertyName)
            // {
            // PropertyName$initialized = true;
            // PropertyName$objRefs = null;
            // super.setPropertyName(propertyName);
            // }
            MethodInstance m_set;
            {
                IMethodVisitor mg = base.VisitMethod(m_set_template);
                m_set = mg.Method;
                mg.PutThisField(f_initialized, delegate(IMethodVisitor mv2)
                {
                    mg.PushEnum(ValueHolderState.INIT);
                });
                mg.PutThisField(f_objRefs, delegate(IMethodVisitor mv2)
                {
                    mv2.PushNull();
                });
                mg.LoadThis();
                mg.LoadArgs();
                mg.InvokeSuperOfCurrentMethod();
                mg.ReturnVoidOrThis();
                mg.EndMethod();
            }

            // public void setPropertyName$NoInit(String propertyName)
            // {
            // super.setPropertyName(propertyName);
            // }
            {
                String         noInitSetMethodName = ValueHolderIEC.GetSetterNameOfRelationPropertyWithNoInit(propertyName);
                IMethodVisitor mv = base.VisitMethod(m_set.Access, noInitSetMethodName, m_set.ReturnType, m_set.Parameters);
                mv.LoadThis();
                mv.LoadArgs();
                mv.InvokeSuper(m_set);
                mv.ReturnVoidOrThis();
                mv.EndMethod();
            }
        }
Exemple #2
0
            public PropertyEntry(Type type, String propertyName)
            {
                this.propertyName = propertyName;
                LinkedHashSet <String> propertyNames = new LinkedHashSet <String>();

                propertyNames.Add(propertyName);
                PropertyInfo prop = type.GetProperty(propertyName);

                doesModifyToBeUpdated        = !AnnotationUtil.IsAnnotationPresent <IgnoreToBeUpdated>(prop, false);
                isParentChildSetter          = AnnotationUtil.IsAnnotationPresent <ParentChild>(prop, false);
                isAddedRemovedCheckNecessary = !prop.PropertyType.IsPrimitive && ImmutableTypeSet.GetUnwrappedType(prop.PropertyType) == null &&
                                               !typeof(String).Equals(prop.PropertyType) && !prop.PropertyType.IsValueType;

                EvaluateDependentProperties(type, prop, propertyNames);

                while (true)
                {
                    int startCount = propertyNames.Count;

                    foreach (String currPropertyName in new List <String>(propertyNames))
                    {
                        PropertyInfo currProp = type.GetProperty(currPropertyName);
                        if (currProp.CanWrite)
                        {
                            continue;
                        }
                        // Is is just an evaluating property which has to be re-evaluated because of the change on the current property
                        EvaluateDependentProperties(type, currProp, propertyNames);
                    }
                    if (startCount == propertyNames.Count)
                    {
                        break;
                    }
                }
                this.propertyNames = propertyNames.ToArray();
                bool firesToBeCreatedPCE = false;

                unknownValues = CreateArrayOfValues(UNKNOWN_VALUE, this.propertyNames.Length);
                pceArgs       = new PropertyChangedEventArgs[propertyNames.Count];
                int index = 0;

                foreach (String invokedPropertyName in propertyNames)
                {
                    pceArgs[index] = new PropertyChangedEventArgs(invokedPropertyName);
                    index++;
                    firesToBeCreatedPCE |= "ToBeCreated".Equals(invokedPropertyName);
                }
                this.firesToBeCreatedPCE = firesToBeCreatedPCE;
                if (prop.CanRead)
                {
                    getDelegate = TypeUtility.GetMemberGetDelegate(type, ValueHolderIEC.GetGetterNameOfRelationPropertyWithNoInit(prop.Name), true);
                    if (getDelegate == null)
                    {
                        getDelegate = TypeUtility.GetMemberGetDelegate(type, prop.Name);
                    }
                }
                if (prop.CanWrite)
                {
                    setDelegate = TypeUtility.GetMemberSetDelegate(type, ValueHolderIEC.GetSetterNameOfRelationPropertyWithNoInit(prop.Name), true);
                    if (setDelegate == null)
                    {
                        setDelegate = TypeUtility.GetMemberSetDelegate(type, prop.Name);
                    }
                }
            }