コード例 #1
0
        public object Create(IBuilderContext context,
                             object buildKey)
        {
            Guard.ArgumentNotNull(context, "context");

            return(Activator.CreateInstance(BuilderStrategy.GetTypeFromBuildKey(buildKey),
                                            GetParameters(context, null)));
        }
コード例 #2
0
ファイル: PolicyList.cs プロジェクト: ljvblfz/ObjectBuilder
        public IBuilderPolicy Get(Type policyInterface,
                                  object buildKey,
                                  bool localOnly)
        {
            Type buildType;

            if (!BuilderStrategy.TryGetTypeFromBuildKey(buildKey, out buildType) || !buildType.IsGenericType)
            {
                return
                    (GetNoDefault(policyInterface, buildKey, localOnly) ??
                     GetNoDefault(policyInterface, null, localOnly));
            }

            return
                (GetNoDefault(policyInterface, buildKey, localOnly) ??
                 GetNoDefault(policyInterface, buildType.GetGenericTypeDefinition(), localOnly) ??
                 GetNoDefault(policyInterface, null, localOnly));
        }