/// <summary> /// Autoes the map properties. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public virtual IEnumerable <AbstractPropertyConfiguration> AutoMapProperties(Type type) { BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy; IEnumerable <PropertyInfo> properties = type.GetProperties(flags); if (type.IsInterface) { foreach (var inter in type.GetInterfaces()) { properties = properties.Union(inter.GetProperties(flags)); } } foreach (var property in properties) { if (Properties.All(x => x.PropertyInfo != property)) { //skipped already mapped properties if (_properties.Any(x => x.PropertyInfo.Name == property.Name)) { continue; } var propConfig = AutoMapProperty(property); if (propConfig != null) { yield return(propConfig); } } } }
public bool IsNumeric() { if (Properties.Count == 0) { if (_ForceNumericWhenUnsure) { return(true); } if (ForceObjectWhenUnsure) { return(false); } return(false);//return true; } if (Properties.Count == 1 && Properties[0].Key == "0") { if (_ForceNumericWhenUnsure) { return(true); } if (ForceObjectWhenUnsure) { return(false); } return(false);//return true; } if (NumericMemo.HasValue) { return(NumericMemo.Value); } int tmp; if (!Properties.All(dr => int.TryParse(dr.Key, out tmp))) { return(false); } var baseQry = Properties.Select(dr => dr.Key); if (!baseQry.SequenceEqual(baseQry.Distinct())) { return(false); } int counter = 0; bool orderPreserved = true; baseQry.Select(dr => int.Parse(dr)).OrderBy(dr => dr).ToList().ForEach(dr => { orderPreserved = orderPreserved && (dr == counter); counter++; }); NumericMemo = orderPreserved; return(orderPreserved); }
public override bool IsValid(ILogger <IValidatable> logger) { var result = base.IsValid(logger); return(result && BaseTypes.All(t => t.IsValid(logger)) && Properties.All(p => p.IsValid(logger)) && Events.All(e => e.IsValid(logger)) && Functions.All(f => f.IsValid(logger))); }
public void SetValue(string id, object value) { Logger.Debug($"Set property {id} to {value}"); if (Properties.All(x => x.Id != id)) { throw new ValueNotFoundException("Could not find the specified property", id); } Properties.First(x => x.Id == id).Set(value); }
public GameProperty GetProperty(string id) { Logger.Debug($"Getting property {id}"); if (Properties.All(x => x.Id != id)) { throw new ValueNotFoundException("Could not find the specified property", id); } return(Properties.First(x => x.Id == id)); }
/// <summary> /// If PolymorphicDiscriminator is set, makes sure we have a PolymorphicDiscriminator property. /// </summary> public void AddPolymorphicPropertyIfNecessary() { if (!string.IsNullOrEmpty(PolymorphicDiscriminator) && Properties.All(p => p.SerializedName != PolymorphicDiscriminator)) { base.Add(New <Property>(new { Name = CodeNamerSwift.Instance.GetPropertyName(PolymorphicDiscriminator), SerializedName = PolymorphicDiscriminator, ModelType = DiscriminatorEnum, })); } }
/// <summary> /// If PolymorphicDiscriminator is set, makes sure we have a PolymorphicDiscriminator property. /// </summary> private void AddPolymorphicPropertyIfNecessary() { if (!string.IsNullOrEmpty(PolymorphicDiscriminator) && Properties.All(p => p.Name != PolymorphicDiscriminator)) { base.Add(New <Property>(new { IsRequired = true, Name = PolymorphicDiscriminator, SerializedName = PolymorphicDiscriminator, Documentation = "Polymorphic Discriminator", ModelType = New <PrimaryType>(KnownPrimaryType.String) })); } }
public void SetValue(string id, string fromId) { if (Properties.All(x => x.Id != id)) { throw new Exception($"Could not the specified property '{id}'"); } if (Properties.All(x => x.Id != fromId)) { throw new Exception($"Could not the specified property '{fromId}'"); } Properties.First(x => x.Id == id).Set(Properties.First(x => x.Id == fromId).Value); }
/// <summary> /// Autoes the map properties. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public virtual IEnumerable <AbstractPropertyConfiguration> AutoMapProperties(Type type) { BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy; IEnumerable <PropertyInfo> properties = type.GetProperties(flags); if (type.IsInterface) { foreach (var inter in type.GetInterfaces()) { properties = properties.Union(inter.GetProperties(flags)); } } var propList = new List <AbstractPropertyConfiguration>(); foreach (var property in properties) { if (Properties.All(x => x.PropertyInfo != property)) { //skipped already mapped properties if (_properties.Any(x => x.PropertyInfo.Name == property.Name)) { continue; } //skip properties that are actually indexers if (property.GetIndexParameters().Length > 0) { continue; } //check for an attribute var propConfig = AttributeTypeLoader.ProcessProperty(property); if (propConfig == null) { //no attribute then automap propConfig = AutoMapProperty(property); } if (propConfig != null) { propList.Add(propConfig); } } } return(propList); }
public void RaiseHasCollectionChanges(TrackItem item, string propertyName) { if (propertyName != null && Properties?.All(p => p.Name != propertyName) == true) { return; } OnPropertyChanged(new PropertyChangedEventArgs(nameof(HasCollectionChanges))); if (item != null && propertyName != null) { ItemPropertyChanged?.Invoke(this, new TrackItemEvent <T> { Item = item as TrackItem <T>, PropertyNameChanged = propertyName }); } ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(HasErrors))); }
public void SyncAttributesAndOperationsFromModel() { foreach (var umlAttribute in Class.Attributes.Where(umlAttribute => Attributes.All(a => a.UmlAttribute != umlAttribute))) { Attributes.Add(new UmlDiagramClassAttribute(umlAttribute)); } foreach (var umlProperty in Class.Properties.Where(umlProperty => Properties.All(a => a.UmlProperty != umlProperty))) { Properties.Add(new UmlDiagramClassProperty(umlProperty)); } foreach (var umlOperation in Class.Operations.Where(umlOperation => Operations.All(c => c.UmlOperation != umlOperation))) { Operations.Add(new UmlDiagramClassOperation(umlOperation, Class)); } }
public bool Equals(T other) { if (ReferenceEquals(this, other)) { return(true); } if (ReferenceEquals(other, null)) { return(false); } if (GetType() != other.GetType()) { return(false); } return(Properties.All(property => Equals(property.Get(this), property.Get(other)))); }
public void AddToValue(string id, int value) { Console.WriteLine($"[{Format.Time(DateTime.UtcNow)}] Adding {value} to property {id}"); if (Properties.All(x => x.Id != id)) { throw new Exception($"Could not find the specified property '{id}'"); } GameProperty property = Properties.First(x => x.Id == id); if (property.ValueType != typeof(int)) { throw new Exception($"Cannot add to attribute '{id}' as it is not a type of Int32"); } property.Value = (int)property.Value + value; }
/// <summary> /// Autoes the map properties. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public virtual IEnumerable <AbstractPropertyConfiguration> AutoMapProperties(Type type) { IEnumerable <PropertyInfo> properties = Utilities.GetAllProperties(type); var propList = new List <AbstractPropertyConfiguration>(); foreach (var property in properties) { if (Properties.All(x => x.PropertyInfo != property)) { //skipped already mapped properties if (_properties.Any(x => x.PropertyInfo.Name == property.Name) || propList.Any(x => x.PropertyInfo.Name == property.Name)) { continue; } //skip properties that are actually indexers if (property.GetIndexParameters().Length > 0) { continue; } //check for an attribute var propConfig = AttributeTypeLoader.ProcessProperty(property); if (propConfig == null) { //no attribute then automap propConfig = AutoMapProperty(property); } if (propConfig != null) { propList.Add(propConfig); } } } return(propList); }
protected override bool OnSaveCanExecute() { return(HasChanges && Properties.All(p => !p.HasErrors)); }