Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class ModifiableTouchLocationState {
- delegate void SetFieldDelegate<FieldType>(
- object touchLocationState, FieldType value
- );
- /// <summary>Initializes the static members of the class</summary>
- static ModifiableTouchLocationState() {
- touchLocationStateType = typeof(TouchCollection).Assembly.GetType(
- "Microsoft.Xna.Framework.Input.Touch.XNAINPUT_TOUCH_LOCATION_STATE"
- );
- BindingFlags publicField = BindingFlags.Instance | BindingFlags.Public;
- FieldInfo countField = touchLocationStateType.GetField("Count", publicField);
- FieldInfo id0Field = touchLocationStateType.GetField("Id0", publicField);
- FieldInfo id1Field = touchLocationStateType.GetField("Id1", publicField);
- FieldInfo id2Field = touchLocationStateType.GetField("Id2", publicField);
- FieldInfo id3Field = touchLocationStateType.GetField("Id3", publicField);
- FieldInfo x0Field = touchLocationStateType.GetField("X0", publicField);
- FieldInfo y0Field = touchLocationStateType.GetField("Y0", publicField);
- FieldInfo x1Field = touchLocationStateType.GetField("X1", publicField);
- FieldInfo y1Field = touchLocationStateType.GetField("Y1", publicField);
- FieldInfo x2Field = touchLocationStateType.GetField("X2", publicField);
- FieldInfo y2Field = touchLocationStateType.GetField("Y2", publicField);
- FieldInfo x3Field = touchLocationStateType.GetField("X3", publicField);
- FieldInfo y3Field = touchLocationStateType.GetField("Y3", publicField);
- var dynamicMethod = new DynamicMethod(
- "SetCount", null, new Type[] { typeof(int) }
- );
- ILGenerator ilGenerator = dynamicMethod.GetILGenerator();
- ilGenerator.Emit(OpCodes.Ldarg_0);
- ilGenerator.Emit(OpCodes.Stfld, countField);
- ilGenerator.Emit(OpCodes.Ret);
- //setfielddelegate<int>
- //delegate test = dynamicmethod.createdelegate(typeof(setfielddelegate<int>));
- }
- public ModifiableTouchLocationState() {
- this.boxedState = Activator.CreateInstance(touchLocationStateType);
- }
- private static Type touchLocationStateType;
- //private static ConstructorInfo constructor;
- //private static FieldInfo countField;
- private object boxedState;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement