Beispiel #1
0
        /// <summary>
        /// Registers the type.
        /// </summary>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="expireMode">The expire mode.</param>
        /// <param name="span">The span.</param>
        /// <param name="lifetime">The lifetime.</param>
        public void RegisterType(Type interfaceType, Type objectType, IoCExpiration expireMode, TimeSpan span,
                                 IoCLifetime lifetime = IoCLifetime.PerCall)
        {
            if (items.ContainsKey(interfaceType))
            {
                items.Remove(interfaceType);
            }
            IoCItem item = new IoCItem(interfaceType, objectType, lifetime);

            item.Expiration = expireMode;
            item.ExpireSpan = span;
            items.Add(interfaceType, item);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IoCItem"/> class.
 /// </summary>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="lifetime">The lifetime.</param>
 public IoCItem(Type interfaceType, Type objectType, IoCLifetime lifetime)
 {
     this.InterfaceType = interfaceType;
     this.ObjectType    = objectType;
     this.Lifetime      = lifetime;
     this.Expiration    = IoCExpiration.Never;
     this.ExpireTime    = DateTime.UtcNow;
     this.ExpireSpan    = TimeSpan.FromDays(1);
     if (this.Lifetime != IoCLifetime.PerCall)
     {
         this.instances = new Dictionary <string, IoCInstance>();
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IoCItem"/> class.
 /// </summary>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="lifetime">The lifetime.</param>
 public IoCItem(Type interfaceType, Type objectType, IoCLifetime lifetime)
 {
     this.InterfaceType = interfaceType;
     this.ObjectType = objectType;
     this.Lifetime = lifetime;
     this.Expiration = IoCExpiration.Never;
     this.ExpireTime = DateTime.UtcNow;
     this.ExpireSpan = TimeSpan.FromDays(1);
     if (this.Lifetime != IoCLifetime.PerCall)
     {
         this.instances = new Dictionary<string, IoCInstance>();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Registers the type.
 /// </summary>
 /// <typeparam name="TInterface">The type of the interface.</typeparam>
 /// <typeparam name="TObject">The type of the object.</typeparam>
 /// <param name="lifetime">The lifetime.</param>
 public void RegisterType <TInterface, TObject>(IoCLifetime lifetime = IoCLifetime.PerCall)
 {
     RegisterType(typeof(TInterface), typeof(TObject), lifetime);
 }
Beispiel #5
0
 /// <summary>
 /// Registers the type.
 /// </summary>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="lifetime">The lifetime.</param>
 public void RegisterType(Type interfaceType, Type objectType, IoCLifetime lifetime = IoCLifetime.PerCall)
 {
     this.RegisterType(interfaceType, objectType, IoCExpiration.Never, TimeSpan.FromMinutes(5), lifetime);
 }
Beispiel #6
0
 /// <summary>
 /// Registers an instantiation type, given the interface, the type and the lifetime.
 /// </summary>
 /// <typeparam name="TInterface">The type of the interface.</typeparam>
 /// <typeparam name="TObject">The type of the object.</typeparam>
 /// <param name="lifetime">The lifetime.</param>
 public static void Register <TInterface, TObject>(IoCLifetime lifetime = IoCLifetime.PerCall)
 {
     container.RegisterType <TInterface, TObject>(lifetime);
 }
Beispiel #7
0
 /// <summary>
 /// Registers an instantiation type, given the interface, the type and the lifetime.
 /// </summary>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="lifetime">The lifetime.</param>
 public static void Register(Type interfaceType, Type objectType, IoCLifetime lifetime = IoCLifetime.PerCall)
 {
     container.RegisterType(interfaceType, objectType, lifetime);
 }
Beispiel #8
0
 /// <summary>
 /// Registers an instantiation type, given its interface, its type, the expiration mode, the span and the lifetime.
 /// </summary>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="expireMode">The expire mode.</param>
 /// <param name="span">The span.</param>
 /// <param name="lifetime">The lifetime.</param>
 public static void Register(Type interfaceType, Type objectType, IoCExpiration expireMode, TimeSpan span, IoCLifetime lifetime = IoCLifetime.PerCall)
 {
     container.RegisterType(interfaceType, objectType, expireMode, span, lifetime);
 }