Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
        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));
                }
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
0
        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;
 }
Exemplo n.º 10
0
        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);
                    }
                }
            }
        }
Exemplo n.º 11
0
        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));
            }
        }
Exemplo n.º 12
0
 internal void CheckHRESULT(RuleBase parent, WinCodecError error, Exception e, params DataEntry[] de)
 {
     CheckHRESULT(parent, error, e, null, de);
 }
Exemplo n.º 13
0
 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 });
     }
 }
Exemplo n.º 14
0
 internal void Add(RuleBase parent, string text, params DataEntry[] data)
 {
     Add(parent, text, data, new DataEntry[0]);
 }