void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         packet.GetField("Sequence", out m_Sequence);
         packet.GetField("TimeStamp", out m_TimeStamp);
         break;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Read back the field values for the current packet.
 /// </summary>
 /// <param name="definition">The definition that was used to perisist the packet.</param>
 /// <param name="packet">The serialized packet to read data from</param>
 void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         packet.GetField("FileStartDateTime", out m_FileStartDateTime);
         packet.GetField("FileEndDateTime", out m_FileEndDateTime);
         packet.GetField("IsLastFile", out m_IsLastFile);
         break;
     }
 }
 void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         packet.GetField("TypeName", out m_TypeName);
         packet.GetField("Message", out m_Message);
         packet.GetField("Source", out m_Source);
         packet.GetField("StackTrace", out m_StackTrace);
         break;
     }
 }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("rawTimeStamp", out m_RawTimestamp);
                packet.GetField("rawValue", out m_RawValue);
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("Id", out m_ID);
                packet.GetField("metricPacketId", out m_MetricId);
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("Id", out m_Id);

                // Hmmm, it's tricky to handle the enum with an out parameter; use a temporary int and cast it.
                int status;
                packet.GetField("Status", out status);
                m_EndingStatus = (SessionStatus)status;
                break;
            }
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("instanceName", out m_InstanceName);
                packet.GetField("definitionId", out m_DefinitionId);
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }

            //find our definition from the definitions on the session
            DefinitionPacket = ((MetricDefinition)m_Session.MetricDefinitions[DefinitionId]).Packet;
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                //read the values by our definition
                Values = new object[definition.Fields.Count];

                for (int valueIndex = 0; valueIndex < definition.Fields.Count; valueIndex++)
                {
                    FieldDefinition fieldDefinition = definition.Fields[valueIndex];
                    object          fieldValue;
                    packet.GetField(fieldDefinition.Name, out fieldValue);
                    Values[valueIndex] = fieldValue;
                }

                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }

            //Now we need to go off and find our value definition so we can be serialized out gain
            IMetric ourMetric;

            if (Session.MetricDefinitions.TryGetMetricValue(MetricId, out ourMetric) == false)
            {
                //BIG problems- no metric for our metric ID?
                throw new ArgumentException("Unable to read event metric sample because the associated metric couldn't be found.");
            }
            m_ValueDefinitions = (EventMetricValueDefinitionCollection)((EventMetric)ourMetric).Definition.Values;
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                long baseValue;
                long counterTimeStamp;
                long counterFrequency;
                long systemFrequency;
                long timeStamp;
                long timeStamp100nSec;

                packet.GetField("baseValue", out baseValue);
                packet.GetField("counterTimeStamp", out counterTimeStamp);
                packet.GetField("counterFrequency", out counterFrequency);
                packet.GetField("systemFrequency", out systemFrequency);
                packet.GetField("timeStamp", out timeStamp);
                packet.GetField("timeStamp100nSec", out timeStamp100nSec);

                //conceptually we shouldn't persist this - it's always the same and it's always on our metric, however
                //we need it here for deserialization purposes because our metric packet object isn't available during
                //the deserialization process.
                int rawCounterType;
                packet.GetField("counterType", out rawCounterType);
                PerformanceCounterType counterType = (PerformanceCounterType)rawCounterType;

                //Now, create our sample object from this data
                m_Sample = new CounterSample((long)base.RawValue, baseValue, counterFrequency, systemFrequency, timeStamp, timeStamp100nSec, counterType, counterTimeStamp);
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
Beispiel #10
0
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("MetricTypeName", out m_MetricTypeName);
                packet.GetField("CategoryName", out m_CategoryName);
                packet.GetField("CounterName", out m_CounterName);

                int rawSampleType;
                packet.GetField("SampleType", out rawSampleType);
                m_SampleType = (SampleType)rawSampleType;

                packet.GetField("Caption", out m_Caption);
                packet.GetField("Description", out m_Description);

                int rawInterval;
                packet.GetField("Interval", out rawInterval);
                m_Interval = (MetricSampleInterval)rawInterval;

                //and our stuff that we have to calculate
                Name = MetricDefinition.GetKey(MetricTypeName, CategoryName, CounterName); //generate the name

                m_ReadOnly = true;                                                         //if we got read out of a file, we're read only.
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }

            //we are NOT live - we came from a serialization reader
            IsLive = false;
        }
 void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         packet.GetField("ThreadId", out m_ThreadId);
         if (definition.Fields.ContainsKey("ThreadIndex"))
         {
             packet.GetField("ThreadIndex", out m_ThreadIndex);
             if (m_ThreadIndex == 0)
             {
                 m_ThreadIndex = m_ThreadId;     // Zero isn't legal, so it must not have had it.  Fall back to ThreadId.
             }
         }
         else
         {
             m_ThreadIndex = m_ThreadId;     // Use the "unique" ThreadId from older Agent code.
         }
         packet.GetField("ThreadName", out m_ThreadName);
         packet.GetField("DomainId", out m_DomainId);
         packet.GetField("DomainName", out m_DomainName);
         packet.GetField("IsBackground", out m_IsBackground);
         packet.GetField("IsThreadPoolThread", out m_IsThreadPoolThread);
         break;
     }
 }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("name", out m_Name);

                string typeName;
                packet.GetField("valueType", out typeName);
                SetType(Type.GetType(typeName));

                packet.GetField("caption", out m_Caption);
                packet.GetField("description", out m_Description);

                int rawDefaultTrend;
                packet.GetField("defaultTrend", out rawDefaultTrend);
                m_DefaultTrend = (EventMetricValueTrend)rawDefaultTrend;

                packet.GetField("eventDefinitionPacketId", out m_EventDefinitionPacketId);
                packet.GetField("unitCaption", out m_UnitCaption);

                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
Beispiel #13
0
 void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         packet.GetField("DefaultValueName", out m_DefaultValueName);
         break;
     }
 }
 void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
 {
     switch (definition.Version)
     {
     case 1:
         int rawCounterType;
         packet.GetField("counterType", out rawCounterType);
         CounterType = (PerformanceCounterType)rawCounterType;
         break;
     }
 }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("unitCaption", out m_UnitCaption);
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                int rawSampleType;
                packet.GetField("metricSampleType", out rawSampleType);
                m_MetricSampleType = (MetricSampleType)rawSampleType;
                break;

            default:
                throw new GibraltarPacketVersionException(definition.Version);
            }
        }
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
            case 2:     //two just adds fields.
            case 3:     //three just adds one field.
                packet.GetField("ID", out m_ID);
                packet.GetField("Caption", out m_Caption);

                // Hmmm, it's tricky to handle the enum with an out parameter; use a temporary int and cast it.
                int severity;
                packet.GetField("Severity", out severity);
                m_Severity = (LogMessageSeverity)severity;

                packet.GetField("LogSystem", out m_LogSystem);
                packet.GetField("CategoryName", out m_CategoryName);
                packet.GetField("UserName", out m_UserName);

                if (definition.Version >= 2)
                {
                    packet.GetField("Description", out m_Description);
                    packet.GetField("Details", out m_Details);
                }

                // These have now been fully integrated here from the former CallInfoPacket
                packet.GetField("ThreadId", out m_ThreadId);
                packet.GetField("MethodName", out m_MethodName);
                packet.GetField("ClassName", out m_ClassName);
                packet.GetField("FileName", out m_FileName);
                packet.GetField("LineNumber", out m_LineNumber);

                if (definition.Fields.ContainsKey("ThreadIndex"))
                {
                    packet.GetField("ThreadIndex", out m_ThreadIndex);
                    if (m_ThreadIndex == 0)
                    {
                        m_ThreadIndex = m_ThreadId;     // Zero isn't legal, so it must not have had it.  Fall back to ThreadId.
                    }
                }
                else
                {
                    m_ThreadIndex = m_ThreadId;     // Oops, older code doesn't have it, so use the ThreadId to fake it.
                }

                //we now know enough to get our thread info packet (if we don't, we can't re-serialize ourselves)
                ThreadInfo threadInfo;
                if (m_SessionPacketCache.Threads.TryGetValue(m_ThreadIndex, out threadInfo))
                {
                    ThreadInfoPacket = threadInfo.Packet;
                }

                // Now the Exception info...

                string[] typeNames;
                string[] messages;
                string[] sources;
                string[] stackTraces;

                packet.GetField("TypeNames", out typeNames);
                packet.GetField("Messages", out messages);
                packet.GetField("Sources", out sources);
                packet.GetField("StackTraces", out stackTraces);

                //these are supposed to be parallel arrays - assume they're all the same size.
                int arrayLength             = typeNames.GetLength(0);
                IExceptionInfo[] exceptions = new IExceptionInfo[arrayLength];     // local holder to build it up

                IExceptionInfo lastException = null;
                for (int i = 0; i < arrayLength; i++)
                {
                    IExceptionInfo exception = new ExceptionInfoPacket()
                    {
                        TypeName   = typeNames[i],
                        Message    = messages[i],
                        Source     = sources[i],
                        StackTrace = stackTraces[i]
                    };
                    exceptions[i] = exception;
                    if (lastException != null)
                    {
                        ((ExceptionInfoPacket)lastException).InnerException = exception;     //we are the inner exception to our parent.
                    }
                    lastException = exception;
                }

                m_ExceptionChain = exceptions;     // Set the rehydrated ExceptionInfo[] array property

                if (definition.Version >= 3)
                {
                    Guid applicationUserId;
                    packet.GetField("ApplicationUserId", out applicationUserId);

                    //we now know enough to get our user packet now if it was specified..
                    ApplicationUser applicationUser;
                    if (m_SessionPacketCache.Users.TryGetValue(applicationUserId, out applicationUser))
                    {
                        UserPacket = applicationUser.Packet;
                    }
                }

                break;
            }
        }
Beispiel #18
0
        void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet)
        {
            switch (definition.Version)
            {
            case 1:
                packet.GetField("Key", out m_Key);
                packet.GetField("UserName", out m_FullyQualifiedUserName);
                packet.GetField("Caption", out m_Caption);
                packet.GetField("Title", out m_Title);
                packet.GetField("Organization", out m_Organization);
                packet.GetField("Role", out m_Role);
                packet.GetField("Tenant", out m_Tenant);
                packet.GetField("TimeZoneCode", out m_TimeZoneCode);
                packet.GetField("EmailAddress", out m_EmailAddress);
                packet.GetField("Phone", out m_Phone);

                string[] propertyNames;
                packet.GetField("PropertyNames", out propertyNames);

                string[] propertyValues;
                packet.GetField("PropertyValues", out propertyValues);

                for (int index = 0; index < propertyNames.Length; index++)
                {
                    var propertyName  = propertyNames[index];
                    var propertyValue = propertyValues[index];
                    m_Properties.Add(propertyName, propertyValue);
                }

                break;
            }
        }