1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 namespace Castle
.Windsor
.Tests
19 using System
.Collections
;
20 using Castle
.Windsor
.Tests
.Components
;
22 public interface IRepository
<T
>
27 public class DemoRepository
<T
> : IRepository
<T
>
30 private ICache
<T
> cache
;
32 public ICache
<T
> Cache
35 set { cache = value; }
46 return Activator
.CreateInstance
<T
>();
50 public class ReviewerRepository
: DemoRepository
<IReviewer
>
53 private ICache
<IReviewer
> cache
;
55 public new ICache
<IReviewer
> Cache
58 set { cache = value; }
61 public new string Name
67 public new IReviewer
Get(int id
)
73 public interface ICache
<T
>
75 void Put(string key
, T item
);
79 public class HashTableCache
<T
> : ICache
<T
>
81 private Hashtable hash
= new Hashtable();
83 public void Put(string key
, T item
)
88 public T
Get(string key
)
94 public class NullCache
<T
> : ICache
<T
>
96 public void Put(string key
, T item
)
100 public T
Get(string key
)
106 public class LoggingRepositoryDecorator
<T
> : IRepository
<T
>
108 public IRepository
<T
> inner
;
110 public LoggingRepositoryDecorator()
114 public LoggingRepositoryDecorator(IRepository
<T
> inner
)
121 Console
.WriteLine("Getting {0}", id
);
122 return inner
.Get(id
);
126 [Castle
.Core
.Transient
]
127 public class TransientRepository
<T
> : IRepository
<T
> where T
: new()
135 public class NeedsGenericType
137 private ICache
<string> cache
;
139 public NeedsGenericType(ICache
<string> cache
)