Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:35:36+00:00 2026-05-31T11:35:36+00:00

From what I’ve read/seen there are 3 ways to define the model for protobuf,

  • 0

From what I’ve read/seen there are 3 ways to define the model for protobuf, with .proto files, with class decoration and with runtime calls to add types and fields. What I’m looking for is a way a bit more like FluentNhibernate where definition of the model is removed to seperate files away from the program for each class individually to leave the model cleaner. In this line of thought I’ve create a class Buffer<T> which when instantiated adds the class it is defining to a type model.

public class CustomerBuffer : Buffer<Customer>
{
    public CustomerBuffer()
    {
        Add("ID");
        Add("SyncID");
        Add("AccountNumber");
        Add("Reference");
        Add("Contact");
        Add("Address");
        Add("CreditInformation");
    }
}

the type model used is created in the Buffer<T> constructor so it is available when the derived classes constructor is called.

When everything has been added I need to be able to merge the models together so they can be compiled.

So far I’ve tried this:

foreach(MetaType MT in model.GetTypes())
{
    InternalModel.Add(MT.Type, false);
}

which obviously won’t work since it’s not copying the field information on the original MetaType.

So I’m looking for a work around which will allow me to search for and add all types deriving from Buffer<T> within an assembly (or multiple assemblies) to a type model and then compile it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:35:37+00:00Added an answer on May 31, 2026 at 11:35 am

    Solved this by using a Singleton for the type model. This way I don’t need to merge type models since everything is added to the same model. Did need to add an override to AddSubType so that it could be called without the type number. This works nicely now.

    Update

    This causes me 2 errors so far both based on initialisation order of the classes being added.

    “Unable to cast type x to type y” Occurs in ProtoWriter and ProtoReader when the base class is initialised after the subclass.
    – This has been solved by added a sort algorithm to wrapping protobufcfg class between finding all the types to initialise and actually initialising them.

    “Possible Recursion Detected” Occurs when a Parent containing a property which is a list of children is initialised after the child and the child contains a “Parent” property.

    Update2

    Both these bugs are through my misuse of the AsReference Property, which needed to be dynamic as well as reference on the “Parent” property of the child and needed to be removed from the list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from django.db import models class Post(models.Model): title = models.CharField(max_length=100) content = models.CharField(max_length=1000) created =
From c++ FAQ: http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.9 Remember: delete p does two things: it calls the destructor
From MSDN If there are no waiting threads, the wait handle remains signaled until
From the paper of bigtable. bigtable I read this: Each METADATA row stores approximately
From your experience, are there any security measures that one should undertake on a
from the app-context.xml: <bean id=userDao class=com.vaannila.dao.UserDAOImpl> <property name=sessionFactory ref=mySessionFactory/> </bean> <bean name=MyServiceT class=com.s.server.ServiceT> <property
From wikipedia: // A class template to express an equality comparison interface. template<typename T>
From what I understand of ActionScript, there are two kinds of casts: var bar0:Bar
From the documentation of oracle : Domain Runtime MBean Server : This MBean server
From JSP file accessed another JSP file which acts like java class, this used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.