Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / MiniReflection / MiniParameterInfo.cs / 1305376 / MiniParameterInfo.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: MiniParameterInfo ** ** Purpose: Represents a method parameter. ** ===========================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.AddIn.MiniReflection.MetadataReader; using System.Diagnostics.Contracts; namespace System.AddIn.MiniReflection { [Serializable] internal sealed class MiniParameterInfo { private CorElementType _elementType; private TypeInfo _paramType; public MiniParameterInfo(CorElementType elementType) { System.Diagnostics.Contracts.Contract.Requires(elementType <= CorElementType.String || elementType == CorElementType.I || elementType == CorElementType.U || elementType == CorElementType.Object); _elementType = elementType; } public MiniParameterInfo(CorElementType elementType, TypeInfo parameterType) { System.Diagnostics.Contracts.Contract.Requires(parameterType != null); System.Diagnostics.Contracts.Contract.Requires(IsValid(elementType)); _elementType = elementType; _paramType = parameterType; } // To avoid reflection with Enum.IsDefined [Pure] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification="Needed for Contracts conditional compilation")] public static bool IsValid(CorElementType elementType) { return (CorElementType.End <= elementType && elementType <= CorElementType.Max) || elementType == CorElementType.Modifier || elementType == CorElementType.Sentinel || elementType == CorElementType.Pinned; } /* // This lets Reflection Type instances sneak into our MiniParameterInfo's. internal MiniParameterInfo(TypeInfo parameterType) { Contract.Requires(parameterType != null); // This isn't technically correct, but we don't need it to be // perfectly accurate because the CorElementType never leaks // out of this class. _elementType = CorElementType.Class; _paramType = parameterType; } */ public TypeInfo ParameterType { get { if (_elementType == CorElementType.Class || _elementType == CorElementType.ValueType) return _paramType; switch (_elementType) { case CorElementType.Boolean: return new TypeInfo(typeof(Boolean)); case CorElementType.I1: return new TypeInfo(typeof(SByte)); case CorElementType.U1: return new TypeInfo(typeof(Byte)); case CorElementType.I2: return new TypeInfo(typeof(Int16)); case CorElementType.U2: return new TypeInfo(typeof(UInt16)); case CorElementType.Char: return new TypeInfo(typeof(Char)); case CorElementType.I4: return new TypeInfo(typeof(Int32)); case CorElementType.U4: return new TypeInfo(typeof(UInt32)); case CorElementType.I8: return new TypeInfo(typeof(Int64)); case CorElementType.U8: return new TypeInfo(typeof(UInt64)); case CorElementType.R4: return new TypeInfo(typeof(Single)); case CorElementType.R8: return new TypeInfo(typeof(Double)); case CorElementType.I: return new TypeInfo(typeof(IntPtr)); case CorElementType.U: return new TypeInfo(typeof(UIntPtr)); case CorElementType.String: return new TypeInfo(typeof(String)); case CorElementType.Object: return new TypeInfo(typeof(Object)); default: System.Diagnostics.Contracts.Contract.Assert(false, "Unrecognized CorElementType."); throw new NotImplementedException(); } } } public override string ToString() { if (_elementType == CorElementType.Class || _elementType == CorElementType.ValueType) return _paramType.ToString(); else return _elementType.ToString(); } } } // 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
- ContentDisposition.cs
- CompositionTarget.cs
- SystemFonts.cs
- KeyPressEvent.cs
- RelatedImageListAttribute.cs
- ClientSideQueueItem.cs
- JsonUriDataContract.cs
- DecoderFallback.cs
- TypeConverters.cs
- DomainConstraint.cs
- BCryptHashAlgorithm.cs
- RectKeyFrameCollection.cs
- XmlEntityReference.cs
- PartialArray.cs
- RelationshipConverter.cs
- MyContact.cs
- GradientStop.cs
- AdPostCacheSubstitution.cs
- DataGridViewToolTip.cs
- RecordsAffectedEventArgs.cs
- LogSwitch.cs
- SqlTriggerAttribute.cs
- WindowsFormsSectionHandler.cs
- TypeBuilderInstantiation.cs
- MDIControlStrip.cs
- CodeExpressionCollection.cs
- TextElement.cs
- XmlFormatMapping.cs
- ControlType.cs
- WindowsToolbarAsMenu.cs
- UserUseLicenseDictionaryLoader.cs
- WinHttpWebProxyFinder.cs
- AttributeAction.cs
- MasterPageParser.cs
- CuspData.cs
- RadioButtonPopupAdapter.cs
- DesignerSerializerAttribute.cs
- ValueUtilsSmi.cs
- DataPager.cs
- Stackframe.cs
- InfoCardSymmetricAlgorithm.cs
- Set.cs
- OuterGlowBitmapEffect.cs
- AttributeQuery.cs
- TdsParserStateObject.cs
- HttpVersion.cs
- LostFocusEventManager.cs
- EncryptedKeyIdentifierClause.cs
- WorkflowServiceAttributes.cs
- CodePageEncoding.cs
- DataGridTableCollection.cs
- ParallelDesigner.cs
- XmlDocumentFragment.cs
- SimpleApplicationHost.cs
- ProjectionNode.cs
- UserControl.cs
- Selection.cs
- PropertyEntry.cs
- Label.cs
- NamedPipeTransportSecurity.cs
- SoapExtensionImporter.cs
- ButtonBase.cs
- ChannelParameterCollection.cs
- BindingExpressionUncommonField.cs
- ObjectDataSourceSelectingEventArgs.cs
- PassportPrincipal.cs
- EditModeSwitchButton.cs
- PreservationFileWriter.cs
- AuthStoreRoleProvider.cs
- DetailsViewCommandEventArgs.cs
- OpenTypeLayoutCache.cs
- MergeLocalizationDirectives.cs
- _Win32.cs
- DiffuseMaterial.cs
- ECDsa.cs
- storepermission.cs
- BindStream.cs
- WebPartEditorApplyVerb.cs
- NotSupportedException.cs
- TextRunCache.cs
- NullableFloatMinMaxAggregationOperator.cs
- _BasicClient.cs
- UnauthorizedWebPart.cs
- ChtmlLinkAdapter.cs
- DesignerRegion.cs
- RegexRunner.cs
- QilParameter.cs
- Trace.cs
- UnsafeNativeMethods.cs
- ReachNamespaceInfo.cs
- FillErrorEventArgs.cs
- IApplicationTrustManager.cs
- LiteralText.cs
- XmlFormatExtensionPrefixAttribute.cs
- RuntimeWrappedException.cs
- SymbolResolver.cs
- EncryptedKey.cs
- XmlSchemaComplexContent.cs
- ActivityExecutorSurrogate.cs
- GcSettings.cs