Adapt_IMessage.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using ETModel;
  3. using Google.Protobuf;
  4. using ILRuntime.Runtime.Enviorment;
  5. using ILRuntime.Runtime.Intepreter;
  6. using AppDomain = ILRuntime.Runtime.Enviorment.AppDomain;
  7. using IMessage = Google.Protobuf.IMessage;
  8. namespace Google.Protobuf
  9. {
  10. [ILAdapter]
  11. public class Adapt_IMessage: CrossBindingAdaptor
  12. {
  13. public override Type BaseCLRType
  14. {
  15. get
  16. {
  17. return typeof (IMessage);
  18. }
  19. }
  20. public override Type AdaptorType
  21. {
  22. get
  23. {
  24. return typeof (Adaptor);
  25. }
  26. }
  27. public override object CreateCLRInstance(AppDomain appdomain, ILTypeInstance instance)
  28. {
  29. return new Adaptor(appdomain, instance);
  30. }
  31. public class Adaptor: MyAdaptor, IMessage
  32. {
  33. public Adaptor(AppDomain appdomain, ILTypeInstance instance): base(appdomain, instance)
  34. {
  35. }
  36. protected override AdaptHelper.AdaptMethod[] GetAdaptMethods()
  37. {
  38. AdaptHelper.AdaptMethod[] methods =
  39. {
  40. new AdaptHelper.AdaptMethod { Name = "MergeFrom", ParamCount = 1 },
  41. new AdaptHelper.AdaptMethod { Name = "WriteTo", ParamCount = 1 },
  42. new AdaptHelper.AdaptMethod { Name = "CalculateSize", ParamCount = 0 },
  43. };
  44. return methods;
  45. }
  46. public void MergeFrom(CodedInputStream input)
  47. {
  48. Invoke(0, input);
  49. }
  50. public void WriteTo(CodedOutputStream output)
  51. {
  52. Invoke(1, output);
  53. }
  54. public int CalculateSize()
  55. {
  56. return (int) Invoke(2);
  57. }
  58. }
  59. }
  60. }