//Add Methods
        //public void addResponse(ResponseCategory responseCategory, string propertyName, string message, string stackTrace = "", object onObject = null)
        //{
        //    if (responseCategory == ResponseCategory.Error)
        //    {
        //        _hasError = true;
        //    }
        //    _responseMessages.Add(new ResponseMessage(responseCategory, propertyName, message, stackTrace, onObject));
        //}

        //public void addResponse(MessageCodes messageCode, string customMessage = null, object onObject = null, string stackTrace = null)
        //{
        //    string msg = string.Empty;
        //    if (string.IsNullOrWhiteSpace(customMessage))
        //        msg = messageCode.GetDescription();
        //    else
        //        msg = string.Format(messageCode.GetDescription() + " => " + customMessage);
        //    if ((int)messageCode >= 400 && (int)messageCode < 500)
        //    {
        //        _hasError = true;
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Error, msg, onObject, stackTrace));
        //    }
        //    else if((int)messageCode >= 300 && (int)messageCode < 400)
        //    {
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Warning, msg, onObject, stackTrace));
        //    }
        //    else if((int)messageCode >= 200 && (int)messageCode < 300)
        //    {
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Information, msg, onObject, stackTrace));
        //    }

        //}

        public void addResponse(string propertyName, MessageCodes messageCode, string customMessage = null, object onObject = null, string stackTrace = null, HttpStatusCode?suggestedStatusCode = null, bool showCustomMessageOnly = false)
        {
            string msg = string.Empty;

            if (string.IsNullOrWhiteSpace(customMessage))
            {
                msg = messageCode.GetDescription();
            }

            if (showCustomMessageOnly && !string.IsNullOrWhiteSpace(customMessage))
            {
                msg = customMessage;
            }
            else
            {
                msg = string.Format(messageCode.GetDescription() + " => " + customMessage);
            }

            if ((int)messageCode >= 400 && (int)messageCode < 500)
            {
                _hasError = true;
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Error, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
            else if ((int)messageCode >= 300 && (int)messageCode < 400)
            {
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Warning, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
            else if ((int)messageCode >= 200 && (int)messageCode < 300)
            {
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Information, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
        }
Exemple #2
0
        public void AddInformation(MessageCodes messageCode)
        {
            Message message = new Message
            {
                Code = messageCode,
                Type = MessageType.Information
            };

            Add(message);
        }
Exemple #3
0
        public void AddError(MessageCodes messageCode)
        {
            Message message = new Message
            {
                Code = messageCode,
                Type = MessageType.Error
            };

            Add(message);
        }
Exemple #4
0
 public CemiFrame(MessageCodes messageCode, Control1Flags control1, Control2Flags control2, IndividualAddress sourceAddress, GroupAddress destinationAddress, byte dataLength, ushort apdu, ArraySegment <byte> data)
 {
     MessageCode        = messageCode;
     Control1           = control1;
     Control2           = control2;
     SourceAddress      = sourceAddress;
     DestinationAddress = destinationAddress;
     DataLength         = dataLength;
     Apdu = apdu;
     Data = data;
 }
Exemple #5
0
        private object OnMessageReceiveAndWaitAnswer(uint messageId, object message)
        {
            try
            {
                MessageCodes messageCode = ( MessageCodes )messageId;

                object result = null;

                switch (messageCode)
                {
                case MessageCodes.AddPathForProtectionCode:
                    result = this.OnAddPathForProtection(message);
                    break;

                case MessageCodes.RemovePathFromProtectionCode:
                    result = this.OnRemovePathFromProtection(message);
                    break;

                case MessageCodes.GetProtectedPathsCode:
                    result = this.OnGetProtectedPaths(message);
                    break;

                case MessageCodes.HasPasswordsCode:
                    result = this.OnHasPasswords(message);
                    break;

                case MessageCodes.AddPasswordCode:
                    result = this.OnAddPassword(message);
                    break;

                case MessageCodes.DeletePasswordCode:
                    result = this.OnDeletePassword(message);
                    break;

                case MessageCodes.ChangePasswordCode:
                    result = this.OnChangePassword(message);
                    break;

                case MessageCodes.CreateAuthSessionKeyCode:
                    result = this.OnCreateAuthSessionKey(message);
                    break;
                }
                return(result);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            return(null);
        }
Exemple #6
0
        public DkmCustomMessage SendLower(DkmCustomMessage message)
        {
            object result;

            byte[]       bytes;
            MessageCodes messageCode = (MessageCodes)message.MessageCode;

            try
            {
                bytes  = (byte[])message.Parameter1;
                result = ProcessMessage(messageCode, bytes);
            }
            catch (Exception e)
            {
                result      = e.ToString();
                messageCode = MessageCodes.Exception;
            }

            bytes = MessageSerializer.Serialize(result);
            return(DkmCustomMessage.Create(message.Connection, message.Process, Guid.Empty, (int)messageCode, bytes, null));
        }
Exemple #7
0
        private object ProcessMessage(MessageCodes messageCode, byte[] bytes)
        {
            switch (messageCode)
            {
            case MessageCodes.ClearCache:
                return(ClearCache(MessageSerializer.Deserialize <bool>(bytes)));

            case MessageCodes.GetClrRuntimes:
                return(GetClrRuntimes(MessageSerializer.Deserialize <uint>(bytes)));

            case MessageCodes.ClrRuntime_GetThreads:
                return(GetClrRuntimeThreads(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetModules:
                return(GetClrRuntimeModules(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetAppDomains:
                return(GetClrRuntimeAppDomains(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetSharedAppDomain:
                return(GetClrRuntimeSharedAppDomain(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetSystemAppDomain:
                return(GetClrRuntimeSystemAppDomain(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetHeapCount:
                return(GetClrRuntimeHeapCount(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_GetServerGC:
                return(GetClrRuntimeServerGC(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrRuntime_ReadFunctionNameAndDisplacement:
                return(ReadClrRuntimeFunctionNameAndDisplacement(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrRuntime_GetInstructionPointerInfo:
                return(GetClrRuntimeInstructionPointerInfo(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrAppDomain_GetModules:
                return(GetClrAppDomainModules(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrHeap_GetCanWalkHeap:
                return(GetClrHeapCanWalkHeap(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrHeap_GetTotalHeapSize:
                return(GetClrHeapTotalHeapSize(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrHeap_GetObjectType:
                return(GetClrHeapObjectType(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrHeap_EnumerateObjects:
                return(EnumerateClrHeapObjects(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrHeap_GetSizeByGeneration:
                return(GetClrHeapSizeByGeneration(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.ClrThread_GetFrames:
                return(GetClrThreadFrames(MessageSerializer.Deserialize <Tuple <int, uint> >(bytes)));

            case MessageCodes.ClrThread_GetLastException:
                return(GetClrThreadLastException(MessageSerializer.Deserialize <Tuple <int, uint> >(bytes)));

            case MessageCodes.ClrThread_EnumerateStackObjects:
                return(EnumerateClrThreadStackObjects(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrStackFrame_GetLocals:
                return(GetClrStackFrameLocals(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrStackFrame_GetArguments:
                return(GetClrStackFrameArguments(MessageSerializer.Deserialize <Tuple <int, uint, int> >(bytes)));

            case MessageCodes.ClrModule_GetTypeByName:
                return(GetClrModuleTypeByName(MessageSerializer.Deserialize <Tuple <int, ulong, string> >(bytes)));

            case MessageCodes.ClrType_GetModule:
                return(GetClrTypeModule(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetSimpleData:
                return(GetClrTypeSimpleData(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetFields:
                return(GetClrTypeFields(MessageSerializer.Deserialize <int>(bytes)));

            case MessageCodes.ClrType_GetArrayElementAddress:
                return(GetClrTypeArrayElementAddress(MessageSerializer.Deserialize <Tuple <int, ulong, int> >(bytes)));

            case MessageCodes.ClrType_GetArrayLength:
                return(GetClrTypeArrayLength(MessageSerializer.Deserialize <Tuple <int, ulong> >(bytes)));

            case MessageCodes.ClrType_GetStaticField:
                return(GetClrTypeStaticField(MessageSerializer.Deserialize <Tuple <int, string> >(bytes)));

            case MessageCodes.ClrStaticField_GetAddress:
                return(GetClrStaticFieldAddress(MessageSerializer.Deserialize <Tuple <int, string, int> >(bytes)));

            case MessageCodes.VariableEnumerator_GetNextBatch:
                return(GetVariableEnumeratorNextBatch(MessageSerializer.Deserialize <Tuple <int, int> >(bytes)));

            case MessageCodes.VariableEnumerator_Dispose:
                return(DisposeVariableEnumerator(MessageSerializer.Deserialize <int>(bytes)));

            default:
                throw new Exception($"Unknown message code: {messageCode}");
            }
        }
Exemple #8
0
 public CemiFrame(MessageCodes messageCode, Control1Flags control1, Control2Flags control2, IndividualAddress sourceAddress, GroupAddress destinationAddress, byte dataLength, ushort apdu)
     : this(messageCode, control1, control2, sourceAddress, destinationAddress, dataLength, apdu, new ArraySegment <byte>())
 {
 }
Exemple #9
0
 public MessageEnvelopeBuilder SetCode(MessageCodes code)
 {
     _code = (int)code;
     return(this);
 }
Exemple #10
0
 public Header(MessageCodes messageCode)
 {
     this.MessageCode = messageCode;
 }
        //Add Methods
        //public void addResponse(ResponseCategory responseCategory, string propertyName, string message, string stackTrace = "", object onObject = null)
        //{
        //    if (responseCategory == ResponseCategory.Error)
        //    {
        //        _hasError = true;
        //    }
        //    _responseMessages.Add(new ResponseMessage(responseCategory, propertyName, message, stackTrace, onObject));
        //}
        //public void addResponse(MessageCodes messageCode, string customMessage = null, object onObject = null, string stackTrace = null)
        //{
        //    string msg = string.Empty;
        //    if (string.IsNullOrWhiteSpace(customMessage))
        //        msg = messageCode.GetDescription();
        //    else
        //        msg = string.Format(messageCode.GetDescription() + " => " + customMessage);
        //    if ((int)messageCode >= 400 && (int)messageCode < 500)
        //    {
        //        _hasError = true;
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Error, msg, onObject, stackTrace));
        //    }
        //    else if((int)messageCode >= 300 && (int)messageCode < 400)
        //    {
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Warning, msg, onObject, stackTrace));
        //    }
        //    else if((int)messageCode >= 200 && (int)messageCode < 300)
        //    {
        //        _responseMessages.Add(new ResponseMessage(ResponseCategory.Information, msg, onObject, stackTrace));
        //    }
        //}
        public void addResponse(string propertyName, MessageCodes messageCode, string customMessage = null, object onObject = null, string stackTrace = null, HttpStatusCode? suggestedStatusCode = null, bool showCustomMessageOnly = false)
        {
            string msg = string.Empty;

            if (string.IsNullOrWhiteSpace(customMessage))
                msg = messageCode.GetDescription();

            if (showCustomMessageOnly && !string.IsNullOrWhiteSpace(customMessage))
                msg = customMessage;
            else
                msg = string.Format(messageCode.GetDescription() + " => " + customMessage);

            if ((int)messageCode >= 400 && (int)messageCode < 500)
            {
                _hasError = true;
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Error, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
            else if ((int)messageCode >= 300 && (int)messageCode < 400)
            {
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Warning, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
            else if ((int)messageCode >= 200 && (int)messageCode < 300)
            {
                _responseMessages.Add(new ResponseMessage(ResponseCategory.Information, propertyName, msg, stackTrace, onObject, suggestedStatusCode));
            }
        }