public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Invoice_id < 1) { Check.isValid = false; Check.list.Add("Invoice_id must be greater than 0"); } if (Employee_id < 1) { Check.isValid = false; Check.list.Add("Employee_id must be greater than 0"); } if (Amount > 99999999.99m || Amount < -99999999.99m) { Check.isValid = false; Check.list.Add("Amount must be between -99999999.99 and 99999999.99"); } if (Hours > 99999999.99m || Hours < -99999999.99m) { Check.isValid = false; Check.list.Add("Hours must be between -99999999.99 and 99999999.99"); } return(Check); }
public void SetMail(string mail) { TypeCheck.IsNullOrEmpty(mail); CommonPolicy.CheckMail(mail); //TODO: Fire event to notify supplier about updated mail address Email = mail; }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Part_id < 1) { Check.isValid = false; Check.list.Add("Part_id must be greater than 0"); } if (Part_instance_id < 1) { Check.isValid = false; Check.list.Add("Part_instance_id must be greater than 0"); } if (!(State is null)) { if (State.Length > 32 || State.Length < 0) { Check.isValid = false; Check.list.Add("State is restricted to 32 characters"); } } if (Price > 99999999.99m || Price < -99999999.99m) { Check.isValid = false; Check.list.Add("Price must be between -99999999.99 and 99999999.99"); } if (Work_order_id < 0) { Check.isValid = false; Check.list.Add("Work_order_id must be positive or 0"); } return(Check); }
public IEnumerable <ProductDto> GetProductsByCategory(Category category) { TypeCheck.IsNull(category); TypeCheck.IsUsableAsId(category.Id); var filter = new ProductByCategoryFilter(category.Id); return(_repo.Find(filter).Select(i => i.ToDto())); }
static void Main(string[] args) { var assignment = new TypeCheck(); var typecast = new TypeCasts(); var overriding = new OverRideClass(); Console.Read(); }
static void Main(string[] args) { if (args.Length == 0 || args[0] == "-h") { Console.WriteLine(helpMessage); Environment.Exit(0); } else { if (args[0] == "-w") { executionType = TypeCheck.Server; } else if (args[0] == "-s") { executionType = TypeCheck.Service; } else { Console.WriteLine(helpMessage); Environment.Exit(0); } if (args.Length >= 2 && !Uri.TryCreate(args[1], UriKind.Absolute, out resource)) { Console.WriteLine("Invalid address"); } if (args.Length > 3 && args[2] == "-t") { checkTimer = new Timer(); if (int.TryParse(args[3], out int periodicity)) { checkTimer.Interval = 1000 * 60 * periodicity; } else { checkTimer.Interval = 1000 * 60 * 1; } checkTimer.Elapsed += CheckTimer_Elapsed; checkTimer.AutoReset = true; checkTimer.Enabled = true; Console.WriteLine("{0} - Check {1} started. Press ENTER or CTRL + C to finish." , DateTime.UtcNow, resource); Console.ReadLine(); Console.WriteLine("Check finished."); } else { Console.WriteLine("Elapsed {0} - {1}", DateTime.UtcNow, RunCheck()); } } Environment.Exit(0); }
public void SetContact(string fullName, string email) { TypeCheck.IsNullOrEmpty(fullName); CommonPolicy.CheckMail(TypeCheck.IsNullOrEmpty(email)); Contact = fullName; ContactEMail = email; //TODO: Fire an event to notify person about being customer as our customer }
public Employee GetManager(int employeeId) { var employee = FindById(employeeId); if (TypeCheck.IsUsableAsId(employee.ManagerId)) { var manager = FindById(employee.ManagerId.Value); return(manager); } return(null); }
public TypeCheck SQLSchemaValidParameters_MINUS_CUSTOMER_ID() { TypeCheck Check = SQLSchemaValidParameters(); Check.list.Remove("CustomerID must be greater than 0"); if (Check.list.Count() > 0) { return(Check); } return(new TypeCheck()); }
public bool Parse() { //e = null; e = MatchStm(); // Match(TokenType.EoFSym); MatchToken(TokenType.EOFSYM); Tc = new TypeCheck(e, Functions); bool tsuccess = Tc.Check(); e = Tc.e; //Exp is modified in TypeCheck return success && tsuccess; //Return success if both parsing and typechecking succeed. }
public TypeCheck SQLSchemaValidParameters_MINUS_INSTANCE_ID() { TypeCheck Check = SQLSchemaValidParameters(); Check.list.Remove("Part_instance_id must be greater than 0"); if (Check.list.Count() > 0) { return(Check); } return(new TypeCheck()); }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (!(Vehicle_model is null)) { if (Vehicle_model.Length > 32 || Vehicle_model.Length < 0) { Check.isValid = false; Check.list.Add("Vehicle_model is restricted to 32 characters"); } }
public bool Parse() { //e = null; e = MatchStm(); // Match(TokenType.EoFSym); MatchToken(TokenType.EOFSYM); Tc = new TypeCheck(e, Functions); bool tsuccess = Tc.Check(); e = Tc.e; //Exp is modified in TypeCheck return(success && tsuccess); //Return success if both parsing and typechecking succeed. }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (!(VIN is null)) { if (VIN.Length > 17 || VIN.Length < 0) { Check.isValid = false; Check.list.Add("VIN is restricted to 17 characters"); } }
public static Supplier Create(string companyName, string manager, string email, string phone) { var supplier = new Supplier(); TypeCheck.IsNullOrEmpty(companyName); TypeCheck.IsNullOrEmpty(manager); TypeCheck.IsNullOrEmpty(phone); supplier.CompanyName = companyName; supplier.Manager = manager; supplier.SetMail(email); supplier.Phone = phone; return(supplier); }
public async Task <T> GetResult <T>() { waitForRequestToBeConfigured.TrySetResult(true); HttpResponseMessage resp = await request; if (typeof(T).IsCastableTo <Exception>() && resp.StatusCode.IsErrorStatus()) { return((T)(object)new NoSuccessError(resp.StatusCode, await GetResult <string>())); } if (HttpStatusCode.OK != resp.StatusCode) { Log.w("response.StatusCode=" + resp.StatusCode); } if (TypeCheck.AreEqual <T, HttpResponseMessage>()) { return((T)(object)resp); } if (TypeCheck.AreEqual <T, HttpStatusCode>()) { return((T)(object)resp.StatusCode); } if (TypeCheck.AreEqual <T, Headers>()) { return((T)(object) await GetResultHeaders()); } HttpContent content = resp.Content; if (TypeCheck.AreEqual <T, HttpContent>()) { return((T)(object)content); } if (TypeCheck.AreEqual <T, Stream>()) { return((T)(object)await content.ReadAsStreamAsync()); } if (TypeCheck.AreEqual <T, byte[]>()) { return((T)(object)await content.ReadAsByteArrayAsync()); } var respText = await content.ReadAsStringAsync(); if (typeof(T) == typeof(string)) { return((T)(object)respText); } AssertV2.IsNotNull(respText, "respText"); AssertV2.IsNotNull(respText.IsNullOrEmpty(), "respText.IsNullOrEmpty"); try { return(jsonReader.Read <T>(respText)); } catch (JsonReaderException e) { throw new JsonReaderException("Cant parse to JSON: " + respText, e); } }
public void TestTypeMatch() { //TypeMatchのテスト var hoge = TypeCheck.GetParamsPriority(typeof(int), typeof(int)); Assert.AreEqual(ParamsPriority.MatchKind.TypeMatch, hoge.matchkind); hoge = TypeCheck.GetParamsPriority(typeof(float), typeof(float)); Assert.AreEqual(ParamsPriority.MatchKind.TypeMatch, hoge.matchkind); //ImplicitCastMatchのテスト hoge = TypeCheck.GetParamsPriority(typeof(float), typeof(double)); Assert.AreEqual(ParamsPriority.MatchKind.ImplicitCastMatch, hoge.matchkind); //UpCastMatch hoge = TypeCheck.GetParamsPriority(typeof(bool), typeof(object)); Assert.AreEqual(ParamsPriority.MatchKind.UpCastMatch, hoge.matchkind); Assert.AreEqual(2, hoge.upCastNest); hoge = TypeCheck.GetParamsPriority(typeof(SubClass), typeof(SuperClass)); Assert.AreEqual(ParamsPriority.MatchKind.UpCastMatch, hoge.matchkind); Assert.AreEqual(1, hoge.upCastNest); //GenericTypeMatch hoge = TypeCheck.GetParamsPriority(typeof(float), typeof(List <>).GetGenericArguments()[0]); Assert.AreEqual(ParamsPriority.MatchKind.GenericTypeMatch, hoge.matchkind); Assert.AreEqual(1, hoge.concreteness); hoge = TypeCheck.GetParamsPriority(typeof(List <int>), typeof(List <>)); Assert.AreEqual(ParamsPriority.MatchKind.GenericTypeMatch, hoge.matchkind); Assert.AreEqual(2, hoge.concreteness); hoge = TypeCheck.GetParamsPriority(typeof(Dictionary <int, double>), typeof(Dictionary <,>)); Assert.AreEqual(ParamsPriority.MatchKind.GenericTypeMatch, hoge.matchkind); Assert.AreEqual(3, hoge.concreteness); hoge = TypeCheck.GetParamsPriority(typeof(Dictionary <int, double>), typeof(UnitTest1).GetMethod("Foo").GetParameters()[0].ParameterType); Assert.AreEqual(ParamsPriority.MatchKind.GenericTypeMatch, hoge.matchkind); Assert.AreEqual(4, hoge.concreteness); hoge = TypeCheck.GetParamsPriority(typeof(List <List <List <int> > >), typeof(List <>)); Assert.AreEqual(ParamsPriority.MatchKind.GenericTypeMatch, hoge.matchkind); Assert.AreEqual(2, hoge.concreteness); //GetGenericUpCast var hoge2 = TypeCheck.GetGenericUpCastInfo(typeof(char[]), typeof(IEnumerable <>)); Assert.AreEqual(typeof(IEnumerable <char>), hoge2.Value.upCastedType); }
public static Product Create(Category category, Supplier supplier, string name, decimal price, double stock) { var product = new Product(); TypeCheck.IsNull(category); TypeCheck.IsUsableAsId(category.Id); TypeCheck.IsNull(supplier); TypeCheck.IsUsableAsId(supplier.Id); product.SetCategory(category.Id); product.SetName(name); product.SetPrice(price); product.SetStock(stock); product.SetSupplier(supplier.Id); return(product); }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Mechanic_id < 1) { Check.isValid = false; Check.list.Add("Mechanic_id must be greater than 0"); } if (Work_order_id < 1) { Check.isValid = false; Check.list.Add("Work_order_id must be greater than 0"); } return(Check); }
public static Order Create(Customer customer, Employee employee, bool isUrgent, DateTime?shipDate) { TypeCheck.IsNull(customer); TypeCheck.IsNullOrEmpty(customer.Id); TypeCheck.IsNull(employee); TypeCheck.IsUsableAsId(employee.Id); var order = new Order() { CustomerId = customer.Id, EmployeeId = employee.Id }; if (isUrgent) { order.SetAsUrgent(shipDate); } return(order); }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Employee_id < 1) { Check.isValid = false; Check.list.Add("Employee_id must be greater than 0"); } if (!(Password is null)) { if (Password.Length > 128 || Password.Length < 0) { Check.isValid = false; Check.list.Add("Password is restricted to 128 characters"); } }
public async Task <T> GetResult <T>() { HttpResponseMessage resp = await request; if (typeof(T).IsCastableTo <Exception>() && resp.StatusCode.IsErrorStatus()) { return((T)(object)new NoSuccessError(resp.StatusCode, await GetResult <string>())); } AssertV2.IsTrue(HttpStatusCode.OK == resp.StatusCode, "response.StatusCode=" + resp.StatusCode); if (TypeCheck.AreEqual <T, HttpResponseMessage>()) { return((T)(object)resp); } if (TypeCheck.AreEqual <T, HttpStatusCode>()) { return((T)(object)resp.StatusCode); } if (TypeCheck.AreEqual <T, Headers>()) { return((T)(object) await GetResultHeaders()); } HttpContent content = resp.Content; if (TypeCheck.AreEqual <T, HttpContent>()) { return((T)(object)content); } if (TypeCheck.AreEqual <T, Stream>()) { return((T)(object)await content.ReadAsStreamAsync()); } if (TypeCheck.AreEqual <T, byte[]>()) { return((T)(object)await content.ReadAsByteArrayAsync()); } var respText = await content.ReadAsStringAsync(); if (typeof(T) == typeof(string)) { return((T)(object)respText); } AssertV2.IsNotNull(respText, "respText"); AssertV2.IsNotNull(respText.IsNullOrEmpty(), "respText.IsNullOrEmpty"); return(jsonReader.Read <T>(respText)); }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (CustomerID < 1) { Check.isValid = false; Check.list.Add("CustomerID must be greater than 0"); } if (!(Fname is null)) { if (Fname.Length > 128 || Fname.Length < 0) { Check.isValid = false; Check.list.Add("Fname is restricted to 128 characters"); } } if (!(Lname is null)) { if (Lname.Length > 128 || Lname.Length < 0) { Check.isValid = false; Check.list.Add("Lname is restricted to 128 characters"); } } if (!(Phone_number is null)) { if (Phone_number.Length > 15 || Phone_number.Length < 0) { Check.isValid = false; Check.list.Add("Lname is restricted to 15 characters"); } } if (!(Address is null)) { if (Address.Length > 256 || Address.Length < 0) { Check.isValid = false; Check.list.Add("Lname is restricted to 256 characters"); } } return(Check); }
public __Type(Type t, Dictionary <Type, __Type> resolver, GraphQlCustomiseSchema customise, bool isInputType = false) { this.resolver = resolver; this.customiseSchema = customise; dotNetType = t; if (resolver.ContainsKey(t) == false) { resolver[t] = this; } if (TypeCheck.IsNumeric(t) || TypeCheck.IsString(t) || TypeCheck.IsDateTime(t) || TypeCheck.IsBoolean(t)) { ScalarType(); } else if (TypeCheck.IsEnum(t)) { EnumType(); } else if (TypeCheck.IsEnumerableType(t)) { ListType(); } else if (TypeCheck.IsClass(t) && isInputType) { InputObjectType(); } else if (TypeCheck.IsClass(t)) { ObjectOrInterfaceType(__TypeKind.OBJECT); } else if (t.IsInterface) { ObjectOrInterfaceType(__TypeKind.INTERFACE); } else if (TypeCheck.IsValueType(t)) { throw new Exception($"Unexpected value type = {t.Name}"); } else { throw new Exception($"Unexpected type = {t.Name}"); } }
private static void PopulateDatas(ModuleDefinition mod, TypeDefinition type, Dictionary <MetadataToken, IMemberDefinition> mems) { TypeDefinition definition = mems[type.MetadataToken] as TypeDefinition; if (type.BaseType != null) { definition.BaseType = ImportType(type.BaseType, mod, null, mems); } foreach (TypeDefinition definition2 in type.NestedTypes) { PopulateDatas(mod, definition2, mems); } foreach (FieldDefinition definition3 in type.Fields) { if (!definition3.IsLiteral) { (mems[definition3.MetadataToken] as FieldDefinition).FieldType = ImportType(definition3.FieldType, mod, null, mems); } } foreach (MethodDefinition definition4 in type.Methods) { TransportAction visible = TransportAction.Public; if (!TypeCheck.KeepMethod(type, definition4, out visible)) { continue; } MethodAttributes methodAtt = definition4.Attributes; if (visible == TransportAction.Public) { if (methodAtt.HasFlag(MethodAttributes.Private)) { methodAtt &= ~MethodAttributes.Private; } methodAtt |= MethodAttributes.Public; } definition4.Attributes = methodAtt; PopulateMethod(mod, definition4, mems[definition4.MetadataToken] as MethodDefinition, mems); } }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Part_id < 1) { Check.isValid = false; Check.list.Add("Part_id must be greater than 0"); } if (!(Part_name is null)) { if (Part_name.Length > 64 || Part_name.Length < 0) { Check.isValid = false; Check.list.Add("Part_name is restricted to 64 characters"); } } return(Check); }
public static OrderDetail Create(Product product, Order order, double price, double quantity, double discount = 0) { var orderDetail = new OrderDetail(); TypeCheck.IsNull(product); TypeCheck.IsUsableAsId(product.Id); TypeCheck.IsNull(product); TypeCheck.IsUsableAsId(order.Id); OrderDetailPolicy.CheckPrice(price); OrderDetailPolicy.CheckQuantity(quantity); orderDetail.SetProduct(product.Id); orderDetail.SetOrder(order.Id); orderDetail.SetPrice(price); orderDetail.SetQuantity(quantity); if (discount > 0) { orderDetail.SetDiscount(discount); } return(orderDetail); }
public async Task <T> GetResult <T>() { var c = (await request).Content; if (TypeCheck.AreEqual <T, Stream>()) { return((T)(object)await c.ReadAsStreamAsync()); } if (TypeCheck.AreEqual <T, byte[]>()) { return((T)(object)await c.ReadAsByteArrayAsync()); } var respText = await c.ReadAsStringAsync(); if (typeof(T) == typeof(string)) { return((T)(object)respText); } return(jsonReader.Read <T>(respText)); }
public CheckClass(int x, int y, ColorCheck cCheck, MainForm mainForm) { mf = mainForm; X = x; Y = y; typeCheck = TypeCheck.check; colorCheck = cCheck; mustGo = false; pictureBox = new PictureBox(); pictureBox.Size = new Size(mf.nSize, mf.nSize); if (!mf.changeSide) { pictureBox.Location = new Point(mf.nSize * y + mf.leftX, mf.nSize * x + mf.leftY); } else { pictureBox.Location = new Point(mf.nSize * (7 - y) + mf.leftX, mf.nSize * (7 - x) + mf.leftY); } if (colorCheck == ColorCheck.black) { pictureBox.Image = global::Checkers.Properties.Resources.check_black; dest = new int[0, 2]; } else if (colorCheck == ColorCheck.white) { pictureBox.Image = global::Checkers.Properties.Resources.check_white; dest = new int[0, 2]; } else if ((x + y) % 2 == 0) { pictureBox.Image = global::Checkers.Properties.Resources.empty; } else { pictureBox.Image = global::Checkers.Properties.Resources.full; } pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(pictureBox_MouseDown); mainForm.Controls.Add(pictureBox); }
public TypeCheck SQLSchemaValidParameters() { TypeCheck Check = new TypeCheck(); if (Work_order_id < 1) { Check.isValid = false; Check.list.Add("Work_order_id must be greater than 0"); } if (Amount_Due > 99999999.99m || Amount_Due < -99999999.99m) { Check.isValid = false; Check.list.Add("Amount_Due must be between -99999999.99 and 99999999.99"); } if (!(Vehicle_VIN is null)) { if (Vehicle_VIN.Length > 17 || Vehicle_VIN.Length < 0) { Check.isValid = false; Check.list.Add("Vehicle_VIN is restricted to 17 characters"); } }
public void TypeExtension_Examples() { Type MySubClass1 = typeof(MySubClass1); // type.IsSubclassOf<..>() examples: Assert.True(MySubClass1.IsSubclassOf <MyClass1>()); Assert.False(MySubClass1.IsSubclassOf <MySubClass2>()); Assert.True(typeof(MySubClass2).IsSubclassOf <MyClass1>()); Assert.False(typeof(MyClass1).IsSubclassOf <MySubClass1>()); // Checking if 2 types are equal using the TypeCheck class: Assert.True(TypeCheck.AreEqual <MyClass1, MyClass1>()); Assert.False(TypeCheck.AreEqual <MySubClass1, MyClass1>()); // type.IsCastableTo<..>() examples: Assert.True(typeof(MySubClass2).IsCastableTo <MyClass1>()); Assert.False(typeof(MyClass1).IsCastableTo <MySubClass2>()); // type.IsCastableTo(..) examples: Assert.True(typeof(MySubClass1).IsCastableTo(typeof(MyClass1))); Assert.True(typeof(MyClass1).IsCastableTo(typeof(MyClass1))); Assert.False(typeof(MyClass1).IsCastableTo(typeof(MySubClass1))); }