Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Configuration / MachineKeyConverter.cs / 5 / MachineKeyConverter.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)]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MachineKeyValidationConverter : ConfigurationConverterBase {
public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) {
if ((value != null) && (value.GetType() != typeof(MachineKeyValidation))) {
throw new ArgumentException(SR.GetString(SR.Invalid_enum_value, "SHA1, MD5, 3DES, AES"));
}
switch ((MachineKeyValidation)value) {
case MachineKeyValidation.SHA1:
return (string) "SHA1";
case MachineKeyValidation.MD5:
return (string)"MD5";
case MachineKeyValidation.TripleDES:
return (string)"3DES";
case MachineKeyValidation.AES:
return (string)"AES";
default:
throw new ArgumentOutOfRangeException("value");
}
}
public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) {
// Debug.Assert( data is string );
string s = (string)data;
switch (s) {
case "SHA1":
return MachineKeyValidation.SHA1;
case "MD5":
return MachineKeyValidation.MD5;
case "3DES":
return MachineKeyValidation.TripleDES;
case "AES":
return MachineKeyValidation.AES;
default:
throw new ArgumentException(SR.GetString(SR.Config_Invalid_enum_value, "SHA1, MD5, 3DES, AES"));
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// 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)]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MachineKeyValidationConverter : ConfigurationConverterBase {
public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) {
if ((value != null) && (value.GetType() != typeof(MachineKeyValidation))) {
throw new ArgumentException(SR.GetString(SR.Invalid_enum_value, "SHA1, MD5, 3DES, AES"));
}
switch ((MachineKeyValidation)value) {
case MachineKeyValidation.SHA1:
return (string) "SHA1";
case MachineKeyValidation.MD5:
return (string)"MD5";
case MachineKeyValidation.TripleDES:
return (string)"3DES";
case MachineKeyValidation.AES:
return (string)"AES";
default:
throw new ArgumentOutOfRangeException("value");
}
}
public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) {
// Debug.Assert( data is string );
string s = (string)data;
switch (s) {
case "SHA1":
return MachineKeyValidation.SHA1;
case "MD5":
return MachineKeyValidation.MD5;
case "3DES":
return MachineKeyValidation.TripleDES;
case "AES":
return MachineKeyValidation.AES;
default:
throw new ArgumentException(SR.GetString(SR.Config_Invalid_enum_value, "SHA1, MD5, 3DES, AES"));
}
}
}
}
// 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
- EDesignUtil.cs
- URL.cs
- QueryContext.cs
- UDPClient.cs
- Resources.Designer.cs
- PagerStyle.cs
- SqlGatherProducedAliases.cs
- GeometryConverter.cs
- StreamUpgradeAcceptor.cs
- HostProtectionPermission.cs
- TextViewBase.cs
- Compilation.cs
- NumericUpDownAccelerationCollection.cs
- Model3D.cs
- CommandManager.cs
- Base64Decoder.cs
- MessageQueue.cs
- InstanceDescriptor.cs
- UnmanagedBitmapWrapper.cs
- AuthenticatedStream.cs
- Rotation3DAnimation.cs
- DataGridToolTip.cs
- OletxTransactionManager.cs
- ProjectionPruner.cs
- LocationSectionRecord.cs
- XmlDataCollection.cs
- DebugHandleTracker.cs
- NamespaceQuery.cs
- XmlSchemaChoice.cs
- SamlAuthorizationDecisionStatement.cs
- DataObjectFieldAttribute.cs
- StackSpiller.cs
- VariableQuery.cs
- DeferredRunTextReference.cs
- PageAsyncTask.cs
- CloseCollectionAsyncResult.cs
- SizeLimitedCache.cs
- FillRuleValidation.cs
- DataGridViewColumnConverter.cs
- fixedPageContentExtractor.cs
- PerspectiveCamera.cs
- SQLBoolean.cs
- RegexNode.cs
- Error.cs
- HScrollBar.cs
- Int32.cs
- CheckBoxBaseAdapter.cs
- XmlWriterDelegator.cs
- CultureSpecificStringDictionary.cs
- _AuthenticationState.cs
- DataFormats.cs
- AnimatedTypeHelpers.cs
- AnnotationStore.cs
- ImageMapEventArgs.cs
- DocumentViewerHelper.cs
- Update.cs
- DynamicPropertyHolder.cs
- ComplusEndpointConfigContainer.cs
- StringReader.cs
- GlobalAclOperationRequirement.cs
- NTAccount.cs
- TemplateApplicationHelper.cs
- CompoundFileStreamReference.cs
- ChannelListenerBase.cs
- CryptoConfig.cs
- Base64Stream.cs
- UIElementCollection.cs
- Scanner.cs
- ValidationEventArgs.cs
- RectangleHotSpot.cs
- Parallel.cs
- ChooseAction.cs
- DocumentOrderQuery.cs
- BaseInfoTable.cs
- WorkflowMarkupSerializerMapping.cs
- TimeZone.cs
- StateChangeEvent.cs
- SafeMemoryMappedFileHandle.cs
- NumericUpDownAcceleration.cs
- ListViewTableRow.cs
- Ipv6Element.cs
- UInt32Converter.cs
- WindowsFormsHostAutomationPeer.cs
- UnsafePeerToPeerMethods.cs
- ObjectItemCollection.cs
- FamilyTypeface.cs
- ZipArchive.cs
- TreeNodeStyleCollectionEditor.cs
- ConnectionInterfaceCollection.cs
- HorizontalAlignConverter.cs
- CommandField.cs
- DocumentEventArgs.cs
- GeometryGroup.cs
- MissingMemberException.cs
- ListViewTableCell.cs
- TrackingValidationObjectDictionary.cs
- ContractHandle.cs
- SectionRecord.cs
- WriteTimeStream.cs
- TransformPattern.cs