-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sagifogel
committed
Jul 4, 2014
1 parent
e73f64d
commit 531a560
Showing
13 changed files
with
172 additions
and
535 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
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
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
40 changes: 40 additions & 0 deletions
40
NCop.Composite/Mixins/Weaving/AtomCompositeMixinsWeaverBuilder.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,40 @@ | ||
using NCop.Composite.Weaving; | ||
using NCop.Core; | ||
using NCop.IoC; | ||
using NCop.Mixins.Engine; | ||
using NCop.Mixins.Weaving; | ||
using NCop.Weaving; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NCop.Composite.Mixins.Weaving | ||
{ | ||
internal class AtomCompositeMixinsWeaverBuilder : AbstractTypeWeaverBuilder, ICompositeMixinsTypeWeaverBuilder | ||
{ | ||
private TypeMap mixin = null; | ||
protected readonly INCopDependencyAwareRegistry registry = null; | ||
private readonly string atomIdentifier = Guid.NewGuid().ToString(); | ||
|
||
public AtomCompositeMixinsWeaverBuilder(Type type, ITypeDefinition typeDefinition, INCopDependencyAwareRegistry registry) | ||
: base(type, typeDefinition) { | ||
this.registry = registry; | ||
} | ||
|
||
public override void AddMethodWeavers() { | ||
base.AddMethodWeavers(); | ||
registry.Register(mixin.ImplementationType, mixin.ContractType, name: atomIdentifier); | ||
} | ||
|
||
public override ITypeWeaver CreateTypeWeaver() { | ||
return new AtomMixinsWeaverStartegy(typeDefinition, mixin, methodWeavers, registry); | ||
} | ||
|
||
public void Add(TypeMap item) { | ||
Interlocked.CompareExchange(ref mixin, item, null); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
NCop.Composite/Mixins/Weaving/CompositeMixinsWeaverBuilder.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,19 @@ | ||
using NCop.Composite.Weaving; | ||
using NCop.IoC; | ||
using NCop.Mixins.Weaving; | ||
using NCop.Weaving; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NCop.Composite.Mixins.Weaving | ||
{ | ||
internal class CompositeMixinsWeaverBuilder : MixinsTypeWeaverBuilder, ICompositeMixinsTypeWeaverBuilder | ||
{ | ||
public CompositeMixinsWeaverBuilder(Type type, ITypeDefinition typeDefinition, INCopDependencyAwareRegistry registry) | ||
: base(type, typeDefinition, registry) { | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
NCop.Composite/Mixins/Weaving/ICompositeMixinsTypeWeaverBuilder.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,14 @@ | ||
using NCop.Mixins.Engine; | ||
using NCop.Weaving; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NCop.Composite.Weaving | ||
{ | ||
public interface ICompositeMixinsTypeWeaverBuilder : ITypeWeaverBuilder, IMethodWeaverBuilderBag, IPropertyWeaverBag, IMixinMapBag | ||
{ | ||
} | ||
} |
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
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,42 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using NCop.Core; | ||
using NCop.Weaving; | ||
using NCop.Core.Extensions; | ||
using System; | ||
using NCop.Mixins.Engine; | ||
using NCop.IoC; | ||
|
||
namespace NCop.Composite.Weaving | ||
{ | ||
internal class AtomMixinsWeaverStartegy : ITypeWeaver | ||
{ | ||
private readonly TypeMap mixin = null; | ||
private readonly ITypeDefinition typeDefinition = null; | ||
private readonly INCopDependencyAwareRegistry registry = null; | ||
private readonly IEnumerable<IMethodWeaver> methodWeavers = null; | ||
|
||
internal AtomMixinsWeaverStartegy(ITypeDefinition typeDefinition, TypeMap mixin, IEnumerable<IMethodWeaver> methodWeavers, INCopDependencyAwareRegistry registry) { | ||
this.mixin = mixin; | ||
this.registry = registry; | ||
this.methodWeavers = methodWeavers; | ||
this.typeDefinition = typeDefinition; | ||
} | ||
|
||
public void Weave() { | ||
Type weavedType = null; | ||
|
||
methodWeavers.ForEach(methodWeaver => { | ||
var methodBuilder = methodWeaver.DefineMethod(); | ||
var ilGenerator = methodBuilder.GetILGenerator(); | ||
|
||
methodWeaver.WeaveMethodScope(ilGenerator); | ||
methodWeaver.WeaveEndMethod(ilGenerator); | ||
}); | ||
|
||
weavedType = typeDefinition.TypeBuilder.CreateType(); | ||
registry.Register(weavedType, typeDefinition.Type, new TypeMapSet { mixin }); | ||
} | ||
} | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -8,6 +8,5 @@ namespace NCop.Mixins.Engine | |
{ | ||
public interface IMixinMapBag : IBag<TypeMap> | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.