Skip to content

Instantly share code, notes, and snippets.

@kamronbatman
Last active February 11, 2018 08:27
Show Gist options
  • Save kamronbatman/14dbc1aaed5193bb47fe9062f4fbcf2d to your computer and use it in GitHub Desktop.
Save kamronbatman/14dbc1aaed5193bb47fe9062f4fbcf2d to your computer and use it in GitHub Desktop.
class NewItemThing : Item, INotifyPropertyChanged, IQueuePersistable
{
public static event EventHandler<PropertyChangedEventArgs<String>> StringPropertyChanged;
private static void StringPropertyChanged(object obj, string propertyName, string value)
{
if (StringPropertyChanged != null)
{
StringPropertyChanged(obj, new PropertyChangedEventArgs_String(propertyName, value));
}
}
private string name;
public string Name
{
get
{
return name;
}
set
{
if (value != name)
{
name = value;
NewItemThing.StringPropertyChanged(this, "Name", value);
}
}
}
}
...
public void Register(ISerial serial)
{
QueueList.Add(serial, this);
}
private void HandleStringPropertyChanges(object sender, PropertyChangedEventArgs_String e)
{
...
IQueuePersistable persistable = e.persistable;
QueueTransaction t;
QueueList.TryGetValue(persistable.Serial, out t);
t.Queue(persistable, e.propertyName, e.value);
...
}
NewItemThing.StringPropertyChanged += HandleStringPropertyChanges
...
...
NewItemThing item = new NewItemThing();
using (t = new QueueTransaction())
{
t.Register(item);
item.Name = "Kamron";
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment