Click here to Skip to main content
15,896,201 members
Home / Discussions / C#
   

C#

 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Pete O'Hanlon24-Mar-14 2:48
mvePete O'Hanlon24-Mar-14 2:48 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 5:54
Mario 5624-Mar-14 5:54 
AnswerRe: Array of classes nested into array of classes (and serialization) Pin
BobJanova24-Mar-14 4:14
BobJanova24-Mar-14 4:14 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 6:17
Mario 5624-Mar-14 6:17 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 7:44
Mario 5624-Mar-14 7:44 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
BobJanova24-Mar-14 8:05
BobJanova24-Mar-14 8:05 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 10:24
Mario 5624-Mar-14 10:24 
QuestionRegarding Role based Login Pin
Member 1067835223-Mar-14 22:08
Member 1067835223-Mar-14 22:08 
SuggestionRe: Regarding Role based Login Pin
Richard MacCutchan23-Mar-14 23:01
mveRichard MacCutchan23-Mar-14 23:01 
GeneralRe: Regarding Role based Login Pin
Member 1067835224-Mar-14 18:28
Member 1067835224-Mar-14 18:28 
GeneralRe: Regarding Role based Login Pin
Richard MacCutchan24-Mar-14 22:23
mveRichard MacCutchan24-Mar-14 22:23 
QuestionGeolocation with c# winforms Pin
Member 1069141122-Mar-14 12:37
Member 1069141122-Mar-14 12:37 
AnswerRe: Geolocation with c# winforms Pin
Peter Leow22-Mar-14 17:05
professionalPeter Leow22-Mar-14 17:05 
Questiondynamic sql result not shown in DevExpress DataGrid Pin
Jassim Rahma21-Mar-14 12:26
Jassim Rahma21-Mar-14 12:26 
Questionmoving from iphone to asp.net Pin
dsp120-Mar-14 23:41
dsp120-Mar-14 23:41 
AnswerRe: moving from iphone to asp.net Pin
Vishal Pand3y21-Mar-14 0:06
Vishal Pand3y21-Mar-14 0:06 
AnswerRe: moving from iphone to asp.net Pin
OriginalGriff21-Mar-14 2:16
mveOriginalGriff21-Mar-14 2:16 
QuestionMany instances of the same class by a loop Pin
mrRsChief20-Mar-14 15:32
mrRsChief20-Mar-14 15:32 
AnswerRe: Many instances of the same class by a loop Pin
Dave Kreskowiak20-Mar-14 17:06
mveDave Kreskowiak20-Mar-14 17:06 
AnswerRe: Many instances of the same class by a loop Pin
Wayne Gaylard20-Mar-14 20:03
professionalWayne Gaylard20-Mar-14 20:03 
AnswerRe: Many instances of the same class by a loop Pin
V.20-Mar-14 20:42
professionalV.20-Mar-14 20:42 
AnswerRe: Many instances of the same class by a loop Pin
OriginalGriff20-Mar-14 23:27
mveOriginalGriff20-Mar-14 23:27 
AnswerRe: Many instances of the same class by a loop Pin
BobJanova21-Mar-14 0:28
BobJanova21-Mar-14 0:28 
QuestionAny Protobuf guru's here? Have problem with outputted data. Pin
DeepToot20-Mar-14 10:23
DeepToot20-Mar-14 10:23 
I have an incoming json object that I can successfully deserialize into an object. However, I now need to send that object back to the UI and to do this we use Google Proto objects.

This is what the json string looks like coming in and what it should look like going back out:

JavaScript
"lang\":{\"en-US\":{\"name\":\"AS Test Assembly Activity\",\"description\":\"Activity to test assembly activities\"}


I am trying to organize my proto messages that would output the same but I am having no luck. Here is what I have so far.

Proto Messages:
JavaScript
message CustomActivityConfig {
optional CustomActivityLanguage lang = 5;
}

message CustomActivityLanguage {
required string key = 1;
repeated LanguageData lang = 2;
}

message LanguageData {
optional string name = 1;
optional string description = 2;
}

This gives me an output of:

JavaScript
"lang":{"key":"en-US","lang":[{"name":"AS Test Assembly Activity","description":"Activity to test assembly activities"}



My Class structure which holds the correct data from the json at the top looks like this:
JavaScript
[Serializable]
public class CustomAssemblyData
{
    public Dictionary<string, LangData> Lang { get; set; }
}

[Serializable]
public class LangData
{
    public string Name { get; set; }
    public string Description { get; set; }
}

So what I am doing is iterating through the KeyValuePair in my class above and trying to pack it into my proto message.

I feel if I can get the proto right that it should work as expected

If this helps, here is how I am currently trying to pack the proto (which gives the second incorrect json output:
JavaScript
var cac = new CustomActivityConfig.Builder();

foreach (KeyValuePair<string, LangData> kvp in genericAssembly.CustomActivityConfig.Lang)
{
   var culture = kvp.Key;
   var name = kvp.Value.Name;
   var desc = kvp.Value.Description;


   var langData = new LanguageData.Builder()
   {
      Name = name,
      Description = desc
   }.Build();

   var customActivityLanguage = new CustomActivityLanguage.Builder()
   {
       Key = culture //will be 'en-US' in json
   };

   //Add class to Value of Dictionary
   customActivityLanguage.AddLang(langData);

   cac.Lang = customActivityLanguage.Build();
}


Also, if anyone can answer me this: Is there any way to get rid of the field names? 'Key', 'Lang' for instance and just show the values?

Hope this makes sense. Appreciate the time.
AnswerRe: Any Protobuf guru's here? Have problem with outputted data. Pin
Pete O'Hanlon20-Mar-14 13:46
mvePete O'Hanlon20-Mar-14 13:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.