This repository has been archived by the owner on Apr 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Theory for Multicast Mixin Rules (#15)
- Loading branch information
Philip Pittle
committed
Jul 6, 2014
1 parent
0068254
commit 030d031
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace CopaceticSoftware.pMixins.TheorySandbox | ||
{ | ||
/// <summary> | ||
/// Basis for applying mulitcast rules. Inheritors can be located anywhere, | ||
/// pMixin code generator will find them! | ||
/// </summary> | ||
public interface IMixinMulticastRule | ||
{ | ||
IEnumerable<Type> MixinsForTypes(string typeFullName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace CopaceticSoftware.pMixins.TheorySandbox.MulticastRule | ||
{ | ||
public class MulticastMixin | ||
{ | ||
public int GetNumber() | ||
{ | ||
return 42; | ||
} | ||
} | ||
|
||
public class MulticastMixinRule : IMixinMulticastRule | ||
{ | ||
public IEnumerable<Type> MixinsForTypes(string typeFullName) | ||
{ | ||
yield return typeof (MulticastMixin); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace CopaceticSoftware.pMixins.TheorySandbox.MulticastRule | ||
{ | ||
/// <summary> | ||
/// Because of <see cref="MulticastMixinRule"/>, | ||
/// <see cref="MulticastMixin"/> should be applied here. | ||
/// </summary> | ||
public partial class MulticastRuleSpec | ||
{ | ||
} | ||
|
||
/*///////////////////////////////////////// | ||
/// Generated Code | ||
/////////////////////////////////////////*/ | ||
public partial class MulticastRuleSpec | ||
{ | ||
private class __pMixinAutoGenerated | ||
{ | ||
public class CopaceticSoftware_pMixin_TheorySandbox_Interceptors_BasicInterceptor_Mixin | ||
{ | ||
//don't need protected wrapper | ||
|
||
//don't need abstract wrapper | ||
|
||
public sealed class MasterWrapper : MasterWrapperBase | ||
{ | ||
public readonly MulticastMixin Mixin; | ||
|
||
public MasterWrapper(MulticastRuleSpec target) | ||
{ | ||
this.Mixin = new MulticastMixin(); | ||
|
||
base.Initialize(target, Mixin, | ||
new List<IMixinInterceptor>()); | ||
} | ||
|
||
public int GetNumber() | ||
{ | ||
return base.ExecuteMethod( | ||
"Method", | ||
new List<Parameter>(), | ||
() => Mixin.GetNumber()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private sealed partial class __Mixins | ||
{ | ||
public static readonly global::System.Object ____Lock = new global::System.Object(); | ||
|
||
public readonly __pMixinAutoGenerated.CopaceticSoftware_pMixin_TheorySandbox_Interceptors_BasicInterceptor_Mixin.MasterWrapper MixinMasterWrapper; | ||
|
||
public __Mixins(MulticastRuleSpec target) | ||
{ | ||
this.MixinMasterWrapper = | ||
new DefaultMixinActivator() | ||
.CreateInstance<__pMixinAutoGenerated.CopaceticSoftware_pMixin_TheorySandbox_Interceptors_BasicInterceptor_Mixin.MasterWrapper>( | ||
target); | ||
} | ||
} | ||
|
||
private __Mixins _____mixins; | ||
private __Mixins ___mixins | ||
{ | ||
get | ||
{ | ||
if (null == _____mixins) | ||
{ | ||
lock (__Mixins.____Lock) | ||
{ | ||
if (null == _____mixins) | ||
{ | ||
_____mixins = new __Mixins(this); | ||
} | ||
} | ||
} | ||
return _____mixins; | ||
} | ||
} | ||
|
||
public int GetNumber() | ||
{ | ||
return ___mixins.MixinMasterWrapper.GetNumber(); | ||
} | ||
} | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
pMixins.TheorySandbox/MulticastRule/MulticastRuleSpecTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using NBehave.Spec.NUnit; | ||
using NUnit.Framework; | ||
|
||
namespace CopaceticSoftware.pMixins.TheorySandbox.MulticastRule | ||
{ | ||
public class MulticastRuleSpecTest : SpecTestBase | ||
{ | ||
private MulticastRuleSpec _spec; | ||
|
||
protected override void Establish_context() | ||
{ | ||
_spec = new MulticastRuleSpec(); | ||
} | ||
|
||
[Test] | ||
public void CanCallMulticastMixinMethod() | ||
{ | ||
_spec.GetNumber().ShouldEqual(42); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters