/// <summary> /// Constructor. /// </summary> public EnumItemTracerFilter() { // Find all candidate enum types and assemblies they reside in. List <Type> possibleEnumTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(Enum), ReflectionHelper.GetApplicationEntryAssemblyAndReferencedAssemblies()); for (int i = possibleEnumTypes.Count - 1; i >= 0; i--) { object[] attributes = possibleEnumTypes[i].GetCustomAttributes(typeof(TracerEnumAttribute), true); if (attributes == null || attributes.Length == 0) { possibleEnumTypes.RemoveAt(i); } else { _assemblies.Add(possibleEnumTypes[i].Assembly); } } }
private void NewsManagerSettingsControl_Load(object sender, EventArgs e) { List<Type> types = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(EventSource), ReflectionHelper.GetApplicationEntryAssemblyReferencedAssemblies()); // Gather suitable news source types, evading the RssNewsSource, since it is up for dynamic creation. foreach (Type type in types) { object[] attributes = type.GetCustomAttributes(typeof(EventItemTypeAttribute), false); if (type != typeof(RssNewsSource) && attributes != null && ((EventItemTypeAttribute)attributes[0]).TypeValue == typeof(RssNewsEvent)) { comboBoxPreconfigured.Items.Add(type.Name); _preconfiguredTypes.Add(type); } } UpdateUI(); }
/// <summary> /// Allows the user of this interface to force an update to an object. /// Also the object itself can raise an request to be updated (saved). /// </summary> public bool RestoreObjectState(IPersistentEx persistent) { TracerHelper.Trace("[" + ActualPersistentId(persistent) + "] invoked by :" + ReflectionHelper.GetFullCallingMethodName(3)); lock (this) { string persistentName = ActualPersistentId(persistent); SystemMonitor.CheckThrow(_verificationObjects.ContainsKey(persistentName) == false || _verificationObjects[persistentName] == persistent); if (_restoredObjects.ContainsKey(persistentName) == false /*|| _restoredObjects[persistentName].Values.Count == 0*/) {// Object restoration infromation not found. return(false); } PersistentData dataCopy = _restoredObjects[persistentName].Clone(); bool result = persistent.OnRestoreState(this, dataCopy); if (result) {// Object restored successfully, remove pending restoration information. _restoredObjects.Remove(persistentName); } return(result); } }
public void RegisterObject(IPersistentEx persistent) { lock (this) { if (persistent.PersistencyIsInitialzed == false) { TracerHelper.Trace("[" + ActualPersistentId(persistent) + "] invoked by: " + ReflectionHelper.GetFullCallingMethodName(2)); persistent.InitializePersistency(this); if (_pendingSaveObjects.ContainsKey(ActualPersistentId(persistent)) == false) { _pendingSaveObjects.Add(ActualPersistentId(persistent), new PersistentData()); } SystemMonitor.CheckThrow(_verificationObjects.ContainsKey(ActualPersistentId(persistent)) == false); _verificationObjects.Add(ActualPersistentId(persistent), persistent); } System.Diagnostics.Debug.Assert(_verificationObjects.ContainsKey(ActualPersistentId(persistent))); } }
/// <summary> /// Allows the user of this interface to force an update to an object. /// Also the object itself can raise an request to be updated (saved). /// </summary> public bool SaveObjectState(IPersistentEx persistent) { TracerHelper.Trace("[" + ActualPersistentId(persistent) + "] invoked by: " + ReflectionHelper.GetFullCallingMethodName(2)); lock (this) { RegisterObject(persistent); PersistentData data = _pendingSaveObjects[ActualPersistentId(persistent)]; if (persistent.OnSaveState(this, data) == false) { return(false); } // Only if the receiver has confirmed the saving operation, replace the current data. _pendingSaveObjects[ActualPersistentId(persistent)] = data; } return(true); }