Exemplo n.º 1
0
        public CommandModel(FrontendManager fm, ChatModel chat, string cmdChar, string data)
        {
            Trace.Call(fm, chat == null ? "(null)" : chat.GetType().ToString(), cmdChar, data);

            _Data             = data;
            _CommandCharacter = cmdChar;
            _FrontendManager  = fm;
            _Chat             = chat;

            try {
                EnhancedParse(data);
            } catch (FormatException) {
                SimpleParse(data);
            }
        }
Exemplo n.º 2
0
        public CommandModel(FrontendManager fm, ChatModel chat, string cmdChar, string data)
        {
            Trace.Call(fm, chat == null ? "(null)" : chat.GetType().ToString(), cmdChar, data);

            _Data = data;
            _DataArray = data.Split(new char[] {' '});
            _Parameter = String.Join(" ", _DataArray, 1, _DataArray.Length - 1);
            _CommandCharacter = cmdChar;
            if (data.StartsWith(cmdChar) &&
                !data.StartsWith(cmdChar + cmdChar)) {
                _IsCommand = true;
                _Command = (_DataArray[0].Length > cmdChar.Length) ?
                                _DataArray[0].Substring(cmdChar.Length).ToLower() :
                                String.Empty;
            } else if (data.StartsWith(cmdChar + cmdChar)) {
                _Data = data.Substring(cmdChar.Length);
                _DataArray[0] = _DataArray[0].Substring(cmdChar.Length);
            }
            _FrontendManager = fm;
            _Chat = chat;
        }
Exemplo n.º 3
0
        public CommandModel(FrontendManager fm, ChatModel chat, string cmdChar, string data)
        {
            Trace.Call(fm, chat == null ? "(null)" : chat.GetType().ToString(), cmdChar, data);

            _Data             = data;
            _DataArray        = data.Split(new char[] { ' ' });
            _Parameter        = String.Join(" ", _DataArray, 1, _DataArray.Length - 1);
            _CommandCharacter = cmdChar;
            if (data.StartsWith(cmdChar) &&
                !data.StartsWith(cmdChar + cmdChar))
            {
                _IsCommand = true;
                _Command   = (_DataArray[0].Length > cmdChar.Length) ?
                             _DataArray[0].Substring(cmdChar.Length).ToLower() :
                             String.Empty;
            }
            else if (data.StartsWith(cmdChar + cmdChar))
            {
                _Data         = data.Substring(cmdChar.Length);
                _DataArray[0] = _DataArray[0].Substring(cmdChar.Length);
            }
            _FrontendManager = fm;
            _Chat            = chat;
        }
Exemplo n.º 4
0
        protected IChatView CreateChatView(ChatModel chat,
                                           ChatType chatType,
                                           Type protocolManagerType,
                                           params object[] parameters)
        {
            Trace.Call(chat, chatType, protocolManagerType, parameters);

            Type type;
            type = _GetChatViewType(chatType, protocolManagerType);
            if (type == null) {
                type = _GetChatViewType(chatType, null);
            }

            if (type == null) {
                throw new ApplicationException("Unsupported ChatModel type: " + chat.GetType());
            }

            object[] ctorParams;
            if (parameters != null && parameters.Length > 0) {
                ctorParams = new object[parameters.Length + 1];
                ctorParams[0] = chat;
                parameters.CopyTo(ctorParams, 1);
            } else {
                ctorParams = new object[] {chat};
            }

            return (IChatView) Activator.CreateInstance(type, ctorParams);
        }
Exemplo n.º 5
0
        protected IChatView CreateChatView(ChatModel chat)
        {
            Trace.Call(chat);

            Type type;
            type = _GetChatViewType(chat.ChatType, chat.ProtocolManager != null ?
                                                   chat.ProtocolManager.GetType() : null);
            if (type == null) {
                type = _GetChatViewType(chat.ChatType, null);
            }

            if (type == null) {
                throw new ApplicationException("Unsupported ChatModel type: " + chat.GetType());
            }

            return (IChatView) Activator.CreateInstance(type, chat);
        }