使用自动生成的代码将C#类型移植到Java [英] Porting C# types to Java using auto-generated code

查看:86
本文介绍了使用自动生成的代码将C#类型移植到Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿大家,



最近,我一直在努力做一些我觉得非常酷的事情,以提高我的项目的生产力(至少我找到它很酷......;))。



无论如何,我要做的是重新生成服务器端的协议类,这是用我的应用程序的客户端语言(用Java和Objective-C)用C#编写。 (我想你知道我要去哪里......)



我的主要目标是:

a。最小化同步开销。客户端开发人员不必重新编写服务器代码。此外,自动过程有望减少错误(错误的序列化配置等...)。

b。客户对象逻辑和序列化参数的分离。我希望在编译任何版本之前重新创建自动生成的代码,而不会影响客户端的逻辑。 (部分课程,你在JAVA中不存在吗?)

c。我的请求形成了一个非常整洁的类树。树中的每个节点都将自己的基本参数添加到请求中。我希望它保持这样。



我在这里讨论Java的替代解决方案。由于不存在部分类。似乎有必要做一些丑陋的事情,比如ProtocolRequest扩展ProtocolRequestParameters,或者它可能包含参数struct作为成员。最符合我需求的方法是在类中自动生成的部分,并在其中嵌入更改。



我主要担心的是,无法正确地向服务器发送请求,而我当前的设计正在尝试非常准确且面向对象(在其他方面)话太棒了)。我担心Java所施加的限制会破坏我的努力。



我会很感激有关如何自动生成课程的一些好建议和建议。如果你们找到一些好方法/可能参考现有解决方案以满足我的需求,我将非常感激。



非常感谢!

Hey everybody,

Lately, I''ve been trying to do something which I find very cool to improve my project''s productivity (at least I find it cool... ;) ).

Anyway, What I''m trying to do is to regenerate my server side''s protocol classes, which is written in C# in my application''s client languages, which are Java and Objective-C. (I think you see where I''m going with that...)

My main goals are:
a. Minimization of synchronization overheads. The client developers should not have to re-write server code. Also, an automatic process would hopefully reduce bugs (wrong serialization configuration, etc...).
b. Separation of client object logic and the serialization parameters. I would like to have the auto-generated code to be recreated before any version is compiled without affecting client''s logic. (Partial classes, Y U NO EXIST IN JAVA?)
c. My requests form a really neat class tree. Where every node in the tree adds its own essential parameters to the request. I would like it to remain like that.

I''m here to discuss alternative solutions for Java. As partial classes do not exist. It seems like it would be necessary to do some ugly things, such as ProtocolRequest extends ProtocolRequestParameters, or maybe it would contain the parameters struct as a member. The closest method that fits my desires would be an auto-generated section within a class, and embedding changes within it.

My main concern is that it would be impossible to send a request to server properly, while my current design is trying to be very accurate and object-oriented (in other words awesome). I''m afraid that limitations imposed by Java will ruin my efforts.

I would appreciate some good advice and suggestions on how to auto-generate my classes. I would be really grateful if you guys find some good methods / maybe references to existing solutions to fit my needs.

Thank you very much!

推荐答案

您可能对 Stab [ ^ ]编程语言:

It''s possible that you would be interested in the Stab[^] programming language:
class C 
{    
 // Manually implemented property    
 private int myProperty;    
 public int MyProperty 
 {        
  get 
  {            
    return myProperty;
  }        
  set 
  {            
    myProperty = value;        
  }    
 }    
 // Indexer    
 private int[] array;    
 public int this[int i] 
 {        
   get 
   {            
    return array[i];        
   }        
   set 
   {            
    array[i] = value;        
   }    
  }    
 // Automatically implemented property    
 public int MyProperty2 
 {
   get; 
   set;    
 }
}





最好的问候

Espen Harlinn



Best regards
Espen Harlinn


这篇关于使用自动生成的代码将C#类型移植到Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆