/// <summary>
 /// Creates a new object of type <paramref name="typeToCreate"/> and
 /// adds interception as needed to match the policies specified in
 /// the default policy configuration.
 /// </summary>
 /// <param name="typeToCreate">Concrete object type to create.</param>
 /// <param name="typeToReturn">Type of reference to return. Must be an interface the object implements.</param>
 /// <param name="args">Arguments to pass to the <paramref name="typeToCreate"/> constructor.</param>
 /// <returns>The intercepted object (or possibly a raw instance if no policies apply).</returns>
 public static object Create(Type typeToCreate, Type typeToReturn, params object[] args)
 {
     using (var policyInjector = new PolicyInjector(EnterpriseLibraryContainer.Current))
     {
         return(policyInjector.Create(typeToCreate, typeToReturn, args));
     }
 }
 /// <summary>
 /// Creates a new object of type <typeparamref name="TObject"/> and
 /// adds interception as needed to match the policies specified in
 /// the default policy configuration.
 /// </summary>
 /// <typeparam name="TObject">Type of object to create.</typeparam>
 /// <param name="args">Arguments to pass to the <typeparamref name="TObject"/> constructor.</param>
 /// <returns>The intercepted object (or possibly a raw instance if no policies apply).</returns>
 public static TObject Create <TObject>(params object[] args)
 {
     using (var policyInjector = new PolicyInjector(EnterpriseLibraryContainer.Current))
     {
         return(policyInjector.Create <TObject>(args));
     }
 }
 /// <summary>
 /// Creates a new object of type <typeparamref name="TObject"/> and
 /// adds interception as needed to match the policies specified in
 /// the default policy configuration.
 /// </summary>
 /// <typeparam name="TObject">Concrete object type to create.</typeparam>
 /// <typeparam name="TInterface">Type of reference to return. Must be an interface the object implements.</typeparam>
 /// <param name="args">Arguments to pass to the <typeparamref name="TObject"/> constructor.</param>
 /// <returns>The intercepted object (or possibly a raw instance if no policies apply).</returns>
 public static TInterface Create <TObject, TInterface>(params object[] args)
     where TObject : TInterface
 {
     using (var policyInjector = new PolicyInjector(EnterpriseLibraryContainer.Current))
     {
         return(policyInjector.Create <TObject, TInterface>(args));
     }
 }
Beispiel #4
0
        /// <summary>
        /// Creates a new object of type <typeparamref name="TObject"/> and
        /// adds interception as needed to match the policies specified in
        /// the policy configuration supplied in <paramref name="configurationSource"/>.
        /// </summary>
        /// <typeparam name="TObject">Concrete object type to create.</typeparam>
        /// <typeparam name="TInterface">Type of reference to return. Must be an interface the object implements.</typeparam>
        /// <param name="configurationSource"><see cref="IConfigurationSource"/> containing the policy configuration.</param>
        /// <param name="args">Arguments to pass to the <typeparamref name="TObject"/> constructor.</param>
        /// <returns>The intercepted object (or possibly a raw instance if no policies apply).</returns>
        public static TInterface Create <TObject, TInterface>(IConfigurationSource configurationSource, params object[] args)
        {
            PolicyInjector policyInjector = GetInjectorFromConfig(configurationSource);

            return(policyInjector.Create <TObject, TInterface>(args));
        }