public Read ( Mono.Cecil.PropertyDefinition property, List |
||
property | Mono.Cecil.PropertyDefinition | |
allProperties | List |
|
Résultat | NotifyPropertyData, |
public void PerformEqualityCheck() { var reader = new NotifyPropertyDataAttributeReader(null); var typeDefinition = DefinitionFinder.FindType<TestClass>(); var propertyDefinitions = new List<PropertyDefinition>(); var trueData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckTrue"), propertyDefinitions); Assert.IsTrue(trueData.CheckForEquality.Value); var falseData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckFalse"), propertyDefinitions); Assert.IsFalse(falseData.CheckForEquality.Value); var defauleData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckDefault"), propertyDefinitions); Assert.IsNull(defauleData.CheckForEquality); }
public void IsChanged() { var reader = new NotifyPropertyDataAttributeReader(null); var typeDefinition = DefinitionFinder.FindType<TestClass>(); var propertyDefinitions = new List<PropertyDefinition>(); var trueData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedTrue"), propertyDefinitions); Assert.IsTrue(trueData.SetIsChanged.Value); var falseData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedFalse"), propertyDefinitions); Assert.IsFalse(falseData.SetIsChanged.Value); var defauleData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedDefault"), propertyDefinitions); Assert.IsNull(defauleData.SetIsChanged); }
public void IsChanged() { var reader = new NotifyPropertyDataAttributeReader(null); var typeDefinition = DefinitionFinder.FindType <TestClass>(); var propertyDefinitions = new List <PropertyDefinition>(); var trueData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedTrue"), propertyDefinitions); Assert.IsTrue(trueData.SetIsChanged.Value); var falseData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedFalse"), propertyDefinitions); Assert.IsFalse(falseData.SetIsChanged.Value); var defauleData = reader.Read(typeDefinition.Properties.First(x => x.Name == "SetIsChangedDefault"), propertyDefinitions); Assert.IsNull(defauleData.SetIsChanged); }
public void PerformEqualityCheck() { var reader = new NotifyPropertyDataAttributeReader(null); var typeDefinition = DefinitionFinder.FindType <TestClass>(); var propertyDefinitions = new List <PropertyDefinition>(); var trueData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckTrue"), propertyDefinitions); Assert.IsTrue(trueData.CheckForEquality.Value); var falseData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckFalse"), propertyDefinitions); Assert.IsFalse(falseData.CheckForEquality.Value); var defauleData = reader.Read(typeDefinition.Properties.First(x => x.Name == "PerformEqualityCheckDefault"), propertyDefinitions); Assert.IsNull(defauleData.CheckForEquality); }
void GetPropertyData(PropertyDefinition propertyDefinition, TypeNode node) { var notifyPropertyData = notifyPropertyDataAttributeReader.Read(propertyDefinition, node.AllProperties); var dependenciesForProperty = node.PropertyDependencies.Where(x => x.WhenPropertyIsSet == propertyDefinition).Select(x => x.ShouldAlsoNotifyFor); var backingFieldReference = node.Mappings.First(x => x.PropertyDefinition == propertyDefinition).FieldDefinition; if (notifyPropertyData == null) { if (node.EventInvoker == null) { return; } node.PropertyDatas.Add(new PropertyData { CheckForEquality = weavingTask.CheckForEquality, SetIsChanged = weavingTask.CheckForIsChanged, BackingFieldReference = backingFieldReference, NotificationAddedDirectly = false, PropertyDefinition = propertyDefinition, // Compute full dependencies for the current property AlsoNotifyFor = GetFullDependencies(propertyDefinition, dependenciesForProperty, node) }); return; } if (node.EventInvoker == null) { throw new WeavingException(string.Format( @"Could not find field for PropertyChanged event on type '{0}'. Looked for 'PropertyChanged', 'propertyChanged', '_PropertyChanged' and '_propertyChanged'. The most likely cause is that you have implemented a custom event accessor for the PropertyChanged event and have called the PropertyChangedEventHandler something stupid.", node.TypeDefinition.FullName)); } node.PropertyDatas.Add(new PropertyData { CheckForEquality = notifyPropertyData.CheckForEquality.GetValueOrDefault(weavingTask.CheckForEquality), BackingFieldReference = backingFieldReference, NotificationAddedDirectly = true, PropertyDefinition = propertyDefinition, // Compute full dependencies for the current property AlsoNotifyFor = GetFullDependencies(propertyDefinition, notifyPropertyData.AlsoNotifyFor.Union(dependenciesForProperty), node), SetIsChanged = notifyPropertyData.SetIsChanged.GetValueOrDefault(weavingTask.CheckForIsChanged), }); }