Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / MachineKeyValidationConverter.cs / 1305376 / MachineKeyValidationConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; using System.Configuration; namespace System.Web.Configuration { [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public sealed class MachineKeyValidationConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { if (!(value is MachineKeyValidation)) { throw new ArgumentException(SR.GetString(SR.Config_Invalid_enum_value, "SHA1, MD5, 3DES, AES, HMACSHA256, HMACSHA384, HMACSHA512")); } return ConvertFromEnum((MachineKeyValidation)value); } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { return ConvertToEnum((string)data); } internal static string ConvertFromEnum(MachineKeyValidation enumValue) { switch (enumValue) { case MachineKeyValidation.SHA1: return "SHA1"; case MachineKeyValidation.MD5: return "MD5"; case MachineKeyValidation.TripleDES: return "3DES"; case MachineKeyValidation.AES: return "AES"; case MachineKeyValidation.HMACSHA256: return "HMACSHA256"; case MachineKeyValidation.HMACSHA384: return "HMACSHA384"; case MachineKeyValidation.HMACSHA512: return "HMACSHA512"; default: throw new ArgumentException(SR.GetString(SR.Wrong_validation_enum)); } } internal static MachineKeyValidation ConvertToEnum(string strValue) { if (strValue==null) return MachineKeySection.DefaultValidation; switch (strValue) { case "SHA1": return MachineKeyValidation.SHA1; case "MD5": return MachineKeyValidation.MD5; case "3DES": return MachineKeyValidation.TripleDES; case "AES": return MachineKeyValidation.AES; case "HMACSHA256": return MachineKeyValidation.HMACSHA256; case "HMACSHA384": return MachineKeyValidation.HMACSHA384; case "HMACSHA512": return MachineKeyValidation.HMACSHA512; default: if (strValue.StartsWith("alg:", StringComparison.Ordinal)) return MachineKeyValidation.Custom; throw new ArgumentException(SR.GetString(SR.Wrong_validation_enum)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TableAdapterManagerNameHandler.cs
- Simplifier.cs
- DependencyPropertyKey.cs
- CompoundFileReference.cs
- DiscriminatorMap.cs
- LinqExpressionNormalizer.cs
- MatrixStack.cs
- CodeTypeReferenceExpression.cs
- TypeNameConverter.cs
- sqlmetadatafactory.cs
- QuaternionAnimationUsingKeyFrames.cs
- MatrixValueSerializer.cs
- FixedTextPointer.cs
- FlowNode.cs
- HttpListenerResponse.cs
- KeyboardNavigation.cs
- XmlBinaryWriterSession.cs
- HttpListenerRequest.cs
- TextServicesDisplayAttribute.cs
- XmlNullResolver.cs
- Model3D.cs
- LazyInitializer.cs
- CultureInfo.cs
- HeaderUtility.cs
- Schema.cs
- ButtonStandardAdapter.cs
- AudioStateChangedEventArgs.cs
- ContentPropertyAttribute.cs
- WebColorConverter.cs
- SchemaElementDecl.cs
- PeerNearMe.cs
- Int64.cs
- RuleSettingsCollection.cs
- WinEventQueueItem.cs
- MimeMultiPart.cs
- UrlAuthorizationModule.cs
- TextChange.cs
- DataGridTablesFactory.cs
- RsaSecurityToken.cs
- CachedCompositeFamily.cs
- WebPartConnectionsConnectVerb.cs
- ListControl.cs
- RequiredFieldValidator.cs
- InteropAutomationProvider.cs
- Events.cs
- Propagator.Evaluator.cs
- NameService.cs
- DataIdProcessor.cs
- TimeEnumHelper.cs
- Part.cs
- LicenseContext.cs
- StatusBarItem.cs
- DesignBindingValueUIHandler.cs
- ViewService.cs
- LinkButton.cs
- BitmapPalette.cs
- ValidationPropertyAttribute.cs
- Misc.cs
- ResponseBodyWriter.cs
- AspNetCacheProfileAttribute.cs
- ReflectionUtil.cs
- QueryOperationResponseOfT.cs
- TypeConverterAttribute.cs
- EdmFunctions.cs
- UserMapPath.cs
- AttachmentCollection.cs
- FontStretches.cs
- TransportationConfigurationTypeInstallComponent.cs
- CountdownEvent.cs
- SchemaNotation.cs
- BoolExpressionVisitors.cs
- SessionPageStateSection.cs
- SafeThemeHandle.cs
- EnvironmentPermission.cs
- MetadataItem.cs
- XmlObjectSerializerContext.cs
- smtppermission.cs
- ShimAsPublicXamlType.cs
- _LoggingObject.cs
- ObjectDataSourceMethodEditor.cs
- DependencyPropertyDescriptor.cs
- UdpContractFilterBehavior.cs
- RootBrowserWindowProxy.cs
- TimelineClockCollection.cs
- DesignObjectWrapper.cs
- DataGridToolTip.cs
- RowUpdatedEventArgs.cs
- IntellisenseTextBox.designer.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- EventLogTraceListener.cs
- BindingCompleteEventArgs.cs
- ConfigurationManagerInternalFactory.cs
- WSHttpTransportSecurityElement.cs
- MessageSecurityVersionConverter.cs
- GenerateScriptTypeAttribute.cs
- BitmapEffectCollection.cs
- XmlStreamStore.cs
- ElementsClipboardData.cs
- ContextToken.cs
- ActivationServices.cs