internal override void PrepareForUpdate() { IgnoreProperties.Add(nameof(baccount)); IgnoreProperties.Add("baccountId"); IgnoreProperties.Add(nameof(locationId)); base.PrepareForUpdate(); }
/// <summary> /// Runs shallow equal on the metadata while ignoring keys starting with '@' /// And replication related properties like replication /// </summary> /// <param name="documentId"></param> /// <param name="origin"></param> /// <param name="external"></param> /// <param name="result">The output metadata incase the metadata are equal</param> /// <returns></returns> protected static bool CheckIfMetadataIsEqualEnoughForReplicationAndMergeHistorires( string documentId, RavenJObject origin, RavenJObject external, out RavenJObject result) { result = null; var keysToCheck = new HashSet <string>(external.Keys.Where(k => !k.StartsWith("@") && !IgnoreProperties.Contains(k))); foreach (var key in origin.Keys.Where(k => !k.StartsWith("@") && !IgnoreProperties.Contains(k))) { var originVal = origin[key]; RavenJToken externalVal; if (external.TryGetValue(key, out externalVal) == false) { return(false); } if (!RavenJTokenEqualityComparer.Default.Equals(originVal, externalVal)) { return(false); } keysToCheck.Remove(key); } if (keysToCheck.Any()) { return(false); } //If we got here the metadata is the same, need to merge histories MergeReplicationHistories(documentId, origin, external, ref result); return(true); }
protected virtual void RaiseErrorsChanged(DataErrorsChangedEventArgs args) { OnPropertyChanged(Empty.HasErrorsChangedArgs); OnPropertyChanged(Empty.IsValidChangedArgs); OnPropertyChanged(Empty.IndexerPropertyChangedArgs); if (ErrorsChanged != null) { ThreadManager.Invoke(Settings.EventExecutionMode, this, args, RaiseErrorsChangedDelegate); } #if NONOTIFYDATAERROR string ignoreProperty = args.PropertyName ?? string.Empty; lock (_locker) { //Disable validation to prevent cycle var contains = IgnoreProperties.Contains(ignoreProperty); if (!contains) { IgnoreProperties.Add(ignoreProperty); } try { OnPropertyChanged(ignoreProperty); } finally { if (!contains) { IgnoreProperties.Remove(ignoreProperty); } } } #endif }
public void GameFilter() { //AreaRegistration.RegisterAllAreas(); //WebApiConfig.Register(GlobalConfiguration.Configuration); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); //AuthConfig.RegisterAuth(); //Database.SetInitializer<SelectumContext>(new SelectumInitializer()); Database.SetInitializer <SelectumContext>(null); int id = 0; // expecteds string messageToUser = "******"; var resultsViewModel = new ResultsByGame(); resultsViewModel.Results.Add(new ResultByGame()); ResultsByGameController controller = new ResultsByGameController(); ViewResult result = controller.GameFilter(id) as ViewResult; Assert.AreEqual(messageToUser, result.ViewBag.MessageToUser); IgnoreProperties ignoreProps = new IgnoreProperties(); ignoreProps.Add(new PropertyComparisonExclusion(typeof(List <string>), "Capacity")); UnitTestingHelper.AssertPublicPropertiesEqual(resultsViewModel, result.Model, ignoreProps); }
public override async Task SetParametersAsync(ParameterView parameters) { await base.SetParametersAsync(parameters); if (parameters.GetValueOrDefault <object>(nameof(DataSource)) != null) { rows = (DataSource as IEnumerable).Cast <object>().ToList(); DataType = DataSource.GetType().GetGenericArguments()[0]; if (AutoGenerateColumns && !headerInitilized) { headerInitilized = true; DataType.GetProperties().Where(p => !IgnoreProperties.Contains(p.Name)).Reverse().ToList().ForEach(property => { if (Headers.Any(x => x.Property?.Name == property.Name)) { return; } var attrs = property.GetCustomAttributes(true); var columnConfig = attrs.OfType <TableColumnAttribute>().FirstOrDefault() ?? new TableColumnAttribute() { Text = property.Name }; Headers.Insert(0, new TableHeader() { Eval = row => { var value = property.GetValue(row); if (string.IsNullOrWhiteSpace(columnConfig.Format)) { return(value); } if (value == null) { return(null); } try { return(Convert.ToDateTime(value).ToString(columnConfig.Format)); } catch (InvalidCastException) { throw new BlazuiException("仅日期列支持 Format 参数"); } }, IsCheckBox = property.PropertyType == typeof(bool) || Nullable.GetUnderlyingType(property.PropertyType) == typeof(bool), Property = property, Text = columnConfig.Text, Width = columnConfig.Width }); } ); } SelectedRows = new HashSet <object>(); chkAll?.MarkAsRequireRender(); ResetSelectAllStatus(); } }
internal override void OnPropertyChangedInternal(PropertyChangedEventArgs args) { base.OnPropertyChangedInternal(args); if (IsEntityInitialized && !IgnoreProperties.Contains(args.PropertyName) && !IsDisposed) { OnPropertyChanged(Empty.HasChangesChangedArgs, ExecutionMode.None); } }
public CustomerInvoice() { DtoFields.Add("documentDueDate", new DtoValue(DateTime.Today.AddDays(14))); DtoFields.Add("cashDiscountDate", new DtoValue(DateTime.Today)); IgnoreProperties.Add(nameof(this.number)); IgnoreProperties.Add(nameof(this.referenceNumber)); }
public Task ValidateAsync() { EnsureInitialized(); if (IgnoreProperties.Contains(string.Empty)) { return(Empty.Task); } return(Validate(string.Empty)); }
public Location(string baccountId, string locationId) { this.baccount = new Baccount(); this.baccount.number = baccountId; this.locationId = locationId; IgnoreProperties.Add(nameof(baccount)); IgnoreProperties.Add("baccountId"); IgnoreProperties.Add(nameof(locationId)); }
internal override void OnPropertyChangedInternal(PropertyChangedEventArgs args) { base.OnPropertyChangedInternal(args); if (IsEntityInitialized && UpdateChangesOnPropertyChanged && !IgnoreProperties.Contains(args.PropertyName) && !IsDisposed) { OnPropertyChanged("HasChanges"); } }
private ICollection <string> UpdateErrorsInternal([NotNull] string propertyName, [CanBeNull] IEnumerable validatorErrors) { Should.NotBeNull(propertyName, "propertyName"); IList <object> errors; if (validatorErrors is string) { errors = new object[] { validatorErrors } } ; else { errors = validatorErrors == null ? Empty.Array <object>() : validatorErrors.OfType <object>().ToArray(); } var hasErrors = errors.Count != 0; if (hasErrors && IgnoreProperties.Contains(propertyName)) { return(Empty.Array <string>()); } ICollection <string> mappingProperties; PropertyMappings.TryGetValue(propertyName, out mappingProperties); if (mappingProperties == null) { if (hasErrors) { _errors[propertyName] = errors; } else { _errors.Remove(propertyName); } return(new[] { propertyName }); } foreach (string property in mappingProperties) { if (hasErrors) { _errors[property] = errors; } else { _errors.Remove(property); } } return(mappingProperties); }
internal override void PrepareForUpdate() { foreach (var salesOrderLine in lines) { salesOrderLine.operation = ApiOperation.Update; } IgnoreProperties.Add(nameof(customer)); if (lines.Count > 0) { IgnoreProperties.Add(nameof(currency)); } }
public Location(string baccountId, string locationId, bool standAloneLocation = false) { this.baccount = new Baccount(); this.baccount.number = baccountId; this.locationId = locationId; IgnoreProperties.Add(nameof(baccount)); if (!standAloneLocation) { IgnoreProperties.Add("baccountId"); IgnoreProperties.Add(nameof(locationId)); } }
/// <summary> /// Updates information about errors in the specified property. /// </summary> /// <param name="propertyName">The specified property name.</param> public Task ValidateAsync(string propertyName) { EnsureNotDisposed(); EnsureInitialized(); if (string.IsNullOrEmpty(propertyName)) { return(ValidateAsync()); } if (IgnoreProperties.Contains(propertyName)) { return(Empty.Task); } List <string> properties = null; string singleMap = null; foreach (var item in PropertyMappings) { if (!item.Value.Contains(propertyName)) { continue; } if (singleMap == null) { singleMap = item.Key; } else { if (properties == null) { properties = new List <string> { singleMap } } ; properties.Add(item.Key); } } if (properties != null) { var tasks = new Task[properties.Count]; for (int index = 0; index < properties.Count; index++) { tasks[index] = Validate(properties[index]); } return(ToolkitExtensions.WhenAll(tasks)); } if (singleMap == null) { singleMap = propertyName; } return(Validate(singleMap)); }
public bool HasDesignatedProperties(string Name) { if (OnlyProperties != null) { return(OnlyProperties.Contains(Name)); } if (IgnoreProperties != null) { return(!IgnoreProperties.Contains(Name)); } return(false); }
public virtual void Initialize() { var conventionMap = new List <dynamic>(); var sourceProperties = typeof(TSource).GetProperties(); var destinationProperties = typeof(TDestination).GetProperties(); var propertyMap = new List <PropertyLookup>(); if (CustomActivator == null) { SpecializedActivator = LambdaCompiler.CreateActivator <TDestination>(); } Conventions.Concat(configuration.Conventions).ToList().ForEach(convention => conventionMap.AddRange(convention(sourceProperties, destinationProperties))); conventionMap.ForEach(item => { if (!item.source.CanRead) { throw new MapperException($"Property to read from {item.source.Name} has no getter!"); } if (!item.destination.CanWrite) { throw new MapperException($"Property to write to {item.destination.Name} has no setter"); } if (IgnoreProperties.Contains(item.destination.Name)) { return; } var getter = typeof(PropertyLookup.GetterInvoker <,>).MakeGenericType(typeof(TSource), item.source.PropertyType); var setter = typeof(PropertyLookup.SetterInvoker <,>).MakeGenericType(typeof(TDestination), item.destination.PropertyType); var lookup = new PropertyLookup { Source = Activator.CreateInstance(getter, new object[] { item.source.Name }), Destination = Activator.CreateInstance(setter, new object[] { item.destination.Name }) }; if (item.source.PropertyType != item.destination.PropertyType) { lookup.Converter = CreateTypeConverter(item); } PropertiesSetByConvention.Add(item.destination.Name); propertyMap.Add(lookup); }); map = propertyMap.Distinct().ToList(); //TODO: verify distinct behavior in this case... }
private void HandleValidationInternal(object sender, object message) { var validationMessage = message as AsyncValidationMessage; if (validationMessage != null) { RaiseErrorsChanged(new DataErrorsChangedEventArgs(validationMessage.PropertyName)); OnHandleAsyncValidationMessage(sender, validationMessage); return; } var errorsMessage = message as DataErrorsChangedMessage; if (errorsMessage == null) { return; } OnErrorsChanged(sender, errorsMessage); #if NONOTIFYDATAERROR //To update property error in UI. ThreadManager.InvokeOnUiThreadAsync(() => { string ignoreProperty = errorsMessage.PropertyName ?? string.Empty; lock (_locker) { //Disable validation to prevent cycle var contains = IgnoreProperties.Contains(ignoreProperty); if (!contains) { IgnoreProperties.Add(ignoreProperty); } try { OnPropertyChanged(errorsMessage.PropertyName, ExecutionMode.None); } finally { if (!contains) { IgnoreProperties.Remove(ignoreProperty); } } } }); #endif }
public override async Task SetParametersAsync(ParameterView parameters) { await base.SetParametersAsync(parameters); if (parameters.GetValueOrDefault <object>(nameof(DataSource)) != null) { rows = (DataSource as IEnumerable).Cast <object>().ToList(); DataType = DataSource.GetType().GetGenericArguments()[0]; if (AutoGenerateColumns && !headerInitilized) { headerInitilized = true; DataType.GetProperties().Where(p => !IgnoreProperties.Contains(p.Name)).Reverse().ToList().ForEach(property => { if (Headers.Any(x => x.Property?.Name == property.Name)) { return; } var attrs = property.GetCustomAttributes(true); var text = attrs.OfType <DisplayAttribute>().FirstOrDefault()?.Name; if (string.IsNullOrWhiteSpace(text)) { text = attrs.OfType <DescriptionAttribute>().FirstOrDefault()?.Description; } var width = attrs.OfType <WidthAttribute>().FirstOrDefault()?.Width; Headers.Insert(0, new TableHeader() { Eval = row => { return(property.GetValue(row)); }, IsCheckBox = property.PropertyType == typeof(bool) || Nullable.GetUnderlyingType(property.PropertyType) == typeof(bool), Property = property, Text = text ?? property.Name, Width = width }); } ); } chkAll?.MarkAsRequireRender(); ResetSelectAllStatus(); } }
public CustomerInvoice() { IgnoreProperties.Add(nameof(referenceNumber)); }
public void GameFilter() { //AreaRegistration.RegisterAllAreas(); //WebApiConfig.Register(GlobalConfiguration.Configuration); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); //AuthConfig.RegisterAuth(); //Database.SetInitializer<SelectumContext>(new SelectumInitializer()); Database.SetInitializer<SelectumContext>(null); int id = 0; // expecteds string messageToUser = "******"; var resultsViewModel = new ResultsByGame(); resultsViewModel.Results.Add(new ResultByGame()); ResultsByGameController controller = new ResultsByGameController(); ViewResult result = controller.GameFilter(id) as ViewResult; Assert.AreEqual(messageToUser, result.ViewBag.MessageToUser); IgnoreProperties ignoreProps = new IgnoreProperties(); ignoreProps.Add(new PropertyComparisonExclusion(typeof(List<string>), "Capacity")); UnitTestingHelper.AssertPublicPropertiesEqual(resultsViewModel, result.Model, ignoreProps); }
protected void RemoveIgnoreProperty <TModel>(Func <Expression <Func <TModel, object> > > getProperty) { IgnoreProperties.Remove(getProperty.GetMemberName()); }
public SupplierInvoice() { IgnoreProperties.Add(nameof(referenceNumber)); }
public Customer() { IgnoreProperties.Add(nameof(this.number)); }
public Project(string projectNumber) { projectID = projectNumber; IgnoreProperties.Add(nameof(this.internalID)); }
public Project() { IgnoreProperties.Add(nameof(this.projectID)); IgnoreProperties.Add(nameof(this.internalID)); }
public string[] GetSelectColumns() => Info.Columns .Where(d => !IgnoreProperties.Any(p => p == d.PropertyInfo.Name)) .Select(d => d.Name).ToArray();
//string[] GetIgnoredColumns() => IgnoreProperties.Select(d => Info[d].Name).ToArray(); public void Ignore(params Expression <Func <T, object> >[] ignore) { IgnoreProperties.AddRange(ignore.GetNames()); }
public SalesOrder() { IgnoreProperties.Add(nameof(orderNo)); IgnoreProperties.Add("orderNumber"); RequiredFields.Add(nameof(orderType), new DtoValue("SO")); }
public Supplier() { IgnoreProperties.Add(nameof(this.number)); }
protected void AddIgnoreProperty(Func <Expression <Func <T, object> > > getProperty) { IgnoreProperties.Add(getProperty.GetMemberName()); }
private void InitilizeHeaders() { if (AutoGenerateColumns && !headerInitilized) { headerInitilized = true; DataType.GetProperties().Where(p => !IgnoreProperties.Contains(p.Name)).Reverse().ToList().ForEach(property => { if (Headers.Any(x => x.Property?.Name == property.Name)) { return; } var attrs = property.GetCustomAttributes(true); if (attrs.OfType <TableIgnoreAttribute>().Any()) { Headers.Add(new TableHeader() { Ignore = true, Property = property }); return; } var columnConfig = attrs.OfType <TableColumnAttribute>().FirstOrDefault() ?? new TableColumnAttribute() { Text = property.Name }; if (columnConfig.Ignore) { Headers.Add(new TableHeader() { Ignore = true, Property = property }); return; } var editorConfig = attrs.OfType <EditorGeneratorAttribute>().FirstOrDefault() ?? new EditorGeneratorAttribute() { Control = typeof(BInput <string>) }; var formConfig = attrs.OfType <FormControlAttribute>().FirstOrDefault(); var propertyConfig = attrs.OfType <PropertyAttribute>().FirstOrDefault(); var tableHeader = new TableHeader() { EvalRaw = row => { object value = property.GetValue(row); return(value); }, SortNo = columnConfig.SortNo, IsCheckBox = property.PropertyType == typeof(bool) || Nullable.GetUnderlyingType(property.PropertyType) == typeof(bool), Property = property, Text = columnConfig.Text, Width = columnConfig.Width, IsEditable = columnConfig.IsEditable }; tableHeader.Eval = displayRender.CreateRenderFactory(tableHeader).CreateRender(tableHeader); if (IsEditable && columnConfig.IsEditable) { InitilizeHeaderEditor(property, editorConfig, tableHeader); } Headers.Insert(0, tableHeader); } ); if (IsEditable) { CreateOperationColumn(); } chkAll?.MarkAsRequireRender(); ResetSelectAllStatus(); } else if (!AutoGenerateColumns && !headerInitilized && Headers.Any()) { headerInitilized = true; foreach (var header in Headers) { if (!CanEdit(header)) { continue; } InitilizeHeaderEditor(header.Property, header.Property.GetCustomAttribute <EditorGeneratorAttribute>() ?? new EditorGeneratorAttribute(), header); } CreateOperationColumn(); Refresh(); } }