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.
15 namespace Castle
.DynamicProxy
.Tests
.GenInterfaces
18 using System
.Collections
;
19 using System
.Collections
.Generic
;
20 using System
.Reflection
;
21 using Castle
.Core
.Interceptor
;
23 public interface GenInterfaceWithGenericTypes
25 IList
Find(string[,] query
);
27 IList
<T
> Find
<T
>(string query
);
29 IList
<String
> FindStrings(string query
);
31 void Populate
<T
>(IList
<T
> list
);
34 public class GenInterfaceWithGenericTypesImpl
: GenInterfaceWithGenericTypes
36 public IList
Find(string[,] query
)
41 public IList
Find(string query
)
46 public IList
<T
> Find
<T
>(string query
)
51 public IList
<string> FindStrings(string query
)
53 return new List
<String
>();
56 public void Populate
<T
>(IList
<T
> list
)
61 public class Proxy
: GenInterfaceWithGenericTypes
63 private readonly IInterceptor
[] interceptors
;
64 private readonly GenInterfaceWithGenericTypesImpl target
;
66 public Proxy(IInterceptor
[] interceptors
, GenInterfaceWithGenericTypesImpl target
)
68 this.interceptors
= interceptors
;
72 public void Populate
<T
>(IList
<T
> list
)
74 Find3Invo
<T
> inv
= new Find3Invo
<T
>(target
, interceptors
, typeof(Proxy
),
75 null, null, new object[] {list}
);
79 public IList
Find(string[,] query
)
81 Find1Invo inv
= new Find1Invo(target
, interceptors
, typeof(Proxy
),
82 null, null, new object[] {query}
);
85 return (IList
) inv
.ReturnValue
;
88 public IList
Find(string query
)
90 Find1InvoA inv
= new Find1InvoA(target
, interceptors
, typeof(Proxy
),
91 null, null, new object[] {query}
);
94 return (IList
) inv
.ReturnValue
;
97 public IList
<T
> Find
<T
>(string query
)
99 Find2Invo
<T
> inv
= new Find2Invo
<T
>(target
, interceptors
, typeof(Proxy
),
100 null, null, new object[] {query}
);
103 return (IList
<T
>) inv
.ReturnValue
;
106 public IList
<string> FindStrings(string query
)
108 throw new NotImplementedException();
111 public class Find2Invo
<T
> : AbstractInvocation
113 private readonly GenInterfaceWithGenericTypesImpl target
;
115 public Find2Invo(GenInterfaceWithGenericTypesImpl target
, IInterceptor
[] interceptors
, Type targetType
,
116 MethodInfo targetMethod
, MethodInfo interfMethod
, object[] arguments
)
117 : base(target
, target
, interceptors
, targetType
, targetMethod
, interfMethod
, arguments
)
119 this.target
= target
;
122 protected override void InvokeMethodOnTarget()
124 ReturnValue
= target
.Find
<T
>((String
) GetArgumentValue(0));
128 public class Find1Invo
: AbstractInvocation
130 private readonly GenInterfaceWithGenericTypesImpl target
;
132 public Find1Invo(GenInterfaceWithGenericTypesImpl target
, IInterceptor
[] interceptors
, Type targetType
,
133 MethodInfo targetMethod
, MethodInfo interfMethod
, object[] arguments
) :
134 base(target
, target
, interceptors
, targetType
, targetMethod
, interfMethod
, arguments
)
136 this.target
= target
;
139 protected override void InvokeMethodOnTarget()
141 ReturnValue
= target
.Find((String
[,]) GetArgumentValue(0));
145 public class Find1InvoA
: AbstractInvocation
147 private readonly GenInterfaceWithGenericTypesImpl target
;
149 public Find1InvoA(GenInterfaceWithGenericTypesImpl target
, IInterceptor
[] interceptors
, Type targetType
,
150 MethodInfo targetMethod
, MethodInfo interfMethod
, object[] arguments
)
152 base(target
, target
, interceptors
, targetType
, targetMethod
, interfMethod
, arguments
)
154 this.target
= target
;
157 protected override void InvokeMethodOnTarget()
159 ReturnValue
= target
.Find((String
) GetArgumentValue(0));
163 public class Find3Invo
<T
> : AbstractInvocation
165 private readonly GenInterfaceWithGenericTypesImpl target
;
167 public Find3Invo(GenInterfaceWithGenericTypesImpl target
,
168 IInterceptor
[] interceptors
, Type targetType
,
169 MethodInfo targetMethod
, MethodInfo interfMethod
, object[] arguments
)
170 : base(target
, target
, interceptors
, targetType
, targetMethod
, interfMethod
, arguments
)
172 this.target
= target
;
175 protected override void InvokeMethodOnTarget()
177 target
.Populate((List
<T
>) GetArgumentValue(0));