ReadJson() публичный Метод

public ReadJson ( JsonReader reader, Type objectType, existingValue, bool hasExistingValue, JsonSerializer serializer ) : LoginRequest
reader JsonReader
objectType Type
hasExistingValue bool
serializer JsonSerializer
Результат LoginRequest
Пример #1
0
        public ConfigurationBuilder AddDefault()
        {
            Assembly   ass    = Assembly.GetEntryAssembly();
            Stream     stream = ass.LoadStream("HakeQuick.default.json");
            RecordBase record = Converter.ReadJson(stream);

            stream.Dispose();

            if (record is SetRecord set)
            {
                if (values == null)
                {
                    values = set;
                }
                else
                {
                    values.Combine(set);
                }
            }
            else
            {
                throw new Exception("invalid configuration format");
            }

            return(this);
        }
        public static void Initialize(ICurrentEnvironment env)
        {
            Stream    defaultConfigStream = Assembly.GetExecutingAssembly().LoadStream("Chrome.BookmarkSearch.default.json");
            SetRecord defaultConfig       = Converter.ReadJson(defaultConfigStream) as SetRecord;

            string configPath = env.ConfigDirectory + "\\bookmarksearch.json";

            if (File.Exists(configPath))
            {
                try
                {
                    Stream    userConfigStream = File.OpenRead(configPath);
                    SetRecord userConfig       = Converter.ReadJson(userConfigStream) as SetRecord;
                    userConfigStream.Dispose();
                    defaultConfig.Combine(userConfig);
                }
                catch
                {
                }
            }
            else
            {
                try
                {
                    defaultConfigStream.Seek(0, SeekOrigin.Begin);
                    FileStream configStream = File.Create(configPath);
                    defaultConfigStream.CopyTo(configStream);
                    configStream.Flush();
                    configStream.Dispose();
                }
                catch
                {
                }
            }
            defaultConfigStream.Dispose();
            ConfigurationRecord = defaultConfig;
            Config = new SearchConfig()
            {
                SearchUrl    = ConfigurationRecord.ReadAs <bool>("allow_url_search"),
                EnableSearch = ConfigurationRecord.ReadAs <bool>("enable")
            };

            Bookmarks = BookmarkCollection.Retrive();
            SearchPatternErrorAction = new ErrorAction(null, "搜索模式错误", "搜索模式错误");
        }
Пример #3
0
        public ConfigurationBuilder AddJson(string file)
        {
            Stream     stream = File.OpenRead(file);
            RecordBase record = Converter.ReadJson(stream);

            stream.Dispose();
            if (record is SetRecord set)
            {
                if (values == null)
                {
                    values = set;
                }
                else
                {
                    values.Combine(set);
                }
            }
            else
            {
                throw new Exception("invalid configuration format");
            }
            return(this);
        }