Exemplo n.º 1
0
        public void SavePublisherTypeDefinition(Stream stream, PublisherTypeDefinition publisherDetails)
        {
            if (publisherDetails == null)
            {
                throw new ArgumentNullException(nameof(publisherDetails));
            }

            if (m_isSimple)
            {
                stream.Write((byte)0);
                publisherDetails.Save(stream);
            }
            else
            {
                int lookupId;
                if (m_publisherTypeDefinitionSaveLookup.TryGetValue(publisherDetails, out lookupId))
                {
                    stream.Write((byte)1);
                    stream.Write(lookupId);
                }
                else
                {
                    lookupId = m_publisherTypeDefinitionSaveLookup.Count;
                    stream.Write((byte)3);
                    publisherDetails.Save(stream);
                    m_publisherTypeDefinitionSaveLookup.Add(publisherDetails, lookupId);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Represents a single owner of a log message.
 /// </summary>
 public LogEventPublisherDetails(PublisherTypeDefinition typeData, string eventName)
 {
     if (typeData == null)
     {
         throw new ArgumentNullException(nameof(typeData));
     }
     if (eventName == null)
     {
         eventName = string.Empty;
     }
     TypeData   = typeData;
     EventName  = eventName;
     m_hashCode = ComputeHashCode();
 }
Exemplo n.º 3
0
        public PublisherTypeDefinition LoadPublisherTypeDefinition(Stream stream)
        {
            byte version = stream.ReadNextByte();

            switch (version)
            {
            case 0:
                return(new PublisherTypeDefinition(stream));

            case 1:
            {
                if (m_isSimple)
                {
                    throw new Exception("Cannot load without a LogMessageSaveHelper");
                }
                int id = stream.ReadInt32();
                return(m_publisherTypeDefinitionLoadLookup[id]);
            }

            case 2:
            {
                if (m_isSimple)
                {
                    throw new Exception("Cannot load without a LogMessageSaveHelper");
                }
                int id      = stream.ReadInt32();
                var details = new PublisherTypeDefinition(stream);
                m_publisherTypeDefinitionLoadLookup.Add(details);
                return(details);
            }

            case 3:
            {
                if (m_isSimple)
                {
                    throw new Exception("Cannot load without a LogMessageSaveHelper");
                }
                var details = new PublisherTypeDefinition(stream);
                m_publisherTypeDefinitionLoadLookup.Add(details);
                return(details);
            }

            default:
                throw new VersionNotFoundException();
            }
        }
Exemplo n.º 4
0
        public LogPublisherInternal(LoggerInternal logger, Type type)
        {
            if ((object)type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            Type     = type;
            Assembly = type.Assembly;
            TypeData = new PublisherTypeDefinition(type);
            m_logger = logger;
            SubscriptionFilterCollection = new MessageAttributeFilterCollection();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loads a log messages from the supplied stream
        /// </summary>
        /// <param name="stream">the stream to load the log message from.</param>
        /// <param name="helper">the helper to assist in loading/saving</param>
        internal LogEventPublisherDetails(Stream stream, LogMessageSaveHelper helper)
        {
            byte version = stream.ReadNextByte();

            switch (version)
            {
            case 1:
                string typeName     = stream.ReadString();
                string assemblyName = stream.ReadString();
                TypeData  = new PublisherTypeDefinition(typeName, assemblyName);
                EventName = stream.ReadString();
                break;

            case 2:
                EventName = stream.ReadString();
                TypeData  = helper.LoadPublisherTypeDefinition(stream);
                break;

            default:
                throw new VersionNotFoundException();
            }
            m_hashCode = ComputeHashCode();
        }