簡體   English   中英

Protobuf3 - Protobuf-net 從 C# 獲取選項/擴展

[英]Protobuf3 - Protobuf-net get Options/Extensions from C#

我有一個具有以下結構的opt.proto文件:

extend google.protobuf.MessageOptions {
  repeated string class_attr = 3003;
}

extend google.protobuf.FieldOptions {
  repeated string field_attr = 3004;
}

另一個classext.proto具有從opt.proto文件導入的內容:


message Stream
{
    option (class_attr) = "TestClassAttribute";
    option (class_attr) = "TestClassAttribute2";
    
    string id = 1 [(field_attr) = "TestFieldAttribute", (field_attr) = "TestFieldAttribute"];
    
    string description = 2;

    string path = 3;
}

編譯時,我需要訪問擴展及其值,以便在需要時添加更多信息。 到目前為止,我只能訪問字段的名稱(class_attr、field_attr),但無法訪問它們的值。

我看到對於 c++ 有類似GetExtension(option)的東西。

根據2016年的這個問題,沒有這種類型的實現,

這有沒有以任何方式解決?

謝謝。

為了解決這個問題,我最終創建了自己的閱讀器來加載信息,以便我可以根據需要滾動瀏覽。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM