public void Init(string configname = "config.json") { LogManager.Instance.Log(ELogtype.Info, "Config Init :" + configname); var context = System.IO.File.ReadAllText(configname); ConfigData = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Config>(context); }
private void LoadPresetNames(Models.Config config) { foreach (var preset in config.Presets) { nameToPreset[preset.Name] = preset; } }
public JsonResult Select(objBST obj)//string sort, string order, string search, int offset = 0, int limit = 10, int flag = 1 { var index = 0; var qry = ""; var cdt = ""; try { var json = new TM.Helper.TMHelperJson(Server.MapPath("~/Systems/config.json")); _Config = json.LoadJson <Models.Config>(); if (_Config.connection.Count < 1) { return(Json(new { total = 0, rows = new List <string>() }, JsonRequestBehavior.AllowGet)); } //Get total item var total = _Config.connection.Count; //Sort And Orders //Page Site var rs = _Config.connection.Skip(obj.offset).Take(obj.limit).ToList(); var ReturnJson = Json(new { total = total, rows = rs }, JsonRequestBehavior.AllowGet); ReturnJson.MaxJsonLength = int.MaxValue; return(ReturnJson); } catch (Exception ex) { return(Json(new { danger = "Không tìm thấy dữ liệu, vui lòng thực hiện lại!" }, JsonRequestBehavior.AllowGet)); } finally { } //return Json(new { success = "Cập nhật thành công!" }, JsonRequestBehavior.AllowGet); }
private void ActivateDefaultPreset(Models.Config config) { if (config.Default != null && nameToPreset.TryGetValue(config.Default, out Preset p)) { ActivatePreset(p, 0); } }
public void ShouldHaveDefaultConfigValues() { var config = new Models.Config("", "", "", "test"); Assert.IsTrue(config.TempZipDir.Contains($"{System.IO.Path.GetTempPath()}\\S3ZipSharp\\")); Assert.IsTrue(config.TempZipPath.Contains(@"tmp")); Assert.AreEqual(CompressionLevel.Default, config.CompressionLevel); }
public override System.Web.Mvc.ActionResult Edit(Models.Config config) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "config", config); EditOverride(callInfo, config); return(callInfo); }
public JsonResult Get(string user) { var config = new Models.Config(); var commInterface = _grp.CommInterface; try { config.DHCP = commInterface.NativeInfo.GetIPProperties().GetIPv4Properties().IsDhcpEnabled; } catch (PlatformNotSupportedException) { config.DHCP = true; } config.MAC = string.Join(":", commInterface.NativeInfo.GetPhysicalAddress().GetAddressBytes().Select(x => BitConverter.ToString(new byte[] { x }))); config.IPAddress = commInterface.SocketLiteInfo.IpAddress; config.NetMask = commInterface.NativeInfo.GetIPProperties().UnicastAddresses.Where(x => (x.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && x.Address.ToString() == config.IPAddress)) .Select(x => x.IPv4Mask) .FirstOrDefault() .ToString(); config.Gateway = commInterface.SocketLiteInfo.GatewayAddress; config.ProxyAddress = ""; config.ProxyPort = 0; config.Name = Environment.MachineName; config.ZigbeeChannel = 15; config.UTC = DateTime.UtcNow.ToString(); config.LocalTime = DateTime.Now.ToString(); config.TimeZone = TimeZoneInfo.Local.ToString(); // authentication if (_grp.AuthenticatorInstance.IsValidUser(user)) { var users = _grp.DatabaseInstance.GetCollection <Models.User>("users"); config.WhiteList = new Dictionary <string, Models.WhiteListItem>(); foreach (var u in users.FindAll()) { config.WhiteList[u.Id] = new Models.WhiteListItem { LastUsedDate = u.LastUsedDate.ToString(), CreateDate = u.CreateDate.ToString(), Name = u.Name }; } } config.SWVersion = "1809121051"; config.APIVersion = "1.24.0"; config.LinkButton = true; config.PortalConnection = ""; config.PortalServices = false; config.PortalState = "none"; config.BridgeId = $"{config.MAC.Substring(0, 6)}FFFE{config.MAC.Substring(6)}"; config.ModelId = "BSB002"; return(Json(config)); }
public async Task GetConfig() { string configURL = "https://api.themoviedb.org/3/configuration?api_key=" + apiKey; HttpResponseMessage responsemsg = await client.GetAsync(configURL); string content = await responsemsg.Content.ReadAsStringAsync(); APIConfig = JsonConvert.DeserializeObject <Models.Config>(content); }
public TwitchClientTests(Fixtures.UserSecretsFixture fixture) { var config = new Models.Config { BearerToken = fixture.BearerToken, ClientId = fixture.ClientId, ClientSecret = fixture.ClientSecret, }; _sut = new TwitchClient(config); }
//public CopyConfig(string consumerKey, string consumerSecret) //{ // Config = new Config() // { // ConsumerKey = consumerKey, // ConsumerSecret = consumerSecret // }; //} public CopyAuth(string callbackURL, string consumerKey, string consumerSecret, Models.Scope scope) { CallbackURL = callbackURL; Scope = scope; Config = new Models.Config() { ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }; }
/// <summary> /// 获取配置文件 /// </summary> /// <param name="context"></param> /// <returns></returns> public Models.Config GetConfig() { var doc = GetXDocument(); var config = new Models.Config() { QrCodeId = int.Parse(doc.Root.Element("QrCodeId").Value), DownloadCount = int.Parse(doc.Root.Element("DownloadCount").Value), Versions = doc.Root.Element("Versions").Elements("Version").Select(z => z.Value).ToList() }; return config; }
public PresetService(Models.Config config, GroupService groupService, LightService lightService) { if (config is null) { throw new ArgumentNullException(nameof(config)); } this.groupService = groupService; this.lightService = lightService; this.tokenSource = new CancellationTokenSource(); this.nameToPreset = new Dictionary <string, Preset>(); LoadPresetNames(config); ActivateDefaultPreset(config); }
public ActionResult Config(Models.Config config) { ConfigRepo = config; string url = string.Format("https://cdn.optimizely.com/json/{0}.json", config.ProjectId); // will throw exception if invalid ProjectId using (var client = new System.Net.WebClient()) config.ProjectConfigJson = FormatJson(client.DownloadString(url)); Optimizely = new Optimizely( datafile: config.ProjectConfigJson, eventDispatcher: null, logger: Logger, errorHandler: InMemoryHandler, skipJsonValidation: false); return(RedirectToAction("Config")); }
public void Init(Models.Config config) { Config = config; limitingService = LimitingFactory.Build(Config.limit.LimitingType, Config.limit.MaxTPS, Config.limit.MaxServiceQum, Config.limit.MaxFreq); }
public static string BuildConfigString(Models.Config c) { return(JsonConvert.SerializeObject(c)); }
partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Models.Config config);
public MainViewModel(ViberDb db) { _db = db; LoadData(); Config = new Models.Config(); }
public ValuesController(IOptionsMonitor <Models.Config> config) { _config = config.CurrentValue; }
public void Init(Models.Config config) { Config = config; connectionManager = new NetConnectionManager(); connectionManager.Init(config); }