Click here to Skip to main content
15,897,273 members
Articles / Programming Languages / C#

Tweaked Events

Rate me:
Please Sign up or sign in to vote.
4.83/5 (12 votes)
18 Dec 2010MIT18 min read 34.8K   289   41  
Framework for customizing events. Comes with Weak Events and Synced Events

namespace JpLabs.TweakedEvents
{
	internal sealed class StrongEvent<TEH> : TweakedEvent<TEH> where TEH : class
	{
		// Static methods / members
		public static readonly TweakedEvent<TEH> Empty = new StrongEvent<TEH>();
		
		// Constructors
		private StrongEvent()
		{}

		internal StrongEvent(IEventEntry<TEH>[] entries) : base(entries)
		{}
		
		// Overridden methods
		protected override ITweakedEvent<TEH> CreateNew(IEventEntry<TEH>[] entries)
		{
			//Empty StrongEvents are converted to {null}
			if (entries == null || entries.Length == 0) return null;
			
			return new StrongEvent<TEH>(entries);
		}
		
		public override IEventEntry<TEH> CreateEntry(TEH handler)
		{
			return new StrongEventEntry<TEH>(handler);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) ThoughtWorks
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions