/// <summary> /// Initializes a new instance of the <see cref="Configuration" /> class /// </summary> public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "http://petstore.swagger.io:80/v2") : this() { if (string.IsNullOrEmpty(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "https://localhost:44300") : this() { if (string.IsNullOrWhiteSpace(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
/// <summary> /// Initializes a new instance of the <see cref="Configuration" /> class /// </summary> public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "https://api.bag.acceptatie.kadaster.nl/esd/huidigebevragingen/v1") : this() { if (string.IsNullOrWhiteSpace(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
/// <summary> /// Initializes a new instance of the <see cref="Configuration" /> class /// </summary> public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "https://13d16e9d-d8b1-4ef4-bc4a-ed8156b2b159.mock.pstmn.io") : this() { if (string.IsNullOrWhiteSpace(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
/// <summary> /// Initializes a new instance of the <see cref="Configuration" /> class /// </summary> public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "https://virtserver.swaggerhub.com/VNGRealisatie/api/brp_update_api") : this() { if (string.IsNullOrWhiteSpace(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
/// <summary> /// Initializes a new instance of the <see cref="Configuration" /> class /// </summary> public Configuration( IDictionary <string, string> defaultHeader, IDictionary <string, string> apiKey, IDictionary <string, string> apiKeyPrefix, string basePath = "https://jsapi-integration.us-east-1.elasticbeanstalk.com") : this() { if (string.IsNullOrEmpty(basePath)) { throw new ArgumentException("The provided basePath is invalid.", "basePath"); } if (defaultHeader == null) { throw new ArgumentNullException("defaultHeader"); } if (apiKey == null) { throw new ArgumentNullException("apiKey"); } if (apiKeyPrefix == null) { throw new ArgumentNullException("apiKeyPrefix"); } BasePath = basePath; foreach (var keyValuePair in defaultHeader) { DefaultHeader.Add(keyValuePair); } foreach (var keyValuePair in apiKey) { ApiKey.Add(keyValuePair); } foreach (var keyValuePair in apiKeyPrefix) { ApiKeyPrefix.Add(keyValuePair); } }
static DefaultHeader CreateStartTroopHeader(String file, Dictionary <String, Dictionary <String, Object> > starttroopConfig) { List <BinElement> startTroopChanges = new List <BinElement>(); List <BinElement> lordStrengthChanges = new List <BinElement>(); List <BinElement> lordTypeChanges = new List <BinElement>(); //look for each individual AI from Rat to Abbot //AI's with Index from 1 to 16 , 17 = europ lord , 18 = arab lord for (int playerIndex = 1; playerIndex <= 18; playerIndex++) { string indexKey = playerIndex.ToString(); Dictionary <String, Object> Player; if (starttroopConfig.TryGetValue(indexKey, out Player)) { startTroopChanges.AddRange(ParsePlayer(Player)); // Only attempt to parse lord strength and dot configurations for AI characters if (playerIndex < 17) { Dictionary <String, BinElement> lords; try { lords = ParseLordType(Player); } catch (Exception e) { throw e; } lordStrengthChanges.Add(lords["Dots"]); lordStrengthChanges.Add(lords["Strength"]); lordTypeChanges.Add(lords["Type"]); } if (playerIndex == 16) { startTroopChanges.Add(new BinSkip(0xF0)); } } else { startTroopChanges.Add(new BinSkip(80)); startTroopChanges.Add(new BinSkip(80)); startTroopChanges.Add(new BinSkip(80)); if (playerIndex < 17) { lordStrengthChanges.Add(new BinSkip(0x4)); lordStrengthChanges.Add(new BinSkip(0x4)); lordTypeChanges.Add(new BinSkip(0x1)); } if (playerIndex == 16) { startTroopChanges.Add(new BinSkip(0xF0)); } } } BinaryEdit troopEdit = new BinaryEdit(troopBlockFile); troopEdit.AddRange(startTroopChanges); BinaryEdit lordStrengthEdit = new BinaryEdit(lordStrengthBlockFile); lordStrengthEdit.AddRange(lordStrengthChanges); BinaryEdit lordTypeEdit = new BinaryEdit(lordTypeBlockFile); lordTypeEdit.AddRange(lordTypeChanges); DefaultHeader header = new DefaultHeader("s_" + file, true) { troopEdit, lordStrengthEdit, lordTypeEdit }; return(header); }
/// <summary> /// Add default header. /// </summary> /// <param name="key">Header field name.</param> /// <param name="value">Header field value.</param> /// <returns></returns> public void AddDefaultHeader(string key, string value) { DefaultHeader.Add(key, value); }
public static void Load(bool changesOnly = false) { List <string> aicConfigurationList = null; List <string> aivConfigurationList = null; List <string> resourceConfigurationList = null; List <string> startTroopConfigurationList = null; if (File.Exists(ConfigFile)) { using (StreamReader sr = new StreamReader(ConfigFile)) { string line; while ((line = sr.ReadLine()) != null) { if (Regex.Replace(@"\s+", "", line).Contains("aic_")) { if (aicConfigurationList == null) { aicConfigurationList = new List <string>(); } aicConfigurationList.Add(line); continue; } else if (Regex.Replace(@"\s+", "", line).StartsWith("aiv_")) { if (aivConfigurationList == null) { aivConfigurationList = new List <string>(); } aivConfigurationList.Add(line); continue; } else if (Regex.Replace(@"\s+", "", line).StartsWith("res_")) { if (resourceConfigurationList == null) { resourceConfigurationList = new List <string>(); } resourceConfigurationList.Add(line); continue; } else if (Regex.Replace(@"\s+", "", line).StartsWith("s_")) { if (startTroopConfigurationList == null) { startTroopConfigurationList = new List <string>(); } startTroopConfigurationList.Add(line); continue; } string[] changeLine = line.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries).Select(str => str.Trim()).ToArray(); if (changeLine.Length < 2) { continue; } string changeKey = changeLine[0]; string changeSetting = changeLine[1]; if (!changesOnly) { if (changeKey == "Path") { Configuration.Path = changeSetting; } else if (changeKey == "Language") { if (int.TryParse(changeSetting, out int result)) { Configuration.Language = result; } } } if (changeKey == "Path" || changeKey == "Language") { continue; } Change change = Version.Changes.Find(c => c.TitleIdent == changeKey); if (change == null) { continue; } int numChanges = changeSetting.Count(ch => ch == '='); string[] changes = changeSetting.Split(new char[] { '}' }, numChanges, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < numChanges; i++) { string headerKey = changes[i].Split('=')[0].Replace(" ", "").Replace("{", String.Empty); string headerValue = changes[i].Split('=')[1].Replace(" ", "").Replace("{", String.Empty).Replace("}", String.Empty); DefaultHeader header = change.FirstOrDefault(c => c.DescrIdent == headerKey); header.LoadValueString(headerValue); } } } } AICChange.LoadConfiguration(aicConfigurationList); AIVChange.LoadConfiguration(aivConfigurationList); ResourceChange.LoadConfiguration(resourceConfigurationList); StartTroopChange.LoadConfiguration(startTroopConfigurationList); }
public static void LoadChanges() { loading = true; if (File.Exists(ConfigFile)) { using (StreamReader sr = new StreamReader(ConfigFile)) { string line; while ((line = sr.ReadLine()) != null) { int index = line.IndexOf('='); if (index < 0) { continue; } // change string changeStr = line.Remove(index).Trim(); Change change = Version.Changes.Find(c => c.TitleIdent == changeStr); if (change == null) { continue; } int startIndex = line.IndexOf('{', index + 1); if (startIndex < 0) { continue; } startIndex++; int endIndex = line.LastIndexOf('}'); if (endIndex < 0) { continue; } // headers while (true) { index = line.IndexOf('=', startIndex); if (index < 0) { break; } string headerStr = line.Substring(startIndex, index - startIndex).Trim(); startIndex = index + 1; DefaultHeader header = change.FirstOrDefault(c => c.DescrIdent == headerStr); if (header == null) { continue; } startIndex = line.IndexOf('{', startIndex); if (startIndex < 0) { break; } index = startIndex + 1; startIndex = line.IndexOf('}', index); if (startIndex < 0 || startIndex == endIndex) { break; } header.LoadValueString(line.Substring(index, startIndex - index)); startIndex++; } } } } loading = false; }
/// <summary> /// Add default header. /// </summary> /// <param name="Key">Header field name.</param> /// <param name="Value">Header field value.</param> /// <returns></returns> public void AddDefaultHeader(string Key, string Value) { DefaultHeader.Add(Key, Value); }