1 // Copyright 2004-2007 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 TestSiteNVelocity
.Controllers
19 using Castle
.MonoRail
.Framework
;
24 public class SmartController
: SmartDispatcherController
26 public SmartController()
30 public void StringMethod(string name
)
32 RenderText("incoming " + name
);
35 public void Complex(string strarg
, int intarg
, String
[] strarray
)
37 RenderText(String
.Format("incoming {0} {1} {2}", strarg
, intarg
, String
.Join(",", strarray
)));
40 public void SimpleBind([DataBind("order")] Order order
)
42 RenderText(String
.Format("incoming {0}", order
.ToString()));
45 public void SimpleBindArray([DataBind("orders")] Order
[] orders
)
49 RenderText("Null array shouldn't be returned by databinder");
53 RenderText(String
.Format("incoming {0}", orders
.Length
));
57 public void ComplexBind([DataBind("order")] Order order
, [DataBind("person")] Person person
)
59 RenderText(String
.Format("incoming {0} {1}", order
.ToString(), person
.ToString()));
62 public void ComplexBindExcludePrice([DataBind("order", Exclude
="order.Price")] Order order
, [DataBind("person")] Person person
)
64 RenderText(String
.Format("incoming {0} {1}", order
.ToString(), person
.ToString()));
67 public void ComplexBindExcludeName([DataBind("order", Exclude
="order.Name")] Order order
, [DataBind("person")] Person person
)
69 RenderText(String
.Format("incoming {0} {1}", order
.ToString(), person
.ToString()));
72 public void ComplexBindWithPrefix([DataBind("order")] Order order
, [DataBind("person")] Person person
)
74 RenderText(String
.Format("incoming {0} {1}", order
.ToString(), person
.ToString()));
77 public void FillingBehavior([DataBind("abc")] ClassWithInitializers clazz
)
79 System
.Threading
.Thread
.CurrentThread
.CurrentCulture
= System
.Globalization
.CultureInfo
.InvariantCulture
;
81 RenderText(String
.Format("incoming {0} {1} {2}", clazz
.Name
, clazz
.Date1
.ToShortDateString(), clazz
.Date2
.ToShortDateString()));
84 public void NullableConversion(Nullables
.NullableDouble amount
)
86 RenderText(String
.Format("incoming {0} {1}", amount
.HasValue
, amount
.ToString()));
89 public void NullableConversion2([DataBind("mov")] Movement movement
)
91 RenderText(String
.Format("incoming {0} {1}", movement
.Name
, movement
.Amount
.ToString()));
94 public void ArrayBinding([DataBind("user")] User2 user
)
96 RenderText(user
.ToString());
98 foreach(int id
in user
.Roles
)
100 RenderText(" " + id
);
102 foreach(int id
in user
.Permissions
)
104 RenderText(" " + id
);
108 public void CalculateUtilizationByDay([DataBind("tp1")] TimePoint tp1
, [DataBind("tp2")] TimePoint tp2
)
110 RenderText(tp1
.ToString());
111 RenderText(tp2
.ToString());
115 public class ClassWithInitializers
118 private DateTime date1
;
119 private DateTime date2
;
121 public ClassWithInitializers()
124 date1
= DateTime
.Now
;
125 date2
= DateTime
.Now
.AddDays(1);
131 set { name = value; }
134 public DateTime Date1
136 get { return date1; }
137 set { date1 = value; }
140 public DateTime Date2
142 get { return date2; }
143 set { date2 = value; }
150 private int itemCount
;
156 set { name = value; }
161 get { return itemCount; }
162 set { itemCount = value; }
167 get { return price; }
168 set { price = value; }
171 public override string ToString()
173 return String
.Format("{0} {1} {2}", name
, itemCount
, price
);
188 public Contact Contact
190 get { return contact; }
191 set { contact = value; }
194 public override string ToString()
196 return String
.Format("{0} {1}", id
, contact
);
208 public Contact(string email
, string phone
)
216 get { return email; }
217 set { email = value; }
222 get { return phone; }
223 set { phone = value; }
226 public override string ToString()
228 return String
.Format("{0} {1}", email
, phone
);
232 public class Movement
234 String name
; Nullables
.NullableDouble amount
;
239 set { name = value; }
242 public NullableDouble Amount
244 get { return amount; }
245 set { amount = value; }
251 String name
; int[] roles
; int[] permissions
;
256 set { name = value; }
261 get { return roles; }
262 set { roles = value; }
265 public int[] Permissions
267 get { return permissions; }
268 set { permissions = value; }
271 public override string ToString()
273 return String
.Format("User {0} {1} {2}", name
, roles
.Length
, permissions
.Length
);
277 public class TimePoint
: IComparable
288 public TimePoint(int hour
, int minute
, int second
)
297 get { return _hour; }
298 set { _hour = value; }
303 get { return _minute; }
304 set { _minute = value; }
309 get { return _second; }
310 set { _second = value; }
313 public override string ToString()
315 return String
.Format(" {0}:{1}:{2} ", _hour
, _minute
, _second
);
318 public int CompareTo(object obj
)
320 throw new NotImplementedException();