Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / ProviderUtil.cs / 2 / ProviderUtil.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Sec * * Copyright (c) 1998-1999, Microsoft Corporation * */ namespace System.Web.Util { using System.Collections.Specialized; using System.Web.Mail; using System.Configuration; using System.Globalization; internal static class ProviderUtil { internal const int Infinite = Int32.MaxValue; internal static void GetAndRemoveStringAttribute(NameValueCollection config, string attrib, string providerName, ref string val) { val = config.Get(attrib); config.Remove(attrib); } internal static void GetAndRemovePositiveAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { GetPositiveAttribute(config, attrib, providerName, ref val); config.Remove(attrib); } internal static void GetPositiveAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { string s = config.Get(attrib); int t; if (s == null) { return; } try { t = Convert.ToInt32(s, CultureInfo.InvariantCulture); } catch (Exception e){ if (e is ArgumentException || e is FormatException || e is OverflowException) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_positive_attributes, attrib, providerName)); } else { throw; } } if (t < 0) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_positive_attributes, attrib, providerName)); } val = t; } internal static void GetAndRemovePositiveOrInfiniteAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { GetPositiveOrInfiniteAttribute(config, attrib, providerName, ref val); config.Remove(attrib); } internal static void GetPositiveOrInfiniteAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { string s = config.Get(attrib); int t; if (s == null) { return; } if (s == "Infinite") { t = ProviderUtil.Infinite; } else { try { t = Convert.ToInt32(s, CultureInfo.InvariantCulture); } catch (Exception e){ if (e is ArgumentException || e is FormatException || e is OverflowException) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_positive_attributes, attrib, providerName)); } else { throw; } } if (t < 0) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_positive_attributes, attrib, providerName)); } } val = t; } internal static void GetAndRemoveNonZeroPositiveOrInfiniteAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { GetNonZeroPositiveOrInfiniteAttribute(config, attrib, providerName, ref val); config.Remove(attrib); } internal static void GetNonZeroPositiveOrInfiniteAttribute(NameValueCollection config, string attrib, string providerName, ref int val) { string s = config.Get(attrib); int t; if (s == null) { return; } if (s == "Infinite") { t = ProviderUtil.Infinite; } else { try { t = Convert.ToInt32(s, CultureInfo.InvariantCulture); } catch (Exception e){ if (e is ArgumentException || e is FormatException || e is OverflowException) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_non_zero_positive_attributes, attrib, providerName)); } else { throw; } } if (t <= 0) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_provider_non_zero_positive_attributes, attrib, providerName)); } } val = t; } internal static void GetAndRemoveBooleanAttribute(NameValueCollection config, string attrib, string providerName, ref bool val) { GetBooleanAttribute(config, attrib, providerName, ref val); config.Remove(attrib); } internal static void GetBooleanAttribute(NameValueCollection config, string attrib, string providerName, ref bool val) { string s = config.Get(attrib); if (s == null) { return; } if (s == "true") { val = true; } else if (s == "false") { val = false; } else { throw new ConfigurationErrorsException(SR.GetString(SR.Invalid_provider_attribute, attrib, providerName, s)); } } internal static void GetAndRemoveRequiredNonEmptyStringAttribute(NameValueCollection config, string attrib, string providerName, ref string val) { GetRequiredNonEmptyStringAttribute(config, attrib, providerName, ref val); config.Remove(attrib); } internal static void GetRequiredNonEmptyStringAttribute(NameValueCollection config, string attrib, string providerName, ref string val) { GetNonEmptyStringAttributeInternal(config, attrib, providerName, ref val, true); } #if UNUSED_CODE internal static void GetAndRemoveNonEmptyStringAttribute(NameValueCollection config, string attrib, string providerName, ref string val) { GetNonEmptyStringAttributeInternal(config, attrib, providerName, ref val, false); config.Remove(attrib); } #endif private static void GetNonEmptyStringAttributeInternal(NameValueCollection config, string attrib, string providerName, ref string val, bool required) { string s = config.Get(attrib); // If it's (null and required) -OR- (empty string) we throw if ((s == null && required) || (s.Length == 0)) { throw new ConfigurationErrorsException( SR.GetString(SR.Provider_missing_attribute, attrib, providerName)); } val = s; } internal static void CheckUnrecognizedAttributes(NameValueCollection config, string providerName) { if (config.Count > 0) { string attribUnrecognized = config.GetKey(0); if (!String.IsNullOrEmpty(attribUnrecognized)) throw new ConfigurationErrorsException( SR.GetString(SR.Unexpected_provider_attribute, attribUnrecognized, providerName)); } } } } // 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
- Image.cs
- ScrollProperties.cs
- DurableInstanceManager.cs
- EditingMode.cs
- ContentElementAutomationPeer.cs
- CompilerHelpers.cs
- DbCommandTree.cs
- IWorkflowDebuggerService.cs
- ListViewGroupItemCollection.cs
- AnnotationAdorner.cs
- ChannelBinding.cs
- UpdateDelegates.Generated.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- TableItemProviderWrapper.cs
- StateMachineDesignerPaint.cs
- SortFieldComparer.cs
- TraceFilter.cs
- SpeakInfo.cs
- IntPtr.cs
- RegionData.cs
- Expander.cs
- BCryptNative.cs
- DetailsViewDeleteEventArgs.cs
- Point3DAnimationUsingKeyFrames.cs
- ObjectPersistData.cs
- LogExtentCollection.cs
- SuppressMessageAttribute.cs
- JoinElimination.cs
- StorageFunctionMapping.cs
- ToolStripKeyboardHandlingService.cs
- FigureHelper.cs
- KeyToListMap.cs
- UTF7Encoding.cs
- ConstraintCollection.cs
- HashJoinQueryOperatorEnumerator.cs
- HandledEventArgs.cs
- RequiredAttributeAttribute.cs
- MarkupCompilePass1.cs
- MenuItemCollection.cs
- FlowDocumentScrollViewer.cs
- ControlAdapter.cs
- LeaseManager.cs
- AutoResetEvent.cs
- ExecutionContext.cs
- DataGridViewButtonCell.cs
- RoutedEventArgs.cs
- XmlQueryCardinality.cs
- DataKeyCollection.cs
- RectangleF.cs
- DataGridView.cs
- HandlerBase.cs
- TextPenaltyModule.cs
- GridViewCellAutomationPeer.cs
- ActivityExecutionContext.cs
- AssemblyAttributes.cs
- AuthenticatedStream.cs
- ProgressBarRenderer.cs
- Setter.cs
- AppDomainUnloadedException.cs
- Publisher.cs
- MarkerProperties.cs
- ExclusiveHandle.cs
- SimpleLine.cs
- RestHandler.cs
- keycontainerpermission.cs
- SpeechRecognitionEngine.cs
- DocumentXmlWriter.cs
- RulePatternOps.cs
- CustomErrorCollection.cs
- EntityWithChangeTrackerStrategy.cs
- DecoderBestFitFallback.cs
- _ListenerResponseStream.cs
- GetLastErrorDetailsRequest.cs
- SortQueryOperator.cs
- SmtpException.cs
- Adorner.cs
- XPathDocument.cs
- HandleTable.cs
- Fonts.cs
- ScrollItemPattern.cs
- IItemContainerGenerator.cs
- ValueTypeFixupInfo.cs
- BaseParagraph.cs
- Point3D.cs
- SecurityHelper.cs
- PackageController.cs
- PowerEase.cs
- _AuthenticationState.cs
- SimpleApplicationHost.cs
- FixedSchema.cs
- XmlComment.cs
- AttributeUsageAttribute.cs
- DataSetMappper.cs
- CommandExpr.cs
- TableCellAutomationPeer.cs
- DataObjectCopyingEventArgs.cs
- PolicyAssertionCollection.cs
- HttpChannelHelper.cs
- XmlSortKey.cs
- TemplateKey.cs