private IObjectBuilder GetBuilder(Type objectType, IDictionary <String, String> parameters, IDictionary <String, String> properties, ServiceTypeAtrribute[] attributes) { IObjectBuilder builder; Boolean isSingleton = attributes.Any(o => o.ReferenceType == ReferenceType.Singleton); if (isSingleton) { builder = new SingletonBuilder(); //TODO create object build with IoC container. } else { builder = new ObjectBuilder(); //TODO create object build with IoC container. } builder.ObjectType = objectType; if (parameters != null) { foreach (var param in parameters) { builder.Parameters.Add(param.Key, param.Value); } } if (properties != null) { foreach (var prop in properties) { builder.Properties.Add(prop.Key, prop.Value); } } builder.Connect(this); return(builder); }
/// <summary> /// Applys a singleton service object. /// </summary> /// <typeparam name="T">The service type of the service object.</typeparam> /// <typeparam name="O">The type of the service object.</typeparam> /// <param name="instance">The service object.</param> /// <param name="name">An <c>System.String</c> that specifies the name of service object to get.</param> /// <param name="version">An <c>System.String</c> that specifies the version of service object to get.</param> /// <returns>An IoC container that implements <c>Alioth.Framework.IAliothServiceContainer</c>.</returns> public IAliothServiceContainer Apply <T, O>(O instance, string name, string version) where O : T { var key = new ServiceKey(typeof(T), name, version); var builder = SingletonBuilder.Create(instance); //TODO create object build with IoC container. AddBuilder(key, builder); return(this); }
/// <summary> /// Creates a new instance of the class <c>Alioth.Framework.SingletonBuilder</c>. /// </summary> /// <param name="instance">A singleton service object.</param> /// <returns><c>Alioth.Framework.SingletonBuilder</c>.</returns> public static SingletonBuilder Create(Object instance) { #region precondition if (instance == null) { throw new ArgumentNullException("instance"); } #endregion SingletonBuilder builder = new SingletonBuilder(instance.GetType()); builder.instance = instance; return(builder); }