IExtensibleAdapter.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using ILRuntime.Other;
  4. using System;
  5. using System.Collections;
  6. using ILRuntime.Runtime.Enviorment;
  7. using ILRuntime.Runtime.Intepreter;
  8. using ILRuntime.CLR.Method;
  9. using ProtoBuf;
  10. namespace ProtoBuf
  11. {
  12. public sealed class IExtensibleAdapter : CrossBindingAdaptor
  13. {
  14. public override Type BaseCLRType
  15. {
  16. get
  17. {
  18. return typeof(IExtensible);
  19. }
  20. }
  21. public override Type AdaptorType
  22. {
  23. get
  24. {
  25. return typeof(Adaptor);
  26. }
  27. }
  28. public override object CreateCLRInstance(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance)
  29. {
  30. return new Adaptor(appdomain, instance);
  31. }
  32. internal class Adaptor : IExtensible, CrossBindingAdaptorType
  33. {
  34. ILTypeInstance instance;
  35. ILRuntime.Runtime.Enviorment.AppDomain appdomain;
  36. public Adaptor():base()
  37. {
  38. }
  39. public Adaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain, ILTypeInstance instance)
  40. {
  41. this.appdomain = appdomain;
  42. this.instance = instance;
  43. Init();
  44. }
  45. public ILTypeInstance ILInstance { get { return instance; } }
  46. public IExtension GetExtensionObject(bool createIfMissing)
  47. {
  48. return appdomain.Invoke(mMethoGetExObject, instance, createIfMissing) as IExtension;
  49. }
  50. IMethod mMethoGetExObject;
  51. void Init()
  52. {
  53. mMethoGetExObject = instance.Type.GetMethod("GetExtensionObject",0);
  54. }
  55. }
  56. }
  57. }