private IProperty InternalAddProperty(IThreatModel model, IPropertyType propertyType, string value) { IProperty result = null; var associatedClass = propertyType.GetType().GetCustomAttributes <AssociatedPropertyClassAttribute>() .FirstOrDefault(); if (associatedClass != null) { var associatedClassType = Type.GetType(associatedClass.AssociatedType, false); if (associatedClassType != null) { result = Activator.CreateInstance(associatedClassType, model, propertyType) as IProperty; } } if (result != null) { if (_properties == null) { _properties = new List <IProperty>(); } result.StringValue = value; _properties.Add(result); Dirty.IsDirty = true; _propertyAdded?.Invoke(PropertiesContainer?.Get(), result); result.Changed += OnPropertyChanged; } return(result); }
public void OnPropertyChanged(IProperty property) { if (property == null) { throw new ArgumentNullException(nameof(property)); } _propertyValueChanged?.Invoke(PropertiesContainer?.Get(), property); }
public void OnPropertyChanged(IProperty property) { if (property == null) { throw new ArgumentNullException(nameof(property)); } if (Instance is IPropertiesContainer container) { _propertyValueChanged?.Invoke(container, property); } }
public IProperty AddProperty(IPropertyType propertyType, string value) { var model = GetModel(); IProperty result = null; if (model != null) { result = InternalAddProperty(model, propertyType, value); if (result != null) { var schema = model.GetSchema(propertyType.SchemaId); if (schema != null) { schema.PropertyTypeAdded += OnPropertyTypeAdded; schema.PropertyTypeRemoved += OnPropertyTypeRemoved; } } } return(result); }