예제 #1
0
        private static void CanWriteCheck(object obj)
        {
            Attribute checking = new AccountsAttribute(Accounts.Checking);

            Attribute validAccounts = obj.GetType().GetCustomAttribute <AccountsAttribute>(false);

            if ((validAccounts != null) && checking.Match(validAccounts))
            {
                Console.WriteLine("{0} types can write check.", obj.GetType());
            }
            else
            {
                Console.WriteLine("{0} types can NOT write checks.", obj.GetType());
            }
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            AccountsAttribute other = (AccountsAttribute)obj;

            if ((other.m_accounts & m_accounts) != m_accounts)
            {
                return(false);
            }

            return(true);
        }