Note that there are some explanatory texts on larger screens.

plurals
  1. POReversing the save method in the Open method
    primarykey
    data
    text
    <p>Fairly new to programming. I just can't wrap my head around how to get this to work in reverse. I have a save method and an open method. Save:</p> <pre><code>IDictionary&lt;string, IDictionary&lt;string, object&gt;&gt; pluginStates = new Dictionary&lt;string, IDictionary&lt;string, object&gt;&gt;(); signaller.RaiseSaveRequest(pluginStates); &lt;--goes out and gets packed plugins //loop through plugins to get values and types //holds all of the plugin arrays Dictionary&lt;string, object&gt; dictProjectState = new Dictionary&lt;string, object&gt;(); foreach (KeyValuePair&lt;string,IDictionary&lt;string,object&gt;&gt; plugin in pluginStates) { //holds jsonRepresented values Dictionary&lt;string, object&gt; dictJsonRep = new Dictionary&lt;string, object&gt;(); //holds object types Dictionary&lt;string, object&gt; dictObjRep = new Dictionary&lt;string, object&gt;(); object[] arrayDictHolder = new object[2]; //holds all of the dictionaries string pluginKey = plugin.Key; IDictionary&lt;string, object&gt; pluginValue = new Dictionary&lt;string, object&gt;(); pluginValue = plugin.Value; foreach (KeyValuePair&lt;string, object&gt; element in pluginValue) { string jsonRepresentation = JsonConvert.SerializeObject(element); object objType = element.Value.GetType().ToString(); dictJsonRep.Add(element.Key, jsonRepresentation); dictObjRep.Add(element.Key, objType); } arrayDictHolder[0] = dictJsonRep; arrayDictHolder[1] = dictObjRep; dictProjectState.Add(pluginKey, arrayDictHolder); } JsonSerializer serializer = new JsonSerializer(); using (StreamWriter sw = new StreamWriter(strPathName)) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, dictProjectState); } </code></pre> <p>So, when someone saves, an event handler goes out and gets the packedState of each plugin, adds it to a dictionary pluginStates. I then go through each plugin in the pluginStates, adding the key, and json string version of the value to 1 dictionary and the key, object type to another dictionary, add those 2 dictionaries to an array and then pack up a dictionary that contains the pluginKey and the array for each plugin. Reasoning: when deserializing, I'm hitting problems going from JArray to type DataTable and other types that are within the dictionary that gets passed back to the plugin to unpack itself upon opening. I'm trying to figure out how to reverse this, so that when user opens project, I have the dictProjectState and need to bring it all the way back through the code to end up with 1 dictionary containing the plugins. How do I mirror this save in the open?? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload