this my base interface:
public interface IFlowFunctionType
{
void RefreshAll();
void ClearAll();
}
and this my base class that implement INotifyPropertyChanged:
public class ObservableObject : INotifyPropertyChanged
{
#region INotifyPropertyChanged Members
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
#endregion
#region Protected Methods
protected void OnPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
and this my class implement above interface:
public class M1 : ObservableObject, ISerializable, IFlowFunctionType
{
public void GetObjectData(SerializationInfo info, StreamingContext context)
{// some code}
public void RefreshAll()
{// some code }
public void ClearAll()
{// some code}
}
Please tell me why when assign secondInstance to firstInstance the property of firstInstance not fire?
class Main() {
public Main()
{
private M1 firstInstance = new M1();
private M1 secondInstance = new M1();
DeQueue(firstInstance);
}
public void DeQueue( IFlowFunctionType obj)
{
obj= secondInstance ;
obj.RefreshAll();
DbQueues.Remove(firstOrDefault);
}
}
No properties of firstInstance
were changed when you assigned secondInstance
to it. Your object has no knowledge of when it is assigned, it observes only its own properties.
If you want to observe reassignment, you'd have to assign an M1
to an object which is itself observable.
public class Host : ObservableObject
{
public M1 Instance {get; set;}
}
...
var host = new Host();
host.Instance = new M1();
host.Instance = new M1(); // Reassigned, Host will see the change.