Ejemplo n.º 1
0
 /// <summary>
 /// Removes a component that ws being kept alive from a container.
 /// </summary>
 /// <typeparam name="T">A component</typeparam>
 /// <param name="thisArg">The component to remove.</param>
 /// <param name="container">The container that kept a reference to the component.</param>
 public static void RemoveDisposeBy <T>(this T thisArg, ICollectorHolder container)
 {
     if (ReferenceEquals(thisArg, null))
     {
         return;
     }
     container.Collector.Remove(thisArg);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Keeps a component alive by adding it to a container.
 /// </summary>
 /// <typeparam name="T">A component</typeparam>
 /// <param name="thisArg">The component to keep alive.</param>
 /// <param name="container">The container that will keep a reference to the component.</param>
 /// <returns>The same component instance</returns>
 public static T DisposeBy <T>(this T thisArg, ICollectorHolder container) where T : IDisposable
 {
     if (ReferenceEquals(thisArg, null))
     {
         return(thisArg);
     }
     return(container.Collector.Add(thisArg));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Keeps a component alive by adding it to a container.
 /// </summary>
 /// <typeparam name="T">A component</typeparam>
 /// <param name="thisArg">The component to keep alive.</param>
 /// <param name="container">The container that will keep a reference to the component.</param>
 /// <returns>The same component instance</returns>
 public static T DisposeBy <T>(this T thisArg, ICollectorHolder container)
 {
     if (ReferenceEquals(thisArg, null))
     {
         return(default(T));
     }
     return(container.Collector.Add(thisArg));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Keeps a component alive by adding it to a container.
 /// </summary>
 /// <typeparam name="T">A component</typeparam>
 /// <param name="thisArg">The component to keep alive.</param>
 /// <param name="container">The container that will keep a reference to the component.</param>
 /// <returns>The same component instance</returns>
 public static void RemoveKeepAliveBy <T>(this T thisArg, ICollectorHolder container) where T : IReferencable
 {
     if (ReferenceEquals(thisArg, null))
     {
         return;
     }
     container.Collector.Remove(thisArg);
 }