Skip to content

Commit 42d89b1

Browse files
Move LazyProxy.Unity to the separate repository.
1 parent 36cf5aa commit 42d89b1

11 files changed

+1
-676
lines changed

LazyProxy.Sample/LazyProxy.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<TargetFramework>netcoreapp2.0</TargetFramework>
55
</PropertyGroup>
66
<ItemGroup>
7-
<ProjectReference Include="..\LazyProxy.Unity\LazyProxy.Unity.csproj" />
7+
<ProjectReference Include="..\LazyProxy.Core\LazyProxy.Core.csproj" />
88
</ItemGroup>
99
</Project>

LazyProxy.Sample/Program.cs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
using System;
22
using LazyProxy.Core;
3-
using LazyProxy.Unity;
4-
using Unity;
53

64
namespace LazyProxy.Sample
75
{
86
internal class Program
97
{
108
public static void Main(string[] args)
11-
{
12-
Console.WriteLine("--- LazyProxyBuilder example ---");
13-
LazyProxyBuilderExample();
14-
15-
Console.WriteLine("--- UnityExtension example #1 ---");
16-
UnityExtensionExample1();
17-
18-
Console.WriteLine("--- UnityExtension example #2 ---");
19-
UnityExtensionExample2();
20-
}
21-
22-
private static void LazyProxyBuilderExample()
239
{
2410
var proxy = LazyProxyBuilder.CreateLazyProxyInstance<IMyService>(() =>
2511
{
@@ -30,47 +16,5 @@ private static void LazyProxyBuilderExample()
3016
Console.WriteLine("Foo execution...");
3117
proxy.Foo();
3218
}
33-
34-
private static void UnityExtensionExample1()
35-
{
36-
var container = new UnityContainer()
37-
.RegisterLazy<IMyService, MyService>();
38-
39-
Console.WriteLine("Resolving service...");
40-
var service = container.Resolve<IMyService>();
41-
42-
Console.WriteLine("Foo execution...");
43-
service.Foo();
44-
}
45-
46-
private static void UnityExtensionExample2()
47-
{
48-
var container = new UnityContainer()
49-
.RegisterLazy<IWeaponService, WeaponService>()
50-
.RegisterLazy<INinjaService, NinjaService>();
51-
52-
Console.WriteLine("Resolving INinjaService...");
53-
var service = container.Resolve<INinjaService>();
54-
Console.WriteLine($"Type of 'ninjaService' is {service.GetType()}");
55-
56-
Console.WriteLine("Invoking property getter 'service.MinNinjaHealth' ...");
57-
var minDamage = service.MinNinjaHealth;
58-
59-
Console.WriteLine("Invoking method 'service.CreateNinja'...");
60-
var ninja = service.CreateNinja();
61-
62-
Console.WriteLine("Invoking parent method 'service.GetDamage'...");
63-
var damage = service.GetDamage(ninja);
64-
65-
try
66-
{
67-
Console.WriteLine("Invoking parent method 'service.GetDamage' with not correct argument...");
68-
service.GetDamage(null);
69-
}
70-
catch (ArgumentNullException e)
71-
{
72-
Console.WriteLine($"Expected exception is thrown: {e.Message}");
73-
}
74-
}
7519
}
7620
}

LazyProxy.Sample/Services.cs

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32

43
namespace LazyProxy.Sample
54
{
@@ -13,102 +12,4 @@ public class MyService : IMyService
1312
public MyService() => Console.WriteLine("Hello from ctor");
1413
public void Foo() => Console.WriteLine("Hello from Foo");
1514
}
16-
17-
public abstract class Warrior
18-
{
19-
public Weapon[] Weapons { get; set; }
20-
}
21-
22-
public class Ninja : Warrior
23-
{
24-
public int Health { get; set; }
25-
26-
public Ninja(int health, params Weapon[] weapons)
27-
{
28-
Health = health;
29-
Weapons = weapons;
30-
}
31-
}
32-
33-
public class Weapon
34-
{
35-
public int Damage { get; set; }
36-
37-
public Weapon(int damage)
38-
{
39-
Damage = damage;
40-
}
41-
}
42-
43-
public interface IWarriorService
44-
{
45-
int GetDamage(Warrior warrior);
46-
}
47-
48-
public interface INinjaService : IWarriorService
49-
{
50-
int MinNinjaHealth { get; set; }
51-
Ninja CreateNinja();
52-
}
53-
54-
public interface IWeaponService
55-
{
56-
int MinWeaponDamage { get; set; }
57-
Weapon CreateSword();
58-
Weapon CreateShuriken();
59-
}
60-
61-
public class NinjaService : INinjaService
62-
{
63-
private readonly IWeaponService _weaponService;
64-
65-
public int MinNinjaHealth { get; set; } = 50;
66-
67-
public NinjaService(IWeaponService weaponService)
68-
{
69-
Console.WriteLine("ctor: NinjaService");
70-
_weaponService = weaponService;
71-
}
72-
73-
public int GetDamage(Warrior warrior)
74-
{
75-
if (warrior == null)
76-
{
77-
throw new ArgumentNullException();
78-
}
79-
80-
return warrior.Weapons.Sum(w => w.Damage);
81-
}
82-
83-
public Ninja CreateNinja()
84-
{
85-
var sword = _weaponService.CreateSword();
86-
var shuriken = _weaponService.CreateShuriken();
87-
var health = MinNinjaHealth + 10;
88-
89-
return new Ninja(health, sword, shuriken);
90-
}
91-
}
92-
93-
public class WeaponService : IWeaponService
94-
{
95-
public int MinWeaponDamage { get; set; } = 10;
96-
97-
public WeaponService()
98-
{
99-
Console.WriteLine("ctor: WeaponService");
100-
}
101-
102-
public Weapon CreateSword()
103-
{
104-
var damage = MinWeaponDamage + 10;
105-
return new Weapon(damage);
106-
}
107-
108-
public Weapon CreateShuriken()
109-
{
110-
var damage = MinWeaponDamage + 5;
111-
return new Weapon(damage);
112-
}
113-
}
11415
}

LazyProxy.Unity.Benchmarks/LazyProxy.Unity.Benchmarks.csproj

Lines changed: 0 additions & 12 deletions
This file was deleted.

LazyProxy.Unity.Benchmarks/Program.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

LazyProxy.Unity.Benchmarks/UnityExtensionBenchmark.cs

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)