Example #1
0
        private PropertyDefinition GenerateProperty(PropertyDefinition property)
        {
            const MethodAttributes attr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName |
                                          MethodAttributes.NewSlot | MethodAttributes.Virtual | MethodAttributes.Final;

            var p = TypeFactory.CreateProperty(property.Name, attr, property.PropertyType, _handler);

            var getter = new IlBuilder(p.GetMethod.Body);

            getter.DeclareLocal(property.PropertyType);
            getter.LoadArg(0);
            getter.LoadField(_result.Fields[0]);
            getter.Call(_model.Properties[_startIndex].GetMethod);
            getter.SetLoc(0);
            var i = getter.Processor.Create(OpCodes.Ldloc_0);

            getter.Br_S(i);
            getter.Instructions.Add(i);
            getter.Return();
            getter.Append();

            var setter = new IlBuilder(p.SetMethod.Body);

            setter.LoadArg(0);
            setter.LoadField(_result.Fields[0]);
            setter.LoadArg(1);
            setter.Call(_model.Properties[_startIndex].SetMethod);
            setter.Return();
            setter.Append();

            _startIndex++;
            return(p);
        }
Example #2
0
        private void ProcessPropertySetHasOneBelongsToLazyLoad(IlBuilder processor)
        {
            processor.LoadArg(0);
            processor.LoadField(_pi.FieldDefinition);
            processor.LoadArg(1);
            var sv       = _pi.FieldDefinition.FieldType.GetMethod("set_Value");
            var setValue = _handler.Import(sv);

            processor.CallVirtual(setValue);
            processor.Return();
            processor.Append();
        }
Example #3
0
        private void ProcessPropertySetNormalCompareString(IlBuilder processor)
        {
            processor.DeclareLocal(_handler.BoolType);
            processor.LoadArg(1);
            processor.LoadArg(0);
            processor.LoadField(_pi.FieldDefinition);
            var mi = _handler.TypeDict[_pi.PropertyDefinition.PropertyType.FullName];

            processor.Call(mi);
            processor.LoadInt(0);
            processor.Ceq();
            processor.SetLoc(0);
            processor.LoadLoc(0);
            processor.BrTrue_S(_pi.PropertyDefinition.SetMethod.Body.Instructions.LastItem());
        }