PoolItem.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace ConnectionPool.test
  5. {
  6. public class PoolItem
  7. {
  8. private IDynamicObject _object;
  9. private bool _bUsing;
  10. private Type _type;
  11. private Object _CreateParam;
  12. public PoolItem(Type type, Object param)
  13. {
  14. _type = type;
  15. _CreateParam = param;
  16. Create();
  17. }
  18. private void Create()
  19. {
  20. _bUsing = false;
  21. _object = (IDynamicObject)System.Activator.CreateInstance(_type);
  22. _object.Create(_CreateParam);
  23. }
  24. public void Recreate()
  25. {
  26. _object.Release();
  27. Create();
  28. }
  29. public void Release()
  30. {
  31. _object.Release();
  32. }
  33. public Object InnerObject
  34. {
  35. get { return _object.GetInnerObject(); }
  36. }
  37. public int InnerObjectHashcode
  38. {
  39. get { return InnerObject.GetHashCode(); }
  40. }
  41. public bool IsValidate
  42. {
  43. get { return _object.IsValidate(); }
  44. }
  45. public bool Using
  46. {
  47. get { return _bUsing; }
  48. set { _bUsing = value; }
  49. }
  50. }// class PoolItem
  51. }