コード例 #1
0
        public bool CheckType(Type looptype)
        {
            if (looptype == null)
            {
                return(false);
            }
            if (RequiredVersionAttribute.TestComponent(looptype) == false)
            {
                Trace.WriteLine("RequiredVersionAttribute returned false for type " + looptype.FullName);
                return(false);
            }

            if (inspectioncallback != null)
            {
                inspectioncallback(looptype);
            }
            if (CheckType(looptype, TypeManage, mcallback))
            {
                if (looptype != null && !ManagedTypes.Contains(looptype))
                {
                    ManagedTypes.Add(looptype);
                }
                return(true);
            }

            return(false);
        }
コード例 #2
0
        //task: loop through all custom attributes on the type.
        //for the RequiredVersionAttribute's, call SupportsVersion, plopping exceptions to Trace.
        //if all tests come back true, return true. if all tests come back false, return false.
        //if a test fails, return false.
        public static bool TestComponent(Type typecheck)
        {
            foreach (var iterate in typecheck.GetCustomAttributes(typeof(RequiredVersionAttribute), true))
            {
                RequiredVersionAttribute rva = iterate as RequiredVersionAttribute;
                try
                {
                    if (!rva.SupportsVersion())
                    {
                        return(false);
                    }
                }
                catch (ArgumentNullException exx)
                {
                    return(false);
                }
            }

            return(true);
        }