/// <summary>
 /// Creates a proxy for the given object that adds interception policies as
 /// defined in the default configuration source.
 /// </summary>
 /// <remarks>
 /// Despite the name of the <typeparamref name="TInterface"/> parameter, this
 /// may be any type that the instance is assignable to, including both interfaces
 /// that it implements and the concrete type of the object.
 /// </remarks>
 /// <typeparam name="TInterface">Type of the proxy to return.</typeparam>
 /// <param name="instance">Instance object to wrap.</param>
 /// <returns>The proxy for the instance, or the raw object if no policies apply.</returns>
 public static TInterface Wrap <TInterface>(object instance)
 {
     using (var policyInjector = new PolicyInjector(EnterpriseLibraryContainer.Current))
     {
         return(policyInjector.Wrap <TInterface>(instance));
     }
 }
 /// <summary>
 /// Creates a proxy for the given object that adds interception policies as
 /// defined in the default configuration source.
 /// </summary>
 /// <param name="typeToReturn">Type of the proxy to return.</param>
 /// <param name="instance">Instance object to wrap.</param>
 /// <returns>The proxy for the instance, or the raw object if no policies apply.</returns>
 public static object Wrap(Type typeToReturn, object instance)
 {
     using (var policyInjector = new PolicyInjector(EnterpriseLibraryContainer.Current))
     {
         return(policyInjector.Wrap(typeToReturn, instance));
     }
 }
コード例 #3
0
        /// <summary>
        /// Creates a proxy for the given object that adds interception policies as
        /// defined in <paramref name="configurationSource"/>.
        /// </summary>
        /// <remarks>
        /// Despite the name of the <typeparamref name="TInterface"/> parameter, this
        /// may be any type that the instance is assignable to, including both interfaces
        /// that it implements and the concrete type of the object.
        /// </remarks>
        /// <typeparam name="TInterface">Type of the proxy to return.</typeparam>
        /// <param name="configurationSource"><see cref="IConfigurationSource"/> containing the policy configuration.</param>
        /// <param name="instance">Instance object to wrap.</param>
        /// <returns>The proxy for the instance, or the raw object if no policies apply.</returns>
        public static TInterface Wrap <TInterface>(IConfigurationSource configurationSource, object instance)
        {
            PolicyInjector policyInjector = GetInjectorFromConfig(configurationSource);

            return(policyInjector.Wrap <TInterface>(instance));
        }