Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / ComPlusServiceLoader.cs / 1 / ComPlusServiceLoader.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.ServiceModel.Description; using System.ServiceModel; using System.ServiceModel.Activation; using System.Diagnostics; using System.ServiceModel.Diagnostics; class ComPlusServiceLoader { ServiceInfo info; ConfigLoader configLoader; ComPlusTypeLoader typeLoader; public ComPlusServiceLoader (ServiceInfo info) { this.info = info; this.typeLoader = new ComPlusTypeLoader(info); this.configLoader = new ConfigLoader(typeLoader); } public ServiceDescription Load(ServiceHostBase host) { ServiceDescription service = new ServiceDescription(this.info.ServiceName); // ServiceBehaviorAttribute needs to go first in the behaviors collection (before config stuff) AddBehaviors(service); this.configLoader.LoadServiceDescription(host, service, this.info.ServiceElement, host.LoadConfigurationSectionHelper); ValidateConfigInstanceSettings(service); ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostCreatedServiceEndpoint, SR.TraceCodeComIntegrationServiceHostCreatedServiceEndpoint, this.info, service.Endpoints); return service; } void AddBehaviors(ServiceDescription service) { // The philosophy here is to respect settings from configuration // At the moment, none of the settings we care about can be modified // through configuration. That may change in the future. // However, we never want to silently overwrite a user's configuration. // So we should either accept overrides or reject them, but never // silently update them. // ServiceBehaviorAttribute serviceBehavior = EnsureBehaviorAttribute(service); serviceBehavior.InstanceProvider = new ComPlusInstanceProvider(this.info); serviceBehavior.InstanceContextMode = InstanceContextMode.Single; // SHOULD: There is no reason to not allow concurrency at this level serviceBehavior.ConcurrencyMode = ConcurrencyMode.Multiple; serviceBehavior.UseSynchronizationContext = false; service.Behaviors.Add(new SecurityCookieModeValidator()); if (ServiceHostingEnvironment.IsHosted) { AspNetCompatibilityRequirementsAttribute aspNetCompatibilityRequirements = service.Behaviors.Find(); if (aspNetCompatibilityRequirements == null) { aspNetCompatibilityRequirements = new AspNetCompatibilityRequirementsAttribute(); service.Behaviors.Add(aspNetCompatibilityRequirements); } } } ServiceBehaviorAttribute EnsureBehaviorAttribute(ServiceDescription service) { ServiceBehaviorAttribute serviceBehavior; if (service.Behaviors.Contains(typeof(ServiceBehaviorAttribute))) { serviceBehavior = (ServiceBehaviorAttribute)service.Behaviors[typeof(ServiceBehaviorAttribute)]; } else { serviceBehavior = new ServiceBehaviorAttribute(); service.Behaviors.Insert(0, serviceBehavior); } return serviceBehavior; } void ValidateConfigInstanceSettings(ServiceDescription service) { ServiceBehaviorAttribute serviceBehavior = EnsureBehaviorAttribute(service); foreach (ServiceEndpoint endpoint in service.Endpoints) { if (endpoint != null && !ServiceMetadataBehavior.IsMetadataEndpoint(service, endpoint)) { if (endpoint.Contract.SessionMode == SessionMode.Required) { if (serviceBehavior.InstanceContextMode == InstanceContextMode.PerCall) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.InconsistentSessionRequirements()); serviceBehavior.InstanceContextMode = InstanceContextMode.PerSession; } else { if (serviceBehavior.InstanceContextMode == InstanceContextMode.PerSession) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.InconsistentSessionRequirements()); serviceBehavior.InstanceContextMode = InstanceContextMode.PerCall; } } } if (serviceBehavior.InstanceContextMode == InstanceContextMode.Single) serviceBehavior.InstanceContextMode = InstanceContextMode.PerSession; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GridSplitterAutomationPeer.cs
- RSAOAEPKeyExchangeFormatter.cs
- RtfControls.cs
- WhitespaceRuleLookup.cs
- SoapMessage.cs
- ConfigurationElementCollection.cs
- ReaderWriterLockWrapper.cs
- ITreeGenerator.cs
- DigestTraceRecordHelper.cs
- XmlSchemaInfo.cs
- VisualStyleTypesAndProperties.cs
- SimpleApplicationHost.cs
- MD5.cs
- _SslState.cs
- PropertyNames.cs
- CustomErrorsSectionWrapper.cs
- SortedSetDebugView.cs
- ReservationCollection.cs
- sqlpipe.cs
- IsolatedStorageFilePermission.cs
- HwndProxyElementProvider.cs
- Constraint.cs
- Vector3dCollection.cs
- SoapIgnoreAttribute.cs
- CompositeActivityValidator.cs
- ModelUIElement3D.cs
- XhtmlBasicCalendarAdapter.cs
- ToolStripItemClickedEventArgs.cs
- PathSegmentCollection.cs
- SourceInterpreter.cs
- PeerMessageDispatcher.cs
- XNodeNavigator.cs
- Mapping.cs
- MarkupExtensionReturnTypeAttribute.cs
- NameTable.cs
- BaseTreeIterator.cs
- NGCSerializationManagerAsync.cs
- LayoutExceptionEventArgs.cs
- DrawingContextWalker.cs
- InstanceContextMode.cs
- ActivityExecutionContext.cs
- TextRunCache.cs
- DrawingGroup.cs
- WebPartPersonalization.cs
- DocComment.cs
- DataGridViewRow.cs
- AttributeCollection.cs
- LoadRetryHandler.cs
- DesignerActionUIStateChangeEventArgs.cs
- MbpInfo.cs
- LinearKeyFrames.cs
- MgmtConfigurationRecord.cs
- SystemInfo.cs
- RawStylusActions.cs
- WebBodyFormatMessageProperty.cs
- DataControlCommands.cs
- assemblycache.cs
- FragmentQuery.cs
- DCSafeHandle.cs
- LassoSelectionBehavior.cs
- QuaternionAnimation.cs
- TextRangeAdaptor.cs
- StatusBarDrawItemEvent.cs
- OdbcStatementHandle.cs
- WebRequest.cs
- AutomationEventArgs.cs
- DBNull.cs
- SafeNativeMethods.cs
- StaticSiteMapProvider.cs
- NewExpression.cs
- BinaryParser.cs
- SHA512Managed.cs
- ItemCollection.cs
- __Filters.cs
- ReferenceEqualityComparer.cs
- SafeRightsManagementQueryHandle.cs
- MsmqAppDomainProtocolHandler.cs
- ResourceContainer.cs
- AvTraceFormat.cs
- PageTheme.cs
- SQLBoolean.cs
- ResourcesGenerator.cs
- OpenTypeLayoutCache.cs
- PolyLineSegment.cs
- ObjectParameter.cs
- RuntimeHelpers.cs
- ScriptResourceAttribute.cs
- TextRangeSerialization.cs
- HashAlgorithm.cs
- KeyTimeConverter.cs
- DoubleLinkListEnumerator.cs
- CheckBoxField.cs
- JsonFormatGeneratorStatics.cs
- EmptyControlCollection.cs
- ExtensionSimplifierMarkupObject.cs
- TextContainerChangedEventArgs.cs
- AQNBuilder.cs
- CodeMethodReturnStatement.cs
- CodeAttributeDeclarationCollection.cs
- PlainXmlDeserializer.cs