Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallimathias committed Jul 3, 2017
2 parents 9e0d4f8 + 4676cc3 commit bcaed9e
Show file tree
Hide file tree
Showing 17 changed files with 481 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Command Management System/Attributes/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CommandManagementSystem.Attributes
/// <summary>
/// Indicates a class as a command
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true)]
public class CommandAttribute : Attribute
{
/// <summary>
Expand Down
20 changes: 0 additions & 20 deletions Command Management System/Attributes/OneTimeCommandAttribute.cs

This file was deleted.

1 change: 0 additions & 1 deletion Command Management System/Command Management System.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
<Compile Include="Attributes\CommandAttribute.cs" />
<Compile Include="Attributes\CommandManagerAttribute.cs" />
<Compile Include="Attributes\DispatchOrderAttribute.cs" />
<Compile Include="Attributes\OneTimeCommandAttribute.cs" />
<Compile Include="Command.cs" />
<Compile Include="CommandHandler.cs" />
<Compile Include="CommandHolder.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Command Management System/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ public abstract class Command<TParameter> : Command<TParameter, dynamic> { }
/// An abstract standard implementation of a command with dynamic as return type and
/// EventArgs As the parameter type
/// </summary>
public abstract class Command : Command<EventArgs, dynamic> { }
public abstract class Command : Command<object, dynamic> { }
}
2 changes: 1 addition & 1 deletion Command Management System/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ public class CommandHandler<TParameter> : CommandHandler<TParameter, dynamic> {
/// Manages individual commands as events with string as command indentifier type and
/// dynamic as return value and EventArgs as parameter type
/// </summary>
public class CommandHandler : CommandHandler<EventArgs> { }
public class CommandHandler : CommandHandler<object> { }
}
6 changes: 3 additions & 3 deletions Command Management System/CommandHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public CommandHolder(string id, Func<TArgs, dynamic> func) : base(id, func) { }
public CommandHolder(string id, Func<TArgs, dynamic> func, int priority) : base(id, func, priority) { }
}

internal class CommandHolder : CommandHolder<EventArgs>
internal class CommandHolder : CommandHolder<object>
{
public CommandHolder(string id) : base(id) { }

public CommandHolder(string id, Func<EventArgs, dynamic> func) : base(id, func) { }
public CommandHolder(string id, Func<object, dynamic> func) : base(id, func) { }

public CommandHolder(string id, Func<EventArgs, dynamic> func, int priority) : base(id, func, priority) { }
public CommandHolder(string id, Func<object, dynamic> func, int priority) : base(id, func, priority) { }
}

}
30 changes: 22 additions & 8 deletions Command Management System/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,23 @@ public abstract class CommandManager<TIn, TParameter, TOut> : ICommandManager<TI
public virtual event CommandManagerEventHandler OnWaitingCommand;

/// <summary>
/// An abstract base implementation of a command manager
/// </summary>
public CommandManager()
/// An abstract base implementation of a command manager. With control over the initialization
/// </summary>
/// <param name="initialize">If this value is set to false, no commands are searched by the manager.</param>
public CommandManager(bool initialize)
{
commandHandler = new CommandHandler<TIn, TParameter, TOut>();
waitingDictionary = new ConcurrentDictionary<TIn, Func<TParameter, TOut>>();
Initialize();

if (initialize)
Initialize();
}
/// <summary>
/// An abstract base implementation of a command manager
/// </summary>
public CommandManager() : this(true)
{

}

/// <summary>
Expand All @@ -56,8 +66,12 @@ public CommandManager()
/// </summary>
public virtual void Initialize()
{
var commandNamespace = GetType().GetCustomAttribute<CommandManagerAttribute>().CommandNamespaces;
var commandNamespace = GetType().GetCustomAttribute<CommandManagerAttribute>()?.CommandNamespaces;
var types = Assembly.GetAssembly(GetType()).GetTypes();

if (commandNamespace == null)
commandNamespace = new[] { GetType().Namespace };

var commands = types.Where(
t => t.GetCustomAttribute<CommandAttribute>() != null && commandNamespace.Contains(t.Namespace)).ToList();

Expand Down Expand Up @@ -189,11 +203,11 @@ protected void InitializeOneTimeCommand(string[] namespaces, Type[] types)
BindingFlags.FlattenHierarchy |
BindingFlags.Static)
.Where(
m => m.GetCustomAttribute<OneTimeCommandAttribute>() != null);
m => m.GetCustomAttribute<CommandAttribute>() != null);

foreach (var member in members)
{
commandHandler[(TIn)member.GetCustomAttribute<OneTimeCommandAttribute>().Tag] += (Func<TParameter, TOut>)(
commandHandler[(TIn)member.GetCustomAttribute<CommandAttribute>().Tag] += (Func<TParameter, TOut>)(
(MethodInfo)member).CreateDelegate(typeof(Func<TParameter, TOut>));
}

Expand Down Expand Up @@ -232,5 +246,5 @@ public abstract class CommandManager<TParameter> : CommandManager<TParameter, dy
/// An abstract base implementation of a command manager with string as command indentifiers
/// and dynamic as result data type and EventArgs as parameter type
/// </summary>
public abstract class CommandManager : CommandManager<EventArgs> { }
public abstract class CommandManager : CommandManager<object> { }
}
2 changes: 1 addition & 1 deletion Command Management System/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
=============================================================================================

Command Management System
Copyright 2016 Maximilian Kr�ger (gallimathias)
Copyright 2017 Maximilian Kr�ger (gallimathias)
https://github.com/Gallimathias/CommandManagementSystem
48 changes: 24 additions & 24 deletions Command Management System/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Command Management System-alpha")]
[assembly: AssemblyDescription("A system for executable and extensible commands as events. This is a beta version which is intended only for test purposes and not for production use. Please report error on GitHub.")]
[assembly: AssemblyTitle("Command Management System")]
[assembly: AssemblyDescription("A system for executable and extensible commands as events.")]
#region AssemblyConfiguration
#if V47
[assembly: AssemblyConfiguration(".NET 4.7")]
Expand Down Expand Up @@ -41,40 +41,40 @@
* from the second digit to the first separating null follows the framework version.
*
* Pattern: Major.MinorAndRevision.Build.AdditionalVersion
* Example: 2.00.1496512783.047
* Example: 2.00.101.047
*/
#endregion version information

#pragma warning disable CS7035 // The specified version string is: Major.MinorAndRevision.Build.AdditionalVersion
#region AssemblyVersion
#if V47
[assembly: AssemblyVersion("2.00.7.147")]
[assembly: AssemblyFileVersion("2.00.7.147")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_147")]
[assembly: AssemblyVersion("2.00.8.047")]
[assembly: AssemblyFileVersion("2.00.8.047")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_047")]
#elif V462
[assembly: AssemblyVersion("2.00.7.1462")]
[assembly: AssemblyFileVersion("2.00.7.1462")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_1462")]
[assembly: AssemblyVersion("2.00.8.0462")]
[assembly: AssemblyFileVersion("2.00.8.0462")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_0462")]
#elif V461
[assembly: AssemblyVersion("2.00.7.1461")]
[assembly: AssemblyFileVersion("2.00.7.1461")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_1461")]
[assembly: AssemblyVersion("2.00.8.0461")]
[assembly: AssemblyFileVersion("2.00.8.0461")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_0461")]
#elif V46
[assembly: AssemblyVersion("2.00.7.146")]
[assembly: AssemblyFileVersion("2.00.7.146")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_146")]
[assembly: AssemblyVersion("2.00.8.046")]
[assembly: AssemblyFileVersion("2.00.8.046")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_046")]
#elif V452
[assembly: AssemblyVersion("2.00.7.1452")]
[assembly: AssemblyFileVersion("2.00.7.1452")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_1452")]
[assembly: AssemblyVersion("2.00.8.0452")]
[assembly: AssemblyFileVersion("2.00.8.0452")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_0452")]
#elif V451
[assembly: AssemblyVersion("2.00.7.1451")]
[assembly: AssemblyFileVersion("2.00.7.1451")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_1451")]
[assembly: AssemblyVersion("2.00.8.0451")]
[assembly: AssemblyFileVersion("2.00.8.0451")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_0451")]
#elif V45
[assembly: AssemblyVersion("2.00.7.145")]
[assembly: AssemblyFileVersion("2.00.7.145")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0 - beta_145")]
[assembly: AssemblyVersion("2.00.8.045")]
[assembly: AssemblyFileVersion("2.00.8.045")]
[assembly: AssemblyInformationalVersion("Napoleon I. 2.0_045")]
#endif
#endregion AssemblyVersion
#pragma warning restore CS7035 // The specified version string is: Major.MinorAndRevision.Build.AdditionalVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Command Management System, Version=2.0.6363.26672, Culture=neutral, PublicKeyToken=304a821013b0b687, processorArchitecture=MSIL">
<HintPath>..\packages\CommandManagementSystem.2.0.0-alpha3\lib\net47\Command Management System.dll</HintPath>
<Reference Include="Command Management System, Version=2.0.7.147, Culture=neutral, PublicKeyToken=304a821013b0b687, processorArchitecture=MSIL">
<HintPath>..\packages\CommandManagementSystem.2.0.0-beta\lib\net47\Command Management System.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -53,6 +53,8 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="LICENSE" />
<None Include="NOTICE" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand Down
Loading

0 comments on commit bcaed9e

Please sign in to comment.