Exemplo n.º 1
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="collector">The collector.</param>
 /// <returns>The same component instance</returns>
 public static T KeepAliveBy <T>(this T thisArg, ObjectCollector collector) where T : IReferencable
 {
     if (ReferenceEquals(thisArg, null))
     {
         return(thisArg);
     }
     return(collector.Add(thisArg));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentBase"/> class.
        /// </summary>
        /// <param name="name">The name attached to this component</param>
        protected ComponentBase(string name)
        {
            Name      = name ?? GetType().Name;
            Id        = Interlocked.Increment(ref globalCounterId);
            collector = new ObjectCollector();

            // Track this component
            if (ComponentTracker.Enable)
            {
                ComponentTracker.Track(this);
            }
            Tags = new PropertyContainer(this);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase"/> class.
 /// </summary>
 protected DisposeBase()
 {
     collector = new ObjectCollector();
     Tags      = new PropertyContainer(this);
 }