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, "搜索模式错误", "搜索模式错误"); }