<commit_before>using System;

namespace MassTransit.ServiceBus
{
    public class MessageEndpoint<T> : 
        IMessageEndpoint<T>,
		IMessageEndpointReceive where T: IMessage
    {
        private readonly IEndpoint _endpoint;

        public MessageEndpoint(IEndpoint endpoint)
        {
            _endpoint = endpoint;
        }

        public event MessageHandler<T> MessageReceived;

    	public void Send(IEnvelope e)
    	{
    		_endpoint.Send(e);
    	}

    	public event EventHandler<EnvelopeReceivedEventArgs> EnvelopeReceived;

    	public string Address
        {
            get
            {
            	return _endpoint.Address;
            }
        }

    	public void OnMessageReceived(IServiceBus bus, IEnvelope envelope, IMessage message)
    	{
			if (message is T)
			{
				if (MessageReceived != null)
				{
					MessageReceived(bus, envelope, (T) message);
				}
			}
    	}
    }
}<commit_msg>added what I have heard is a best practice with events. Thoughts?<commit_after>using System;

namespace MassTransit.ServiceBus
{
    public class MessageEndpoint<T> : 
        IMessageEndpoint<T>,
		IMessageEndpointReceive where T: IMessage
    {
        private readonly IEndpoint _endpoint;

        public MessageEndpoint(IEndpoint endpoint)
        {
            _endpoint = endpoint;
        }

        public event MessageHandler<T> MessageReceived;

    	public void Send(IEnvelope e)
    	{
    		_endpoint.Send(e);
    	}

    	public event EventHandler<EnvelopeReceivedEventArgs> EnvelopeReceived;

    	public string Address
        {
            get
            {
            	return _endpoint.Address;
            }
        }

    	public void OnMessageReceived(IServiceBus bus, IEnvelope envelope, IMessage message)
    	{
			if (message is T)
			{
			    MessageHandler<T> local = MessageReceived;
				if (local != null)
				{
					local(bus, envelope, (T) message);
				}
			}
    	}
    }
}
{'fraction_non_alphanumeric': 0.07142857142857142, 'fraction_numerical': 0.0, 'mean_word_length': 2.087859424920128, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4727001', 'n_tokens_mistral': 594, 'n_tokens_neox': 533, 'n_words': 132}