|
From: <br...@us...> - 2008-08-04 21:57:54
|
Revision: 306
http://acmcontester.svn.sourceforge.net/acmcontester/?rev=306&view=rev
Author: brus07
Date: 2008-08-04 21:57:57 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
Add doc comment. Refactoring.
Modified Paths:
--------------
ACMServer/trunk/ACMServer/Plugins/PluginsFramework/BaseMediatorPlugin.cs
ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs
Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/BaseMediatorPlugin.cs
===================================================================
--- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/BaseMediatorPlugin.cs 2008-08-02 12:49:14 UTC (rev 305)
+++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/BaseMediatorPlugin.cs 2008-08-04 21:57:57 UTC (rev 306)
@@ -3,6 +3,9 @@
namespace AcmContester.Plugins.PluginsFramework
{
+ /// <summary>
+ /// <para>\xC0\xE1\xF1\xF2\xF0\xE0\xEA\xF2\xED\xE8\xE9 \xE2\xB3\xE4\xEA\xF0\xE8\xF2\xE8\xE9 \xEA\xEB\xE0\xF1 \xE4\xEB\xFF \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xBF \xEF\xEB\xE0\xE3\xB3\xED\xB3\xE2.</para>
+ /// </summary>
public abstract class BaseMediatorPlugin
{
public delegate void DataArrived_EventHandler(string message);
Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs
===================================================================
--- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs 2008-08-02 12:49:14 UTC (rev 305)
+++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsLoader.cs 2008-08-04 21:57:57 UTC (rev 306)
@@ -5,26 +5,42 @@
namespace AcmContester.Plugins.PluginsFramework
{
+ /// <summary>
+ /// <para>\xC4\xEE\xEF\xEE\xEC\xB3\xE6\xED\xE8\xE9 \xEA\xEB\xE0\xF1 \xE4\xEB\xFF \xE4\xE8\xED\xE0\xEC\xB3\xF7\xED\xEE\xE3\xEE \xE7\xE0\xE2\xE0\xED\xF2\xE0\xE6\xE5\xED\xED\xFF \xE2\xF1\xB3\xF5
+ /// \xF2\xE8\xEF\xB3\xE2 <typeparamref name="T"/> \xB3\xE7 dll, \xFF\xEA\xB3 \xE7\xED\xE0\xF5\xEE\xE4\xFF\xF2\xFC\xF1\xFF
+ /// \xF3 \xE2\xEA\xE0\xE7\xE0\xED\xB3\xE9 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xBF.</para>
+ /// </summary>
+ /// <typeparam name="T">\xD2\xE8\xEF, \xFF\xEA\xE8\xE9 \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE7\xE0\xE2\xE0\xED\xF2\xE0\xE6\xE8\xF2\xE8.</typeparam>
public static class PluginsLoader<T> where T : class
{
/// <summary>
- /// Try to load all the instances of type T in all the DLLs,
- /// found at path
+ /// <para>Try to load all the instances of type <typeparamref name="T"/> in all the DLLs,
+ /// found at path.</para>
+ /// <para>\xD8\xF3\xEA\xE0\xFE\xF2\xFC\xF1\xFF \xE2\xF1\xB3 dll, \xE2 \xFF\xEA\xE8\xF5 \xBA \xF0\xE5\xE0\xEB\xB3\xE7\xE0\xF6\xB3\xFF \xF2\xE8\xEF\xF3 <typeparamref name="T"/>.
+ /// \xC4\xEB\xFF \xF6\xFC\xEE\xE3\xEE \xEF\xE5\xF0\xE5\xE1\xE8\xF0\xE0\xBA\xF2\xFC\xF1\xFF \xEA\xEE\xE6\xED\xE0 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xFF \xE2 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xBF, \xF9\xEE \xE2\xEA\xE0\xE7\xF3\xBA\xF2\xFC\xF1\xFF
+ /// \xEF\xE0\xF0\xE0\xEC\xE5\xF2\xF0\xEE\xEC <paramref name="path"/> \xB3 \xF6\xE8\xF5 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xE9 \xE1\xE5\xF0\xE5\xF2\xFC\xF1\xFF
+ /// \xE4\xEE \xF3\xE2\xE0\xE3\xE8 \xF2\xB3\xEB\xFC\xEA\xE8 \xF2\xE0 dll \xF9\xEE \xEC\xE0\xBA \xED\xE0\xE7\xE2\xF3 \xF2\xE0\xEA\xF3 \xF1\xE0\xEC\xF3 \xFF\xEA \xB3 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xFF
+ /// \xE2 \xFF\xEA\xB3\xE9 \xE2\xEE\xED\xE0 \xE7\xED\xE0\xF5\xEE\xE4\xE8\xF2\xFC\xF1\xFF.</para>
/// </summary>
- /// <param name="path">Path where to find appropriate DLLs</param>
- /// <returns>List of all instaces found</returns>
+ /// <param name="path">Path where to find appropriate DLLs.</param>
+ /// <returns>List of all instaces found.</returns>
+ /// <exception cref="DirectoryNotFoundException">Specified path (<paramref name="path"/>) does not exists.</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="path"/> is a null reference.</exception>
+ /// <exception cref="ArgumentException">The <paramref name="path"/> parameter is the empty string ("").</exception>
public static List<T> Load(string path)
{
+ if (path == null)
+ throw new ArgumentNullException("path", "Parameter is a null reference");
+ if (path.Length == 0)
+ throw new ArgumentException("The parameter is the empty string (\"\").", "path");
+ if (!Directory.Exists(path))
+ throw new DirectoryNotFoundException("Specified path (" + path + ") does not exists!");
+
List<T> plugins = new List<T>();
- if (!Directory.Exists(path))
- throw new ArgumentException("Specified path does not exists!");
- //TODO:
- if (Directory.Exists(path) == false)
- return plugins;
string[] allDirectories = Directory.GetDirectories(path);
- //string[] allFiles = Directory.GetFiles(path, "*.dllx", SearchOption.TopDirectoryOnly);
foreach (string directory in allDirectories)
{
+ ///\xE3\xE5\xED\xE5\xF0\xF3\xBA\xF2\xFC\xF1\xFF \xEF\xEE\xF2\xF0\xB3\xE1\xED\xE8\xE9 \xF8\xEB\xFF\xF5 \xE4\xEE dll \xF3 \xE4\xE8\xF0\xE5\xEA\xF2\xEE\xF0\xB3\xBF directory
string fileName = directory.Substring(directory.LastIndexOf('\\')+1) + ".dll";
string fileFullName = directory + "\\" + fileName;
ScanAndLoad(fileFullName, ref plugins);
@@ -33,23 +49,30 @@
}
/// <summary>
- /// Load all instances of type T in specified file and
- /// add them to provided list
+ /// <para>Load all instances of type <typeparamref name="T"/> in specified file and
+ /// add them to provided list.</para>
/// </summary>
- /// <param name="filename">Which file to scan</param>
- /// <param name="lst">Where to add found objects</param>
+ /// <param name="filename">Which file to scan.</param>
+ /// <param name="lst">Where to add found objects.</param>
private static void ScanAndLoad(string filename, ref List<T> lst)
{
if (File.Exists(filename) == false)
{
- //throw new Exception("!!!!!!!!!!");
return;
}
- Assembly assembly = Assembly.LoadFrom(filename);
+
+ Assembly assembly;
+ try
+ {
+ assembly = Assembly.LoadFrom(filename);
+ }
+ catch
+ {
+ return;
+ }
if (assembly != null)
{
Type[] types = assembly.GetExportedTypes();
-
foreach (Type t in types)
{
try
@@ -58,21 +81,21 @@
if (t.GetInterface(typeof(T).FullName) != null || t.IsSubclassOf(typeof(T)))
lst.Add((T)Activator.CreateInstance(t));
}
- catch (System.Reflection.TargetInvocationException ex)
+ catch (System.Reflection.TargetInvocationException)
{
//throw ex;
}
- catch (System.MissingMethodException ex)
+ catch (System.MissingMethodException)
{
//throw ex;
}
- catch (System.InvalidCastException ex)
+ catch (System.InvalidCastException)
{
//throw ex;
}
- catch (Exception ex)
+ catch
{
- //throw ex;
+ throw;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|