Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Protocols / ValueCollectionParameterReader.cs / 1305376 / ValueCollectionParameterReader.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Protocols { using System.IO; using System; using System.Xml.Serialization; using System.Reflection; using System.Collections; using System.Collections.Specialized; using System.Web.Services; using System.Text; using System.Security.Permissions; ////// /// public abstract class ValueCollectionParameterReader : MimeParameterReader { ParameterInfo[] paramInfos; ///[To be supplied.] ////// /// public override void Initialize(object o) { paramInfos = (ParameterInfo[])o; } ///[To be supplied.] ////// /// public override object GetInitializer(LogicalMethodInfo methodInfo) { if (!IsSupported(methodInfo)) return null; return methodInfo.InParameters; } ///[To be supplied.] ////// /// protected object[] Read(NameValueCollection collection) { object[] parameters = new object[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; i++) { ParameterInfo paramInfo = paramInfos[i]; if (paramInfo.ParameterType.IsArray) { string[] arrayValues = collection.GetValues(paramInfo.Name); Type arrayType = paramInfo.ParameterType.GetElementType(); Array array = Array.CreateInstance(arrayType, arrayValues.Length); for (int j = 0; j < arrayValues.Length; j++) { string value = arrayValues[j]; array.SetValue(ScalarFormatter.FromString(value, arrayType), j); } parameters[i] = array; } else { string value = collection[paramInfo.Name]; if (value == null) throw new InvalidOperationException(Res.GetString(Res.WebMissingParameter, paramInfo.Name)); parameters[i] = ScalarFormatter.FromString(value, paramInfo.ParameterType); } } return parameters; } ///[To be supplied.] ////// /// static public bool IsSupported(LogicalMethodInfo methodInfo) { if (methodInfo.OutParameters.Length > 0) return false; ParameterInfo[] paramInfos = methodInfo.InParameters; for (int i = 0; i < paramInfos.Length; i++) if (!IsSupported(paramInfos[i])) return false; return true; } ///[To be supplied.] ////// /// static public bool IsSupported(ParameterInfo paramInfo) { Type type = paramInfo.ParameterType; if (type.IsArray) type = type.GetElementType(); return ScalarFormatter.IsTypeSupported(type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Protocols { using System.IO; using System; using System.Xml.Serialization; using System.Reflection; using System.Collections; using System.Collections.Specialized; using System.Web.Services; using System.Text; using System.Security.Permissions; ////// /// public abstract class ValueCollectionParameterReader : MimeParameterReader { ParameterInfo[] paramInfos; ///[To be supplied.] ////// /// public override void Initialize(object o) { paramInfos = (ParameterInfo[])o; } ///[To be supplied.] ////// /// public override object GetInitializer(LogicalMethodInfo methodInfo) { if (!IsSupported(methodInfo)) return null; return methodInfo.InParameters; } ///[To be supplied.] ////// /// protected object[] Read(NameValueCollection collection) { object[] parameters = new object[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; i++) { ParameterInfo paramInfo = paramInfos[i]; if (paramInfo.ParameterType.IsArray) { string[] arrayValues = collection.GetValues(paramInfo.Name); Type arrayType = paramInfo.ParameterType.GetElementType(); Array array = Array.CreateInstance(arrayType, arrayValues.Length); for (int j = 0; j < arrayValues.Length; j++) { string value = arrayValues[j]; array.SetValue(ScalarFormatter.FromString(value, arrayType), j); } parameters[i] = array; } else { string value = collection[paramInfo.Name]; if (value == null) throw new InvalidOperationException(Res.GetString(Res.WebMissingParameter, paramInfo.Name)); parameters[i] = ScalarFormatter.FromString(value, paramInfo.ParameterType); } } return parameters; } ///[To be supplied.] ////// /// static public bool IsSupported(LogicalMethodInfo methodInfo) { if (methodInfo.OutParameters.Length > 0) return false; ParameterInfo[] paramInfos = methodInfo.InParameters; for (int i = 0; i < paramInfos.Length; i++) if (!IsSupported(paramInfos[i])) return false; return true; } ///[To be supplied.] ////// /// static public bool IsSupported(ParameterInfo paramInfo) { Type type = paramInfo.ParameterType; if (type.IsArray) type = type.GetElementType(); return ScalarFormatter.IsTypeSupported(type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LZCodec.cs
- DynamicPropertyHolder.cs
- CqlLexer.cs
- ResolvedKeyFrameEntry.cs
- UserControlAutomationPeer.cs
- Canonicalizers.cs
- baseaxisquery.cs
- XmlSchemaObjectTable.cs
- ExpressionEditorAttribute.cs
- BulletChrome.cs
- ScriptManager.cs
- SqlParameterizer.cs
- MutexSecurity.cs
- AsymmetricKeyExchangeFormatter.cs
- ImageMap.cs
- Memoizer.cs
- DynamicObject.cs
- TraceEventCache.cs
- AnnotationMap.cs
- PersonalizationState.cs
- CssClassPropertyAttribute.cs
- HwndSourceKeyboardInputSite.cs
- FontEmbeddingManager.cs
- _NativeSSPI.cs
- XmlCustomFormatter.cs
- ActivityIdHeader.cs
- FloatUtil.cs
- EventLogger.cs
- Missing.cs
- CompositeDuplexElement.cs
- Hex.cs
- TimeSpanSecondsConverter.cs
- DayRenderEvent.cs
- DetailsViewRowCollection.cs
- MDIControlStrip.cs
- ConfigurationSectionCollection.cs
- DataListItemEventArgs.cs
- DocumentApplicationDocumentViewer.cs
- NamespaceTable.cs
- InteropAutomationProvider.cs
- URI.cs
- CurrencyManager.cs
- ResourcesBuildProvider.cs
- ReaderWriterLockWrapper.cs
- DateTimeFormat.cs
- InputBuffer.cs
- TableRowsCollectionEditor.cs
- RadialGradientBrush.cs
- TransformerConfigurationWizardBase.cs
- SapiRecognizer.cs
- AuthenticationModuleElementCollection.cs
- AutomationElementCollection.cs
- MobileContainerDesigner.cs
- SuppressIldasmAttribute.cs
- SizeAnimation.cs
- SelectedDatesCollection.cs
- ScrollBarAutomationPeer.cs
- TranslateTransform3D.cs
- FileDialog.cs
- FamilyCollection.cs
- MemberMaps.cs
- MediaSystem.cs
- MissingMethodException.cs
- SymbolEqualComparer.cs
- RootProfilePropertySettingsCollection.cs
- ToolStripItemCollection.cs
- CodeTypeOfExpression.cs
- ComponentSerializationService.cs
- ResXFileRef.cs
- ListItemParagraph.cs
- AppDomainUnloadedException.cs
- Environment.cs
- ErrorTolerantObjectWriter.cs
- OdbcPermission.cs
- TemplatePartAttribute.cs
- Int32KeyFrameCollection.cs
- Configuration.cs
- _SslState.cs
- WebScriptEndpoint.cs
- NotImplementedException.cs
- EventArgs.cs
- EntityTemplateFactory.cs
- LinkedList.cs
- BasicCellRelation.cs
- COM2PropertyDescriptor.cs
- Compiler.cs
- ListViewGroupItemCollection.cs
- ColorContext.cs
- Expression.cs
- DeclaredTypeValidatorAttribute.cs
- LockedHandleGlyph.cs
- MimeWriter.cs
- XmlDataImplementation.cs
- PersonalizationState.cs
- ComContractElement.cs
- RoleService.cs
- SignedXml.cs
- AuthorizationRuleCollection.cs
- ApplicationSecurityInfo.cs
- LongValidatorAttribute.cs