Browse Source

Some XML documentation for ICSharpCode.Core.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2318 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
a594307239
  1. 1
      data/resources/image/BitmapResources/BitmapResources.res
  2. BIN
      data/resources/image/BitmapResources/SetupIcons/Setup.Icons.16x16.Component.png
  3. 7
      data/schemas/AddIn.xsd
  4. 26
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/InsightWindow/IInsightDataProvider.cs
  5. 7
      src/Main/Core/Project/Src/AddInTree/AddIn/IDoozer.cs
  6. 103
      src/Main/Core/Project/Src/AddInTree/AddInManager.cs
  7. 71
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs
  8. 43
      src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs
  9. 72
      src/Main/Core/Project/Src/AddInTree/CoreStartup.cs
  10. 10
      src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs
  11. 3
      src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs
  12. 2
      src/Main/Core/Project/Src/Services/MessageService/InputBox.cs
  13. 126
      src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

1
data/resources/image/BitmapResources/BitmapResources.res

@ -498,3 +498,4 @@ Icons.16x16.NavigateForward = NavigationIcons\Icons.16x16.NavigateF @@ -498,3 +498,4 @@ Icons.16x16.NavigateForward = NavigationIcons\Icons.16x16.NavigateF
#Setup icons (Wix)
Setup.Icons.16x16.SetupDialogsPad = SetupIcons\Setup.Icons.16x16.SetupDialogsPad.png
Setup.Icons.16x16.Component = SetupIcons\Setup.Icons.16x16.Component.png

BIN
data/resources/image/BitmapResources/SetupIcons/Setup.Icons.16x16.Component.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

7
data/schemas/AddIn.xsd

@ -1,5 +1,10 @@ @@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Ivo Kovacka (Kovacka) -->
<!-- SharpDevelop .addin schema -->
<!--
This schema is not used for validation (it does not cover custom doozers),
but to provide XML completion in XML editors.
Parts of the file are automatically generated by Tools/BuildAddInDocumentation.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.icsharpcode.net/2005/addin" xmlns="http://www.icsharpcode.net/2005/addin">
<xs:complexType name="AddIn">
<xs:choice minOccurs="1" maxOccurs="unbounded">

26
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/InsightWindow/IInsightDataProvider.cs

@ -11,17 +11,41 @@ namespace ICSharpCode.TextEditor.Gui.InsightWindow @@ -11,17 +11,41 @@ namespace ICSharpCode.TextEditor.Gui.InsightWindow
{
public interface IInsightDataProvider
{
/// <summary>
/// Tells the insight provider to prepare its data.
/// </summary>
/// <param name="fileName">The name of the edited file</param>
/// <param name="textArea">The text area in which the file is being edited</param>
void SetupDataProvider(string fileName, TextArea textArea);
/// <summary>
/// Notifies the insight provider that the caret offset has changed.
/// </summary>
/// <returns>Return true to close the insight window (e.g. when the
/// caret was moved outside the region where insight is displayed for).
/// Return false to keep the window open.</returns>
bool CaretOffsetChanged();
bool CharTyped();
/// <summary>
/// Gets the text to display in the insight window.
/// </summary>
/// <param name="number">The number of the active insight entry.
/// Multiple insight entries might be multiple overloads of the same method.</param>
/// <returns>The text to display, e.g. a multi-line string where
/// the first line is the method definition, followed by a description.</returns>
string GetInsightData(int number);
/// <summary>
/// Gets the number of available insight entries, e.g. the number of available
/// overloads to call.
/// </summary>
int InsightDataCount {
get;
}
/// <summary>
/// Gets the index of the entry to initially select.
/// </summary>
int DefaultIndex {
get;
}

7
src/Main/Core/Project/Src/AddInTree/AddIn/IDoozer.cs

@ -22,6 +22,13 @@ namespace ICSharpCode.Core @@ -22,6 +22,13 @@ namespace ICSharpCode.Core
/// </summary>
bool HandleConditions { get; }
/// <summary>
/// Construct the item.
/// </summary>
/// <param name="caller">The caller passed to <see cref="AddInTree.BuildItem"/>.</param>
/// <param name="codon">The codon to build.</param>
/// <param name="subItems">The list of objects created by (other) doozers for the sub items.</param>
/// <returns>The constructed item.</returns>
object BuildItem(object caller, Codon codon, ArrayList subItems);
}
}

103
src/Main/Core/Project/Src/AddInTree/AddInManager.cs

@ -13,24 +13,70 @@ using System.Xml; @@ -13,24 +13,70 @@ using System.Xml;
namespace ICSharpCode.Core
{
/// <summary>
/// Specifies the action to be taken for a specific <see cref="AddIn"/>.
/// </summary>
public enum AddInAction
{
/// <summary>
/// Enable the <see cref="AddIn"/>.
/// </summary>
Enable,
/// <summary>
/// Disable the <see cref="AddIn"/>.
/// </summary>
Disable,
/// <summary>
/// Install the <see cref="AddIn"/>.
/// </summary>
Install,
/// <summary>
/// Uninstall the <see cref="AddIn"/>.
/// </summary>
Uninstall,
/// <summary>
/// Update the <see cref="AddIn"/>.
/// </summary>
Update,
/// <summary>
/// The <see cref="AddIn"/> is disabled because it has been installed
/// twice (duplicate identity).
/// </summary>
InstalledTwice,
/// <summary>
/// Tells that the <see cref="AddIn"/> cannot be loaded because not all dependencies are satisfied.
/// </summary>
DependencyError,
/// <summary>
/// A custom error has occurred (e.g. the AddIn disabled itself using a condition).
/// </summary>
CustomError
}
/// <summary>
/// Manages all actions performed on <see cref="AddIn"/>s.
/// An AddInManager GUI can use the methods here to install/update/uninstall
/// <see cref="AddIn"/>s.
///
/// There are three types of AddIns:
/// - Preinstalled AddIns (added by host application) -> can only be disabled
/// - External AddIns -> can be added, disabled and removed
/// Removing external AddIns only removes the reference to the .addin file
/// but does not delete the AddIn.
/// - User AddIns -> are installed to UserAddInPath, can be installed, disabled
/// and uninstalled
/// </summary>
public static class AddInManager
{
static string configurationFileName;
static string addInInstallTemp;
static string userAddInPath;
/// <summary>
/// Gets or sets the user addin path.
/// This is the path where user AddIns are installed to.
/// This property is normally initialized by <see cref="CoreStartup.ConfigureUserAddIns"/>.
/// </summary>
public static string UserAddInPath {
get {
return userAddInPath;
@ -40,6 +86,12 @@ namespace ICSharpCode.Core @@ -40,6 +86,12 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Gets or sets the addin install temporary directory.
/// This is a directory used to store AddIns that should be installed on
/// the next start of the application.
/// This property is normally initialized by <see cref="CoreStartup.ConfigureUserAddIns"/>.
/// </summary>
public static string AddInInstallTemp {
get {
return addInInstallTemp;
@ -49,6 +101,12 @@ namespace ICSharpCode.Core @@ -49,6 +101,12 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Gets or sets the full name of the configuration file.
/// In this file, the AddInManager stores the list of disabled AddIns
/// and the list of installed external AddIns.
/// This property is normally initialized by <see cref="CoreStartup.ConfigureExternalAddIns"/>.
/// </summary>
public static string ConfigurationFileName {
get {
return configurationFileName;
@ -62,6 +120,7 @@ namespace ICSharpCode.Core @@ -62,6 +120,7 @@ namespace ICSharpCode.Core
/// Installs the AddIns from AddInInstallTemp to the UserAddInPath.
/// In case of installation errors, a error message is displayed to the user
/// and the affected AddIn is added to the disabled list.
/// This method is normally called by <see cref="CoreStartup.ConfigureUserAddIns"/>
/// </summary>
public static void InstallAddIns(List<string> disabled)
{
@ -139,6 +198,13 @@ namespace ICSharpCode.Core @@ -139,6 +198,13 @@ namespace ICSharpCode.Core
return true;
}
/// <summary>
/// Uninstalls the user addin on next start.
/// <see cref="RemoveUserAddInOnNextStart"/> schedules the AddIn for
/// deinstallation, you can unschedule it using
/// <see cref="AbortRemoveUserAddInOnNextStart"/>
/// </summary>
/// <param name="identity">The identity of the addin to remove.</param>
public static void RemoveUserAddInOnNextStart(string identity)
{
List<string> removeEntries = new List<string>();
@ -163,6 +229,13 @@ namespace ICSharpCode.Core @@ -163,6 +229,13 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Prevents a user AddIn from being uninstalled.
/// <see cref="RemoveUserAddInOnNextStart"/> schedules the AddIn for
/// deinstallation, you can unschedule it using
/// <see cref="AbortRemoveUserAddInOnNextStart"/>
/// </summary>
/// <param name="identity">The identity of which to abort the removal.</param>
public static void AbortRemoveUserAddInOnNextStart(string identity)
{
string removeFile = Path.Combine(addInInstallTemp, "remove.txt");
@ -185,6 +258,14 @@ namespace ICSharpCode.Core @@ -185,6 +258,14 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Adds the specified external AddIns to the list of registered external
/// AddIns.
/// </summary>
/// <param name="addIns">
/// The list of AddIns to add. (use <see cref="AddIn"/> instances
/// created by <see cref="AddIn.Load(TextReader)"/>).
/// </param>
public static void AddExternalAddIns(IList<AddIn> addIns)
{
List<string> addInFiles = new List<string>();
@ -202,6 +283,12 @@ namespace ICSharpCode.Core @@ -202,6 +283,12 @@ namespace ICSharpCode.Core
SaveAddInConfiguration(addInFiles, disabled);
}
/// <summary>
/// Removes the specified external AddIns from the list of registered external
/// AddIns.
/// </summary>
/// The list of AddIns to remove.
/// (use external AddIns from the <see cref="AddInTree.AddIns"/> collection).
public static void RemoveExternalAddIns(IList<AddIn> addIns)
{
List<string> addInFiles = new List<string>();
@ -222,6 +309,10 @@ namespace ICSharpCode.Core @@ -222,6 +309,10 @@ namespace ICSharpCode.Core
SaveAddInConfiguration(addInFiles, disabled);
}
/// <summary>
/// Marks the specified AddIns as enabled (will take effect after
/// next application restart).
/// </summary>
public static void Enable(IList<AddIn> addIns)
{
List<string> addInFiles = new List<string>();
@ -248,6 +339,10 @@ namespace ICSharpCode.Core @@ -248,6 +339,10 @@ namespace ICSharpCode.Core
SaveAddInConfiguration(addInFiles, disabled);
}
/// <summary>
/// Marks the specified AddIns as disabled (will take effect after
/// next application restart).
/// </summary>
public static void Disable(IList<AddIn> addIns)
{
List<string> addInFiles = new List<string>();
@ -274,6 +369,8 @@ namespace ICSharpCode.Core @@ -274,6 +369,8 @@ namespace ICSharpCode.Core
/// "&lt;Disable addin='addin identity'&gt;" will be added to <paramref name="disabledAddIns"/>,
/// all other XML elements are ignored.
/// </summary>
/// <param name="addInFiles">File names of external AddIns are added to this collection.</param>
/// <param name="disabledAddIns">Identities of disabled addins are added to this collection.</param>
public static void LoadAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns)
{
if (!File.Exists(configurationFileName))
@ -297,6 +394,12 @@ namespace ICSharpCode.Core @@ -297,6 +394,12 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Saves the AddIn configuration in the format expected by
/// <see cref="LoadAddInConfiguration"/>.
/// </summary>
/// <param name="addInFiles">List of file names of external AddIns.</param>
/// <param name="disabledAddIns">List of Identities of disabled addins.</param>
public static void SaveAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns)
{
using (XmlTextWriter writer = new XmlTextWriter(configurationFileName, Encoding.UTF8)) {

71
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -38,24 +38,36 @@ namespace ICSharpCode.Core @@ -38,24 +38,36 @@ namespace ICSharpCode.Core
conditionEvaluators.Add("Ownerstate", new OwnerStateConditionEvaluator());
}
/// <summary>
/// Gets the list of loaded AddIns.
/// </summary>
public static IList<AddIn> AddIns {
get {
return addIns.AsReadOnly();
}
}
/// <summary>
/// Gets a dictionary of registered doozers.
/// </summary>
public static Dictionary<string, IDoozer> Doozers {
get {
return doozers;
}
}
/// <summary>
/// Gets a dictionary of registered condition evaluators.
/// </summary>
public static Dictionary<string, IConditionEvaluator> ConditionEvaluators {
get {
return conditionEvaluators;
}
}
/// <summary>
/// Checks whether the specified path exists in the AddIn tree.
/// </summary>
public static bool ExistsTreeNode(string path)
{
if (path == null || path.Length == 0) {
@ -66,20 +78,34 @@ namespace ICSharpCode.Core @@ -66,20 +78,34 @@ namespace ICSharpCode.Core
AddInTreeNode curPath = rootNode;
int i = 0;
while (i < splittedPath.Length) {
if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) {
// curPath = curPath.ChildNodes[splittedPath[i]] - check if child path exists
if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) {
return false;
}
curPath = curPath.ChildNodes[splittedPath[i]];
++i;
}
return true;
}
/// <summary>
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
/// This method throws a <see cref="TreePathNotFoundException"/> when the
/// path does not exist.
/// </summary>
public static AddInTreeNode GetTreeNode(string path)
{
return GetTreeNode(path, true);
}
/// <summary>
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
/// </summary>
/// <param name="path">The path of the AddIn tree node</param>
/// <param name="throwOnNotFound">
/// If set to <c>true</c>, this method throws a
/// <see cref="TreePathNotFoundException"/> when the path does not exist.
/// If set to <c>false</c>, <c>null</c> is returned for non-existing paths.
/// </param>
public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound)
{
if (path == null || path.Length == 0) {
@ -89,13 +115,13 @@ namespace ICSharpCode.Core @@ -89,13 +115,13 @@ namespace ICSharpCode.Core
AddInTreeNode curPath = rootNode;
int i = 0;
while (i < splittedPath.Length) {
if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) {
if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) {
if (throwOnNotFound)
throw new TreePathNotFoundException(path);
else
return null;
}
curPath = curPath.ChildNodes[splittedPath[i]];
// curPath = curPath.ChildNodes[splittedPath[i]]; already done by TryGetValue
++i;
}
return curPath;
@ -104,6 +130,10 @@ namespace ICSharpCode.Core @@ -104,6 +130,10 @@ namespace ICSharpCode.Core
/// <summary>
/// Builds a single item in the addin tree.
/// </summary>
/// <param name="path">A path to the item in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
/// <exception cref="TreePathNotFoundException">The path does not
/// exist or does not point to an item.</exception>
public static object BuildItem(string path, object caller)
{
int pos = path.LastIndexOf('/');
@ -118,9 +148,10 @@ namespace ICSharpCode.Core @@ -118,9 +148,10 @@ namespace ICSharpCode.Core
/// </summary>
/// <param name="path">A path in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
/// <param name="throwOnNotFound">If true, throws an TreePathNotFoundException
/// if the path is not found. If false, an empty ArrayList is returned when the
/// path is not found.</param>
/// <param name="throwOnNotFound">
/// If <c>true</c>, throws a <see cref="TreePathNotFoundException"/> if the path is not found.
/// If <c>false</c>, an empty ArrayList is returned when the path is not found.
/// </param>
public static ArrayList BuildItems(string path, object caller, bool throwOnNotFound)
{
AddInTreeNode node = GetTreeNode(path, throwOnNotFound);
@ -132,7 +163,7 @@ namespace ICSharpCode.Core @@ -132,7 +163,7 @@ namespace ICSharpCode.Core
/// <summary>
/// Builds the items in the path. Ensures that all items have the type T.
/// Throws an exception if the path is not found.
/// Throws a <see cref="TreePathNotFoundException"/> if the path is not found.
/// </summary>
/// <param name="path">A path in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
@ -146,7 +177,7 @@ namespace ICSharpCode.Core @@ -146,7 +177,7 @@ namespace ICSharpCode.Core
/// </summary>
/// <param name="path">A path in the addin tree.</param>
/// <param name="caller">The owner used to create the objects.</param>
/// <param name="throwOnNotFound">If true, throws an TreePathNotFoundException
/// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/>
/// if the path is not found. If false, an empty ArrayList is returned when the
/// path is not found.</param>
public static List<T> BuildItems<T>(string path, object caller, bool throwOnNotFound)
@ -185,6 +216,12 @@ namespace ICSharpCode.Core @@ -185,6 +216,12 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// The specified AddIn is added to the <see cref="AddIns"/> collection.
/// If the AddIn is enabled, its doozers, condition evaluators and extension
/// paths are added to the AddInTree and its resources are added to the
/// <see cref="ResourceService"/>.
/// </summary>
public static void InsertAddIn(AddIn addIn)
{
if (addIn.Enabled) {
@ -227,6 +264,12 @@ namespace ICSharpCode.Core @@ -227,6 +264,12 @@ namespace ICSharpCode.Core
addIns.Add(addIn);
}
/// <summary>
/// The specified AddIn is removed to the <see cref="AddIns"/> collection.
/// This is only possible for disabled AddIns, enabled AddIns require
/// a restart of the application to be removed.
/// </summary>
/// <exception cref="ArgumentException">Occurs when trying to remove an enabled AddIn.</exception>
public static void RemoveAddIn(AddIn addIn)
{
if (addIn.Enabled) {
@ -282,6 +325,16 @@ namespace ICSharpCode.Core @@ -282,6 +325,16 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Loads a list of .addin files, ensuring that dependencies are satisfied.
/// This method is normally called by <see cref="CoreStartup.RunInitialization"/>.
/// </summary>
/// <param name="addInFiles">
/// The list of .addin file names to load.
/// </param>
/// <param name="disabledAddIns">
/// The list of disabled AddIn identity names.
/// </param>
public static void Load(List<string> addInFiles, List<string> disabledAddIns)
{
List<AddIn> list = new List<AddIn>();

43
src/Main/Core/Project/Src/AddInTree/AddInTreeNode.cs

@ -12,29 +12,32 @@ using System.Collections.Generic; @@ -12,29 +12,32 @@ using System.Collections.Generic;
namespace ICSharpCode.Core
{
/// <summary>
/// Description of AddInTreeNode.
/// Represents an extension path in the <see cref="AddInTree"/>.
/// </summary>
public class AddInTreeNode
public sealed class AddInTreeNode
{
Dictionary<string, AddInTreeNode> childNodes = new Dictionary<string, AddInTreeNode>();
List<Codon> codons = new List<Codon>();
bool isSorted = false;
/// <summary>
/// A dictionary containing the child paths.
/// </summary>
public Dictionary<string, AddInTreeNode> ChildNodes {
get {
return childNodes;
}
}
/// <summary>
/// A list of child <see cref="Codon"/>s.
/// </summary>
public List<Codon> Codons {
get {
return codons;
}
}
public AddInTreeNode()
{
}
//
// public void BinarySerialize(BinaryWriter writer)
// {
@ -54,7 +57,10 @@ namespace ICSharpCode.Core @@ -54,7 +57,10 @@ namespace ICSharpCode.Core
// }
// }
public class TopologicalSort
/// <summary>
/// Supports sorting codons using InsertBefore/InsertAfter
/// </summary>
sealed class TopologicalSort
{
List<Codon> codons;
bool[] visited;
@ -126,6 +132,10 @@ namespace ICSharpCode.Core @@ -126,6 +132,10 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Builds the child items in this path. Ensures that all items have the type T.
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
public List<T> BuildChildItems<T>(object caller)
{
List<T> items = new List<T>(codons.Count);
@ -155,12 +165,20 @@ namespace ICSharpCode.Core @@ -155,12 +165,20 @@ namespace ICSharpCode.Core
return items;
}
// Workaround for Boo compiler (it cannot distinguish between the generic and non-generic method)
/// <summary>
/// Same as <see cref="BuildChildItems"/> (no type arguments).
/// Workaround for Boo compiler (it cannot distinguish between the generic and non-generic method).
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
public ArrayList BuildChildItemsArrayList(object caller)
{
return BuildChildItems(caller);
}
/// <summary>
/// Builds the child items in this path.
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
public ArrayList BuildChildItems(object caller)
{
ArrayList items = new ArrayList(codons.Count);
@ -186,6 +204,17 @@ namespace ICSharpCode.Core @@ -186,6 +204,17 @@ namespace ICSharpCode.Core
return items;
}
/// <summary>
/// Builds a specific child items in this path.
/// </summary>
/// <param name="childItemID">
/// The ID of the child item to build.
/// </param>
/// <param name="caller">The owner used to create the objects.</param>
/// <param name="subItems">The subitems to pass to the doozer</param>
/// <exception cref="TreePathNotFoundException">
/// Occurs when <paramref name="childItemID"/> does not exist in this path.
/// </exception>
public object BuildChildItem(string childItemID, object caller, ArrayList subItems)
{
foreach (Codon codon in codons) {

72
src/Main/Core/Project/Src/AddInTree/CoreStartup.cs

@ -14,10 +14,26 @@ namespace ICSharpCode.Core @@ -14,10 +14,26 @@ namespace ICSharpCode.Core
/// <summary>
/// Class that helps starting up ICSharpCode.Core.
/// </summary>
public class CoreStartup
/// <remarks>
/// Initializing ICSharpCode.Core requires initializing several static classes
/// and the <see cref="AddInTree"/>. <see cref="CoreStartup"/> does this work
/// for you, provided you use it like this:
/// 1. Create a new CoreStartup instance
/// 2. (Optional) Set the values of the properties.
/// 3. Call <see cref="StartCoreServices()"/>.
/// 4. Add "preinstalled" AddIns using <see cref="AddAddInsFromDirectory"/>
/// and <see cref="AddAddInFile"/>.
/// 5. (Optional) Call <see cref="ConfigureExternalAddIns"/> to support
/// disabling AddIns and installing external AddIns
/// 6. (Optional) Call <see cref="ConfigureUserAddIns"/> to support installing
/// user AddIns.
/// 7. Call <see cref="RunInitialization"/>.
/// </remarks>
public sealed class CoreStartup
{
List<string> addInFiles = new List<string>();
List<string> disabledAddIns = new List<string>();
bool externalAddInsConfigured;
string propertiesName;
string configDirectory;
string dataDirectory;
@ -41,7 +57,11 @@ namespace ICSharpCode.Core @@ -41,7 +57,11 @@ namespace ICSharpCode.Core
/// <summary>
/// Sets the directory name used for the property service.
/// Must be set before StartCoreServices() is called.
/// Use null to use the default path "ApplicationData\ApplicationName".
/// Use null to use the default path "%ApplicationData%\%ApplicationName%",
/// where %ApplicationData% is the system setting for
/// "c:\documents and settings\username\application data"
/// and %ApplicationName% is the application name you used in the
/// CoreStartup constructor call.
/// </summary>
public string ConfigDirectory {
get {
@ -66,6 +86,14 @@ namespace ICSharpCode.Core @@ -66,6 +86,14 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Creates a new CoreStartup instance.
/// </summary>
/// <param name="applicationName">
/// The name of your application.
/// This is used as default title for message boxes,
/// default name for the configuration directory etc.
/// </param>
public CoreStartup(string applicationName)
{
if (applicationName == null)
@ -78,6 +106,7 @@ namespace ICSharpCode.Core @@ -78,6 +106,7 @@ namespace ICSharpCode.Core
/// <summary>
/// Find AddIns by searching all .addin files recursively in <paramref name="addInDir"/>.
/// The found AddIns are added to the list of AddIn files to load.
/// </summary>
public void AddAddInsFromDirectory(string addInDir)
{
@ -87,7 +116,7 @@ namespace ICSharpCode.Core @@ -87,7 +116,7 @@ namespace ICSharpCode.Core
}
/// <summary>
/// Add the specified .addin file.
/// Add the specified .addin file to the list of AddIn files to load.
/// </summary>
public void AddAddInFile(string addInFile)
{
@ -96,14 +125,41 @@ namespace ICSharpCode.Core @@ -96,14 +125,41 @@ namespace ICSharpCode.Core
addInFiles.Add(addInFile);
}
/// <summary>
/// Use the specified configuration file to store information about
/// disabled AddIns and external AddIns.
/// You have to call this method to support the <see cref="AddInManager"/>.
/// </summary>
/// <param name="addInConfigurationFile">
/// The name of the file used to store the list of disabled AddIns
/// and the list of installed external AddIns.
/// A good value for this parameter would be
/// <c>Path.Combine(<see cref="PropertyService.ConfigDirectory"/>, "AddIns.xml")</c>.
/// </param>
public void ConfigureExternalAddIns(string addInConfigurationFile)
{
externalAddInsConfigured = true;
AddInManager.ConfigurationFileName = addInConfigurationFile;
AddInManager.LoadAddInConfiguration(addInFiles, disabledAddIns);
}
/// <summary>
/// Configures user AddIn support.
/// </summary>
/// <param name="addInInstallTemp">
/// The AddIn installation temporary directory.
/// ConfigureUserAddIns will install the AddIns from this directory and
/// store the parameter value in <see cref="AddInManager.AddInInstallTemp"/>.
/// </param>
/// <param name="userAddInPath">
/// The path where user AddIns are installed to.
/// AddIns from this directory will be loaded.
/// </param>
public void ConfigureUserAddIns(string addInInstallTemp, string userAddInPath)
{
if (!externalAddInsConfigured) {
throw new InvalidOperationException("ConfigureExternalAddIns must be called before ConfigureUserAddIns");
}
AddInManager.AddInInstallTemp = addInInstallTemp;
AddInManager.UserAddInPath = userAddInPath;
if (Directory.Exists(addInInstallTemp)) {
@ -114,6 +170,12 @@ namespace ICSharpCode.Core @@ -114,6 +170,12 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Initializes the AddIn system.
/// This loads the AddIns that were added to the list,
/// then it executes the <see cref="ICommand">commands</see>
/// in <c>/Workspace/Autostart</c>.
/// </summary>
public void RunInitialization()
{
AddInTree.Load(addInFiles, disabledAddIns);
@ -125,6 +187,10 @@ namespace ICSharpCode.Core @@ -125,6 +187,10 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Starts the core services.
/// This initializes the PropertyService and ResourceService.
/// </summary>
public void StartCoreServices()
{
if (configDirectory == null)

10
src/Main/Core/Project/Src/AddInTree/TreePathNotFoundException.cs

@ -23,15 +23,23 @@ namespace ICSharpCode.Core @@ -23,15 +23,23 @@ namespace ICSharpCode.Core
{
}
// Required for Serialization
/// <summary>
/// Constructs a new <see cref="TreePathNotFoundException"/>
/// </summary>
public TreePathNotFoundException() : base()
{
}
/// <summary>
/// Constructs a new <see cref="TreePathNotFoundException"/>
/// </summary>
public TreePathNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
/// <summary>
/// Deserializes a <see cref="TreePathNotFoundException"/>
/// </summary>
protected TreePathNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

3
src/Main/Core/Project/Src/Services/LoggingService/LoggingService.cs

@ -12,6 +12,9 @@ using log4net.Config; @@ -12,6 +12,9 @@ using log4net.Config;
namespace ICSharpCode.Core
{
/// <summary>
/// Class for easy logging. Uses log4net as backend.
/// </summary>
public static class LoggingService
{
static ILog log = LogManager.GetLogger(typeof(LoggingService));

2
src/Main/Core/Project/Src/Services/MessageService/InputBox.cs

@ -12,7 +12,7 @@ using System.Windows.Forms; @@ -12,7 +12,7 @@ using System.Windows.Forms;
namespace ICSharpCode.Core
{
/// <summary>
/// Description of InputBox.
/// Class used to display an input box.
/// </summary>
internal class InputBox : System.Windows.Forms.Form
{

126
src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

@ -13,53 +13,72 @@ namespace ICSharpCode.Core @@ -13,53 +13,72 @@ namespace ICSharpCode.Core
{
/// <summary>
/// Class with static methods to show message boxes.
/// All text displayed using the MessageService is passed to the
/// <see cref="StringParser"/> to replace ${res} markers.
/// </summary>
public static class MessageService
{
static Form mainForm;
/// <summary>
/// Gets/Sets the form used as owner for shown message boxes.
/// It is also used to synchronize message boxes shown on other threads.
/// </summary>
public static Form MainForm {
get {
return mainForm;
}
set {
mainForm = value;
}
get { return mainForm; }
set { mainForm = value; }
}
/// <summary>
/// Delegate used for custom error callbacks.
/// </summary>
public delegate void ShowErrorDelegate(Exception ex, string message);
static ShowErrorDelegate customErrorReporter;
/// <summary>
/// Gets/Sets the custom error reporter callback delegate.
/// If this property is null, the default messagebox is used.
/// </summary>
public static ShowErrorDelegate CustomErrorReporter {
get { return customErrorReporter; }
set { customErrorReporter = value; }
}
/// <summary>
/// Shows an exception error using the <see cref="CustomErrorReporter"/>.
/// </summary>
public static void ShowError(Exception ex)
{
ShowError(ex, null);
}
/// <summary>
/// Shows an error using a message box.
/// </summary>
public static void ShowError(string message)
{
ShowError(null, message);
}
/// <summary>
/// Shows an error using a message box.
/// <paramref name="formatstring"/> is first passed through the
/// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary>
public static void ShowErrorFormatted(string formatstring, params string[] formatitems)
{
ShowError(null, Format(formatstring, formatitems));
}
public delegate void ShowErrorDelegate(Exception ex, string message);
static ShowErrorDelegate customErrorReporter;
/// <summary>
/// Gets/Sets the custom error reporter. If this property is null, the default
/// messagebox is used.
/// Shows an error.
/// If <paramref name="ex"/> is null, the message is shown inside
/// a message box.
/// Otherwise, the custom error reporter is used to display
/// the exception error.
/// </summary>
public static ShowErrorDelegate CustomErrorReporter {
get {
return customErrorReporter;
}
set {
customErrorReporter = value;
}
}
public static void ShowError(Exception ex, string message)
{
if (message == null) message = string.Empty;
@ -95,6 +114,9 @@ namespace ICSharpCode.Core @@ -95,6 +114,9 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Shows a warning message.
/// </summary>
public static void ShowWarning(string message)
{
message = StringParser.Parse(message);
@ -120,11 +142,21 @@ namespace ICSharpCode.Core @@ -120,11 +142,21 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Shows a warning message.
/// <paramref name="formatstring"/> is first passed through the
/// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary>
public static void ShowWarningFormatted(string formatstring, params string[] formatitems)
{
ShowWarning(Format(formatstring, formatitems));
}
/// <summary>
/// Asks the user a Yes/No question, using "Yes" as the default button.
/// Returns <c>true</c> if yes was clicked, <c>false</c> if no was clicked.
/// </summary>
public static bool AskQuestion(string question, string caption)
{
return MessageBox.Show(MessageService.MainForm,
@ -163,11 +195,30 @@ namespace ICSharpCode.Core @@ -163,11 +195,30 @@ namespace ICSharpCode.Core
return AskQuestion(Format(formatstring, formatitems));
}
/// <summary>
/// Asks the user a Yes/No question, using "Yes" as the default button.
/// Returns <c>true</c> if yes was clicked, <c>false</c> if no was clicked.
/// </summary>
public static bool AskQuestion(string question)
{
return AskQuestion(StringParser.Parse(question), StringParser.Parse("${res:Global.QuestionText}"));
}
/// <summary>
/// Shows a custom dialog.
/// </summary>
/// <param name="caption">The title of the dialog.</param>
/// <param name="dialogText">The description shown in the dialog.</param>
/// <param name="acceptButtonIndex">
/// The number of the button that is the default accept button.
/// Use -1 if you don't want to have an accept button.
/// </param>
/// <param name="cancelButtonIndex">
/// The number of the button that is the cancel button.
/// Use -1 if you don't want to have a cancel button.
/// </param>
/// <param name="buttontexts">The captions of the buttons.</param>
/// <returns>The number of the button that was clicked.</returns>
public static int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts)
{
using (CustomDialog messageBox = new CustomDialog(caption, dialogText, acceptButtonIndex, cancelButtonIndex, buttontexts)) {
@ -176,6 +227,13 @@ namespace ICSharpCode.Core @@ -176,6 +227,13 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Shows a custom dialog.
/// </summary>
/// <param name="caption">The title of the dialog.</param>
/// <param name="dialogText">The description shown in the dialog.</param>
/// <param name="buttontexts">The captions of the buttons.</param>
/// <returns>The number of the button that was clicked.</returns>
public static int ShowCustomDialog(string caption, string dialogText, params string[] buttontexts)
{
return ShowCustomDialog(caption, dialogText, -1, -1, buttontexts);
@ -192,22 +250,22 @@ namespace ICSharpCode.Core @@ -192,22 +250,22 @@ namespace ICSharpCode.Core
static string defaultMessageBoxTitle = "MessageBox";
static string productName = "Application Name";
/// <summary>
/// Gets/Sets the name of the product using ICSharpCode.Core.
/// Is used by the string parser as replacement for ${ProductName}.
/// </summary>
public static string ProductName {
get {
return productName;
}
set {
productName = value;
}
get { return productName; }
set { productName = value; }
}
/// <summary>
/// Gets/Sets the default title for message boxes displayed
/// by the message service.
/// </summary>
public static string DefaultMessageBoxTitle {
get {
return defaultMessageBoxTitle;
}
set {
defaultMessageBoxTitle = value;
}
get { return defaultMessageBoxTitle; }
set { defaultMessageBoxTitle = value; }
}
public static void ShowMessage(string message)

Loading…
Cancel
Save