public static void CheckEquals <TInfo>(MainForm form, Func <TInfo> method, RuleBase <ComponentRuleGroup> rule, Func <TInfo, TInfo, DataEntry[][]> compare) where TInfo : class, IWICComponentInfo { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); TInfo info = factory.CreateComponentInfo(rule.Parent.Clsid) as TInfo; TInfo i = null; try { i = method(); if (i == null) { form.Add(rule, method.ToString(Resources._0_NULL)); } else { foreach (DataEntry[] de in compare(info, i)) { form.Add(rule, string.Format(CultureInfo.CurrentUICulture, Resources.InconsistentComponentInfo, typeof(TInfo).Name, method.ToString("{0}")), de); } } } catch (Exception e) { form.Add(rule, method.ToString(Resources._0_Failed), new DataEntry(e)); } finally { i.ReleaseComObject(); info.ReleaseComObject(); factory.ReleaseComObject(); } }
public Message(RuleBase parent, string text, params DataEntry[][] data) : base(text) { this.parent = parent; this.data.Add(new DataEntryCollection(parent, data)); SubItems.Add(parent.FullPath); }
public static void CheckNotReserverdGuid(MainForm form, GeGuidMethod method, RuleBase rule) { Guid guid; method(out guid); string s; if (ReservedGuids.Instance.TryGetValue(guid, out s)) { form.Add(rule, method.ToString(Resources._0_ReservedGUID), new DataEntry(Resources.Value, guid)); } }
public static void CheckVersion(MainForm form, Extensions.GetStringMethod method, RuleBase rule) { string version = CheckNotEmptyString(form, method, rule); if (!string.IsNullOrEmpty(version)) { if (VersionMask.IsMatch(version)) { form.Add(rule, method.ToString(Resources._0_DontMatchMask), new DataEntry(Resources.Value, version)); } } }
public static string CheckNotEmptyString(MainForm form, Extensions.GetStringMethod method, RuleBase rule) { string s = Extensions.GetString(method); if (string.IsNullOrEmpty(s)) { form.Add(rule, method.ToString(Resources._0_EmptyString)); } return(s); }
public static string[] CheckCommaSeparatedString(MainForm form, Extensions.GetStringMethod method, Regex mask, RuleBase rule) { HashSet <string> res = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); HashSet <string> dups = new HashSet <string>(); foreach (string s in CheckNotEmptyString(form, method, rule).Split(',')) { if (res.Contains(s)) { dups.Add(s); } else if (!mask.IsMatch(s)) { form.Add(rule, method.ToString(Resources._0_DontMatchMask), new DataEntry(Resources.Value, s)); } else { res.Add(s); } } if (dups.Count > 0) { form.Add(rule, method.ToString(Resources._0_Duplicated), new DataEntry(Resources.Value, dups.ToArray())); } return(res.ToArray()); }
public static void Check <TInfo, TTag>(MainForm form, Guid clsid, Action <MainForm, TInfo, TTag> check, TTag tag, RuleBase rule, bool checkVersions) where TInfo : class, IWICComponentInfo where TTag : class { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); TInfo info = null; try { info = (TInfo)factory.CreateComponentInfo(clsid); CheckNotEmptyString(form, info.GetAuthor, rule); CheckNotEmptyString(form, info.GetFriendlyName, rule); if ((info.GetSigningStatus() & WICComponentSigning.WICComponentDisabled) == WICComponentSigning.WICComponentDisabled) { form.Add(rule, Resources.ComponentDisabled); } CheckNotReserverdGuid(form, info.GetVendorGUID, rule); if (checkVersions || info.GetSpecVersion(0, null) > 0) { CheckVersion(form, info.GetSpecVersion, rule); } if (checkVersions || info.GetVersion(0, null) > 0) { CheckVersion(form, info.GetVersion, rule); } check(form, info, tag); } finally { factory.ReleaseComObject(); info.ReleaseComObject(); } }
private void AddInternal(RuleBase parent, string text, DataEntry[] de, DataEntry[] data) { foreach (Message m in messagesListView.Items) { if (m.Parent == parent && m.Text == text) { m.Data.Add(new DataEntryCollection(parent, de, data)); return; } } messagesListView.Items.Add(new Message(parent, text, de, data)); }
public DataEntryPropertyDescriptor(DataEntry entry, RuleBase rule) : base(typeof(DataEntryCollection), entry.Text, entry.Value == null ? typeof(object): entry.Value.GetType(), null) { this.entry = entry; this.rule = rule; }
internal void RunParentRemotely(RuleBase rule) { string path = rule.Parent.FullPath; Remote.MessageInfo[] a = remote.Run(path); DataEntry de = new DataEntry(Resources.Mode, Resources.Wow); if (a == null) { Add(rule, Resources.WowNotImplemented, de); } else { foreach (Remote.MessageInfo m in a) { RuleBase r = m.Path == path ? rule : GetRule(m.Path); foreach (DataEntryCollection c in m.Data) { Add(r, m.Text, c.ToArray(), de); } } } }
internal void CheckHRESULT(RuleBase parent, WinCodecError error, Exception e, string param, params DataEntry[] de) { if (Marshal.GetHRForException(e) != (int)error) { string text = param == null ? e.TargetSite.ToString(Resources._0_FailedWithIncorrectHRESULT) : e.TargetSite.ToString(Resources._0_FailedWithIncorrectHRESULT, param); Add(parent, text, de, new DataEntry(Resources.Actual, e), new DataEntry(Resources.Expected, error)); } }
internal void CheckHRESULT(RuleBase parent, WinCodecError error, Exception e, params DataEntry[] de) { CheckHRESULT(parent, error, e, null, de); }
internal void Add(RuleBase parent, string text, DataEntry[] de, params DataEntry[] data) { if (remoted) { AddInternal(parent, text, de, data); } else { Invoke(new Action<RuleBase, string, DataEntry[], DataEntry[]>(AddInternal), new object[] { parent, text, de, data }); } }
internal void Add(RuleBase parent, string text, params DataEntry[] data) { Add(parent, text, data, new DataEntry[0]); }