4 using System.Collections.Generic;
5 using System.Diagnostics;
9 namespace SiliconStudio.Core.Diagnostics
19 public static readonly
bool Enable =
false;
24 public static readonly
bool EnableEvents =
false;
26 private static readonly Dictionary<long, ComponentReference> ObjectReferences =
new Dictionary<long, ComponentReference>();
34 if (component == null)
36 lock (ObjectReferences)
41 if (!ObjectReferences.TryGetValue(component.
Id, out componentReference))
46 if (Enable && EnableEvents)
57 lock (ObjectReferences)
62 if (ObjectReferences.TryGetValue(
id, out componentReference))
63 return componentReference;
75 return Find(component.
Id);
84 if (component == null)
87 if (Enable && EnableEvents)
94 lock (ObjectReferences)
96 ObjectReferences.Remove(component.Id);
111 if (ObjectReferences.TryGetValue(component.
Id, out componentReference))
116 componentReference.IsDestroyed =
true;
127 var activeObjects =
new List<ComponentReference>();
128 lock (ObjectReferences)
130 activeObjects.AddRange(ObjectReferences.Values.Where(x => !x.IsDestroyed));
133 return activeObjects;
142 var text =
new StringBuilder();
143 foreach (var findActiveObject
in FindActiveObjects())
145 var findActiveObjectStr = findActiveObject.ToString();
146 if (!
string.IsNullOrEmpty(findActiveObjectStr))
147 text.AppendLine(findActiveObjectStr);
149 return text.ToString();
ComponentEventType
TODO: Update summary.
static void NotifyEvent(IComponent component, ComponentEventType eventType)
Should be called everytime an event happens for a IComponent.
Track all allocated objects.
long Id
Gets the id of this component.
static ComponentReference Find(long id)
Finds a component reference from a specified id.
Contains information about a tracked component.
static string ReportActiveObjects()
Reports all COM object that are active and not yet disposed.
static ComponentReference Find(IComponent component)
Finds a component reference for a specific component.
static List< ComponentReference > FindActiveObjects()
Reports all COM and IReferencable object that are active and not yet disposed.
static void Track(IComponent component)
Tracks the specified component object.
Base interface for all components.
static void UnTrack(IComponent component)
Untracks the specified component.
Contains information about a AddReference/Release event.