Esempio n. 1
0
 public virtual void Track(object instance, Burden burden)
 {
     if (burden.RequiresPolicyRelease == false)
     {
         var lifestyle = ((object)burden.Model.CustomLifestyle) ?? burden.Model.LifestyleType;
         throw new ArgumentException(
                   string.Format(
                       "Release policy was asked to track object '{0}', but its burden has 'RequiresPolicyRelease' set to false. If object is to be tracked the flag must be true. This is likely a bug in the lifetime manager '{1}'.",
                       instance, lifestyle));
     }
     try
     {
         using (@lock.ForWriting())
         {
             instance2Burden.Add(instance, burden);
         }
     }
     catch (ArgumentNullException)
     {
         //eventually we should probably throw something more useful here too
         throw;
     }
     catch (ArgumentException)
     {
         throw HelpfulExceptionsUtil.TrackInstanceCalledMultipleTimes(instance, burden);
     }
     burden.Released += OnInstanceReleased;
     perfCounter.IncrementTrackedInstancesCount();
 }
Esempio n. 2
0
 public virtual void Track(object instance, Burden burden)
 {
     if (burden.RequiresPolicyRelease == false)
     {
         var lifestyle = ((object)burden.Model.CustomLifestyle) ?? burden.Model.LifestyleType;
         throw new ArgumentException(
                   string.Format(
                       "Release policy was asked to track object '{0}', but its burden has 'RequiresPolicyRelease' set to false. If object is to be tracked the flag must be true. This is likely a bug in the lifetime manager '{1}'.",
                       instance, lifestyle));
     }
     using (@lock.ForWriting())
     {
         instance2Burden.Add(instance, burden);
         burden.Released += OnInstanceReleased;
     }
     perfCounter.IncrementTrackedInstancesCount();
 }