IBuildContext MakeEnumEnabledChild() { var child = new BuildContext(_container); child._parent = this; child._multiBinds = new List<KeyValuePair<ICRegMulti, int>>(); return child; }
public IBuildContext FreezeMulti() { if (_multiBinds == null) return this; return _parent; var child = new BuildContext(_container); child._parent = this; return child; }
public IBuildContext IncrementEnumerable() { if (_multiBinds == null) throw new InvalidOperationException("This context was not create by MakeEnumEnabledChild"); var nextMultiBind = _multiBinds.ToList(); while (nextMultiBind.Count > 0) { var pair = nextMultiBind[nextMultiBind.Count - 1]; pair = new KeyValuePair<ICRegMulti, int>(pair.Key, pair.Value + 1); if (pair.Value < pair.Key.Regs.Count()) { nextMultiBind[nextMultiBind.Count - 1] = pair; var child = new BuildContext(_container) { _parent = _parent, _multiBinds = nextMultiBind }; return child; } nextMultiBind.RemoveAt(nextMultiBind.Count - 1); } return null; }
Func<object> Build(object key, Type type) { var buildContext = new BuildContext(this); var registration = buildContext.ResolveNeedBy(type, key); if (registration != null) { return BuildFromRegistration(registration, buildContext); } return null; }