Skip to content

A down-to-earth IoC container implementation written in C#.

License

Notifications You must be signed in to change notification settings

arenanet/sprout-ioc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon Sprout IoC

Build status License Stories in Ready

A down-to-earth IoC container implementation written in C#.

Usage

namespace MyNamespace
{
	[Component]
	public class MyComponent
	{
		[Inject]
		MyOtherComponent OtherComponent
		{
			set;
			get;
		}

		public void DoStuff()
		{
			...
		}

		[OnStart]
		void OnStart()
		{
			...
		}

		[OnEnd]
		void OnEnd()
		{
			...
		}
	}

	[Component]
	public class MyOtherComponent
	{
		...
	}
}

...

class MyMain
{
	static void Main(string[] args)
	{
		// Create context instance
		Context context = new Context();

		// Register application namespace and start
		context.Scan("MyNamespace").Start();

		// Register shutdown hook
		AppDomain.CurrentDomain.ProcessExit += (s, e) => context.Stop();

		// Get Context scoped components and interact with them
		MyComponent component = context.GetComponent<MyComponent>();
		component.DoStuff();

		// Wait until Context stops
		while (context.State != ContextState.Stopped)
		{
			Thread.Sleep(1000);
		}
	}
}

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

LICENSE

Copyright 2015 ArenaNet, LLC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

A down-to-earth IoC container implementation written in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages