public EnumerableImpl(object key, Type type, Type resultType, IBuildContext firstBuildCtx, ICRegILGen firstReg) { _key = key; _type = type; _resultType = resultType; _list.Add(new KeyValuePair<IBuildContext, ICRegILGen>(firstBuildCtx, firstReg)); }
public DelegateImpl(object key, Type type, ICRegILGen nestedRegistration) { _key = key; _type = type; _nestedRegistration = nestedRegistration; _myNeed = new Need {Kind = NeedKind.Constant, ClrType = _type}; }
public GenerationContext(ContainerImpl container, ICRegILGen registration, IBuildContext buildContext, ParameterInfo[] parameterInfos) { _container = container; _registration = registration; _buildContext = buildContext; _parameterInfos = parameterInfos; }
public LazyImpl(Type type, ICRegILGen nestedRegistration) { _type = type; _nestedRegistration = nestedRegistration; _myNeed = new Need { Kind = NeedKind.Constant, ClrType = _type }; }
public DelegateImpl(object?key, Type type, ICRegILGen nestedRegistration) { _key = key; _type = type; _nestedRegistration = nestedRegistration; _myNeed = new Need { Kind = NeedKind.Constant, ClrType = _type }; }
internal Func<object> BuildFromRegistration(ICRegILGen registration, IBuildContext buildContext) { if (registration is ICRegFuncOptimized regOpt) { var result = (Func<object>)regOpt.BuildFuncOfT(this, typeof(Func<object>)); if (result != null) { return result; } } var context = new GenerationContext(this, registration, buildContext); return (Func<object>)context.GenerateFunc(typeof(Func<object>)); }
internal void GatherNeeds(ICRegILGen regILGen, HashSet <Tuple <IBuildContext, ICRegILGen> > processed) { var processingContext = new Tuple <IBuildContext, ICRegILGen>(_buildContext, regILGen); if (processed.Contains(processingContext)) { return; } processed.Add(processingContext); foreach (var need in regILGen.GetNeeds(this)) { if (need.Kind == NeedKind.CReg) { GatherNeeds((ICRegILGen)need.Key, processed); continue; } var k = new Tuple <IBuildContext, INeed>(_buildContext, need); if (_resolvers.ContainsKey(k)) { continue; } if (need == Need.ContainerNeed) { _resolvers.Add(k, AddConstant(_container, need.ClrType)); continue; } if (need.Kind == NeedKind.Constant) { _resolvers.Add(k, AddConstant(need.Key, need.ClrType)); continue; } if (need.Kind == NeedKind.ConstructorParameter) { var reg = ResolveNeedBy(need.ClrType, need.Key); if (reg == null && !need.ForcedKey) { reg = ResolveNeedBy(need.ClrType, null); } if (reg == null && need.Optional) { reg = new OptionalImpl(need.OptionalValue, need.ClrType); } if (reg == null) { throw new ArgumentException($"Cannot resolve {need.ClrType.ToSimpleName()} with key {need.Key}"); } _resolvers.Add(new Tuple <IBuildContext, INeed>(_buildContext, need), reg); GatherNeeds(reg, processed); } } }
internal Func<object> BuildFromRegistration(ICRegILGen registration, IBuildContext buildContext) { var regOpt = registration as ICRegFuncOptimized; if (regOpt != null) { var result = (Func<object>)regOpt.BuildFuncOfT(this, typeof(Func<object>)); if (result != null) { return result; } } var context = new GenerationContext(this, registration, buildContext); return (Func<object>)context.GenerateFunc(typeof(Func<object>)); }
public EnumerableImpl(object key, Type type, Type resultType, IBuildContext firstBuildCtx, ICRegILGen firstReg) { _key = key; _type = type; _resultType = resultType; _list.Add(new KeyValuePair <IBuildContext, ICRegILGen>(firstBuildCtx, firstReg)); }
public SingletonImpl(Type implementationType, ICRegILGen wrapping, int singletonIndex) { _implementationType = implementationType; _wrapping = wrapping; _singletonIndex = singletonIndex; }
public SingletonImpl(Type implementationType, ICRegILGen wrapping, int singletonIndex) { _implementationType = implementationType; _wrapping = wrapping; _singletonIndex = singletonIndex; }