static NonPublicFastObjectRW() { Initialize_Func = DynamicAssembly.BuildDynamicMethod <Action <object> >((dm, ilGen) => StaticFastObjectRW <T> .ImplInitialize(ilGen), typeof(T).Module, true); GetOrdinal_String_Func = DynamicAssembly.BuildDynamicMethod <Func <object, string, int> >((dm, ilGen) => StaticFastObjectRW <T> .ImplGetOrdinal <string>(ilGen), typeof(T).Module, true); GetOrdinal_UTF16_Func = DynamicAssembly.BuildDynamicMethod <Func <object, Ps <char>, int> >((dm, ilGen) => StaticFastObjectRW <T> .ImplGetOrdinal <Ps <char> >(ilGen), typeof(T).Module, true); GetOrdinal_UTF8_Func = DynamicAssembly.BuildDynamicMethod <Func <object, Ps <Utf8Byte>, int> >((dm, ilGen) => StaticFastObjectRW <T> .ImplGetOrdinal <Ps <Utf8Byte> >(ilGen), typeof(T).Module, true); OnReadAll_String_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataWriter <string> > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadAll <string>(ilGen), typeof(T).Module, true); OnReadAll_UTF16_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataWriter <Ps <char> > > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadAll <Ps <char> >(ilGen), typeof(T).Module, true); OnReadAll_UTF8_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataWriter <Ps <Utf8Byte> > > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadAll <Ps <Utf8Byte> >(ilGen), typeof(T).Module, true); OnReadAll_INT32_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataWriter <int> > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadAll <int>(ilGen), typeof(T).Module, true); OnWriteAll_String_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataReader <string> > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteAll <string>(ilGen), typeof(T).Module, true); OnWriteAll_UTF16_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataReader <Ps <char> > > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteAll <Ps <char> >(ilGen), typeof(T).Module, true); OnWriteAll_UTF8_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataReader <Ps <Utf8Byte> > > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteAll <Ps <Utf8Byte> >(ilGen), typeof(T).Module, true); OnWriteAll_INT32_Func = DynamicAssembly.BuildDynamicMethod <Action <object, IDataReader <int> > >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteAll <int>(ilGen), typeof(T).Module, true); OnReadValue_String_Func = DynamicAssembly.BuildDynamicMethod <Action <object, string, IValueWriter> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadValue <string>(ilGen), typeof(T).Module, true); OnReadValue_UTF16_Func = DynamicAssembly.BuildDynamicMethod <Action <object, Ps <char>, IValueWriter> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadValue <Ps <char> >(ilGen), typeof(T).Module, true); OnReadValue_UTF8_Func = DynamicAssembly.BuildDynamicMethod <Action <object, Ps <Utf8Byte>, IValueWriter> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadValue <Ps <Utf8Byte> >(ilGen), typeof(T).Module, true); OnReadValue_Int32_Func = DynamicAssembly.BuildDynamicMethod <Action <object, int, IValueWriter> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnReadValue <int>(ilGen), typeof(T).Module, true); OnWriteValue_String_Func = DynamicAssembly.BuildDynamicMethod <Action <object, string, IValueReader> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteValue <string>(ilGen), typeof(T).Module, true); OnWriteValue_UTF16_Func = DynamicAssembly.BuildDynamicMethod <Action <object, Ps <char>, IValueReader> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteValue <Ps <char> >(ilGen), typeof(T).Module, true); OnWriteValue_UTF8_Func = DynamicAssembly.BuildDynamicMethod <Action <object, Ps <Utf8Byte>, IValueReader> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteValue <Ps <Utf8Byte> >(ilGen), typeof(T).Module, true); OnWriteValue_Int32_Func = DynamicAssembly.BuildDynamicMethod <Action <object, int, IValueReader> >((dm, ilGen) => StaticFastObjectRW <T> .ImplOnWriteValue <int>(ilGen), typeof(T).Module, true); }
public void OverrideTest() { var @delegate = DynamicAssembly.BuildDynamicMethod <Func <int, int, int> >((dynamicMethod, ilGenerator) => { ilGenerator.LoadArgument(0); ilGenerator.LoadArgument(1); ilGenerator.Multiply(); ilGenerator.Return(); }); Assert.AreEqual(12 * 18, @delegate(12, 18)); Override(MethodOf <int, int, int>(OverrideTestTest), @delegate.GetFunctionPointer()); Assert.AreEqual(@delegate(12, 18), OverrideTestTest(12, 18)); }