using System; using System.Collections.Generic; using System.Text; using CarLibrary2; using Simple.IoC; using Simple.IoC.Loaders; namespace CarLibrary2 { [Implements(typeof(IVehicle), LifecycleType.OncePerRequest)] public class Car : IVehicle, IInitialize { private IEngine _engine; private IPerson _person; public IEngine Engine { get { return _engine; } set { _engine = value; } } public IPerson Driver { get { return _person; } set { _person = value; } } public void Move() { if (_engine == null || _person == null) return; _engine.Start(); Console.WriteLine("{0} says: I�m moving!", _person.Name); } public void Park() { if (_engine == null || _person == null) return; _engine.Stop(); Console.WriteLine("{0} says: I�m parked!", _person.Name); } #region IInitialize Members public void Initialize(IContainer container) { _engine = container.GetService<IEngine>(); _person = container.GetService<IPerson>(); } #endregion } }
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.
This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)