Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Configuration / ProvidersHelper.cs / 2 / ProvidersHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Configuration; using System.Configuration.Provider; using System.Web.Compilation; using System.Collections.Specialized; using System; using System.Security; using System.Security.Permissions; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public static class ProvidersHelper { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)] public static ProviderBase InstantiateProvider(ProviderSettings providerSettings, Type providerType) { ProviderBase provider = null; try { string pnType = (providerSettings.Type == null) ? null : providerSettings.Type.Trim(); if (string.IsNullOrEmpty(pnType)) throw new ArgumentException(SR.GetString(SR.Provider_no_type_name)); Type t = ConfigUtil.GetType(pnType, "type", providerSettings, true, true); if (!providerType.IsAssignableFrom(t)) throw new ArgumentException(SR.GetString(SR.Provider_must_implement_type, providerType.ToString())); provider = (ProviderBase)HttpRuntime.CreatePublicInstance(t); // Because providers modify the parameters collection (i.e. delete stuff), pass in a clone of the collection NameValueCollection pars = providerSettings.Parameters; NameValueCollection cloneParams = new NameValueCollection(pars.Count, StringComparer.Ordinal); foreach (string key in pars) cloneParams[key] = pars[key]; provider.Initialize(providerSettings.Name, cloneParams); } catch (Exception e) { if (e is ConfigurationException) throw; throw new ConfigurationErrorsException(e.Message, providerSettings.ElementInformation.Properties["type"].Source, providerSettings.ElementInformation.Properties["type"].LineNumber); } return provider; } [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)] public static void InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType) { foreach (ProviderSettings ps in configProviders) { providers.Add(InstantiateProvider(ps, providerType)); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RepeaterItemCollection.cs
- SafeCoTaskMem.cs
- Pair.cs
- SiteMapDataSource.cs
- WebUtil.cs
- XamlVector3DCollectionSerializer.cs
- NewExpression.cs
- ConditionalAttribute.cs
- _NegoStream.cs
- ObjectDataSource.cs
- DesignerRegion.cs
- TypedAsyncResult.cs
- HtmlImage.cs
- XmlDataCollection.cs
- OlePropertyStructs.cs
- ContextMarshalException.cs
- KnownTypesHelper.cs
- NetworkStream.cs
- AsyncOperationManager.cs
- WebBrowserProgressChangedEventHandler.cs
- DecimalConstantAttribute.cs
- Int64KeyFrameCollection.cs
- X509SecurityTokenAuthenticator.cs
- TemplateBuilder.cs
- sqlcontext.cs
- UDPClient.cs
- CompilerHelpers.cs
- NewArrayExpression.cs
- DataViewSettingCollection.cs
- SchemaDeclBase.cs
- SmtpReplyReaderFactory.cs
- WizardDesigner.cs
- RecordConverter.cs
- PrimitiveDataContract.cs
- ProtocolElementCollection.cs
- DLinqDataModelProvider.cs
- autovalidator.cs
- MethodCallConverter.cs
- TemplateLookupAction.cs
- SAPICategories.cs
- ProtectedProviderSettings.cs
- TextBoxBase.cs
- FixedSOMContainer.cs
- WebScriptMetadataMessage.cs
- XmlSerializationWriter.cs
- Bits.cs
- FixedPageAutomationPeer.cs
- TextStore.cs
- ItemsPanelTemplate.cs
- ConfigXmlCDataSection.cs
- WebZone.cs
- EditingScope.cs
- RuntimeComponentFilter.cs
- SqlRowUpdatedEvent.cs
- PrintPageEvent.cs
- Graphics.cs
- Object.cs
- ButtonChrome.cs
- ImmutableObjectAttribute.cs
- COM2Properties.cs
- RSAPKCS1KeyExchangeFormatter.cs
- FreezableCollection.cs
- ProfileSettingsCollection.cs
- XXXOnTypeBuilderInstantiation.cs
- PersistenceProviderElement.cs
- ExpressionCopier.cs
- FlagsAttribute.cs
- CodeComment.cs
- HttpSocketManager.cs
- AbstractSvcMapFileLoader.cs
- FixedTextView.cs
- WorkflowDesigner.cs
- XsdCachingReader.cs
- ExpressionBindings.cs
- SmtpDigestAuthenticationModule.cs
- EventWaitHandleSecurity.cs
- SqlBuilder.cs
- ExclusiveCanonicalizationTransform.cs
- PropertyEmitter.cs
- XmlAttributes.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- PackagingUtilities.cs
- _ConnectOverlappedAsyncResult.cs
- JapaneseLunisolarCalendar.cs
- IsolatedStorageFile.cs
- CompilerResults.cs
- RtfFormatStack.cs
- MultipartContentParser.cs
- StylusPoint.cs
- UriScheme.cs
- CapiHashAlgorithm.cs
- WindowsUpDown.cs
- XPathDescendantIterator.cs
- SessionConnectionReader.cs
- XmlNodeChangedEventArgs.cs
- ProtectedConfiguration.cs
- X509Certificate2.cs
- followingquery.cs
- BindingCompleteEventArgs.cs
- StylusButtonCollection.cs