예제 #1
0
 private static DynamicTypeInfo EmitConcreteInstanceSupport <T>(
     this DynamicTypeInfo that)
 {
     that
     .WithField("__concreteinstance", typeof(T))
     .WithMethod("__SetConcreteInstance")
     .WithParameter(typeof(T))
     .Returns(typeof(void))
     .Ldarg(0)
     .Ldarg(1)
     .Stfld("__concreteinstance")
     .Ret();
     return(that);
 }
예제 #2
0
        private static DynamicTypeInfo EmitProxyMonitorSupport(
            this DynamicTypeInfo that,
            bool condition
            )
        {
            if (!condition)
            {
                return(that);
            }

            that
            .WithField("__proxymonitor", typeof(IProxyMonitor))
            .WithMethod("__SetProxyMonitor")
            .WithParameter(typeof(IProxyMonitor))
            .Returns(typeof(void))
            .Ldarg(0)
            .Ldarg(1)
            .Stfld("__proxymonitor")
            .Ret();

            return(that);
        }
예제 #3
0
        public void Emit(
            string propertyName,
            Type propertyType
            )
        {
            var fieldName = $"_{Guid.NewGuid()}";

            _dynamicTypeInfoField
            .WithField(fieldName, propertyType)
            .WithProperty(
                propertyName,
                propertyType,
                mget => mget
                .Ldarg(0)                 // this;
                .Ldfld(fieldName)
                .Ret(),
                mset => mset
                .Ldarg(0)                 // this;
                .Ldarg("value")
                .Stfld(fieldName)
                .Ret()
                );
        }
예제 #4
0
        public void Emit(
            string propertyName,
            Type propertyType
            )
        {
            string fieldName = string.Format("_{0}", Guid.NewGuid());

            dynamicTypeInfoField
            .WithField(fieldName, propertyType)
            .WithProperty(
                propertyName,
                propertyType,
                mget => mget
                .Ldarg(0)                 // this;
                .Ldfld(fieldName)
                .Ret(),
                mset => mset
                .Ldarg(0)                 // this;
                .Ldarg("value")
                .Stfld(fieldName)
                .Ret()
                );
        }