public ExpectedExceptionModel Build(AttributeData attributeData) { if (MatchType == null && ExpectedMessage != null) { MatchType = MemberAccess(IdentifierName("MessageMatch"), "Exact"); } if (ExceptionName != null && ExceptionType != null) { throw new InvalidOperationException( "Unable to convert ExpectedException attribute, " + $"both a name: {ExceptionName.ToString()} and a type: {ExceptionType.ToString()} are specified"); } if (ExceptionName is LiteralExpressionSyntax nameLiteral && ExceptionType == null) { var value = nameLiteral.Token.ValueText; ExceptionType = TypeOfExpression(IdentifierName(value)); } if (attributeData == null) { throw new InvalidOperationException($"Required field {nameof(attributeData)} is null."); } ExceptionType ??= IdentifierName("Exception"); return(new ExpectedExceptionModel( attributeData, ExceptionType, UserMessage, ExpectedMessage, MatchType)); }
public override int GetHashCode() { unchecked { var hashCode = (ExceptionName != null ? ExceptionName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ StopOnThrow.GetHashCode(); hashCode = (hashCode * 397) ^ StopUncaught.GetHashCode(); return(hashCode); } }
public bool IsEmpty(CredentialType CredentialType, params string[] ExceptionName) { object Credential = null; switch (CredentialType) { case CredentialType.Discord: Credential = Discord; break; case CredentialType.Imgur: Credential = Imgur; break; case CredentialType.osu: Credential = osu; break; case CredentialType.Sankaku: Credential = Sankaku; break; case CredentialType.WaifuCloud: Credential = WaifuCloud; break; case CredentialType.Twitch: Credential = Twitch; break; case CredentialType.Gelbooru: Credential = Gelbooru; break; } Type Type = Credential.GetType(); PropertyInfo[] Properties = Type.GetProperties(BindingFlags.Public | BindingFlags.Instance); for (int i = 0; i < Properties.Length; i++) { if (Properties[i].PropertyType == typeof(string) && !ExceptionName.Contains(Properties[i].Name)) { string Value = Properties[i].GetValue(Credential) as string; if (string.IsNullOrWhiteSpace(Value)) { return(true); } } } return(false); }
protected override IEnumerable <Command> OnDrop(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context) { yield return(new Command() .Append($"DROP EXCEPTION {ExceptionName.AsSqlIndentifier()}")); }
protected override IEnumerable <Command> OnCreate(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context) { yield return(new Command() .Append($"CREATE OR ALTER EXCEPTION {ExceptionName.AsSqlIndentifier()} '{SqlHelper.DoubleSingleQuotes(Message)}'")); }
static void Main(string[] args) { //1. Create a list which will store 5 student names and then display it search it index number try { var Names = new List <string>(); Names.Capacity = 5; ExceptionName en = new ExceptionName(); for (int i = 0; i < Names.Capacity; i++) { Console.WriteLine($"Enter {i + 1} name :"); Names.Add(Console.ReadLine()); } Console.WriteLine($"-------------------------------------------------------------------------------------------------------------"); Console.WriteLine($"Enter a name which you want to search : "); string name = Console.ReadLine(); int index = en.FindName(Names, name); Console.WriteLine($"Name {name} is at {index}"); } catch (Exception e) { Console.WriteLine(e.Message); } Stack ages = new Stack(); bool newAge = true; while (newAge == true) { Console.WriteLine($"-------------------------------------------------------------------------------------------------------------"); Console.WriteLine($"Enter a age"); ages.Push(Convert.ToInt32(Console.ReadLine())); Console.WriteLine($"Enter true to enter another age or false to exit"); newAge = Convert.ToBoolean(Console.ReadLine()); } Console.WriteLine($"-------------------------------------------------------------------------------------------------------------"); Console.WriteLine($"Printing ages in last in first out order"); for (int i = 0; i <= ages.Count - 1; i++) { Console.WriteLine($"{ages.ToArray()[i]}"); } // Store a product information in map object. Key will be a product item and value will be the price of that product. //Search the product by product name. ExceptionProduct ep = new ExceptionProduct(); IDictionary <string, int> products = new Dictionary <string, int>(); try { bool newProduct = true; while (newProduct == true) { Console.WriteLine($"-------------------------------------------------------------------------------------------------------------"); Console.WriteLine($"Do you want to add a product?Enter 'yes' or 'no'"); string flag = Console.ReadLine(); if (flag.ToLower() == "yes") { newProduct = true; Console.WriteLine($"Enter product name and price respectively:"); string productName = Console.ReadLine(); ep.ValidateProduct(products, productName); int price = Convert.ToInt32(Console.ReadLine()); ep.validatePrice(price); products.Add(productName, price); } else { newProduct = false; } } } catch (Exception e) { Console.WriteLine(e.Message); } try { Console.WriteLine($"-------------------------------------------------------------------------------------------------------------"); Console.WriteLine($"Enter product name to find it out..."); string ProductName = Console.ReadLine(); bool flagProduct = ep.FindProduct(products, ProductName); if (flagProduct == true) { Console.WriteLine($"product is founded successfully.."); } } catch (Exception e) { Console.WriteLine(e.Message); } }