public void UpdateUsage(Audio audio) { if (audio.Value == null) //As far as I can tell, only a default constructed Audio can have this property { return; } m_toUpdate.Add(GetPath(audio)); UpdateQueued.TryExecute(); }
public ProjectElementList(GetFilePath getFilePath, Func <string, bool> fileLocationOk, Func <IEnumerable <Tuple <Id <FileInProject>, DocumentPath> >, IEnumerable <TElement> > loader, Func <DirectoryInfo, TElement> makeEmpty) { m_getFilePath = getFilePath; m_data = new CallbackDictionary <Id <FileInProject>, TElement>(); m_data.Removing += (key, element) => { element.Removed(); }; m_data.Clearing += () => { m_data.Values.ForAll(element => { element.Removed(); }); }; m_loader = loader; m_makeEmpty = makeEmpty; m_fileLocationOk = fileLocationOk; m_suppressibleGotChanged = new SuppressibleAction(() => { GotChanged.Execute(); }); Added += a => m_suppressibleGotChanged.TryExecute(); Removed += a => m_suppressibleGotChanged.TryExecute(); }
public TData this[TKey key] { get { if (m_data.ContainsKey(key)) { return(m_data[key]); } else { return(m_defaults(key)); } } set { if (value == null) { m_data.Remove(key); } else { m_data[key] = value; } m_valueChanged.TryExecute(); } }
public ConfigParameterList(string name, Func <ConfigParameter <TValue> > nodeFactory) { m_name = name; m_suppressibleValueChanged = new SuppressibleAction(() => ValueChanged.Execute()); m_data.Modified += () => { m_suppressibleValueChanged.TryExecute(); }; m_nodeFactory = nodeFactory; }
public static void TestZeroSuppressions() { bool triggered = false; SuppressibleAction action = new SuppressibleAction(() => { triggered = true; }); { Assert.False(action.Suppressed); var executed = action.TryExecute(); Assert.True(executed); Assert.True(triggered); } }
public static void TestOneSuppression() { bool triggered = false; SuppressibleAction action = new SuppressibleAction(() => { triggered = true; }); { using (action.SuppressCallback()) { Assert.True(action.Suppressed); var executed = action.TryExecute(); Assert.False(executed); Assert.False(triggered); } Assert.True(triggered); Assert.False(action.Suppressed); } }