protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { // Look for the CLR property with this name first. return(GetProperties(bindingAttr).FirstOrDefault(prop => prop.Name == name) // and then for a custom property ?? CustomProperties.FirstOrDefault(prop => prop.Name == name)); }
public SwitchBlockModel(LinkDefinition.LinkWrapper lw, IdeCollection <IdeBaseItem> source) : base(source) //load { _wrapper = lw; _property = (PropertyItemModel)CustomProperties.FirstOrDefault(x => ((PropertyItemModel)x)._property.Name == _wrapper.Conditional.switchProperty); Items = new IdeCollection <IdeBaseItem>(this); if (lw.Conditional.switchNodeList != null) { foreach (var switchcase in lw.Conditional.switchNodeList) { Items.Add(new SwitchCaseModel(switchcase, Items)); } } Items.CollectionChanged += (a, b) => { BuildSwitchDefinitions(b); }; if (lw.Conditional.elseNode != null) { Items.Add(new DefaultCaseModel(lw.Conditional.elseNode, Items)); } Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action)); AddCaseCommand = new RelayCommand(AddCase); AddDefaultCommand = new RelayCommand(AddDefault); }
/// <summary> /// Sets a property value by name /// </summary> /// <param name="propertyName"></param> /// <param name="value"></param> public void SetPropertyValue(string propertyName, object value) { CustomPropertyInfoHelper propertyInfo = CustomProperties.FirstOrDefault(prop => prop.Name == propertyName); if (propertyName != null) { if (propertyInfo == null || !_customPropertyValues.ContainsKey(propertyName)) { throw new Exception("There is no property with the name " + propertyName); } } if (ValidateValueType(value, propertyInfo._type)) { // if (_customPropertyValues[propertyName] != value) //{ //if (propertyName != null) //{ _customPropertyValues[propertyName] = value; RaisePropertyChanged(propertyName); // } // } } else { throw new Exception("Value is of the wrong type or null for a non-nullable type."); } }
/// <summary> /// Removes a specific property by name /// </summary> /// <param name="name">Property to remove</param> public static void RemoveProperty(string name) { var item = CustomProperties.FirstOrDefault(cp => cp.Name == name); if (item != null) { CustomProperties.Remove(item); } }
public ElseIfCaseModel(CaseDefinition caseItem, IdeCollection <IdeBaseItem> source) : base(source) //load { _case = caseItem; _property = (PropertyItemModel)CustomProperties.FirstOrDefault(x => ((PropertyItemModel)x)._property.Name == _case.property); BlockContainer = new BlockContainer(caseItem.linkList); BlockContainer.OnContainerChanged += (a, b) => { _case.linkList = BlockContainer.BuildTemplateBlockDef(b); }; Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action)); }
protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { return(GetProperties(bindingAttr).FirstOrDefault(prop => prop.Name == name) ?? CustomProperties.FirstOrDefault(prop => prop.Name == name)); }