public void Notify(WICRawChangeNotification NotificationMask) { if ((uint)(NotificationMask & expected) != 0 || (uint)NotificationMask == 0) { notified = true; } raised.Add(NotificationMask); }
void CheckSetSupported <T>(MainForm form, WinCodecError?error, Func <T> getter, Action <T> setter, IWICDevelopRaw raw, WICRawChangeNotification mask, DataEntry[] de, Guid pixelFormatOriginal, params T[] values) where T : struct { Notification[] notifications = new Notification[] { new Notification(), new Notification(), null }; foreach (Notification n in notifications) { try { raw.SetNotificationCallback(n); } catch (Exception e) { form.Add(this, n == null ? e.TargetSite.ToString(Resources._0_Failed, "NULL") : e.TargetSite.ToString(Resources._0_Failed), de, new DataEntry(e)); } foreach (T value in values) { T saved = default(T); bool getSupported = false; try { saved = getter(); getSupported = true; } catch { break; } if (getSupported) { try { notifications[0].Expect(mask); notifications[1].Expect(mask); setter(value); if (error.HasValue) { form.Add(this, setter.ToString(Resources._0_ShouldFail), de, new DataEntry(Resources.Expected, error.Value)); } else { if (n != null && !n.Notified && saved.Equals(value)) { form.Add(this, Resources.DevelopRawRule_NoNotification, de, new DataEntry(Resources.Actual, n.GetRaised()), new DataEntry(Resources.Expected, mask), new DataEntry(Resources.Method, setter.ToString("{0}")), new DataEntry(Resources.Value, value)); } if (n != notifications[0] && notifications[0].Notified) { form.Add(this, Resources.DevelopRawRule_NotificationOnWrong, de, new DataEntry(Resources.Method, setter.ToString("{0}")), new DataEntry(Resources.Value, value)); } CheckGetSupported <T>(form, true, getter, de, value); } } catch (Exception e) { CheckGetSupported <T>(form, true, getter, de, saved); if (error.HasValue) { DataEntry[] de2 = de.Clone() as DataEntry[]; Array.Resize(ref de2, de2.Length + 1); de2[de2.Length - 1] = new DataEntry(Resources.Value, value); form.CheckHRESULT(this, error.Value, e, de2); } else { form.Add(this, setter.ToString(Resources._0_Failed), de, new DataEntry(e), new DataEntry(Resources.Value, value)); } } } CheckPixelFormat(form, raw, de, pixelFormatOriginal); } } }
internal void Expect(WICRawChangeNotification expected) { notified = false; this.expected = expected; raised.Clear(); }