Skip to content

Commit

Permalink
ref[csharp]: refactor generate csharp protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed May 22, 2024
1 parent e935f86 commit 7fedbe5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions net/src/main/java/com/zfoo/net/config/model/NetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class NetConfig {
/**
* {@link GenerateOperation}
*/
private boolean oneProtocol;
private boolean mergerProtocol;
/**
* {@link GenerateOperation}
*/
Expand Down Expand Up @@ -81,12 +81,12 @@ public void setProtocolLocation(String protocolLocation) {
this.protocolLocation = protocolLocation;
}

public boolean isOneProtocol() {
return oneProtocol;
public boolean isMergerProtocol() {
return mergerProtocol;
}

public void setOneProtocol(boolean oneProtocol) {
this.oneProtocol = oneProtocol;
public void setMergerProtocol(boolean mergerProtocol) {
this.mergerProtocol = mergerProtocol;
}

public boolean isFoldProtocol() {
Expand Down
2 changes: 1 addition & 1 deletion net/src/main/java/com/zfoo/net/packet/PacketService.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void init() {
var protocolLocation = netConfig.getProtocolLocation();

var generateOperation = new GenerateOperation();
generateOperation.setMergeProtocol(netConfig.isOneProtocol());
generateOperation.setMergeProtocol(netConfig.isMergerProtocol());
generateOperation.setFoldProtocol(netConfig.isFoldProtocol());
generateOperation.setProtocolPath(netConfig.getProtocolPath());
generateOperation.setProtocolParam(netConfig.getProtocolParam());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void parseNetConfig(Element element, ParserContext parserContext) {
resolvePlaceholder("protocol-location", "protocolLocation", builder, element, parserContext);

// 协议文件是否生成在同一个协议文件中
resolvePlaceholder("one-protocol", "oneProtocol", builder, element, parserContext);
resolvePlaceholder("merger-protocol", "mergerProtocol", builder, element, parserContext);
// 文件是否折叠
resolvePlaceholder("fold-protocol", "foldProtocol", builder, element, parserContext);
// 生成各种语言的协议列表
Expand Down
2 changes: 1 addition & 1 deletion net/src/main/resources/net-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="protocol-location" type="xsd:string" use="required"/>
<xsd:attribute name="one-protocol" type="xsd:boolean" default="false"/>
<xsd:attribute name="merger-protocol" type="xsd:boolean" default="false"/>
<xsd:attribute name="fold-protocol" type="xsd:boolean" default="false"/>
<xsd:attribute name="code-languages" type="xsd:string"/>
<xsd:attribute name="protocol-path" type="xsd:string"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ public interface ICodeGenerate {

void init(GenerateOperation generateOperation);

/**
* 将一个包下的协议文件生成在一个协议文件里
*/
void mergerProtocol(List<IProtocolRegistration> registrations) throws IOException;

/**
* 折叠协议,生成协议文件会和Java源文件保持相同的目录结构
*/
void foldProtocol(List<IProtocolRegistration> registrations) throws IOException;

/**
* 默认把所有的协议文件放在同一个更目录下,不做任何操作
*/
void defaultProtocol(List<IProtocolRegistration> registrations) throws IOException;

}

0 comments on commit 7fedbe5

Please sign in to comment.