Example #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 checks.", obj.GetType());
            }
            else
            {
                Console.WriteLine("{0} types can not write checks,", obj.GetType());
            }
        }
Example #2
0
            private static void CanWriteCheck(object obj)
            {
                Attribute checking      = new AccountsAttribute(Accounts.Checking);
                Attribute validAccounts = Attribute.GetCustomAttribute(
                    obj.GetType(), typeof(AccountsAttribute), false);

                if ((validAccounts != null) && checking.Match(validAccounts))
                {
                    Console.WriteLine("{0} types can write checks.", obj.GetType());
                }
                else
                {
                    Console.WriteLine("{0} types can NOT write checks.", obj.GetType());
                }
            }
Example #3
0
    private static void CanWriteCheck(Object obj)
    {
        // Construct an instance of the attribute type and initialize it
        // to what we are explicitly looking for.
        Attribute checking = new AccountsAttribute(Accounts.Checking);

        // Construct the attribute instance that was applied to the type
        Attribute validAccounts = obj.GetType().GetCustomAttribute <AccountsAttribute>(false);

        // If the attribute was applied to the type AND the
        // attribute specifies the "Checking" account, then the
        // type can write a check
        if ((validAccounts != null) && checking.Match(validAccounts))
        {
            Console.WriteLine("{0} types can write checks.", obj.GetType());
        }
        else
        {
            Console.WriteLine("{0} types can NOT write checks.", obj.GetType());
        }
    }
Example #4
0
   private static void CanWriteCheck(Object obj) {
      // Construct an instance of the attribute type and initialize it
      // to what we are explicitly looking for.
      Attribute checking = new AccountsAttribute(Accounts.Checking);

      // Construct the attribute instance that was applied to the type
      Attribute validAccounts = obj.GetType().GetCustomAttribute<AccountsAttribute>(false);

      // If the attribute was applied to the type AND the 
      // attribute specifies the "Checking" account, then the
      // type can write a check
      if ((validAccounts != null) && checking.Match(validAccounts)) {
         Console.WriteLine("{0} types can write checks.", obj.GetType());
      } else {
         Console.WriteLine("{0} types can NOT write checks.", obj.GetType());
      }
   }