Adapt_IMessage.cs 1.5 KB

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