Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / ContractDescription.cs / 1 / ContractDescription.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Description { using System; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Transactions; using System.Runtime.Serialization; using System.ServiceModel.Channels; using System.Collections.ObjectModel; using System.Diagnostics; using System.Net.Security; using System.ServiceModel.Security; [DebuggerDisplay("Name={name}, Namespace={ns}, ContractType={contractType}")] public class ContractDescription { Type callbackContractType; string configurationName; Type contractType; XmlName name; string ns; OperationDescriptionCollection operations; SessionMode sessionMode; KeyedByTypeCollectionbehaviors = new KeyedByTypeCollection (); ProtectionLevel protectionLevel; bool hasProtectionLevel; public ContractDescription(string name) : this(name, null) { } public ContractDescription(string name, string ns) { // the property setter validates given value this.Name = name; if (!string.IsNullOrEmpty(ns)) NamingHelper.CheckUriParameter(ns, "ns"); this.operations = new OperationDescriptionCollection(); this.ns = ns ?? NamingHelper.DefaultNamespace; // ns can be "" } internal string CodeName { get { return this.name.DecodedName; } } public string ConfigurationName { get { return this.configurationName; } set { this.configurationName = value; } } public Type ContractType { get { return this.contractType; } set { this.contractType = value; } } public Type CallbackContractType { get { return this.callbackContractType; } set { this.callbackContractType = value; } } public string Name { get { return this.name.EncodedName; } set { if (value == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value"); } if (value.Length == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("value", SR.GetString(SR.SFxContractDescriptionNameCannotBeEmpty))); } this.name = new XmlName(value, true /*isEncoded*/); } } public string Namespace { get { return this.ns; } set { if (!string.IsNullOrEmpty(value)) NamingHelper.CheckUriProperty(value, "Namespace"); this.ns = value; } } public OperationDescriptionCollection Operations { get { return this.operations; } } public ProtectionLevel ProtectionLevel { get { return this.protectionLevel; } set { if (!ProtectionLevelHelper.IsDefined(value)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); this.protectionLevel = value; this.hasProtectionLevel = true; } } public bool HasProtectionLevel { get { return this.hasProtectionLevel; } } public SessionMode SessionMode { get { return this.sessionMode; } set { if (!SessionModeHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.sessionMode = value; } } public KeyedByTypeCollection Behaviors { get { return this.behaviors; } } public static ContractDescription GetContract(Type contractType) { if (contractType == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType"); TypeLoader typeLoader = new TypeLoader(); return typeLoader.LoadContractDescription(contractType); } public static ContractDescription GetContract(Type contractType, Type serviceType) { if (contractType == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType"); if (serviceType == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType"); TypeLoader typeLoader = new TypeLoader(); ContractDescription description = typeLoader.LoadContractDescription(contractType, serviceType); return description; } public static ContractDescription GetContract(Type contractType, object serviceImplementation) { if (contractType == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType"); if (serviceImplementation == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceImplementation"); TypeLoader typeLoader = new TypeLoader(); Type serviceType = serviceImplementation.GetType(); ContractDescription description = typeLoader.LoadContractDescription(contractType, serviceType, serviceImplementation); return description; } public Collection GetInheritedContracts() { Collection result = new Collection (); for (int i = 0; i < Operations.Count; i++) { OperationDescription od = Operations[i]; if (od.DeclaringContract != this) { ContractDescription inheritedContract = od.DeclaringContract; if (!result.Contains(inheritedContract)) { result.Add(inheritedContract); } } } return result; } internal void EnsureInvariants() { if (string.IsNullOrEmpty(this.Name)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.AChannelServiceEndpointSContractSNameIsNull0))); } if (this.Namespace == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.AChannelServiceEndpointSContractSNamespace0))); } if (this.Operations.Count == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.SFxContractHasZeroOperations, this.Name))); } bool thereIsAtLeastOneInitiatingOperation = false; for (int i = 0; i < this.Operations.Count; i++) { OperationDescription operationDescription = this.Operations[i]; operationDescription.EnsureInvariants(); if (operationDescription.IsInitiating) thereIsAtLeastOneInitiatingOperation = true; if ((!operationDescription.IsInitiating || operationDescription.IsTerminating) && (this.SessionMode != SessionMode.Required)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.ContractIsNotSelfConsistentItHasOneOrMore2, this.Name))); } } if (!thereIsAtLeastOneInitiatingOperation) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.SFxContractHasZeroInitiatingOperations, this.Name))); } } internal bool IsDuplex() { for (int i=0; i
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TemplatedMailWebEventProvider.cs
- ProxySimple.cs
- GridViewCellAutomationPeer.cs
- Int32Collection.cs
- DefaultProfileManager.cs
- CodeCompiler.cs
- VerificationException.cs
- MultiTouchSystemGestureLogic.cs
- RecordManager.cs
- behaviorssection.cs
- ReadOnlyDataSourceView.cs
- AddDataControlFieldDialog.cs
- QueryCacheEntry.cs
- AssemblySettingAttributes.cs
- ClientCultureInfo.cs
- _HeaderInfo.cs
- StylusPointPropertyInfoDefaults.cs
- XsdBuildProvider.cs
- SafeLibraryHandle.cs
- StrongNamePublicKeyBlob.cs
- WebRequestModuleElement.cs
- BitmapEffectCollection.cs
- SqlGatherConsumedAliases.cs
- TreeIterators.cs
- CustomSignedXml.cs
- XmlReflectionMember.cs
- JumpPath.cs
- ToolStripItemEventArgs.cs
- EventLogTraceListener.cs
- HybridDictionary.cs
- ExpressionVisitor.cs
- XmlExtensionFunction.cs
- FixedDocumentSequencePaginator.cs
- CommonObjectSecurity.cs
- ResolveNextArgumentWorkItem.cs
- Stackframe.cs
- HtmlControlPersistable.cs
- BufferedReadStream.cs
- ResourcesChangeInfo.cs
- XmlDocumentType.cs
- FrameworkContentElementAutomationPeer.cs
- RegexStringValidator.cs
- PromptEventArgs.cs
- IntegerFacetDescriptionElement.cs
- SafeMILHandle.cs
- DataKey.cs
- SafeRightsManagementSessionHandle.cs
- SmiEventSink_Default.cs
- Single.cs
- CultureInfo.cs
- MemoryRecordBuffer.cs
- Opcode.cs
- ObjectAssociationEndMapping.cs
- Trigger.cs
- Point3D.cs
- PinnedBufferMemoryStream.cs
- DesignerDeviceConfig.cs
- DocumentPageTextView.cs
- ProfilePropertySettings.cs
- ActivityTypeCodeDomSerializer.cs
- ImageFormat.cs
- CheckBoxBaseAdapter.cs
- ViewStateModeByIdAttribute.cs
- SecurityHeaderLayout.cs
- CodeIdentifier.cs
- OAVariantLib.cs
- DummyDataSource.cs
- AsyncDataRequest.cs
- XmlChildNodes.cs
- DataTable.cs
- PointHitTestParameters.cs
- MarkedHighlightComponent.cs
- AppSettingsExpressionBuilder.cs
- PartitionResolver.cs
- OleDbParameter.cs
- ConfigurationProviderException.cs
- MenuItem.cs
- ServiceBuildProvider.cs
- AutomationPropertyInfo.cs
- TextEditorSpelling.cs
- CTreeGenerator.cs
- InlineCollection.cs
- XmlLinkedNode.cs
- xml.cs
- BindingCollection.cs
- FieldTemplateFactory.cs
- RoleManagerSection.cs
- CompositionDesigner.cs
- ActiveXSite.cs
- SessionPageStatePersister.cs
- PostBackTrigger.cs
- MetadataArtifactLoaderResource.cs
- KeyValueSerializer.cs
- WindowsPrincipal.cs
- HtmlEmptyTagControlBuilder.cs
- ResourceCategoryAttribute.cs
- XmlSchemaException.cs
- TextBoxAutomationPeer.cs
- NGCSerializationManager.cs
- DynamicResourceExtensionConverter.cs