예제 #1
0
        public static Level GetAttributeInfo(MethodBase method)
        {
            OperatorMessageAttribute attribute = (OperatorMessageAttribute)method
                                                 .GetCustomAttribute(typeof(OperatorMessageAttribute), true);

            return(attribute.Level);
        }
예제 #2
0
        public void SendMessage(MobileAccount forWhom, string message)
        {
            MethodBase method = MethodBase.GetCurrentMethod();
            Level      level  = OperatorMessageAttribute.GetAttributeInfo(method);

            if (Balance >= _messagePrice)
            {
                if (SentSMS != null)
                {
                    SentSMS(this, new MobileEventArgs(MobileOperation.Message, forWhom, message));
                    Balance -= _messagePrice;
                }
            }
            else
            {
                if (level == Level.Warn)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("It's not enought money to send message to {0}!", forWhom);
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
        }
예제 #3
0
        public void MakeCall(MobileAccount forWhom)
        {
            MethodBase method = MethodBase.GetCurrentMethod();
            Level      level  = OperatorMessageAttribute.GetAttributeInfo(method);

            if (Balance >= _callPrice)
            {
                if (MadeCall != null)
                {
                    MadeCall(this, new MobileEventArgs(MobileOperation.Call, forWhom));
                    Balance -= _callPrice;
                }
            }
            else
            {
                if (level == Level.Warn)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("It's not enought money to make call to {0}!", forWhom);
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
        }