예제 #1
0
 internal static Dictionary <UILanguage, string> GetLocalizedHeaders(JsonDTO json)
 {
     return(new Dictionary <UILanguage, string>
     {
         { UILanguage.RU, json.LocalizedHeaders.RU },
         { UILanguage.EN, json.LocalizedHeaders.EN }
     });
 }
예제 #2
0
        internal static IUIElementModel CreateElementModel(JsonDTO json, UILanguage language)
        {
            var type    = Type.GetType($"SophiApp.Models.{json.Type}");
            var element = Activator.CreateInstance(type, json) as IUIElementModel;

            element.SetLocalizationTo(language);
            return(element);
        }
예제 #3
0
        internal static IEnumerable <JsonDTO> ParseJson(byte[] jsonData)
        {
            var matchPattern = @"\n    {(.*?)\n    }";

            return(Regex.Matches(Encoding.UTF8.GetString(jsonData), matchPattern, RegexOptions.Compiled | RegexOptions.Singleline)
                   .Cast <Match>()
                   .Select(match =>
            {
                var dto = new JsonDTO();

                using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(match.Value)))
                {
                    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(JsonDTO));
                    dto = (JsonDTO)jsonSerializer.ReadObject(memoryStream);
                }

                return dto;
            }));
        }