Skip to content

Commit f8fa328

Browse files
committed
refactoring
1 parent 7a0ba5a commit f8fa328

18 files changed

+1241
-1252
lines changed

Benchmark/Benchmark.cs

Lines changed: 222 additions & 221 deletions
Large diffs are not rendered by default.

Benchmark/Benchmark.csproj renamed to Benchmark/MikeNakis.Intertwine.Benchmark.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -8,10 +8,11 @@
88
<ProjectGuid>{DA9C27C3-6348-4D2A-A8B0-AF69CD49FE18}</ProjectGuid>
99
<OutputType>Exe</OutputType>
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>Intertwine.Benchmark</RootNamespace>
12-
<AssemblyName>Intertwine.Benchmark</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
11+
<RootNamespace>MikeNakis.Intertwine.Benchmark</RootNamespace>
12+
<AssemblyName>MikeNakis.Intertwine.Benchmark</AssemblyName>
13+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile />
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1718
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
2324
<ErrorReport>prompt</ErrorReport>
2425
<WarningLevel>4</WarningLevel>
2526
<UseVSHostingProcess>false</UseVSHostingProcess>
27+
<Prefer32Bit>false</Prefer32Bit>
2628
</PropertyGroup>
2729
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2830
<DebugType>pdbonly</DebugType>
@@ -32,6 +34,7 @@
3234
<DefineConstants>TRACE</DefineConstants>
3335
<ErrorReport>prompt</ErrorReport>
3436
<WarningLevel>4</WarningLevel>
37+
<Prefer32Bit>false</Prefer32Bit>
3538
</PropertyGroup>
3639
<PropertyGroup>
3740
<StartupObject />
@@ -55,12 +58,13 @@
5558
<Compile Include="ReflectingUntwiner.cs" />
5659
</ItemGroup>
5760
<ItemGroup>
61+
<None Include="app.config" />
5862
<None Include="packages.config" />
5963
</ItemGroup>
6064
<ItemGroup>
61-
<ProjectReference Include="..\Intertwine\Intertwine.csproj">
65+
<ProjectReference Include="..\Intertwine\MikeNakis.Intertwine.csproj">
6266
<Project>{b840485b-a5c6-4d9b-a8ff-67e971b2c488}</Project>
63-
<Name>Intertwine</Name>
67+
<Name>MikeNakis.Intertwine</Name>
6468
</ProjectReference>
6569
</ItemGroup>
6670
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Benchmark/ReflectingUntwiner.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
//Author MikeNakis (michael.gr)
2-
namespace MikeNakis.Intertwine
2+
3+
namespace MikeNakis.Intertwine.Benchmark
34
{
4-
/// <summary>
5-
/// An untwiner which uses reflection to do its job. Keep for reference. WARNING: SLOW AS MOLASSES.
6-
/// </summary>
7-
public class ReflectingUntwiner: Untwiner
8-
{
9-
private readonly object _Target;
10-
private readonly System.Reflection.MethodInfo[] Methodinfos;
5+
/// <summary>
6+
/// An untwiner which uses reflection to do its job. Keep for reference. WARNING: SLOW AS MOLASSES.
7+
/// </summary>
8+
public class ReflectingUntwiner : Untwiner
9+
{
10+
private readonly System.Reflection.MethodInfo[] method_infos;
1111

12-
public ReflectingUntwiner( System.Type twinee, object target )
13-
:base( twinee )
14-
{
15-
_Target = target;
16-
Methodinfos = Twinee.GetMethods( System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic |
17-
System.Reflection.BindingFlags.Instance );
18-
}
12+
public ReflectingUntwiner( System.Type twinee, object target )
13+
: base( twinee )
14+
{
15+
Target = target;
16+
method_infos = Twinee.GetMethods( System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
17+
}
1918

20-
public override object Target { get { return _Target; } }
19+
public override object Target { get; }
2120

22-
public override object AnyCall( int selector, object[] arguments )
23-
{
24-
return Methodinfos[selector].Invoke( Target, arguments );
25-
}
26-
}
21+
public override object AnyCall( int selector, object[] arguments )
22+
{
23+
return method_infos[selector].Invoke( Target, arguments );
24+
}
25+
}
2726
}

Benchmark/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>

Benchmark/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Castle.Core" version="3.3.3" targetFramework="net40" />
3+
<package id="Castle.Core" version="3.3.3" targetFramework="net40" requireReinstallation="true" />
44
<package id="LinFu.DynamicProxy.OfficialRelease" version="1.0.5" targetFramework="net40" />
55
</packages>
Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
11
//Author MikeNakis (michael.gr)
2-
namespace MikeNakis.InterfaceEvents
2+
3+
namespace MikeNakis.Intertwine.InterfaceEvents
34
{
4-
/// <summary>
5-
/// Defines the operations that can be performed on the source of an interface-event.
6-
/// </summary>
7-
/// <typeparam name="I">The type of interface of the event.</typeparam>
8-
public interface IInterfaceEventSource<I>
9-
where I: class //actually, interface.
10-
{
11-
/// <summary>
12-
/// Registers or deregisters an observer.
13-
/// </summary>
14-
/// <param name="register">Indicates whether the observer should be registered or deregistered.</param>
15-
/// <param name="observer">The observer to register or deregister.</param>
16-
void RegisterObserver( bool register, I observer );
5+
/// <summary>
6+
/// Defines the operations that can be performed on the source of an interface-event.
7+
/// </summary>
8+
/// <typeparam name="I">The type of interface of the event.</typeparam>
9+
public interface IInterfaceEventSource<in I> where I : class //actually, interface.
10+
{
11+
/// <summary>
12+
/// Registers or unregisters an observer.
13+
/// </summary>
14+
/// <param name="register">Indicates whether the observer should be registered or unregistered.</param>
15+
/// <param name="observer">The observer to register or unregister.</param>
16+
void RegisterObserver( bool register, I observer );
1717

18-
/// <summary>
19-
/// Checks whether an observer is registered.
20-
/// </summary>
21-
/// <param name="observer">The observer to check.</param>
22-
/// <returns>true if the observer is registered; false otherwise.</returns>
23-
bool IsObserverRegistered( I observer );
24-
}
18+
/// <summary>
19+
/// Checks whether an observer is registered.
20+
/// </summary>
21+
/// <param name="observer">The observer to check.</param>
22+
/// <returns>true if the observer is registered; false otherwise.</returns>
23+
bool IsObserverRegistered( I observer );
24+
}
2525

26-
namespace Extensions
27-
{
28-
public static partial class Extensions
29-
{
30-
/// <summary>
31-
/// Registers an observer.
32-
/// </summary>
33-
/// <typeparam name="I">The type of interface of the event.</typeparam>
34-
/// <param name="source">The event-source with which to register the observer.</param>
35-
/// <param name="observer">The observer to register.</param>
36-
public static void RegisterObserver<I>( this IInterfaceEventSource<I> source, I observer )
37-
where I: class //actually, interface.
38-
{
39-
source.RegisterObserver( true, observer );
40-
}
26+
namespace Extensions
27+
{
28+
public static class InterfaceEventsExtensions
29+
{
30+
/// <summary>
31+
/// Registers an observer.
32+
/// </summary>
33+
/// <typeparam name="I">The type of interface of the event.</typeparam>
34+
/// <param name="source">The event-source with which to register the observer.</param>
35+
/// <param name="observer">The observer to register.</param>
36+
public static void RegisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) where I : class //actually, interface.
37+
{
38+
source.RegisterObserver( true, observer );
39+
}
4140

42-
/// <summary>
43-
/// Deregisters an observer.
44-
/// </summary>
45-
/// <typeparam name="I">The type of interface of the event.</typeparam>
46-
/// <param name="source">The event-source with which the observer has been registered.</param>
47-
/// <param name="observer">The observer to deregister.</param>
48-
public static void DeregisterObserver<I>( this IInterfaceEventSource<I> source, I observer )
49-
where I: class //actually, interface.
50-
{
51-
source.RegisterObserver( false, observer );
52-
}
53-
}
54-
}
41+
/// <summary>
42+
/// Unregisters an observer.
43+
/// </summary>
44+
/// <typeparam name="I">The type of interface of the event.</typeparam>
45+
/// <param name="source">The event-source with which the observer has been registered.</param>
46+
/// <param name="observer">The observer to unregister.</param>
47+
public static void UnregisterObserver<I>( this IInterfaceEventSource<I> source, I observer ) where I : class //actually, interface.
48+
{
49+
source.RegisterObserver( false, observer );
50+
}
51+
}
52+
}
5553
}

0 commit comments

Comments
 (0)