/src/NHibernate.DomainModel/Baz.cs

https://github.com/whut/nhibernate-core · C# · 456 lines · 290 code · 56 blank · 110 comment · 0 complexity · 625a0ecee1c8683bc410409ba8440f08 MD5 · raw file

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Iesi.Collections.Generic;
  5. using System.Linq;
  6. namespace NHibernate.DomainModel
  7. {
  8. [Serializable]
  9. public class Baz : INamed, IComparable
  10. {
  11. #region Fields
  12. private NestingComponent _collectionComponent;
  13. private String _code;
  14. private FooComponent[] _components;
  15. private DateTime[] _timeArray;
  16. private string[] _stringArray;
  17. private int[] _intArray;
  18. private FooProxy[] _fooArray;
  19. private Int32 _count;
  20. private String _name;
  21. private Foo _foo;
  22. private IList<string> _stringList;
  23. private IList<Fee> _fees;
  24. private IList<string[]> _customs;
  25. private IList<FooComponent> _topComponents;
  26. private IDictionary<Foo, GlarchProxy> _fooToGlarch;
  27. private IDictionary<FooComponent, Foo> _fooComponentToFoo;
  28. private IDictionary<Foo, GlarchProxy> _glarchToFoo;
  29. private IDictionary<string, DateTime?> _stringDateMap;
  30. private IDictionary<char, GlarchProxy> _topGlarchez;
  31. private IDictionary<Baz, CompositeElement> _cachedMap;
  32. private IDictionary<string, Glarch> _stringGlarchMap;
  33. private IDictionary<object, object> _anyToAny;
  34. private IList<object> _manyToAny;
  35. private ISet<FooProxy> _fooSet;
  36. private ISet<string> _stringSet;
  37. private ISet<Bar> _topFoos;
  38. private ISet<BarProxy> _cascadingBars;
  39. private ISet<CompositeElement> _cached;
  40. private ISet<Sortable> _sortablez;
  41. private IList<string> _bag;
  42. private IList<Foo> _fooBag;
  43. private IList<Foo> _idFooBag;
  44. private IList<byte[]> _byteBag;
  45. private IList<Baz> _bazez;
  46. private IList<Part> _parts;
  47. #endregion
  48. #region Constructors
  49. /// <summary>
  50. /// Default constructor for class Baz
  51. /// </summary>
  52. public Baz()
  53. {
  54. }
  55. #endregion
  56. #region Properties
  57. /// <summary>
  58. /// Gets or sets the _collectionComponent
  59. /// </summary>
  60. public NestingComponent CollectionComponent
  61. {
  62. get { return _collectionComponent; }
  63. set { _collectionComponent = value; }
  64. }
  65. /// <summary>
  66. /// Get/set for Code
  67. /// </summary>
  68. public String Code
  69. {
  70. get { return this._code; }
  71. set { this._code = value; }
  72. }
  73. /// <summary>
  74. /// Get/set for count
  75. /// </summary>
  76. public Int32 Count
  77. {
  78. get { return this._count; }
  79. set { this._count = value; }
  80. }
  81. /// <summary>
  82. /// Get/set for name
  83. /// </summary>
  84. public String Name
  85. {
  86. get { return this._name; }
  87. set { this._name = value; }
  88. }
  89. /// <summary>
  90. /// Get/set for Foo
  91. /// </summary>
  92. public Foo Foo
  93. {
  94. get { return this._foo; }
  95. set { this._foo = value; }
  96. }
  97. /// <summary>
  98. /// Get/set for stringList
  99. /// </summary>
  100. public IList<string> StringList
  101. {
  102. get { return this._stringList; }
  103. set { this._stringList = value; }
  104. }
  105. /// <summary>
  106. /// Get/set for fees
  107. /// </summary>
  108. public IList<Fee> Fees
  109. {
  110. get { return _fees; }
  111. set { _fees = value; }
  112. }
  113. /// <summary>
  114. /// Get/set for customs
  115. /// </summary>
  116. public IList<string[]> Customs
  117. {
  118. get { return this._customs; }
  119. set { this._customs = value; }
  120. }
  121. /// <summary>
  122. /// Get/set for topComponents
  123. /// </summary>
  124. public IList<FooComponent> TopComponents
  125. {
  126. get { return this._topComponents; }
  127. set { this._topComponents = value; }
  128. }
  129. /// <summary>
  130. /// Get/set for fooToGlarch
  131. /// </summary>
  132. public IDictionary<Foo, GlarchProxy> FooToGlarch
  133. {
  134. get { return this._fooToGlarch; }
  135. set { this._fooToGlarch = value; }
  136. }
  137. /// <summary>
  138. /// Get/set for fooComponentToFoo
  139. /// </summary>
  140. public IDictionary<FooComponent, Foo> FooComponentToFoo
  141. {
  142. get { return this._fooComponentToFoo; }
  143. set { this._fooComponentToFoo = value; }
  144. }
  145. /// <summary>
  146. /// Get/set for glarchToFoo
  147. /// </summary>
  148. public IDictionary<Foo, GlarchProxy> GlarchToFoo
  149. {
  150. get { return this._glarchToFoo; }
  151. set { this._glarchToFoo = value; }
  152. }
  153. /// <summary>
  154. /// Get/set for stringDateMap
  155. /// </summary>
  156. public IDictionary<string, DateTime?> StringDateMap
  157. {
  158. get { return this._stringDateMap; }
  159. set { this._stringDateMap = value; }
  160. }
  161. /// <summary>
  162. /// Get/set for topGlarchez
  163. /// </summary>
  164. public IDictionary<char, GlarchProxy> TopGlarchez
  165. {
  166. get { return this._topGlarchez; }
  167. set { this._topGlarchez = value; }
  168. }
  169. /// <summary>
  170. /// Get/set for cachedMap
  171. /// </summary>
  172. public IDictionary<Baz,CompositeElement> CachedMap
  173. {
  174. get { return this._cachedMap; }
  175. set { this._cachedMap = value; }
  176. }
  177. /// <summary>
  178. /// Get/set for stringGlarchMap
  179. /// </summary>
  180. public IDictionary<string, Glarch> StringGlarchMap
  181. {
  182. get { return this._stringGlarchMap; }
  183. set { this._stringGlarchMap = value; }
  184. }
  185. /// <summary>
  186. /// Get/set for anyToAny
  187. /// </summary>
  188. public IDictionary<object, object> AnyToAny
  189. {
  190. get { return this._anyToAny; }
  191. set { this._anyToAny = value; }
  192. }
  193. /// <summary>
  194. /// Get/set for manyToAny
  195. /// </summary>
  196. public IList<object> ManyToAny
  197. {
  198. get { return this._manyToAny; }
  199. set { this._manyToAny = value; }
  200. }
  201. /// <summary>
  202. /// Gets or sets the intArray
  203. /// </summary>
  204. public int[] IntArray
  205. {
  206. get { return _intArray; }
  207. set { _intArray = value; }
  208. }
  209. /// <summary>
  210. /// Gets or sets the _components
  211. /// </summary>
  212. public FooComponent[] Components
  213. {
  214. get { return _components; }
  215. set { _components = value; }
  216. }
  217. /// <summary>
  218. /// Gets or sets the timeArray
  219. /// </summary>
  220. public DateTime[] TimeArray
  221. {
  222. get { return _timeArray; }
  223. set { _timeArray = value; }
  224. }
  225. /// <summary>
  226. /// Gets or sets the stringArray
  227. /// </summary>
  228. public string[] StringArray
  229. {
  230. get { return _stringArray; }
  231. set { _stringArray = value; }
  232. }
  233. /// <summary>
  234. /// Gets or sets the fooArray
  235. /// </summary>
  236. public FooProxy[] FooArray
  237. {
  238. get { return _fooArray; }
  239. set { _fooArray = value; }
  240. }
  241. /// <summary>
  242. /// Get/set for fooSet
  243. /// </summary>
  244. public ISet<FooProxy> FooSet
  245. {
  246. get { return this._fooSet; }
  247. set { this._fooSet = value; }
  248. }
  249. /// <summary>
  250. /// Get/set for stringSet
  251. /// </summary>
  252. public ISet<string> StringSet
  253. {
  254. get { return this._stringSet; }
  255. set { this._stringSet = value; }
  256. }
  257. /// <summary>
  258. /// Get/set for topFoos
  259. /// </summary>
  260. public ISet<Bar> TopFoos
  261. {
  262. get { return this._topFoos; }
  263. set { this._topFoos = value; }
  264. }
  265. /// <summary>
  266. /// Get/set for cascadingBars
  267. /// </summary>
  268. public ISet<BarProxy> CascadingBars
  269. {
  270. get { return this._cascadingBars; }
  271. set { this._cascadingBars = value; }
  272. }
  273. /// <summary>
  274. /// Get/set for cached
  275. /// </summary>
  276. public ISet<CompositeElement> Cached
  277. {
  278. get { return this._cached; }
  279. set { this._cached = value; }
  280. }
  281. /// <summary>
  282. /// Get/set for sortablez
  283. /// </summary>
  284. public ISet<Sortable> Sortablez
  285. {
  286. get { return this._sortablez; }
  287. set { this._sortablez = value; }
  288. }
  289. /// <summary>
  290. /// Get/set for bag
  291. /// </summary>
  292. public IList<string> Bag
  293. {
  294. get { return this._bag; }
  295. set { this._bag = value; }
  296. }
  297. /// <summary>
  298. /// Get/set for fooBag
  299. /// </summary>
  300. public IList<Foo> FooBag
  301. {
  302. get { return this._fooBag; }
  303. set { this._fooBag = value; }
  304. }
  305. /// <summary>
  306. /// Get/set for bazez
  307. /// </summary>
  308. public IList<Baz> Bazez
  309. {
  310. get { return this._bazez; }
  311. set { this._bazez = value; }
  312. }
  313. /// <summary>
  314. /// Get/set for idFooBag
  315. /// </summary>
  316. public IList<Foo> IdFooBag
  317. {
  318. get { return this._idFooBag; }
  319. set { this._idFooBag = value; }
  320. }
  321. /// <summary>
  322. /// Get/set for byteBag
  323. /// </summary>
  324. public IList<byte[]> ByteBag
  325. {
  326. get { return this._byteBag; }
  327. set { this._byteBag = value; }
  328. }
  329. /// <summary>
  330. /// Get/set for parts
  331. /// </summary>
  332. public IList<Part> Parts
  333. {
  334. get { return this._parts; }
  335. set { this._parts = value; }
  336. }
  337. #endregion
  338. public void SetDefaults()
  339. {
  340. DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  341. StringSet = new HashSet<string> {"foo", "bar", "baz"};
  342. StringDateMap = new SortedList<string, DateTime?>();
  343. StringDateMap.Add("now", DateTime.Now);
  344. StringDateMap.Add("never", null); // value is persisted since NH-2199
  345. // according to SQL Server the big bag happened in 1753 ;)
  346. StringDateMap.Add("big bang", new DateTime(1753, 01, 01));
  347. //StringDateMap.Add( "millenium", new DateTime( 2000, 01, 01 ) );
  348. StringArray = StringSet.ToArray();
  349. StringList = new List<string>(StringArray);
  350. IntArray = new int[] {1, 3, 3, 7};
  351. FooArray = new Foo[0];
  352. Customs = new List<string[]>();
  353. Customs.Add(new String[] {"foo", "bar"});
  354. Customs.Add(new String[] {"A", "B"});
  355. Customs.Add(new String[] {"1", "2"});
  356. FooSet = new HashSet<FooProxy>();
  357. Components = new FooComponent[]
  358. {
  359. new FooComponent("foo", 42, null, null),
  360. new FooComponent("bar", 88, null, new FooComponent("sub", 69, null, null))
  361. };
  362. TimeArray = new DateTime[]
  363. {
  364. new DateTime(),
  365. new DateTime(),
  366. new DateTime(), // H2.1 has null here, but it's illegal on .NET
  367. new DateTime(0)
  368. };
  369. Count = 667;
  370. Name = "Bazza";
  371. TopComponents = new List<FooComponent>();
  372. TopComponents.Add(new FooComponent("foo", 11, new DateTime[] {today, new DateTime(2123, 1, 1)}, null));
  373. TopComponents.Add(
  374. new FooComponent("bar", 22, new DateTime[] {new DateTime(2007, 2, 3), new DateTime(1945, 6, 1)}, null));
  375. TopComponents.Add(null);
  376. Bag = new List<string>();
  377. Bag.Add("duplicate");
  378. Bag.Add("duplicate");
  379. Bag.Add("duplicate");
  380. Bag.Add("unique");
  381. Cached = new LinkedHashSet<CompositeElement>();
  382. CompositeElement ce = new CompositeElement();
  383. ce.Foo = "foo";
  384. ce.Bar = "bar";
  385. CompositeElement ce2 = new CompositeElement();
  386. ce2.Foo = "fooxxx";
  387. ce2.Bar = "barxxx";
  388. Cached.Add(ce);
  389. Cached.Add(ce2);
  390. CachedMap = new SortedList<Baz, CompositeElement>();
  391. CachedMap.Add(this, ce);
  392. }
  393. #region IComparable Members
  394. public int CompareTo(object obj)
  395. {
  396. return ((Baz) obj).Code.CompareTo(Code);
  397. }
  398. #endregion
  399. }
  400. }