Turn off Policies?

Sep 5, 2011 at 12:04 PM

Hi,

I'm very new to Unity and we're using Unity for plain old DI in a ASP.NET 3.5 web application.  

Looking at the app in RedGate ANTS Profiler I'm seeing that the PolicyList.Set function (see below) is horribly inefficient.

 

        /// <summary>
        /// Sets an individual policy.
        /// </summary>
        /// <param name="policyInterface">The <see cref="Type"/> of the policy.</param>
        /// <param name="policy">The policy to be registered.</param>
        /// <param name="buildKey">The key the policy applies.</param>
        public void Set(Type policyInterface,
                        IBuilderPolicy policy,
                        object buildKey)
        {
            lock (lockObject)
            {
                Dictionary<PolicyKey, IBuilderPolicy> newPolicies = ClonePolicies(); // takes a huge amount of % time
                newPolicies[new PolicyKey(policyInterface, buildKey)] = policy;
                SwapPolicies(newPolicies);
            }
        }

 

We are not using Policies (if I understand them correctly - and there's a good chance I don't) at all.  Is there a config setting or code I can use to "disable" them?  It would speed up my app ~70%!

Thanks in advance,

Nic

 

Sep 6, 2011 at 6:39 AM

Hi,

It seems you got the same issue like on this thread. If this is not the case, then maybe you can post your relevant code here.

 

Noel Angelo Bolasoc
Avanade Software
Avanade, Inc.
entlib.support@avanade.com