public void AddCReg(IEnumerable<KeyAndType> asTypes, bool preserveExistingDefaults, ICReg registration)
 {
     foreach (var asType in asTypes)
     {
         AddCReg(asType, preserveExistingDefaults, registration);
     }
 }
Example #2
0
 public void Add(ICReg reg, bool preserveExistingDefaults)
 {
     if (!preserveExistingDefaults || _regs.Count == 0)
     {
         _chosenOne = reg;
     }
     _regs.Add(reg);
 }
Example #3
0
 public void PushToCycleDetector(ICReg reg, string name)
 {
     if (_cycleDetectionStack.Any(t => t.Item1 == reg))
     {
         throw new InvalidOperationException("Cycle detected in registrations: " + string.Join(", ", _cycleDetectionStack.Select(t => t.Item2)) + ". Consider using Lazy<> to break cycle.");
     }
     _cycleDetectionStack.Push(new Tuple <ICReg, string>(reg, name));
 }
 void AddCReg(KeyAndType asType, bool preserveExistingDefaults, ICReg registration)
 {
     ICReg currentReg;
     if (!_registrations.TryGetValue(asType, out currentReg))
     {
         _registrations.Add(asType, registration);
         return;
     }
     var multi = currentReg as ICRegMulti;
     if (multi != null)
     {
         multi.Add(registration, preserveExistingDefaults);
         return;
     }
     multi = new CRegMulti();
     multi.Add(currentReg, false);
     multi.Add(registration, preserveExistingDefaults);
     _registrations[asType] = multi;
 }
        void AddCReg(KeyAndType asType, bool preserveExistingDefaults, ICReg registration)
        {
            ICReg currentReg;

            if (!_registrations.TryGetValue(asType, out currentReg))
            {
                _registrations.Add(asType, registration);
                return;
            }
            var multi = currentReg as ICRegMulti;

            if (multi != null)
            {
                multi.Add(registration, preserveExistingDefaults);
                return;
            }
            multi = new CRegMulti();
            multi.Add(currentReg, false);
            multi.Add(registration, preserveExistingDefaults);
            _registrations[asType] = multi;
        }
Example #6
0
 public void Add(ICReg reg, bool preserveExistingDefaults)
 {
     if (!preserveExistingDefaults || _regs.Count == 0) _chosenOne = reg;
     _regs.Add(reg);
 }
Example #7
0
 public void Add(ICReg key, IILLocal local)
 {
     _map.Add(key, local);
 }
Example #8
0
 internal IILLocal?Get(ICReg key)
 {
     return(_map.TryGetValue(key, out var result) ? result : null);
 }
 public void AddCReg(IEnumerable <KeyAndType> asTypes, bool preserveExistingDefaults, ICReg registration)
 {
     foreach (var asType in asTypes)
     {
         AddCReg(asType, preserveExistingDefaults, registration);
     }
 }
Example #10
0
 public void Add(ICReg key, IILLocal local)
 {
     _map.Add(key, local);
 }
Example #11
0
 internal IILLocal Get(ICReg key)
 {
     IILLocal result;
     return _map.TryGetValue(key, out result) ? result : null;
 }
Example #12
0
            internal IILLocal Get(ICReg key)
            {
                IILLocal result;

                return(_map.TryGetValue(key, out result) ? result : null);
            }