game_machine 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +72 -0
  4. data/Rakefile +38 -0
  5. data/bin/game_machine +79 -0
  6. data/config/cluster.conf +65 -0
  7. data/config/config.example.yml +93 -0
  8. data/config/game_messages.proto +45 -0
  9. data/config/messages.proto +339 -0
  10. data/config/regions.example.yml +9 -0
  11. data/config/standalone.conf +36 -0
  12. data/db/do_not_delete +0 -0
  13. data/game_machine.gemspec +38 -0
  14. data/games/example/boot.rb +6 -0
  15. data/games/example/data/game_data.yml +13 -0
  16. data/games/example/lib/aggressive_npc.rb +176 -0
  17. data/games/example/lib/authentication_handler.rb +69 -0
  18. data/games/example/lib/chatbot.rb +61 -0
  19. data/games/example/lib/combat_controller.rb +145 -0
  20. data/games/example/lib/example_controller.rb +21 -0
  21. data/games/example/lib/game.rb +85 -0
  22. data/games/example/lib/models/attack.rb +9 -0
  23. data/games/example/lib/models/combat_update.rb +11 -0
  24. data/games/example/lib/models/player_command.rb +7 -0
  25. data/games/example/lib/models/user.rb +11 -0
  26. data/games/example/lib/models/vitals.rb +17 -0
  27. data/games/example/lib/npc.rb +111 -0
  28. data/games/example/lib/npc_group.rb +42 -0
  29. data/games/example/lib/npc_movement.rb +116 -0
  30. data/games/example/lib/player_manager.rb +58 -0
  31. data/games/example/lib/player_register.rb +80 -0
  32. data/games/example/lib/tracking_handler.rb +17 -0
  33. data/games/example/lib/zone_manager.rb +57 -0
  34. data/games/preload.rb +8 -0
  35. data/integration_tests/basic_spec.rb +68 -0
  36. data/integration_tests/bot_spec.rb +18 -0
  37. data/integration_tests/chat_spec.rb +45 -0
  38. data/integration_tests/distributed_spec.rb +34 -0
  39. data/integration_tests/entity_tracking_spec.rb +48 -0
  40. data/integration_tests/mono_spec.rb +16 -0
  41. data/integration_tests/objectdb_spec.rb +55 -0
  42. data/integration_tests/tcp_client_spec.rb +71 -0
  43. data/integration_tests/udp_client_spec.rb +61 -0
  44. data/integration_tests/udp_spec.rb +20 -0
  45. data/integration_tests/udt_client_spec.rb +23 -0
  46. data/integration_tests/udt_spec.rb +31 -0
  47. data/java/.gitignore +1 -0
  48. data/java/build.gradle +93 -0
  49. data/java/component.erb +396 -0
  50. data/java/gradle.properties +6 -0
  51. data/java/gradle/wrapper/gradle-wrapper.jar +0 -0
  52. data/java/gradle/wrapper/gradle-wrapper.properties +6 -0
  53. data/java/gradlew +164 -0
  54. data/java/gradlew.bat +90 -0
  55. data/java/local_lib/protostuff-compiler-1.0.7-jarjar.jar +0 -0
  56. data/java/settings.gradle +2 -0
  57. data/java/src/main/java/com/game_machine/core/ActorFactory.java +25 -0
  58. data/java/src/main/java/com/game_machine/core/ActorUtil.java +39 -0
  59. data/java/src/main/java/com/game_machine/core/CommandProxy.java +9 -0
  60. data/java/src/main/java/com/game_machine/core/EntitySerializer.java +66 -0
  61. data/java/src/main/java/com/game_machine/core/EventStreamHandler.java +43 -0
  62. data/java/src/main/java/com/game_machine/core/GameMachineLoader.java +25 -0
  63. data/java/src/main/java/com/game_machine/core/Grid.java +195 -0
  64. data/java/src/main/java/com/game_machine/core/GridValue.java +30 -0
  65. data/java/src/main/java/com/game_machine/core/IActorFactory.java +7 -0
  66. data/java/src/main/java/com/game_machine/core/NetMessage.java +28 -0
  67. data/java/src/main/java/com/game_machine/core/UdpServer.java +97 -0
  68. data/java/src/main/java/com/game_machine/core/UdpServerHandler.java +90 -0
  69. data/java/src/main/resources/game_machine.java.stg +738 -0
  70. data/java/src/main/resources/logback.xml +14 -0
  71. data/java/src/main/resources/logging.properties +3 -0
  72. data/java/src/main/resources/protostuff.properties +7 -0
  73. data/lib/game_machine.rb +85 -0
  74. data/lib/game_machine/actor.rb +7 -0
  75. data/lib/game_machine/actor/base.rb +184 -0
  76. data/lib/game_machine/actor/builder.rb +108 -0
  77. data/lib/game_machine/actor/development.rb +31 -0
  78. data/lib/game_machine/actor/factory.rb +35 -0
  79. data/lib/game_machine/actor/mono_actor.rb +89 -0
  80. data/lib/game_machine/actor/ref.rb +81 -0
  81. data/lib/game_machine/actor/reloadable.rb +98 -0
  82. data/lib/game_machine/actor/system.rb +32 -0
  83. data/lib/game_machine/akka.rb +98 -0
  84. data/lib/game_machine/app_config.rb +49 -0
  85. data/lib/game_machine/application.rb +181 -0
  86. data/lib/game_machine/auth_handlers/base.rb +21 -0
  87. data/lib/game_machine/auth_handlers/public.rb +34 -0
  88. data/lib/game_machine/bot/chat.rb +66 -0
  89. data/lib/game_machine/bot/client.rb +54 -0
  90. data/lib/game_machine/client_manager.rb +204 -0
  91. data/lib/game_machine/clients.rb +4 -0
  92. data/lib/game_machine/clients/client.rb +45 -0
  93. data/lib/game_machine/clients/tcp_client.rb +25 -0
  94. data/lib/game_machine/clients/test_client.rb +151 -0
  95. data/lib/game_machine/clients/udp_client.rb +25 -0
  96. data/lib/game_machine/clients/udt_client.rb +34 -0
  97. data/lib/game_machine/cluster_monitor.rb +115 -0
  98. data/lib/game_machine/commands.rb +23 -0
  99. data/lib/game_machine/commands/base.rb +21 -0
  100. data/lib/game_machine/commands/chat_commands.rb +88 -0
  101. data/lib/game_machine/commands/datastore_commands.rb +60 -0
  102. data/lib/game_machine/commands/grid_commands.rb +35 -0
  103. data/lib/game_machine/commands/message_helper.rb +25 -0
  104. data/lib/game_machine/commands/misc_commands.rb +29 -0
  105. data/lib/game_machine/commands/navigation_commands.rb +24 -0
  106. data/lib/game_machine/commands/player_commands.rb +28 -0
  107. data/lib/game_machine/commands/proxy.rb +16 -0
  108. data/lib/game_machine/console.rb +3 -0
  109. data/lib/game_machine/console/build.rb +74 -0
  110. data/lib/game_machine/console/install.rb +92 -0
  111. data/lib/game_machine/console/server.rb +120 -0
  112. data/lib/game_machine/data_store.rb +52 -0
  113. data/lib/game_machine/data_stores/couchbase.rb +18 -0
  114. data/lib/game_machine/data_stores/mapdb.rb +49 -0
  115. data/lib/game_machine/data_stores/memory.rb +35 -0
  116. data/lib/game_machine/data_stores/redis.rb +46 -0
  117. data/lib/game_machine/endpoints.rb +6 -0
  118. data/lib/game_machine/endpoints/mono_gateway.rb +87 -0
  119. data/lib/game_machine/endpoints/tcp.rb +51 -0
  120. data/lib/game_machine/endpoints/tcp_handler.rb +75 -0
  121. data/lib/game_machine/endpoints/udp.rb +88 -0
  122. data/lib/game_machine/endpoints/udp_incoming.rb +113 -0
  123. data/lib/game_machine/endpoints/udp_outgoing.rb +46 -0
  124. data/lib/game_machine/game_loader.rb +46 -0
  125. data/lib/game_machine/game_systems.rb +14 -0
  126. data/lib/game_machine/game_systems/agents/controller.rb +118 -0
  127. data/lib/game_machine/game_systems/chat.rb +256 -0
  128. data/lib/game_machine/game_systems/chat_manager.rb +108 -0
  129. data/lib/game_machine/game_systems/chat_topic.rb +36 -0
  130. data/lib/game_machine/game_systems/devnull.rb +13 -0
  131. data/lib/game_machine/game_systems/entity_loader.rb +12 -0
  132. data/lib/game_machine/game_systems/entity_tracking.rb +133 -0
  133. data/lib/game_machine/game_systems/local_echo.rb +16 -0
  134. data/lib/game_machine/game_systems/objectdb_proxy.rb +61 -0
  135. data/lib/game_machine/game_systems/private_chat.rb +20 -0
  136. data/lib/game_machine/game_systems/region_manager.rb +91 -0
  137. data/lib/game_machine/game_systems/region_service.rb +94 -0
  138. data/lib/game_machine/game_systems/region_settings.rb +13 -0
  139. data/lib/game_machine/game_systems/remote_echo.rb +14 -0
  140. data/lib/game_machine/game_systems/stress_test.rb +21 -0
  141. data/lib/game_machine/grid.rb +60 -0
  142. data/lib/game_machine/grid_replicator.rb +31 -0
  143. data/lib/game_machine/handlers/authentication.rb +55 -0
  144. data/lib/game_machine/handlers/game.rb +63 -0
  145. data/lib/game_machine/handlers/request.rb +80 -0
  146. data/lib/game_machine/hashring.rb +48 -0
  147. data/lib/game_machine/helpers/game_message.rb +159 -0
  148. data/lib/game_machine/helpers/state_machine.rb +29 -0
  149. data/lib/game_machine/java_lib.rb +51 -0
  150. data/lib/game_machine/logger.rb +39 -0
  151. data/lib/game_machine/message_buffer.rb +58 -0
  152. data/lib/game_machine/message_queue.rb +63 -0
  153. data/lib/game_machine/model.rb +125 -0
  154. data/lib/game_machine/models.rb +3 -0
  155. data/lib/game_machine/models/player_status_update.rb +8 -0
  156. data/lib/game_machine/models/region.rb +9 -0
  157. data/lib/game_machine/mono_server.rb +20 -0
  158. data/lib/game_machine/navigation.rb +4 -0
  159. data/lib/game_machine/navigation/detour.rb +20 -0
  160. data/lib/game_machine/navigation/detour_navmesh.rb +53 -0
  161. data/lib/game_machine/navigation/detour_path.rb +53 -0
  162. data/lib/game_machine/navigation/path.rb +31 -0
  163. data/lib/game_machine/object_db.rb +67 -0
  164. data/lib/game_machine/protobuf.rb +6 -0
  165. data/lib/game_machine/protobuf/game_messages.rb +24 -0
  166. data/lib/game_machine/protobuf/generate.rb +113 -0
  167. data/lib/game_machine/protobuf_extensions/entity_helper.rb +11 -0
  168. data/lib/game_machine/reloadable_monitor.rb +26 -0
  169. data/lib/game_machine/restart_watcher.rb +17 -0
  170. data/lib/game_machine/ruby_extensions/nilclass.rb +10 -0
  171. data/lib/game_machine/ruby_extensions/string.rb +17 -0
  172. data/lib/game_machine/scheduler.rb +23 -0
  173. data/lib/game_machine/securerandom.rb +6 -0
  174. data/lib/game_machine/settings.rb +11 -0
  175. data/lib/game_machine/system_monitor.rb +19 -0
  176. data/lib/game_machine/system_stats.rb +24 -0
  177. data/lib/game_machine/uniqueid.rb +23 -0
  178. data/lib/game_machine/vector.rb +95 -0
  179. data/lib/game_machine/version.rb +3 -0
  180. data/lib/game_machine/write_behind_cache.rb +164 -0
  181. data/mono/bin/csharp/common.xslt +109 -0
  182. data/mono/bin/csharp/csharp.xslt +628 -0
  183. data/mono/bin/csharp/descriptor.proto +533 -0
  184. data/mono/bin/csharp/protobuf-net.dll +0 -0
  185. data/mono/bin/csharp/protobuf-net.pdb +0 -0
  186. data/mono/bin/csharp/protobuf-net.xml +2879 -0
  187. data/mono/bin/csharp/protogen.exe.config +3 -0
  188. data/mono/bin/csharp/protogen.pdb +0 -0
  189. data/mono/bin/csharp/protogen_csharp.exe +0 -0
  190. data/mono/bin/csharp/vb.xslt +745 -0
  191. data/mono/bin/csharp/xml.xslt +26 -0
  192. data/mono/server/Makefile +6 -0
  193. data/mono/server/NLog.config +12 -0
  194. data/mono/server/NLog.dll +0 -0
  195. data/mono/server/actor.cs +37 -0
  196. data/mono/server/build.bat +3 -0
  197. data/mono/server/cscompmgd.dll +0 -0
  198. data/mono/server/iactor.cs +11 -0
  199. data/mono/server/message_router.cs +67 -0
  200. data/mono/server/message_util.cs +29 -0
  201. data/mono/server/messages.cs +1888 -0
  202. data/mono/server/protobuf-net.dll +0 -0
  203. data/mono/server/proxy_client.cs +73 -0
  204. data/mono/server/proxy_server.cs +30 -0
  205. data/mono/server/test_actor.cs +33 -0
  206. data/pathfinding/bin/premake4 +0 -0
  207. data/pathfinding/include/mesh_loader.h +28 -0
  208. data/pathfinding/include/pathfind.h +167 -0
  209. data/pathfinding/main.cpp +39 -0
  210. data/pathfinding/mesh_loader.cpp +108 -0
  211. data/pathfinding/pathfind.cpp +174 -0
  212. data/pathfinding/pathfinder.cs +66 -0
  213. data/pathfinding/premake4.lua +109 -0
  214. data/script/server.sh +109 -0
  215. data/script/watch.sh +11 -0
  216. data/spec/actor/actor_spec.rb +73 -0
  217. data/spec/actor/builder_spec.rb +56 -0
  218. data/spec/actor/ref_spec.rb +83 -0
  219. data/spec/application_spec.rb +7 -0
  220. data/spec/client_manager_spec.rb +171 -0
  221. data/spec/commands/chat_commands_spec.rb +38 -0
  222. data/spec/commands/datastore_commands_spec.rb +91 -0
  223. data/spec/commands/grid_commands_spec.rb +37 -0
  224. data/spec/commands/navigation_commands_spec.rb +51 -0
  225. data/spec/commands/player_commands_spec.rb +48 -0
  226. data/spec/commands_spec.rb +38 -0
  227. data/spec/data_stores/mapdb_spec.rb +46 -0
  228. data/spec/data_stores/redis_spec.rb +44 -0
  229. data/spec/game_systems/agents/controller_spec.rb +84 -0
  230. data/spec/game_systems/agents/test_agent.rb +10 -0
  231. data/spec/game_systems/agents/test_agent_config.rb +29 -0
  232. data/spec/game_systems/chat_manager_spec.rb +66 -0
  233. data/spec/game_systems/chat_spec.rb +187 -0
  234. data/spec/game_systems/entity_tracking_spec.rb +64 -0
  235. data/spec/game_systems/region_manager_spec.rb +138 -0
  236. data/spec/grid_spec.rb +37 -0
  237. data/spec/handlers/authentication_spec.rb +36 -0
  238. data/spec/handlers/game_spec.rb +49 -0
  239. data/spec/handlers/request_spec.rb +65 -0
  240. data/spec/hashring_spec.rb +59 -0
  241. data/spec/integration_helper.rb +120 -0
  242. data/spec/java_grid_spec.rb +89 -0
  243. data/spec/message_buffer_spec.rb +67 -0
  244. data/spec/message_expectations.rb +47 -0
  245. data/spec/message_queue_spec.rb +23 -0
  246. data/spec/misc_spec.rb +71 -0
  247. data/spec/model_spec.rb +103 -0
  248. data/spec/mono_spec.rb +36 -0
  249. data/spec/mono_test.rb +18 -0
  250. data/spec/navigation/detour_navmesh_spec.rb +34 -0
  251. data/spec/navigation/detour_path_spec.rb +25 -0
  252. data/spec/spec_helper.rb +40 -0
  253. data/spec/udp_server_spec.rb +10 -0
  254. data/spec/write_behind_cache_spec.rb +109 -0
  255. data/web/app.rb +131 -0
  256. data/web/config/trinidad.yml +4 -0
  257. data/web/controllers/auth_controller.rb +19 -0
  258. data/web/controllers/base_controller.rb +16 -0
  259. data/web/controllers/index_controller.rb +7 -0
  260. data/web/controllers/log_controller.rb +47 -0
  261. data/web/controllers/messages_controller.rb +59 -0
  262. data/web/controllers/player_register_controller.rb +15 -0
  263. data/web/log/development.log +1339 -0
  264. data/web/tmp/restart.txt +0 -0
  265. data/web/views/game_messages.haml +45 -0
  266. data/web/views/index.haml +6 -0
  267. data/web/views/layout.haml +41 -0
  268. data/web/views/logs.haml +32 -0
  269. data/web/views/player_register.haml +22 -0
  270. data/web/views/player_registered.haml +2 -0
  271. data/web/views/register_layout.haml +22 -0
  272. data/web/views/restart.haml +35 -0
  273. metadata +576 -0
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0"?>
2
+ <configuration>
3
+ <startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
Binary file
Binary file
@@ -0,0 +1,745 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <xsl:stylesheet version="1.0"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="xsl msxsl"
5
+ >
6
+ <xsl:import href="common.xslt"/>
7
+ <xsl:param name="help"/>
8
+ <xsl:param name="xml"/>
9
+ <xsl:param name="datacontract"/>
10
+ <xsl:param name="binary"/>
11
+ <xsl:param name="protoRpc"/>
12
+ <xsl:param name="observable"/>
13
+ <xsl:param name="preObservable"/>
14
+ <xsl:param name="partialMethods"/>
15
+ <xsl:param name="detectMissing"/>
16
+ <xsl:param name="lightFramework"/>
17
+ <xsl:param name="asynchronous"/>
18
+ <xsl:param name="clientProxy"/>
19
+ <xsl:param name="defaultNamespace"/>
20
+
21
+
22
+ <xsl:key name="fieldNames" match="//FieldDescriptorProto" use="name"/>
23
+
24
+ <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
25
+ <xsl:variable name="types" select="//EnumDescriptorProto | //DescriptorProto"/>
26
+ <xsl:variable name="optionXml" select="$xml='true'"/>
27
+ <xsl:variable name="optionDataContract" select="$datacontract='true'"/>
28
+ <xsl:variable name="optionBinary" select="$binary='true'"/>
29
+ <xsl:variable name="optionProtoRpc" select="$protoRpc='true'"/>
30
+ <xsl:variable name="optionObservable" select="$observable='true'"/>
31
+ <xsl:variable name="optionPreObservable" select="$preObservable='true'"/>
32
+ <xsl:variable name="optionPartialMethods" select="$partialMethods='true'"/>
33
+ <xsl:variable name="optionDetectMissing" select="$detectMissing='true'"/>
34
+ <xsl:variable name="optionFullFramework" select="not($lightFramework='true')"/>
35
+ <xsl:variable name="optionAsynchronous" select="$asynchronous='true'"/>
36
+ <xsl:variable name="optionClientProxy" select="$clientProxy='true'"/>
37
+ <xsl:variable name="optionFixCase" select="$fixCase='true'"/>
38
+
39
+ <xsl:template match="FileDescriptorSet">
40
+ <xsl:if test="$help='true'">
41
+ <xsl:message terminate="yes">
42
+ VisualBasic template for protobuf-net.
43
+ Options:
44
+ General:
45
+ "help" - this page
46
+ Additional serializer support:
47
+ "xml" - enable explicit xml support (XmlSerializer)
48
+ "datacontract" - enable data-contract support (DataContractSerializer; requires .NET 3.0)
49
+ "binary" - enable binary support (BinaryFormatter; not supported on Silverlight)
50
+ Other:
51
+ "protoRpc" - enable proto-rpc client
52
+ "observable" - change notification (observer pattern) support
53
+ "preObservable" - pre-change notification (observer pattern) support (requires .NET 3.5)
54
+ "partialMethods" - provide partial methods for changes (requires C# 3.0)
55
+ "detectMissing" - provide *Specified properties to indicate whether fields are present
56
+ "lightFramework" - omit additional attributes not included in CF/Silverlight
57
+ "asynchronous" - emit asynchronous methods for use with WCF
58
+ "clientProxy" - emit asynchronous client proxy class
59
+ </xsl:message>
60
+ </xsl:if>
61
+
62
+ <xsl:if test="$optionXml and $optionDataContract">
63
+ <xsl:message terminate="yes">
64
+ Invalid options: xml and data-contract serialization are mutually exclusive.
65
+ </xsl:message>
66
+ </xsl:if>
67
+ ' Generated from <xsl:value-of select="name"/>
68
+ <xsl:if test="$optionXml">
69
+ ' Option: xml serialization ([XmlType]/[XmlElement]) enabled
70
+ </xsl:if><xsl:if test="$optionDataContract">
71
+ ' Option: data-contract serialization ([DataContract]/[DataMember]) enabled
72
+ </xsl:if><xsl:if test="$optionBinary">
73
+ ' Option: binary serialization (ISerializable) enabled
74
+ </xsl:if><xsl:if test="$optionObservable">
75
+ ' Option: observable (OnPropertyChanged) enabled
76
+ </xsl:if><xsl:if test="$optionPreObservable">
77
+ ' Option: pre-observable (OnPropertyChanging) enabled
78
+ </xsl:if><xsl:if test="$partialMethods">
79
+ ' Option: partial methods (On*Changing/On*Changed) enabled
80
+ </xsl:if><xsl:if test="$detectMissing">
81
+ ' Option: missing-value detection (*Specified/ShouldSerialize*/Reset*) enabled
82
+ </xsl:if><xsl:if test="not($optionFullFramework)">
83
+ ' Option: light framework (CF/Silverlight) enabled
84
+ </xsl:if><xsl:if test="$optionProtoRpc">
85
+ ' Option: proto-rpc enabled
86
+ </xsl:if>
87
+ <xsl:apply-templates select="file/FileDescriptorProto"/>
88
+ </xsl:template>
89
+
90
+ <xsl:template match="FileDescriptorProto">
91
+ ' Generated from: <xsl:value-of select="name"/>
92
+ <xsl:apply-templates select="dependency/string[.!='']"/>
93
+ <xsl:variable name="namespace"><xsl:call-template name="PickNamespace">
94
+ <xsl:with-param name="defaultNamespace" select="$defaultNamespace"/>
95
+ </xsl:call-template>
96
+ </xsl:variable>
97
+ <xsl:if test="string($namespace) != ''">
98
+ Namespace <xsl:value-of select="translate($namespace,':-/\','__..')"/>
99
+ </xsl:if>
100
+ <xsl:apply-templates select="message_type | enum_type | service"/>
101
+ <xsl:if test="string($namespace) != ''">
102
+ End Namespace</xsl:if></xsl:template>
103
+
104
+ <xsl:template match="FileDescriptorProto/dependency/string">
105
+ ' Note: requires additional types generated from: <xsl:value-of select="."/></xsl:template>
106
+
107
+ <xsl:template match="DescriptorProto">
108
+ <xsl:choose>
109
+ <xsl:when test="$optionDataContract">
110
+ &lt;Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="<xsl:value-of select="name"/>")&gt; _
111
+ &lt;Global.System.Runtime.Serialization.DataContract(Name:="<xsl:value-of select="name"/>")&gt; _
112
+ </xsl:when>
113
+ <xsl:when test="$optionXml">
114
+ &lt;Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="<xsl:value-of select="name"/>")&gt; _
115
+ &lt;Global.System.Xml.Serialization.XmlType(TypeName:="<xsl:value-of select="name"/>")&gt; _
116
+ </xsl:when>
117
+ <xsl:otherwise>
118
+ &lt;Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="<xsl:value-of select="name"/>")&gt; _
119
+ </xsl:otherwise>
120
+ </xsl:choose><!--
121
+ -->Public Partial Class <xsl:call-template name="pascal"/>
122
+ implements Global.ProtoBuf.IExtensible<!--
123
+ --><xsl:if test="$optionBinary">, Global.System.Runtime.Serialization.ISerializable</xsl:if><!--
124
+ --><xsl:if test="$optionObservable">, Global.System.ComponentModel.INotifyPropertyChanged</xsl:if><!--
125
+ --><xsl:if test="$optionPreObservable">, Global.System.ComponentModel.INotifyPropertyChanging</xsl:if>
126
+
127
+ Public Sub New
128
+ End Sub
129
+ <xsl:apply-templates select="*"/><xsl:if test="$optionBinary">
130
+ Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext)
131
+ MyBase.New()
132
+ Global.ProtoBuf.Serializer.Merge(info, Me)
133
+ End Sub
134
+
135
+ Sub GetObjectData(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) implements Global.System.Runtime.Serialization.ISerializable.GetObjectData
136
+ Global.ProtoBuf.Serializer.Serialize(info, Me)
137
+ End Sub
138
+
139
+ </xsl:if><xsl:if test="$optionObservable">
140
+ Public Event PropertyChanged As Global.System.ComponentModel.PropertyChangedEventHandler Implements Global.System.ComponentModel.INotifyPropertyChanged.PropertyChanged
141
+ Protected Overridable Sub OnPropertyChanged(ByVal propertyName As String)
142
+ RaiseEvent PropertyChanged(Me, New Global.System.ComponentModel.PropertyChangedEventArgs(propertyName))
143
+ End Sub
144
+ </xsl:if><xsl:if test="$optionPreObservable">
145
+ Public Event PropertyChanging As Global.System.ComponentModel.PropertyChangingEventHandler Implements Global.System.ComponentModel.INotifyPropertyChanging.PropertyChanging
146
+ Protected Overridable Sub OnPropertyChanging(ByVal propertyName As String)
147
+ RaiseEvent PropertyChanging(Me, New Global.System.ComponentModel.PropertyChangingEventArgs(propertyName))
148
+ End Sub
149
+ </xsl:if>
150
+ Private extensionObject As Global.ProtoBuf.IExtension
151
+ Function GetExtensionObject(createIfMissing As Boolean) As Global.ProtoBuf.IExtension Implements Global.ProtoBuf.IExtensible.GetExtensionObject
152
+ Return Global.ProtoBuf.Extensible.GetExtensionObject(extensionObject, createIfMissing)
153
+ End Function
154
+ End Class
155
+ </xsl:template>
156
+
157
+
158
+
159
+ <xsl:template match="DescriptorProto/name | DescriptorProto/extension_range | DescriptorProto/extension"/>
160
+
161
+ <xsl:template match="
162
+ FileDescriptorProto/message_type | FileDescriptorProto/enum_type | FileDescriptorProto/service
163
+ | DescriptorProto/field | DescriptorProto/enum_type | DescriptorProto/message_type
164
+ | DescriptorProto/nested_type | EnumDescriptorProto/value | ServiceDescriptorProto/method">
165
+ <xsl:apply-templates select="*"/>
166
+ </xsl:template>
167
+
168
+ <xsl:template match="EnumDescriptorProto">
169
+ Public Enum <xsl:call-template name="pascal"/>
170
+ <xsl:apply-templates select="value"/>
171
+ End Enum
172
+ </xsl:template>
173
+
174
+ <xsl:template match="EnumValueDescriptorProto">
175
+ <xsl:text>
176
+ </xsl:text>
177
+ <xsl:value-of select="name"/>
178
+ <xsl:text xml:space="preserve"> = </xsl:text><xsl:choose>
179
+ <xsl:when test="number"><xsl:value-of select="number"/></xsl:when>
180
+ <xsl:otherwise>0</xsl:otherwise>
181
+ </xsl:choose><xsl:if test="position()!=last()">
182
+ </xsl:if>
183
+ </xsl:template>
184
+
185
+ <xsl:template match="FieldDescriptorProto" mode="field">
186
+ <xsl:choose>
187
+ <xsl:when test="not(key('fieldNames',concat('_',name)))"><xsl:value-of select="concat('_',name)"/></xsl:when>
188
+ <xsl:when test="not(key('fieldNames',concat(name,'Field')))"><xsl:value-of select="concat(name,'Field')"/></xsl:when>
189
+ <xsl:otherwise><xsl:value-of select="concat('_',generate-id())"/></xsl:otherwise>
190
+ </xsl:choose>
191
+ </xsl:template>
192
+
193
+ <xsl:template match="FieldDescriptorProto" mode="format">
194
+ <xsl:choose>
195
+ <xsl:when test="type='TYPE_DOUBLE' or type='TYPE_FLOAT'
196
+ or type='TYPE_FIXED32' or type='TYPE_FIXED64'
197
+ or type='TYPE_SFIXED32' or type='TYPE_SFIXED64'">FixedSize</xsl:when>
198
+ <xsl:when test="type='TYPE_GROUP'">Group</xsl:when>
199
+ <xsl:when test="not(type) or type='TYPE_INT32' or type='TYPE_INT64'
200
+ or type='TYPE_UINT32' or type='TYPE_UINT64'
201
+ or type='TYPE_ENUM'">TwosComplement</xsl:when>
202
+ <xsl:when test="type='TYPE_SINT32' or type='TYPE_SINT64'">ZigZag</xsl:when>
203
+ <xsl:otherwise>Default</xsl:otherwise>
204
+ </xsl:choose>
205
+ </xsl:template>
206
+ <xsl:template match="FieldDescriptorProto" mode="primitiveType">
207
+ <xsl:choose>
208
+ <xsl:when test="not(type)">struct</xsl:when>
209
+ <xsl:when test="type='TYPE_DOUBLE'">struct</xsl:when>
210
+ <xsl:when test="type='TYPE_FLOAT'">struct</xsl:when>
211
+ <xsl:when test="type='TYPE_INT64'">struct</xsl:when>
212
+ <xsl:when test="type='TYPE_UINT64'">struct</xsl:when>
213
+ <xsl:when test="type='TYPE_INT32'">struct</xsl:when>
214
+ <xsl:when test="type='TYPE_FIXED64'">struct</xsl:when>
215
+ <xsl:when test="type='TYPE_FIXED32'">struct</xsl:when>
216
+ <xsl:when test="type='TYPE_BOOL'">struct</xsl:when>
217
+ <xsl:when test="type='TYPE_STRING'">class</xsl:when>
218
+ <xsl:when test="type='TYPE_BYTES'">class</xsl:when>
219
+ <xsl:when test="type='TYPE_UINT32'">struct</xsl:when>
220
+ <xsl:when test="type='TYPE_SFIXED32'">struct</xsl:when>
221
+ <xsl:when test="type='TYPE_SFIXED64'">struct</xsl:when>
222
+ <xsl:when test="type='TYPE_SINT32'">struct</xsl:when>
223
+ <xsl:when test="type='TYPE_SINT64'">struct</xsl:when>
224
+ <xsl:when test="type='TYPE_ENUM'">struct</xsl:when>
225
+ <xsl:when test="type='TYPE_GROUP' or type='TYPE_MESSAGE'">none</xsl:when>
226
+ <xsl:otherwise>
227
+ <xsl:message terminate="yes">
228
+ Field type not implemented: <xsl:value-of select="type"/> (<xsl:value-of select="../../name"/>.<xsl:value-of select="name"/>)
229
+ </xsl:message>
230
+ </xsl:otherwise>
231
+ </xsl:choose>
232
+ </xsl:template>
233
+ <xsl:template match="FieldDescriptorProto" mode="type">
234
+ <xsl:choose>
235
+ <xsl:when test="not(type)">double</xsl:when>
236
+ <xsl:when test="type='TYPE_DOUBLE'">Double</xsl:when>
237
+ <xsl:when test="type='TYPE_FLOAT'">Single</xsl:when>
238
+ <xsl:when test="type='TYPE_INT64'">Long</xsl:when>
239
+ <xsl:when test="type='TYPE_UINT64'">ULong</xsl:when>
240
+ <xsl:when test="type='TYPE_INT32'">Integer</xsl:when>
241
+ <xsl:when test="type='TYPE_FIXED64'">ULong</xsl:when>
242
+ <xsl:when test="type='TYPE_FIXED32'">UInteger</xsl:when>
243
+ <xsl:when test="type='TYPE_BOOL'">Boolean</xsl:when>
244
+ <xsl:when test="type='TYPE_STRING'">String</xsl:when>
245
+ <xsl:when test="type='TYPE_BYTES'">Byte()</xsl:when>
246
+ <xsl:when test="type='TYPE_UINT32'">UInteger</xsl:when>
247
+ <xsl:when test="type='TYPE_SFIXED32'">Integer</xsl:when>
248
+ <xsl:when test="type='TYPE_SFIXED64'">Long</xsl:when>
249
+ <xsl:when test="type='TYPE_SINT32'">Integer</xsl:when>
250
+ <xsl:when test="type='TYPE_SINT64'">Long</xsl:when>
251
+ <xsl:when test="type='TYPE_GROUP' or type='TYPE_MESSAGE' or type='TYPE_ENUM'"><xsl:call-template name="pascal">
252
+ <xsl:with-param name="value" select="substring-after(type_name,'.')"/>
253
+ </xsl:call-template></xsl:when>
254
+ <xsl:otherwise>
255
+ <xsl:message terminate="yes">
256
+ Field type not implemented: <xsl:value-of select="type"/> (<xsl:value-of select="../../name"/>.<xsl:value-of select="name"/>)
257
+ </xsl:message>
258
+ </xsl:otherwise>
259
+ </xsl:choose>
260
+
261
+ </xsl:template>
262
+
263
+ <xsl:template match="FieldDescriptorProto[default_value]" mode="defaultValue">
264
+ <xsl:choose>
265
+ <xsl:when test="type='TYPE_STRING'">"<xsl:value-of select="default_value"/>"</xsl:when>
266
+ <xsl:when test="type='TYPE_ENUM'"><xsl:apply-templates select="." mode="type"/>.<xsl:value-of select="default_value"/></xsl:when>
267
+ <xsl:when test="type='TYPE_BYTES'"> ' <xsl:value-of select="default_value"/></xsl:when>
268
+ <xsl:otherwise>CType(<xsl:value-of select="default_value"/>, <xsl:apply-templates select="." mode="type"/>)</xsl:otherwise>
269
+ </xsl:choose>
270
+ </xsl:template>
271
+
272
+ <!--
273
+ We need to find the first enum value given .foo.bar.SomeEnum - but the enum itself
274
+ only knows about SomeEnum; we need to look at all parent DescriptorProto nodes, and
275
+ the FileDescriptorProto for the namespace.
276
+
277
+ This does an annoying up/down recursion... a bit expensive, but *generally* OK.
278
+ Could perhaps index the last part of the enum name to reduce overhead?
279
+ -->
280
+ <xsl:template name="GetFirstEnumValue">
281
+ <xsl:variable name="hunt" select="type_name"/>
282
+ <xsl:for-each select="//EnumDescriptorProto">
283
+ <xsl:variable name="fullName">
284
+ <xsl:for-each select="ancestor::FileDescriptorProto">.<xsl:value-of select="package"/></xsl:for-each>
285
+ <xsl:for-each select="ancestor::DescriptorProto">.<xsl:value-of select="name"/></xsl:for-each>
286
+ <xsl:value-of select="concat('.',name)"/>
287
+ </xsl:variable>
288
+ <xsl:if test="$fullName=$hunt"><xsl:value-of select="(value/EnumValueDescriptorProto)[1]/name"/></xsl:if>
289
+ </xsl:for-each>
290
+ </xsl:template>
291
+
292
+ <xsl:template match="FieldDescriptorProto[not(default_value)]" mode="defaultValue">
293
+ <xsl:choose>
294
+ <xsl:when test="type='TYPE_DOUBLE'">0.0</xsl:when>
295
+ <xsl:when test="type='TYPE_FLOAT'">0.0F</xsl:when>
296
+ <xsl:when test="type='TYPE_INT64'">0L</xsl:when>
297
+ <xsl:when test="type='TYPE_UINT64'">0L</xsl:when>
298
+ <xsl:when test="type='TYPE_INT32'">0</xsl:when>
299
+ <xsl:when test="type='TYPE_FIXED64'">0L</xsl:when>
300
+ <xsl:when test="type='TYPE_FIXED32'">0</xsl:when>
301
+ <xsl:when test="type='TYPE_BOOL'">False</xsl:when>
302
+ <xsl:when test="type='TYPE_STRING'">""</xsl:when>
303
+ <xsl:when test="type='TYPE_BYTES'">Nothing</xsl:when>
304
+ <xsl:when test="type='TYPE_UINT32'">0</xsl:when>
305
+ <xsl:when test="type='TYPE_SFIXED32'">0</xsl:when>
306
+ <xsl:when test="type='TYPE_SFIXED64'">0L</xsl:when>
307
+ <xsl:when test="type='TYPE_SINT32'">0</xsl:when>
308
+ <xsl:when test="type='TYPE_SINT64'">0L</xsl:when>
309
+ <xsl:when test="type='TYPE_MESSAGE'">Nothing</xsl:when>
310
+ <xsl:when test="type='TYPE_ENUM'"><xsl:apply-templates select="." mode="type"/>.<xsl:call-template name="GetFirstEnumValue"/></xsl:when>
311
+ <xsl:otherwise>Nothing</xsl:otherwise>
312
+ </xsl:choose>
313
+ </xsl:template>
314
+
315
+ <xsl:template match="FieldDescriptorProto[label='LABEL_OPTIONAL' or not(label)]">
316
+ <xsl:variable name="propType"><xsl:apply-templates select="." mode="type"/></xsl:variable>
317
+ <xsl:variable name="format"><xsl:apply-templates select="." mode="format"/></xsl:variable>
318
+ <xsl:variable name="primitiveType"><xsl:apply-templates select="." mode="primitiveType"/></xsl:variable>
319
+ <xsl:variable name="defaultValue"><xsl:apply-templates select="." mode="defaultValue"/></xsl:variable>
320
+ <xsl:variable name="field"><xsl:apply-templates select="." mode="field"/></xsl:variable>
321
+ <xsl:variable name="specified" select="$optionDetectMissing and ($primitiveType='struct' or $primitiveType='class')"/>
322
+ <xsl:variable name="fieldType"><xsl:if test="$specified and $primitiveType='struct'">Nullable(Of </xsl:if><xsl:value-of select="$propType"/><xsl:if test="$specified and $primitiveType='struct'">)</xsl:if></xsl:variable>
323
+
324
+ <xsl:choose>
325
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
326
+ Private <xsl:value-of select="concat($field,' As ',substring-after($fieldType, 'google.protobuf.'))"/><xsl:if test="not($specified)"> =<xsl:value-of select="$defaultValue"/></xsl:if>
327
+ </xsl:when>
328
+ <xsl:otherwise>
329
+ Private <xsl:value-of select="concat($field,' As ',$fieldType)"/><xsl:if test="not($specified)"> =<xsl:value-of select="$defaultValue"/></xsl:if>
330
+ </xsl:otherwise>
331
+ </xsl:choose>
332
+ <xsl:choose>
333
+ <xsl:when test="not($specified) and $optionXml">
334
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
335
+ <xsl:choose>
336
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
337
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="substring-after($fieldType, 'google.protobuf.')"/>))&gt; _
338
+ </xsl:when>
339
+ <xsl:otherwise>
340
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="$fieldType"/>))&gt; _
341
+ </xsl:otherwise>
342
+ </xsl:choose>
343
+ &lt;Global.System.Xml.Serialization.XmlElement("<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>)&gt; _ <!--
344
+ --></xsl:when>
345
+ <xsl:when test="not($specified) and $optionDataContract">
346
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
347
+ <xsl:choose>
348
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
349
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="substring-after($fieldType, 'google.protobuf.')"/>))&gt; _
350
+ </xsl:when>
351
+ <xsl:otherwise>
352
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="$fieldType"/>))&gt; _
353
+ </xsl:otherwise>
354
+ </xsl:choose>
355
+ &lt;Global.System.Runtime.Serialization.DataMember(Name:="<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>, IsRequired:=False)&gt; _ <!--
356
+ --></xsl:when>
357
+ <xsl:when test="not($specified)">
358
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _ <!--
359
+ --><xsl:choose>
360
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
361
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="substring-after($fieldType, 'google.protobuf.')"/>))&gt; _ <!--
362
+ --></xsl:when>
363
+ <xsl:otherwise>
364
+ &lt;Global.System.ComponentModel.DefaultValue(CType(<xsl:value-of select="$defaultValue"/>, <xsl:value-of select="$fieldType"/>))&gt; _ <!--
365
+ --></xsl:otherwise>
366
+ </xsl:choose><!--
367
+ --></xsl:when>
368
+ <xsl:when test="$optionDataContract">
369
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
370
+ &lt;Global.System.Runtime.Serialization.DataMember(Name:="<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>, IsRequired:=False)&gt; _ <!--
371
+ --></xsl:when>
372
+ <xsl:when test="$optionXml">
373
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
374
+ &lt;Global.System.Xml.Serialization.XmlElement("<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>)&gt; _ <!--
375
+ --></xsl:when>
376
+ <xsl:otherwise>
377
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=False, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _ <!--
378
+ --></xsl:otherwise>
379
+ </xsl:choose><!--
380
+ --><xsl:call-template name="WriteGetSet">
381
+ <xsl:with-param name="fieldType" select="$fieldType"/>
382
+ <xsl:with-param name="propType" select="$propType"/>
383
+ <xsl:with-param name="name"><xsl:call-template name="pascalPropName"/></xsl:with-param>
384
+ <xsl:with-param name="field" select="$field"/>
385
+ <xsl:with-param name="defaultValue" select="$defaultValue"/>
386
+ <xsl:with-param name="specified" select="$specified"/>
387
+ </xsl:call-template>
388
+ </xsl:template>
389
+
390
+ <xsl:template name="pascalPropName">
391
+ <xsl:param name="value" select="name"/>
392
+ <xsl:param name="delimiter" select="'_'"/>
393
+ <xsl:variable name="valueUC" select="translate($value,$alpha,$ALPHA)"/>
394
+ <xsl:variable name="finalName">
395
+ <xsl:choose>
396
+ <xsl:when test="$types[translate(name,$alpha,$ALPHA)=$valueUC]"><xsl:value-of select="concat($value,$delimiter,'Property')"/></xsl:when>
397
+ <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
398
+ </xsl:choose>
399
+ </xsl:variable>
400
+ <xsl:call-template name="pascal">
401
+ <xsl:with-param name="value" select="$finalName"/>
402
+ <xsl:with-param name="delimiter" select="$delimiter"/>
403
+ </xsl:call-template>
404
+ </xsl:template>
405
+
406
+ <xsl:template match="FieldDescriptorProto[label='LABEL_REQUIRED']">
407
+ <xsl:variable name="type"><xsl:apply-templates select="." mode="type"/></xsl:variable>
408
+ <xsl:variable name="format"><xsl:apply-templates select="." mode="format"/></xsl:variable>
409
+ <xsl:variable name="field"><xsl:apply-templates select="." mode="field"/></xsl:variable>
410
+ Private <xsl:value-of select="concat($field, ' As ', $type)"/>
411
+ <xsl:choose>
412
+ <xsl:when test="$optionDataContract">
413
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=True, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
414
+ &lt;Global.System.Runtime.Serialization.DataMember(Name:="<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>, IsRequired:=True)&gt; _ <!--
415
+ --></xsl:when>
416
+ <xsl:when test="$optionXml">
417
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=True, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
418
+ &lt;Global.System.Xml.Serialization.XmlElement("<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>)&gt; _ <!--
419
+ --></xsl:when>
420
+ <xsl:otherwise>
421
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, IsRequired:=True, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _ <!--
422
+ --></xsl:otherwise>
423
+ </xsl:choose><!--
424
+ --><xsl:call-template name="WriteGetSet">
425
+ <xsl:with-param name="fieldType" select="$type"/>
426
+ <xsl:with-param name="propType" select="$type"/>
427
+ <xsl:with-param name="name" select="name"/>
428
+ <xsl:with-param name="field" select="$field"/>
429
+ </xsl:call-template>
430
+ </xsl:template>
431
+
432
+ <xsl:template name="WriteGetSet">
433
+ <xsl:param name="fieldType"/>
434
+ <xsl:param name="propType"/>
435
+ <xsl:param name="name"/>
436
+ <xsl:param name="field"/>
437
+ <xsl:param name="specified" select="false()"/>
438
+ <xsl:param name="defaultValue"/>
439
+ <xsl:variable name="primitiveType"><xsl:apply-templates select="." mode="primitiveType"/></xsl:variable>
440
+ <xsl:choose>
441
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
442
+ Public Property <xsl:value-of select="concat($name,' As ',substring-after($fieldType, 'google.protobuf.'))"/>
443
+ </xsl:when>
444
+ <xsl:otherwise>
445
+ Public Property <xsl:value-of select="concat($name,' As ',$fieldType)"/>
446
+ </xsl:otherwise>
447
+ </xsl:choose>
448
+ Get
449
+ <xsl:choose>
450
+ <xsl:when test="$specified and $primitiveType='struct'"><!--
451
+ -->Return <xsl:value-of select="$field"/><!--
452
+ --></xsl:when>
453
+ <xsl:when test="$specified">
454
+ If Not <xsl:value-of select="$field"/> Is Nothing Then
455
+ Return <xsl:value-of select="$field"/>
456
+ Else
457
+ Return <xsl:value-of select="$defaultValue"/>
458
+ End If<!--
459
+ --></xsl:when>
460
+ <xsl:otherwise><!--
461
+ -->Return <xsl:value-of select="$field"/><!--
462
+ --></xsl:otherwise>
463
+ </xsl:choose>
464
+ End Get
465
+ <xsl:choose>
466
+ <xsl:when test="substring-after($fieldType, 'google.protobuf.')">
467
+ Set(<xsl:value-of select="concat('value As ',substring-after($fieldType, 'google.protobuf.'))"/>)
468
+ </xsl:when>
469
+ <xsl:otherwise>
470
+ Set(<xsl:value-of select="concat('value As ',$fieldType)"/>)
471
+ </xsl:otherwise>
472
+ </xsl:choose>
473
+ <xsl:if test="$optionPartialMethods">On<xsl:value-of select="$name"/>Changing(value)
474
+ </xsl:if><xsl:if test="$optionPreObservable">OnPropertyChanging("<xsl:value-of select="$name"/>")
475
+ </xsl:if><xsl:value-of select="$field"/> = value
476
+ <xsl:if test="$optionObservable">OnPropertyChanged("<xsl:value-of select="$name"/>") </xsl:if><xsl:if test="$optionPartialMethods">On<xsl:value-of select="$name"/>Changed()</xsl:if>
477
+ End Set
478
+ End Property
479
+ <xsl:if test="$optionPartialMethods">
480
+ partial void On<xsl:value-of select="$name"/>Changing(<xsl:value-of select="$propType"/> value);
481
+ partial void On<xsl:value-of select="$name"/>Changed();</xsl:if><xsl:if test="$specified">
482
+ &lt;Global.System.Xml.Serialization.XmlIgnore&gt; _
483
+ <xsl:if test="$optionFullFramework">&lt;Global.System.ComponentModel.Browsable(false)&gt; _ </xsl:if>
484
+ <xsl:choose>
485
+ <xsl:when test="$specified and $primitiveType='struct'">
486
+ Public Property <xsl:value-of select="$name"/>Specified As Boolean
487
+ Get
488
+ Return <xsl:value-of select="$field"/>.HasValue
489
+ End Get
490
+ Set (ByVal value As Boolean)
491
+ If Not <xsl:value-of select="$field"/>.HasValue Then
492
+ If value = True then <xsl:value-of select="$field"/> = <xsl:value-of select="$name"/>
493
+ Else
494
+ If value = False then <xsl:value-of select="$field"/> = Nothing
495
+ End If
496
+ End Set
497
+ End Property
498
+ </xsl:when>
499
+ <xsl:otherwise>
500
+ Public Property <xsl:value-of select="$name"/>Specified As Boolean
501
+ Get
502
+ Return <xsl:value-of select="$field"/> IsNot Nothing
503
+ End Get
504
+ Set (ByVal value As Boolean)
505
+ If <xsl:value-of select="$field"/> Is Nothing Then
506
+ If value = True then <xsl:value-of select="$field"/> = <xsl:value-of select="$name"/>
507
+ Else
508
+ If value = False then <xsl:value-of select="$field"/> = Nothing
509
+ End If
510
+ End Set
511
+ End Property
512
+ </xsl:otherwise>
513
+ </xsl:choose>
514
+ Private Function ShouldSerialize<xsl:value-of select="$name"/>() As Boolean
515
+ Return <xsl:value-of select="$name"/>Specified
516
+ End Function
517
+ Private Sub Reset<xsl:value-of select="$name"/>()
518
+ <xsl:value-of select="$name"/>Specified = false
519
+ End Sub
520
+ </xsl:if>
521
+ </xsl:template>
522
+ <xsl:template match="FieldDescriptorProto[label='LABEL_REPEATED']">
523
+ <xsl:variable name="type"><xsl:apply-templates select="." mode="type"/></xsl:variable>
524
+ <xsl:variable name="format"><xsl:apply-templates select="." mode="format"/></xsl:variable>
525
+ <xsl:variable name="field"><xsl:apply-templates select="." mode="field"/></xsl:variable>
526
+ <xsl:choose>
527
+ <xsl:when test="substring-after($type, 'google.protobuf.')">
528
+ Private <xsl:if test="not($optionXml)">ReadOnly </xsl:if> <xsl:value-of select="$field"/> as Global.System.Collections.Generic.List(Of <xsl:value-of select="substring-after($type, 'google.protobuf.')" />) = New Global.System.Collections.Generic.List(Of <xsl:value-of select="substring-after($type, 'google.protobuf.')"/>)()
529
+ </xsl:when>
530
+ <xsl:otherwise>
531
+ Private <xsl:if test="not($optionXml)">ReadOnly </xsl:if> <xsl:value-of select="$field"/> as Global.System.Collections.Generic.List(Of <xsl:value-of select="$type" />) = New Global.System.Collections.Generic.List(Of <xsl:value-of select="$type"/>)()
532
+ </xsl:otherwise>
533
+ </xsl:choose>
534
+ <xsl:choose>
535
+ <xsl:when test="$optionDataContract">
536
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
537
+ &lt;Global.System.Runtime.Serialization.DataMember(Name:="<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>, IsRequired:=False)&gt; _
538
+ </xsl:when>
539
+ <xsl:when test="$optionXml">
540
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
541
+ &lt;Global.System.Xml.Serialization.XmlElement("<xsl:value-of select="name"/>", Order:=<xsl:value-of select="number"/>)&gt; _
542
+ </xsl:when>
543
+ <xsl:otherwise>
544
+ &lt;Global.ProtoBuf.ProtoMember(<xsl:value-of select="number"/>, Name:="<xsl:value-of select="name"/>", DataFormat:=Global.ProtoBuf.DataFormat.<xsl:value-of select="$format"/>)&gt; _
545
+ </xsl:otherwise>
546
+ </xsl:choose><!--
547
+ --><xsl:choose>
548
+ <xsl:when test="substring-after($type, 'google.protobuf.')"><!--
549
+ -->Public <xsl:if test="not($optionXml)">ReadOnly </xsl:if>Property <xsl:value-of select="name"/> As Global.System.Collections.Generic.List(Of <xsl:value-of select="substring-after($type, 'google.protobuf.')" />)
550
+ </xsl:when>
551
+ <xsl:otherwise><!--
552
+ -->Public <xsl:if test="not($optionXml)">ReadOnly </xsl:if>Property <xsl:value-of select="name"/> As Global.System.Collections.Generic.List(Of <xsl:value-of select="$type" />)
553
+ </xsl:otherwise>
554
+ </xsl:choose>
555
+ Get
556
+ Return <xsl:value-of select="$field"/>
557
+ End Get
558
+ <!----><xsl:if test="$optionXml">
559
+ <xsl:choose>
560
+ <xsl:when test="substring-after($type, 'google.protobuf.')">
561
+ Set (value As Global.System.Collections.Generic.List(Of <xsl:value-of select="substring-after($type, 'google.protobuf.')" />))
562
+ </xsl:when>
563
+ <xsl:otherwise>
564
+ Set (value As Global.System.Collections.Generic.List(Of <xsl:value-of select="$type" />))
565
+ </xsl:otherwise>
566
+ </xsl:choose>
567
+ <xsl:value-of select="$field"/> = value
568
+ End Set
569
+ </xsl:if>
570
+ End Property
571
+ </xsl:template>
572
+
573
+ <xsl:template match="ServiceDescriptorProto">
574
+ <xsl:if test="($optionClientProxy or $optionDataContract)">
575
+ &lt;Global.System.ServiceModel.ServiceContract(Name:="<xsl:value-of select="name"/>")&gt; _
576
+ </xsl:if>
577
+ Public Interface I<xsl:value-of select="name"/>
578
+ <xsl:apply-templates select="method"/>
579
+ End Interface
580
+
581
+ <xsl:if test="$optionProtoRpc">
582
+ Public Class <xsl:value-of select="name"/>Client : Global.ProtoBuf.ServiceModel.RpcClient
583
+ public <xsl:value-of select="name"/>Client() : base(typeof(I<xsl:value-of select="name"/>)) { }
584
+
585
+ <xsl:apply-templates select="method/MethodDescriptorProto" mode="protoRpc"/>
586
+ End Class
587
+ </xsl:if>
588
+ <xsl:apply-templates select="." mode="clientProxy"/>
589
+
590
+ </xsl:template>
591
+
592
+ <xsl:template match="MethodDescriptorProto">
593
+ <xsl:if test="$optionDataContract">
594
+ &lt;Global.System.ServiceModel.OperationContract(Name:="<xsl:value-of select="name"/>")&gt; _
595
+ &lt;Global.ProtoBuf.ServiceModel.ProtoBehavior()&gt; _
596
+ </xsl:if>
597
+ <xsl:apply-templates select="output_type"/><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="name"/>(<xsl:apply-templates select="input_type"/> request);
598
+ <xsl:if test="$optionAsynchronous and $optionDataContract">
599
+ &lt;Global.System.ServiceModel.OperationContract(AsyncPattern:=True, Name:="<xsl:value-of select="name"/>")&gt; _
600
+ Global.System.IAsyncResult Begin<xsl:value-of select="name"/>(<xsl:apply-templates select="input_type"/> request, Global.System.AsyncCallback callback, object state);
601
+ <xsl:apply-templates select="output_type"/> End<xsl:value-of select="name"/>(Global.System.IAsyncResult ar);
602
+ </xsl:if>
603
+ </xsl:template>
604
+
605
+ <xsl:template match="MethodDescriptorProto" mode="protoRpc">
606
+ <xsl:apply-templates select="output_type"/><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="name"/>(<xsl:apply-templates select="input_type"/> request)
607
+ {
608
+ return (<xsl:apply-templates select="output_type"/>) Send("<xsl:value-of select="name"/>", request);
609
+ }
610
+ </xsl:template>
611
+
612
+ <xsl:template match="MethodDescriptorProto/input_type | MethodDescriptorProto/output_type">
613
+ <xsl:value-of select="substring-after(.,'.')"/>
614
+ </xsl:template>
615
+
616
+ <xsl:template match="MethodDescriptorProto" mode="CompleteEvent">
617
+ <xsl:if test="$optionAsynchronous and $optionDataContract">
618
+ Public Class <xsl:value-of select="name"/>CompletedEventArgs : Global.System.ComponentModel.AsyncCompletedEventArgs
619
+ private object[] results;
620
+
621
+ public <xsl:value-of select="name"/>CompletedEventArgs(object[] results, Global.System.Exception exception, bool cancelled, object userState)
622
+ : base(exception, cancelled, userState)
623
+ {
624
+ this.results = results;
625
+ }
626
+
627
+ public <xsl:apply-templates select="output_type"/> Result
628
+ {
629
+ get {
630
+ base.RaiseExceptionIfNecessary();
631
+ return (<xsl:apply-templates select="output_type"/>)(this.results[0]);
632
+ }
633
+ }
634
+ End Class
635
+ </xsl:if>
636
+ </xsl:template>
637
+
638
+ <xsl:template match="ServiceDescriptorProto" mode="clientProxy">
639
+ <xsl:if test="$optionAsynchronous and $optionDataContract and $optionClientProxy">
640
+ <xsl:apply-templates select="method/MethodDescriptorProto" mode="CompleteEvent"/>
641
+
642
+ &lt;Global.System.Diagnostics.DebuggerStepThroughAttribute()&gt; _
643
+ public partial class <xsl:value-of select="name"/>Client : Global.System.ServiceModel.ClientBase&lt;I<xsl:value-of select="name"/>&gt;, I<xsl:value-of select="name"/>
644
+ {
645
+
646
+ public <xsl:value-of select="name"/>Client()
647
+ {}
648
+ public <xsl:value-of select="name"/>Client(string endpointConfigurationName)
649
+ : base(endpointConfigurationName)
650
+ {}
651
+ public <xsl:value-of select="name"/>Client(string endpointConfigurationName, string remoteAddress)
652
+ : base(endpointConfigurationName, remoteAddress)
653
+ {}
654
+ public <xsl:value-of select="name"/>Client(string endpointConfigurationName, Global.System.ServiceModel.EndpointAddress remoteAddress)
655
+ : base(endpointConfigurationName, remoteAddress)
656
+ {}
657
+ public <xsl:value-of select="name"/>Client(Global.System.ServiceModel.Channels.Binding binding, Global.System.ServiceModel.EndpointAddress remoteAddress)
658
+ : base(binding, remoteAddress)
659
+ {}
660
+
661
+ <xsl:apply-templates select="method/MethodDescriptorProto" mode="clientProxy"/>
662
+ }
663
+ </xsl:if>
664
+ </xsl:template>
665
+
666
+ <xsl:template match="MethodDescriptorProto" mode="clientProxy">
667
+ <xsl:if test="$optionAsynchronous and $optionDataContract and $optionClientProxy">
668
+ private BeginOperationDelegate onBegin<xsl:value-of select="name"/>Delegate;
669
+ private EndOperationDelegate onEnd<xsl:value-of select="name"/>Delegate;
670
+ private Global.System.Threading.SendOrPostCallback on<xsl:value-of select="name"/>CompletedDelegate;
671
+
672
+ public event Global.System.EventHandler&lt;<xsl:value-of select="name"/>CompletedEventArgs&gt; <xsl:value-of select="name"/>Completed;
673
+
674
+ public <xsl:apply-templates select="output_type"/><xsl:text xml:space="preserve"> </xsl:text><xsl:value-of select="name"/>(<xsl:apply-templates select="input_type"/> request)
675
+ {
676
+ return base.Channel.<xsl:value-of select="name"/>(request);
677
+ }
678
+
679
+ &lt;Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)&gt; _
680
+ public Global.System.IAsyncResult Begin<xsl:value-of select="name"/>(<xsl:apply-templates select="input_type"/> request, Global.System.AsyncCallback callback, object asyncState)
681
+ {
682
+ return base.Channel.Begin<xsl:value-of select="name"/>(request, callback, asyncState);
683
+ }
684
+
685
+ &lt;Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)&gt; _
686
+ public <xsl:apply-templates select="output_type"/> End<xsl:value-of select="name"/>(Global.System.IAsyncResult result)
687
+ {
688
+ return base.Channel.End<xsl:value-of select="name"/>(result);
689
+ }
690
+
691
+ private Global.System.IAsyncResult OnBegin<xsl:value-of select="name"/>(object[] inValues, Global.System.AsyncCallback callback, object asyncState)
692
+ {
693
+ <xsl:apply-templates select="input_type"/> request = ((<xsl:apply-templates select="input_type"/>)(inValues[0]));
694
+ return this.Begin<xsl:value-of select="name"/>(request, callback, asyncState);
695
+ }
696
+
697
+ private object[] OnEnd<xsl:value-of select="name"/>(Global.System.IAsyncResult result)
698
+ {
699
+ <xsl:apply-templates select="output_type"/> retVal = this.End<xsl:value-of select="name"/>(result);
700
+ return new object[] {
701
+ retVal};
702
+ }
703
+
704
+ private void On<xsl:value-of select="name"/>Completed(object state)
705
+ {
706
+ if ((this.<xsl:value-of select="name"/>Completed != null))
707
+ {
708
+ InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
709
+ this.<xsl:value-of select="name"/>Completed(this, new <xsl:value-of select="name"/>CompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
710
+ }
711
+ }
712
+
713
+ public void <xsl:value-of select="name"/>Async(<xsl:apply-templates select="input_type"/> request)
714
+ {
715
+ this.<xsl:value-of select="name"/>Async(request, null);
716
+ }
717
+
718
+ public void <xsl:value-of select="name"/>Async(<xsl:apply-templates select="input_type"/> request, object userState)
719
+ {
720
+ if ((this.onBegin<xsl:value-of select="name"/>Delegate == null))
721
+ {
722
+ this.onBegin<xsl:value-of select="name"/>Delegate = new BeginOperationDelegate(this.OnBegin<xsl:value-of select="name"/>);
723
+ }
724
+ if ((this.onEnd<xsl:value-of select="name"/>Delegate == null))
725
+ {
726
+ this.onEnd<xsl:value-of select="name"/>Delegate = new EndOperationDelegate(this.OnEnd<xsl:value-of select="name"/>);
727
+ }
728
+ if ((this.on<xsl:value-of select="name"/>CompletedDelegate == null))
729
+ {
730
+ this.on<xsl:value-of select="name"/>CompletedDelegate = new Global.System.Threading.SendOrPostCallback(this.On<xsl:value-of select="name"/>Completed);
731
+ }
732
+ base.InvokeAsync(this.onBegin<xsl:value-of select="name"/>Delegate, new object[] {
733
+ request}, this.onEnd<xsl:value-of select="name"/>Delegate, this.on<xsl:value-of select="name"/>CompletedDelegate, userState);
734
+ }
735
+ </xsl:if>
736
+ </xsl:template>
737
+
738
+ <xsl:template name="escapeKeyword"><xsl:param name="value"/><xsl:choose>
739
+ <xsl:when test="contains($keywordsUpper,concat('|',translate($value, $alpha, $ALPHA),'|'))">[<xsl:value-of select="$value"/>]</xsl:when>
740
+ <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
741
+ </xsl:choose></xsl:template>
742
+ <xsl:variable name="keywords">|AddHandler|AddressOf|Alias|And|AndAlso|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDec|CDbl|Char|CInt|Class|CLng|CObj|Const|Continue|CSByte|CShort|CSng|CStr|CType|CUInt|CULng|CUShort|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|False|Finally|For|Friend|Function|Get|GetType|GetXMLNamespace|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|Narrowing|New|Next|Not|Nothing|NotInheritable|NotOverridable|Object|Of|On|Operator|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|REM|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|True|Try|TryCast|TypeOf|Variant|Wend|UInteger|ULong|UShort|Using|When|While|Widening|With|WithEvents|WriteOnly|Xor|</xsl:variable>
743
+ <xsl:variable name="keywordsUpper" select="translate($keywords, $alpha, $ALPHA)"/>
744
+
745
+ </xsl:stylesheet>