Пример #1
0
        public static void Init()
        {
            var jsonPath = AppDomain.CurrentDomain.BaseDirectory + FilePath;

            if (System.IO.File.Exists(jsonPath))
            {
                using (StreamReader sr = new StreamReader(jsonPath))
                {
                    try
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Converters.Add(new JavaScriptDateTimeConverter());
                        serializer.NullValueHandling = NullValueHandling.Ignore;

                        //构建Json.net的读取流
                        JsonReader reader = new JsonTextReader(sr);
                        //对读取出的Json.net的reader流进行反序列化,并装载到模型中
                        LocationInf = serializer.Deserialize <ItemLocationList>(reader);
                    }
                    catch (Exception ex)
                    {
                        ex.Message.ToString();
                    }
                }

                MergerLocationItems();
            }
            else
            {
                LoadLocationItemDefault();
            }
        }
Пример #2
0
        public static void LoadLocationItemDefault()
        {
            LocationInf = new ItemLocationList();
            var items = GetDefinedItemLocations();

            foreach (var item in items)
            {
                LocationInf.AddItem(item);
            }
        }