/// <summary> /// Default constructor to initialize /// an instance of the cache. /// </summary> public XmlSerializerCache() { SyncRoot = new object(); stats = new PerfCounterManager(); //Serializers = new Dictionary<string, System.Xml.Serialization.XmlSerializer>(); Serializers = new Hashtable(); }
/// <summary> /// Default constructor to initialize /// an instance of the cache. /// </summary> public XmlSerializerCache() { SyncRoot = new object(); stats = new PerfCounterManager(); //Serializers = new Dictionary<string, System.Xml.Serialization.XmlSerializer>(); Serializers = new Hashtable(); }
public void CacheHit() { string instanceName = GetCounterInstanceName(0); using (PerfCounterManager manager = new PerfCounterManager()) { using (PerformanceCounter counter = new PerformanceCounter(CATEGORY , SERIALIZER_HITS_NAME , instanceName , true)) { Assert.IsNotNull(counter); Assert.AreEqual(0.0, (decimal)counter.NextValue()); manager.IncrementHitCount(); Assert.AreEqual(1.0, (decimal)counter.NextValue()); } } using (PerformanceCounter counter = new PerformanceCounter(CATEGORY , SERIALIZER_HITS_NAME , instanceName , true)) { try { long l = counter.RawValue; } catch (InvalidOperationException) { // the counter instance went away when we // disposed the manager object. // This exception is what we wanted. } } }