public static List <string> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "PasswordGenerator/String")] HttpRequest req, ILogger log, ExecutionContext executionContext) { log.LogInformation("PasswordGeneratorString function processed a request."); StringConfig config = new StringConfig(); string body = req.ReadAsStringAsync().Result; if (!string.IsNullOrEmpty(body)) { // Deserialize config object from body config = JsonConvert.DeserializeObject <StringConfig>(body); } else { // Deserialize config object from parameters config = JsonConvert.DeserializeObject <StringConfig>(JsonConvert.SerializeObject(req.GetQueryParameterDictionary())); } List <string> passwords = new List <string>(); for (int i = 0; i < config.NumberOfPasswords; i++) { passwords.Add(Common.GenerateStringPassword(config)); } return(passwords); }
public static string GenerateStringPassword(StringConfig config) { string password = ""; // Select list of all desired characters string chars = ""; if (config.Uppercase) { chars += string.Join("", config.UppercaseAlphabet.ToUpper().ToList().Distinct()); } if (config.Lowercase) { chars += string.Join("", config.LowercaseAlphabet.ToLower().ToList().Distinct()); } if (config.Numbers) { chars += string.Join("", config.NumericAlphabet.ToList().Distinct()); } if (config.SpecialCharacters) { chars += string.Join("", config.SpecialCharacterAlphabet.ToList().Distinct()); } password = GetRandomString(config.Length, chars); return(password); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogCustomAttributeDefinition other && ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Description == null && other.Description == null) || (Description?.Equals(other.Description) == true)) && ((SourceApplication == null && other.SourceApplication == null) || (SourceApplication?.Equals(other.SourceApplication) == true)) && ((AllowedObjectTypes == null && other.AllowedObjectTypes == null) || (AllowedObjectTypes?.Equals(other.AllowedObjectTypes) == true)) && ((SellerVisibility == null && other.SellerVisibility == null) || (SellerVisibility?.Equals(other.SellerVisibility) == true)) && ((AppVisibility == null && other.AppVisibility == null) || (AppVisibility?.Equals(other.AppVisibility) == true)) && ((StringConfig == null && other.StringConfig == null) || (StringConfig?.Equals(other.StringConfig) == true)) && ((NumberConfig == null && other.NumberConfig == null) || (NumberConfig?.Equals(other.NumberConfig) == true)) && ((SelectionConfig == null && other.SelectionConfig == null) || (SelectionConfig?.Equals(other.SelectionConfig) == true)) && ((CustomAttributeUsageCount == null && other.CustomAttributeUsageCount == null) || (CustomAttributeUsageCount?.Equals(other.CustomAttributeUsageCount) == true)) && ((Key == null && other.Key == null) || (Key?.Equals(other.Key) == true))); }
public IActionResult Index() { // Try and get cookies string wordConfigCookie = _httpContextAccessor.HttpContext.Request.Cookies["wordConfig"]; string stringConfigCookie = _httpContextAccessor.HttpContext.Request.Cookies["stringConfig"]; WordConfig wordConfig = new WordConfig(); if (!string.IsNullOrEmpty(wordConfigCookie)) { wordConfig = JsonConvert.DeserializeObject <WordConfig>(wordConfigCookie); } StringConfig stringConfig = new StringConfig(); if (!string.IsNullOrEmpty(stringConfigCookie)) { stringConfig = JsonConvert.DeserializeObject <StringConfig>(stringConfigCookie); } TempData.Put("WordConfig", wordConfig); TempData.Put("StringConfig", stringConfig); return(View("~/Views/Projects/PasswordGenerator/Index.cshtml")); }
protected void ToString(List <string> toStringOutput) { toStringOutput.Add($"Type = {(Type == null ? "null" : Type.ToString())}"); toStringOutput.Add($"Name = {(Name == null ? "null" : Name == string.Empty ? "" : Name)}"); toStringOutput.Add($"Description = {(Description == null ? "null" : Description == string.Empty ? "" : Description)}"); toStringOutput.Add($"SourceApplication = {(SourceApplication == null ? "null" : SourceApplication.ToString())}"); toStringOutput.Add($"AllowedObjectTypes = {(AllowedObjectTypes == null ? "null" : $"[{ string.Join(", ", AllowedObjectTypes)} ]")}"); toStringOutput.Add($"SellerVisibility = {(SellerVisibility == null ? "null" : SellerVisibility.ToString())}"); toStringOutput.Add($"AppVisibility = {(AppVisibility == null ? "null" : AppVisibility.ToString())}"); toStringOutput.Add($"StringConfig = {(StringConfig == null ? "null" : StringConfig.ToString())}"); toStringOutput.Add($"NumberConfig = {(NumberConfig == null ? "null" : NumberConfig.ToString())}"); toStringOutput.Add($"SelectionConfig = {(SelectionConfig == null ? "null" : SelectionConfig.ToString())}"); toStringOutput.Add($"CustomAttributeUsageCount = {(CustomAttributeUsageCount == null ? "null" : CustomAttributeUsageCount.ToString())}"); toStringOutput.Add($"Key = {(Key == null ? "null" : Key == string.Empty ? "" : Key)}"); }
/// <summary> /// 得到备注的描述字符串(不包括前后的 (* *))。 /// </summary> /// <returns>备注的描述字符串。</returns> public override string GetCommentDecl() { StringConfig config = new StringConfig(string.Empty); if (!string.IsNullOrEmpty(this.Comment)) { config["_C"] = this.Comment; } if (!string.IsNullOrEmpty(this.UUID)) { config["UUID"] = this.UUID; } return(config.ToString()); }
/// <summary> /// 将文本行描述的变量定义,解析为变量对象。 /// </summary> /// <param name="decl">变量的文本行描述</param> /// <param name="typeCreation">自动创建变量数据类型的方式</param> /// <returns>变量对象,null 表示解析失败</returns> public static new ViGlobalVariable Parse(string decl, ViTypeCreation typeCreation) { ViGlobalVariable variable = Parse(decl, typeCreation, (name, dataType) => new ViGlobalVariable(name, dataType)) as ViGlobalVariable; if (variable == null) { return(null); } StringConfig config = new StringConfig(variable.Comment); variable.Comment = config["_C"]; variable.UUID = config["UUID"]; // return(variable); }
protected virtual BaseLogger CreateLoggers() { var ldcConfig = new StringConfig(Args, 0); var xmlConfig = new XmlConfig(ConfigFile, 1); Configuration = new ConfigPackage(); Configuration.AddSource(ldcConfig); Configuration.AddSource(xmlConfig); var log = new MultiLogger(); ConsoleLogger = new ConsoleLogger(CfgConsole, Configuration); FileLogger = new FileLogger(CfgFile, Configuration); log.AddLogger(ConsoleLogger); log.AddLogger(FileLogger); return(log); }
protected override BaseLogger CreateLoggers() { var ldcConfig = new StringConfig(Args, 0); var xmlConfig = new XmlConfig(ConfigFile, 1); Configuration = new ConfigPackage(); Configuration.AddSource(ldcConfig); Configuration.AddSource(xmlConfig); var log = new MultiLogger(); ConsoleLogger = new NotifyIconLogger(CfgConsole, Configuration, this, GetType().Assembly.GetName().Name, 1); FileLogger = new FileLogger(CfgFile, Configuration); log.AddLogger(ConsoleLogger); log.AddLogger(FileLogger); return(log); }
public void ReadConfig() { if (isLoadFinish == false) { return; } isLoadFinish = false; lock (LockObject) { GameSystem.Instance.readConfigCnt += 1; } UnityEngine.Debug.Log("Config reading " + name); string text = ResourceLoadManager.Instance.GetConfigText(name); if (text == null) { UnityEngine.Debug.LogError("LoadConfig failed: " + name); return; } constStringConfig.Clear(); //读取以及处理XML文本的类 XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(name, text); //解析XML的过程 XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes; foreach (XmlElement xe in nodelist) { StringConfig data = new StringConfig(); foreach (XmlElement xel in xe) { if (xel.Name == "name") { data.name = xel.InnerText; } else if (xel.Name == "info") { data.info = xel.InnerText; } } if (!constStringConfig.ContainsKey(data.name)) { constStringConfig.Add(data.name, data.info); } } }
/// ----------------------------------------------------------------------------- /// <summary> /// Initialisation des loggers /// </summary> /// <returns>un MultiLogger lié à une source fichier et console</returns> /// ----------------------------------------------------------------------------- protected override BaseLogger CreateLoggers() { var ldcConfig = new StringConfig(Args, 0); var xmlConfig = new XMLConfig(ConfigFile, 1); Configuration = new ConfigPackage(); Configuration.AddSource(ldcConfig); Configuration.AddSource(xmlConfig); var log = new MultiLogger(); // on utilise le référence d'un BdtGuiClient au lieu de passer directement un NotifyIcon car à ce stade // on ne peut pas créer de formulaire, car la Culture serait incorrecte, le fichier de configuration // n'étant pas déjà parsé ConsoleLogger = new NotifyIconLogger(CfgConsole, Configuration, this, GetType().Assembly.GetName().Name, 1); FileLogger = new FileLogger(CfgFile, Configuration); log.AddLogger(ConsoleLogger); log.AddLogger(FileLogger); return(log); }
public override int GetHashCode() { int hashCode = 1892852076; if (Type != null) { hashCode += Type.GetHashCode(); } if (Name != null) { hashCode += Name.GetHashCode(); } if (Description != null) { hashCode += Description.GetHashCode(); } if (SourceApplication != null) { hashCode += SourceApplication.GetHashCode(); } if (AllowedObjectTypes != null) { hashCode += AllowedObjectTypes.GetHashCode(); } if (SellerVisibility != null) { hashCode += SellerVisibility.GetHashCode(); } if (AppVisibility != null) { hashCode += AppVisibility.GetHashCode(); } if (StringConfig != null) { hashCode += StringConfig.GetHashCode(); } if (NumberConfig != null) { hashCode += NumberConfig.GetHashCode(); } if (SelectionConfig != null) { hashCode += SelectionConfig.GetHashCode(); } if (CustomAttributeUsageCount != null) { hashCode += CustomAttributeUsageCount.GetHashCode(); } if (Key != null) { hashCode += Key.GetHashCode(); } return(hashCode); }
public StringConfigTests() { _configRepository = Substitute.For <IConfigRepository>(); _subject = new StringConfig(_configRepository); }