ContractDescription.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // ContractDescription.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc. http://www.novell.com
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.Collections.ObjectModel;
  32. using System.Net.Security;
  33. using System.Reflection;
  34. using System.Runtime.Serialization;
  35. using System.ServiceModel;
  36. using System.ServiceModel.Channels;
  37. namespace System.ServiceModel.Description
  38. {
  39. public class ContractDescription
  40. {
  41. [MonoTODO]
  42. public static ContractDescription GetContract (
  43. Type contractType)
  44. {
  45. return ContractDescriptionGenerator.GetContract (contractType);
  46. }
  47. [MonoTODO]
  48. public static ContractDescription GetContract (
  49. Type contractType, object serviceImplementation)
  50. {
  51. return ContractDescriptionGenerator.GetContract (contractType, serviceImplementation);
  52. }
  53. [MonoTODO]
  54. public static ContractDescription GetContract (
  55. Type contractType, Type serviceType)
  56. {
  57. return ContractDescriptionGenerator.GetContract (contractType, serviceType);
  58. }
  59. OperationDescriptionCollection operations;
  60. KeyedByTypeCollection<IContractBehavior> behaviors;
  61. Type callback_contract_type, contract_type;
  62. string name, ns, config_name;
  63. ProtectionLevel protection_level;
  64. bool has_protection_level;
  65. SessionMode session;
  66. public ContractDescription (string name)
  67. : this (name, null)
  68. {
  69. }
  70. public ContractDescription (string name, string ns)
  71. {
  72. if (name == null)
  73. throw new ArgumentNullException ("name");
  74. if (name.Length == 0)
  75. throw new ArgumentOutOfRangeException ("ContractDescription's Name must be a non-empty string.");
  76. if (ns == null)
  77. ns = "http://tempuri.org/";
  78. this.name = name;
  79. this.ns = ns;
  80. behaviors = new KeyedByTypeCollection<IContractBehavior> ();
  81. operations = new OperationDescriptionCollection ();
  82. }
  83. public KeyedByTypeCollection<IContractBehavior> Behaviors {
  84. get { return behaviors; }
  85. }
  86. public Type CallbackContractType {
  87. get { return callback_contract_type; }
  88. set { callback_contract_type = value; }
  89. }
  90. public string ConfigurationName {
  91. get { return config_name; }
  92. set { config_name = value; }
  93. }
  94. public Type ContractType {
  95. get { return contract_type; }
  96. set { contract_type = value; }
  97. }
  98. public bool HasProtectionLevel {
  99. get { return has_protection_level; }
  100. }
  101. public ProtectionLevel ProtectionLevel {
  102. get { return protection_level; }
  103. set {
  104. protection_level = value;
  105. has_protection_level = true;
  106. }
  107. }
  108. public string Name {
  109. get { return name; }
  110. }
  111. public string Namespace {
  112. get { return ns; }
  113. set { ns = value; }
  114. }
  115. public OperationDescriptionCollection Operations {
  116. get { return operations; }
  117. }
  118. public SessionMode SessionMode {
  119. get { return session; }
  120. set { session = value; }
  121. }
  122. [MonoTODO]
  123. public Collection<ContractDescription> GetInheritedContracts ()
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. }
  128. }