protected virtual void ValidateUsingDataAnnotation(object newValidationValue) { ValidationStarted?.Invoke(); var messages = new ValidationMessageStore(EditContext); EditContextValidator.ValidateField(EditContext, messages, fieldIdentifier, MessageLocalizer ?? Options.ValidationMessageLocalizer); var matchStatus = messages[fieldIdentifier].Any() ? ValidationStatus.Error : ValidationStatus.Success; var matchMessages = matchStatus == ValidationStatus.Error ? messages[fieldIdentifier] : null; // Sometime status will stay the same and error message will change // eg. StringLength > empty string > Required if (Status != matchStatus || !Comparers.AreEqual(Messages?.ToArray(), matchMessages?.ToArray())) { Status = matchStatus; Messages = matchMessages; NotifyValidationStatusChanged(Status, Messages); } }
internal void UpdateInputValue(object value) { if (value is Array) { if (!Comparers.AreEqual(this.value as Array, value as Array)) { this.value = value; if (Mode == ValidationMode.Auto) { Validate(); } } } else { if (this.value != value) { this.value = value; if (Mode == ValidationMode.Auto) { Validate(); } } } }
protected virtual void ValidateUsingValidator(Action <ValidatorEventArgs> validatorHandler, object newValidationValue) { ValidationStarted?.Invoke(); var validatorEventArgs = new ValidatorEventArgs(newValidationValue); validatorHandler(validatorEventArgs); var matchMessages = Status == ValidationStatus.Error ? new string[] { validatorEventArgs.ErrorText } : null; if (Status != validatorEventArgs.Status || !Comparers.AreEqual(Messages?.ToArray(), matchMessages)) { Status = validatorEventArgs.Status; Messages = matchMessages; NotifyValidationStatusChanged(Status, Messages); } }
internal void NotifyInputChanged() { if (inputComponent.ValidationValue is Array) { if (!Comparers.AreEqual(this.lastKnownValue as Array, inputComponent.ValidationValue as Array)) { this.lastKnownValue = inputComponent.ValidationValue; if (EditContext != null && hasFieldIdentifier) { EditContext.NotifyFieldChanged(fieldIdentifier); } if (Mode == ValidationMode.Auto) { Validate(); } } } else { if (this.lastKnownValue != inputComponent.ValidationValue) { this.lastKnownValue = inputComponent.ValidationValue; if (EditContext != null && hasFieldIdentifier) { EditContext.NotifyFieldChanged(fieldIdentifier); } if (Mode == ValidationMode.Auto) { Validate(); } } } }
static void Main(string[] args) { Trace.Write("START"); Debuggers.LogError("error occured"); Debuggers.LogError(new Exception("ex occured")); Dictionary <string, int> dict = new Dictionary <string, int>() { { "Marketing", 1 }, { "Sales", 2 }, { "IT", 3 } }; var dictExists = dict.Contains(new KeyValuePair <string, int>("IT", 2)); Formaters.DateAndTime(DateTime.Now, 10.23456D); Debuggers.Start(); var customers = Linqers.CustomersWithOrdersByYear(2017); Linqers.GetProductsLongestNameByCategory(); string asyncResult; Task.Run(async() => { asyncResult = await Threads.StartAsync(); }).GetAwaiter().GetResult(); Threads.RunTimer(); var publicTypes = new Reflections().GetPublicTypes(); var assemblyName = new Reflections().GetAssemblyName(); var isPositiveDecimal = Regexes.PositiveWithTwoDecimalPlaces(5.666M); Console.WriteLine("Available memory: " + new PerformanceCounter("Memory", "Available MBytes").NextValue()); var assemblies = new Reflections().GetTypesFromCurrentDomain(); Product productForSerialization = new Product() { CategoryId = 1, Id = 2, IsValid = true }; Serializators.SerializeWithBinaryFormatter(productForSerialization, "bin.dat"); Serializators.SerializeWithDataContractToFile(productForSerialization, "datacontract.dat"); string userSerialized = Serializators.SerializeWithBinaryWriter(new Product { Id = 10 }); DateTime?nullableDateTime = null; bool isDateNotNull = nullableDateTime.HasValue; RateCollection rateCollection = new RateCollection(new Rate[] { new Rate { Value = 1 } }); foreach (var item in rateCollection) { Console.WriteLine(item); } var currentAssembly = Assembly.GetExecutingAssembly(); var sb = new StringBuilder(); sb.Append("First"); sb.AppendLine(); sb.Append("Second"); Console.WriteLine(sb); SortedList <string, string> sortedList = new SortedList <string, string>() { { "asd", "dsa" } }; Debug.Assert(false, "stop"); float amount = 1.6F; object amountObj = amount; int amountInt = (int)(float)amountObj; new Product().Add("book1"); User newUser = new User() { UserGroup = Group.Supervisors | Group.Users }; bool isTrue = newUser.UserGroup < Group.Administrator; var userGroup = newUser.UserGroup; Console.WriteLine(userGroup); string stringNull = null; string stringNotNull = "asd"; Comparers.AreEqual(stringNull, stringNotNull); Rate rate1 = new Rate() { Value = 1, Category = "cat" }; string xml = Serializators.SerializeWithDataContract(rate1); string json = Serializators.SerializeWithDataContractJson(rate1); Console.WriteLine("xml:\r\n" + xml); Console.WriteLine("json:\r\n" + json); Subscriber sub = new Subscriber(); sub.Subscribe(); sub.Execute(); Console.Read(); return; DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Rate)); Console.WriteLine(string.Format("{0} asdasd {1:000#} asd", 4, 159)); Console.WriteLine(123.ToString("000#")); Rate ratenull = null; int wynik; int.TryParse(ratenull.Category, out wynik); Console.Read(); BaseLogger logger = new Logger(); logger.Log("Log started"); logger.Log("Base: Log contiuniug"); ((Logger)logger).LogCompleted(); Console.Read(); return; Reflections.SetPropertiesOnObject(new Rate() { MyInt = 10 }, "MyInt", "MyIntSpecified"); float mojfloat = 1.6F; double dable = (double)mojfloat; var hashed = Hashers.HashByAlgName(@"C:\windows-version.txt", "SHA"); Threads.ConcurrentDict(); var x = from i in new List <int> { 1, 2 } group i by i into grouped where grouped.Key > 1 select grouped.Key; string xmlInput = "<xml><RateSheet><rate category=\"boutou\" date=\"2012-12-12\"><value>0.03</value></rate><rate category=\"druga\" date=\"2011-11-11\"><value>0.04</value></rate></RateSheet></xml>"; var result = Serializators.ReadFromXml(xmlInput); SHA1Managed SHhash = new SHA1Managed(); //new Class2().Method1(); Class1 class1 = new Class1(); INewInterface interf = class1; interf.Method1(); IEnumerable <Person> people = new List <Person>() { new Person { PhoneNumbers = new List <PhoneNumber> { new PhoneNumber { Number = "1" }, new PhoneNumber { Number = "2" } } }, new Person { PhoneNumbers = new List <PhoneNumber> { new PhoneNumber { Number = "2" }, new PhoneNumber { Number = "3" } } }, }; IEnumerable <IEnumerable <PhoneNumber> > phoneLists = people.Select(p => p.PhoneNumbers); IEnumerable <PhoneNumber> phoneNumbers = people.SelectMany(p => p.PhoneNumbers); }