| /** |
| * |
| * Copyright 2005-2006 The Apache Software Foundation |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| import org.apache.activemq.openwire.tool.OpenWireCSharpClassesScript |
| |
| /** |
| * Generates the C# commands for the Open Wire Format |
| * |
| * @version $Revision$ |
| */ |
| class GenerateCSharpClasses extends OpenWireCSharpClassesScript { |
| |
| void generateFile(PrintWriter out) { |
| out << """/* |
| * Copyright 2006 The Apache Software Foundation or its licensors, as |
| * applicable. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // |
| // NOTE!: This file is autogenerated - do not modify! |
| // if you need to make a change, please see the Groovy scripts in the |
| // activemq-core module |
| // |
| |
| using System; |
| using System.Collections; |
| |
| using ActiveMQ.OpenWire; |
| using ActiveMQ.Commands; |
| |
| namespace ActiveMQ.Commands |
| { |
| /// <summary> |
| /// The ActiveMQ ${jclass.simpleName} Command |
| /// </summary> |
| public class ${jclass.simpleName} : $baseClass""" |
| |
| for( i in jclass.interfaces ) { |
| out << ", ${i.simpleName}"; |
| } |
| |
| out << """ |
| { |
| public const byte ID_${jclass.simpleName} = ${getOpenWireOpCode(jclass)}; |
| |
| """ |
| for (property in properties) { |
| def type = toCSharpType(property.type) |
| def name = decapitalize(property.simpleName) |
| out << """ $type $name; |
| """ |
| } |
| |
| def text = makeHashCodeBody() |
| if (text != null) out << |
| """ |
| public override int GetHashCode() { |
| $text |
| } |
| |
| """ |
| |
| text = makeEqualsBody() |
| if (text != null) out << |
| """ |
| public override bool Equals(object that) { |
| if (that is ${className}) { |
| return Equals((${className}) that); |
| } |
| return false; |
| } |
| |
| public virtual bool Equals(${className} that) { |
| $text |
| } |
| |
| """ |
| |
| text = makeToStringBody() |
| if (text != null) out << """ |
| public override string ToString() { |
| $text |
| } |
| |
| """ |
| |
| out << """ |
| |
| public override byte GetDataStructureType() { |
| return ID_${jclass.simpleName}; |
| } |
| |
| |
| // Properties |
| """ |
| for (property in properties) { |
| def type = toCSharpType(property.type) |
| def name = decapitalize(property.simpleName) |
| def propertyName = property.simpleName |
| def getter = capitalize(property.getter.simpleName) |
| def setter = capitalize(property.setter.simpleName) |
| |
| |
| out << """ |
| public $type $propertyName |
| { |
| get { return $name; } |
| set { this.$name = value; } |
| } |
| """ |
| } |
| |
| out << """ |
| } |
| } |
| """ |
| } |
| } |