c# - ASP.NET *.resx serialization -


Contributing to the IHTML project and having a call to serialize our * .resx files as a JSN object (for whatever reason)

).

What I'm thinking:

  • Is there a way to get a list of all valid keys for a given * .resx file so that we
  • If that will not work, then has anyone come up with a clever solution?
  •   subreadres file () '' # requirements assembly system. Windows.forms As the DMRSXR system. Resources. RISISCO RESOURCEERDER = NEW SYSTEM. Resource. Recycle Resider ("Items.resx") '' Repeat through # resources and display the content in the console In each D, DNM D for RSXR Console Deindentry (DK.ToString () + ":" + Control Chars. Tab + D. Vel. Toasting ()) Next D '# Reader Close. Rsxr.Close () End Sub  

    Then you have to add it to a serialable dictionary, which you can then order on JSON using System.Web.Extensions.dll

    public class JSONHelper Public Shared Function Serialize (by T) system (as in the form of volt obj) string Dim JSONserializer. Web.Script.Serialization.JavaScriptSerializer = New system. Web.Script.Serialization.JavaScriptSerializer () Return JSONserializer .Serialize (obj) end function Public Shared Function Deserialize (as T) String as Byval json T as obj as T = Activator.CreateInstance (T ) () Dim JSONserializer as the system. Web.Script.Serialization.JavaScriptSerializer = New system. Web. Script Serialization. JavaScript Cyrilizer () obj = JSONserializer Generalization (TK) (JSK) return obj and function and class

    Edit: C #:

      Public Zero ReadRessourceFile () {// Assembly The system is required. Windows.Forms' System.Resources.ResXResourceReader rsxr = new Syst em.Resources.ResXResourceReader ("items.resx"); // Repeat through the resources and display the content in the console 'System.Collections.DictionaryEntry D = Default (System.Collections.DictionaryEntry); Foreign exchange (RSXR only in English entry de_lop) {d = d_loopVariable; Console.lightline (d.Key.ToString () + ":" + ControlChars.Tab + d.Value.ToString ()); } // Close the reader 'Rsxr.Close (); }  

    and JSON assistant:

      public class JSONHelper {public static string serialize & lt; T & gt; (T.O.B.J.) {System.Web.Script.Serialization. JavaScriptSerializer JSONserializer = New System Web.Script.Serialization.JavaScriptSerializer (); Return JSONserializer } Desertialize Public Static T & lt; T & gt; (String jsn) {t obj = Activator.CreateInstance & lt; T & gt; (); System.Web.Script.Serialization.JavaScriptSerializer JSONserializer = New System. Web.Script.Serialization.JavaScriptSerializer (); Obj = JSONserializer.Deserialize & lt; T & gt; (Json); Return obj; }}  

Comments