diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2022-06-16 14:17:30 +0300 |
---|---|---|
committer | Lluis Sanchez <llsan@microsoft.com> | 2022-09-13 20:38:42 +0300 |
commit | d15a376e0b7436668d221a70527f7a2f12559164 (patch) | |
tree | bc30406f74df5cc044e7044d35f838ced8db4383 | |
parent | 02395022e0116c66e7c9c02f23fd4452a71f9c3d (diff) |
Add some docs and fix formatting
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs | 8 | ||||
-rw-r--r-- | Mono.Addins/Mono.Addins/ExtensionContext.cs | 23 | ||||
-rw-r--r-- | Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs | 24 | ||||
-rw-r--r-- | Mono.Addins/Mono.Addins/ExtensionNodeList.cs | 4 |
4 files changed, 36 insertions, 23 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs b/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs index 713384a..571deda 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinHostIndex.cs @@ -137,7 +137,7 @@ namespace Mono.Addins.Database { Dictionary<string, string> index; - public ImmutableAddinHostIndex (): this(new Dictionary<string, string>()) + public ImmutableAddinHostIndex () : this (new Dictionary<string, string> ()) { } @@ -151,9 +151,9 @@ namespace Mono.Addins.Database return AddinHostIndex.LookupAddinForAssembly (index, assemblyLocation, out addinId, out addinLocation, out domain); } - public Dictionary<string, string> ToDictionary () - { + public Dictionary<string, string> ToDictionary () + { return new Dictionary<string, string> (index); } - } + } } diff --git a/Mono.Addins/Mono.Addins/ExtensionContext.cs b/Mono.Addins/Mono.Addins/ExtensionContext.cs index b3205b9..5e719d4 100644 --- a/Mono.Addins/Mono.Addins/ExtensionContext.cs +++ b/Mono.Addins/Mono.Addins/ExtensionContext.cs @@ -31,24 +31,23 @@ using System; using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; -using System.Collections.Specialized; using System.Linq; using System.Threading; using Mono.Addins.Description; namespace Mono.Addins { - /// <summary> - /// An extension context. - /// </summary> - /// <remarks> - /// Extension contexts can be used to query the extension tree - /// using particular condition values. Extension points which - /// declare the availability of a condition type can only be - /// queryed using an extension context which provides an - /// evaluator for that condition. - /// </remarks> - public class ExtensionContext + /// <summary> + /// An extension context. + /// </summary> + /// <remarks> + /// Extension contexts can be used to query the extension tree + /// using particular condition values. Extension points which + /// declare the availability of a condition type can only be + /// queryed using an extension context which provides an + /// evaluator for that condition. + /// </remarks> + public class ExtensionContext { internal object LocalLock = new object (); diff --git a/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs b/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs index 3507f49..18d0eb3 100644 --- a/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs +++ b/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs @@ -33,8 +33,20 @@ using System.Threading; namespace Mono.Addins { - class ExtensionContextTransaction : IDisposable - { + /// <summary> + /// Represents a mutation action of an extension context. It is necessary to acquire a transaction object + /// when doing changes in a context (methods that modify a context take a transaction as parameter). + /// Getting a transaction is a blocking operation: if a thread has started a transaction, other threads trying + /// to get one will be blocked until the current transaction is finished. + /// The transaction objects collects two kind of information: + /// 1) changes to be done in the context. For example, it collects conditions to be registered, and then all conditions + /// are added to the context at once when the transaction is completed (so the immutable collection that holds + /// the condition list can be updated with a single allocation). + /// 2) events to be fired once the transaction is completed. This is to avoid firing events while the context + /// lock is taken. + /// </summary> + class ExtensionContextTransaction : IDisposable + { List<TreeNode> loadedNodes; HashSet<TreeNode> childrenChanged; HashSet<string> extensionsChanged; @@ -59,8 +71,10 @@ namespace Mono.Addins public bool DisableEvents { get; set; } public void Dispose () - { + { try { + // Update the context + if (nodeConditions != null) { Context.BulkRegisterNodeConditions (this, nodeConditions); } @@ -93,7 +107,7 @@ namespace Mono.Addins } if (extensionsChanged != null) { foreach (var path in extensionsChanged) - Context.NotifyExtensionsChanged(new ExtensionEventArgs(path)); + Context.NotifyExtensionsChanged (new ExtensionEventArgs (path)); } if (registeredAutoExtensionPoints != null) { var engine = (AddinEngine)Context; @@ -113,7 +127,7 @@ namespace Mono.Addins } if (addinLoadEvents != null) { var engine = (AddinEngine)Context; - foreach(var addin in addinLoadEvents) + foreach (var addin in addinLoadEvents) engine.ReportAddinLoad (addin); } if (addinUnloadEvents != null) { diff --git a/Mono.Addins/Mono.Addins/ExtensionNodeList.cs b/Mono.Addins/Mono.Addins/ExtensionNodeList.cs index b2a6586..fc90fc8 100644 --- a/Mono.Addins/Mono.Addins/ExtensionNodeList.cs +++ b/Mono.Addins/Mono.Addins/ExtensionNodeList.cs @@ -103,8 +103,8 @@ namespace Mono.Addins list.CopyTo (array, index); } - IEnumerator<ExtensionNode> IEnumerable<ExtensionNode>.GetEnumerator () - { + IEnumerator<ExtensionNode> IEnumerable<ExtensionNode>.GetEnumerator () + { return list.GetEnumerator (); } } |