Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void Register(Type interfaceType, object instance, string token)
        {
            IoCItem item;

            if (!items.ContainsKey(interfaceType))
            {
                item = new IoCItem(interfaceType, instance.GetType(), IoCLifetime.PerToken);
                items.Add(interfaceType, item);
            }
            else
            {
                item = items[interfaceType];
            }
            item.AddByToken(instance, token);
        }