Пример #1
0
        /// <summary>
        /// Привязать один тип к другому
        /// </summary>
        /// <typeparam name="T">Тип привязки к</typeparam>
        /// <param name="isSingleInstance">Использовать единственный экземпляр</param>
        /// <returns></returns>
        public SimpleDI To <T>(bool isSingleInstance)
        {
            _newBindSetting.TTo = typeof(T);
            _newBindSetting.IsSingleInstance = isSingleInstance;

            _settings.Add(_newBindSetting.TFrom, _newBindSetting);

            _newBindSetting = null;

            return(this);
        }
Пример #2
0
        public SimpleDI To(object instance)
        {
            _newBindSetting.TTo = null;
            _newBindSetting.IsSingleInstance = true;
            _newBindSetting.Instance         = instance;

            _settings.Add(_newBindSetting.TFrom, _newBindSetting);

            _newBindSetting = null;

            return(this);
        }
Пример #3
0
        /// <summary>
        /// Привязать один тип к другому
        /// </summary>
        /// <typeparam name="T">Типа привязки от</typeparam>
        /// <returns></returns>
        public IBinderTo Bind <T>()
        {
            var type = typeof(T);

            if (_settings.ContainsKey(type))
            {
                throw new Exception($"Type {type} allready presented in bindings");
            }

            _newBindSetting       = new BindSettings();
            _newBindSetting.TFrom = typeof(T);

            return(this);
        }