Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / Reflection / Emit / TypeBuilderInstantiation.cs / 1 / TypeBuilderInstantiation.cs
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
using System.Globalization;
namespace System.Reflection.Emit
{
internal sealed class TypeBuilderInstantiation: Type
{
#region Private Data Mebers
private Type m_type;
private Type[] m_inst;
private string m_strFullQualName;
#endregion
#region Constructor
internal TypeBuilderInstantiation(Type type, Type[] inst)
{
m_type = type;
m_inst = inst;
}
#endregion
#region Object Overrides
public override String ToString()
{
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
}
#endregion
#region MemberInfo Overrides
public override Type DeclaringType { get { return m_type.DeclaringType; } }
public override Type ReflectedType { get { return m_type.ReflectedType; } }
public override String Name { get { return m_type.Name; } }
public override Module Module { get { return m_type.Module; } }
internal override int MetadataTokenInternal { get { throw new NotSupportedException(); } }
#endregion
#region Type Overrides
public override Type MakePointerType()
{
return SymbolType.FormCompoundType("*".ToCharArray(), this, 0);
}
public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&".ToCharArray(), this, 0);
}
public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]".ToCharArray(), this, 0);
}
public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
string comma = "";
for(int i = 1; i < rank; i++)
comma += ",";
string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", comma);
return SymbolType.FormCompoundType(s.ToCharArray(), this, 0);
}
public override Guid GUID { get { throw new NotSupportedException(); } }
public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); }
public override Assembly Assembly { get { return m_type.Assembly; } }
public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
public override String FullName
{
get
{
if (m_strFullQualName == null)
m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
return m_strFullQualName;
}
}
public override String Namespace { get { return m_type.Namespace; } }
public override String AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } }
internal Type Substitute(Type[] substitutes)
{
Type[] inst = GetGenericArguments();
Type[] instSubstituted = new Type[inst.Length];
for (int i = 0; i < instSubstituted.Length; i++)
{
Type t = inst[i];
if (t is TypeBuilderInstantiation)
{
instSubstituted[i] = (t as TypeBuilderInstantiation).Substitute(substitutes);
}
else if (t is GenericTypeParameterBuilder)
{
// Substitute
instSubstituted[i] = substitutes[t.GenericParameterPosition];
}
else
{
instSubstituted[i] = t;
}
}
return GetGenericTypeDefinition().MakeGenericType(instSubstituted);
}
public override Type BaseType
{
// B
// D : B,char>
// D : B,char>
// D : B,char>
// D : B,char>
get
{
Type typeBldrBase = m_type.BaseType;
if (typeBldrBase == null)
return null;
TypeBuilderInstantiation typeBldrBaseAs = typeBldrBase as TypeBuilderInstantiation;
if (typeBldrBaseAs == null)
return typeBldrBase;
return typeBldrBaseAs.Substitute(GetGenericArguments());
}
}
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override FieldInfo GetField(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type GetInterface(String name, bool ignoreCase) { throw new NotSupportedException(); }
public override Type[] GetInterfaces() { throw new NotSupportedException(); }
public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents() { throw new NotSupportedException(); }
protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type GetNestedType(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; }
protected override bool IsArrayImpl() { return false; }
protected override bool IsByRefImpl() { return false; }
protected override bool IsPointerImpl() { return false; }
protected override bool IsPrimitiveImpl() { return false; }
protected override bool IsCOMObjectImpl() { return false; }
public override Type GetElementType() { throw new NotSupportedException(); }
protected override bool HasElementTypeImpl() { return false; }
public override Type UnderlyingSystemType { get { return this; } }
public override Type[] GetGenericArguments() { return m_inst; }
public override bool IsGenericTypeDefinition { get { return false; } }
public override bool IsGenericType { get { return true; } }
public override bool IsGenericParameter { get { return false; } }
public override int GenericParameterPosition { get { throw new InvalidOperationException(); } }
protected override bool IsValueTypeImpl() { return m_type.IsValueType; }
public override bool ContainsGenericParameters
{
get
{
for (int i = 0; i < m_inst.Length; i++)
{
if (m_inst[i].ContainsGenericParameters)
return true;
}
return false;
}
}
public override MethodBase DeclaringMethod { get { return null; } }
public override Type GetGenericTypeDefinition() { return m_type; }
public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); }
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override bool IsSubclassOf(Type c)
{
throw new NotSupportedException();
/*
if (!c.IsGenericType)
return false;
if (c.IsGenericTypeDefinition)
return false;
Type cgtd = c.GetGenericTypeDefinition();
Type gtd = GetGenericTypeDefinition();
while (gtd != cgtd)
{
gtd = gtd.BaseType;
if (gtd == null)
return false;
}
for (int i = 0; i < gtd.GetGenericArguments().Length; i++)
{
if (gtd.GetGenericArguments()[i] != c.GetGenericArguments()[i])
return false;
}
return true;
*/
}
#endregion
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); }
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); }
public override bool IsDefined(Type attributeType, bool inherit) { throw new NotSupportedException(); }
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
using System.Globalization;
namespace System.Reflection.Emit
{
internal sealed class TypeBuilderInstantiation: Type
{
#region Private Data Mebers
private Type m_type;
private Type[] m_inst;
private string m_strFullQualName;
#endregion
#region Constructor
internal TypeBuilderInstantiation(Type type, Type[] inst)
{
m_type = type;
m_inst = inst;
}
#endregion
#region Object Overrides
public override String ToString()
{
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
}
#endregion
#region MemberInfo Overrides
public override Type DeclaringType { get { return m_type.DeclaringType; } }
public override Type ReflectedType { get { return m_type.ReflectedType; } }
public override String Name { get { return m_type.Name; } }
public override Module Module { get { return m_type.Module; } }
internal override int MetadataTokenInternal { get { throw new NotSupportedException(); } }
#endregion
#region Type Overrides
public override Type MakePointerType()
{
return SymbolType.FormCompoundType("*".ToCharArray(), this, 0);
}
public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&".ToCharArray(), this, 0);
}
public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]".ToCharArray(), this, 0);
}
public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
string comma = "";
for(int i = 1; i < rank; i++)
comma += ",";
string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", comma);
return SymbolType.FormCompoundType(s.ToCharArray(), this, 0);
}
public override Guid GUID { get { throw new NotSupportedException(); } }
public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); }
public override Assembly Assembly { get { return m_type.Assembly; } }
public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
public override String FullName
{
get
{
if (m_strFullQualName == null)
m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
return m_strFullQualName;
}
}
public override String Namespace { get { return m_type.Namespace; } }
public override String AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } }
internal Type Substitute(Type[] substitutes)
{
Type[] inst = GetGenericArguments();
Type[] instSubstituted = new Type[inst.Length];
for (int i = 0; i < instSubstituted.Length; i++)
{
Type t = inst[i];
if (t is TypeBuilderInstantiation)
{
instSubstituted[i] = (t as TypeBuilderInstantiation).Substitute(substitutes);
}
else if (t is GenericTypeParameterBuilder)
{
// Substitute
instSubstituted[i] = substitutes[t.GenericParameterPosition];
}
else
{
instSubstituted[i] = t;
}
}
return GetGenericTypeDefinition().MakeGenericType(instSubstituted);
}
public override Type BaseType
{
// B
// D : B,char>
// D : B,char>
// D : B,char>
// D : B,char>
get
{
Type typeBldrBase = m_type.BaseType;
if (typeBldrBase == null)
return null;
TypeBuilderInstantiation typeBldrBaseAs = typeBldrBase as TypeBuilderInstantiation;
if (typeBldrBaseAs == null)
return typeBldrBase;
return typeBldrBaseAs.Substitute(GetGenericArguments());
}
}
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override FieldInfo GetField(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type GetInterface(String name, bool ignoreCase) { throw new NotSupportedException(); }
public override Type[] GetInterfaces() { throw new NotSupportedException(); }
public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents() { throw new NotSupportedException(); }
protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override Type GetNestedType(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; }
protected override bool IsArrayImpl() { return false; }
protected override bool IsByRefImpl() { return false; }
protected override bool IsPointerImpl() { return false; }
protected override bool IsPrimitiveImpl() { return false; }
protected override bool IsCOMObjectImpl() { return false; }
public override Type GetElementType() { throw new NotSupportedException(); }
protected override bool HasElementTypeImpl() { return false; }
public override Type UnderlyingSystemType { get { return this; } }
public override Type[] GetGenericArguments() { return m_inst; }
public override bool IsGenericTypeDefinition { get { return false; } }
public override bool IsGenericType { get { return true; } }
public override bool IsGenericParameter { get { return false; } }
public override int GenericParameterPosition { get { throw new InvalidOperationException(); } }
protected override bool IsValueTypeImpl() { return m_type.IsValueType; }
public override bool ContainsGenericParameters
{
get
{
for (int i = 0; i < m_inst.Length; i++)
{
if (m_inst[i].ContainsGenericParameters)
return true;
}
return false;
}
}
public override MethodBase DeclaringMethod { get { return null; } }
public override Type GetGenericTypeDefinition() { return m_type; }
public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); }
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
[System.Runtime.InteropServices.ComVisible(true)]
public override bool IsSubclassOf(Type c)
{
throw new NotSupportedException();
/*
if (!c.IsGenericType)
return false;
if (c.IsGenericTypeDefinition)
return false;
Type cgtd = c.GetGenericTypeDefinition();
Type gtd = GetGenericTypeDefinition();
while (gtd != cgtd)
{
gtd = gtd.BaseType;
if (gtd == null)
return false;
}
for (int i = 0; i < gtd.GetGenericArguments().Length; i++)
{
if (gtd.GetGenericArguments()[i] != c.GetGenericArguments()[i])
return false;
}
return true;
*/
}
#endregion
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); }
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); }
public override bool IsDefined(Type attributeType, bool inherit) { throw new NotSupportedException(); }
#endregion
}
}
// 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
- ColumnCollection.cs
- RootNamespaceAttribute.cs
- ResourceWriter.cs
- ListViewContainer.cs
- StorageMappingItemCollection.cs
- Model3DGroup.cs
- RequestCacheManager.cs
- FlowDocumentReaderAutomationPeer.cs
- WebPartDisplayModeCancelEventArgs.cs
- CodeConditionStatement.cs
- EntitySqlQueryCacheKey.cs
- Exception.cs
- XmlBinaryReader.cs
- VSWCFServiceContractGenerator.cs
- GregorianCalendarHelper.cs
- OrthographicCamera.cs
- IssuanceLicense.cs
- TakeQueryOptionExpression.cs
- cookie.cs
- XmlValueConverter.cs
- CodeTypeMemberCollection.cs
- AsymmetricKeyExchangeDeformatter.cs
- FilterUserControlBase.cs
- ProfileGroupSettingsCollection.cs
- FilteredDataSetHelper.cs
- CodeSnippetExpression.cs
- ToolBarDesigner.cs
- LightweightCodeGenerator.cs
- HelpInfo.cs
- WebUtil.cs
- UIElement3D.cs
- ToolboxItem.cs
- XamlSerializationHelper.cs
- SHA256CryptoServiceProvider.cs
- _AutoWebProxyScriptHelper.cs
- SemanticValue.cs
- ImageAutomationPeer.cs
- MemoryPressure.cs
- AuthenticationManager.cs
- ButtonAutomationPeer.cs
- HandleRef.cs
- TableItemPatternIdentifiers.cs
- DefinitionBase.cs
- PropertyMetadata.cs
- mactripleDES.cs
- XamlBuildTaskServices.cs
- DefaultPrintController.cs
- sortedlist.cs
- ReferencedAssembly.cs
- SrgsItemList.cs
- MarkupObject.cs
- TreeView.cs
- WebPartDescription.cs
- XmlQueryContext.cs
- CodeDesigner.cs
- HelloMessage11.cs
- JsonFaultDetail.cs
- ResourceCategoryAttribute.cs
- KnownBoxes.cs
- ContractType.cs
- PrincipalPermission.cs
- DBCSCodePageEncoding.cs
- FolderBrowserDialogDesigner.cs
- IConvertible.cs
- AssertHelper.cs
- MetadataResolver.cs
- SqlBuffer.cs
- LinqDataSourceInsertEventArgs.cs
- HelpEvent.cs
- CLSCompliantAttribute.cs
- ConfigXmlCDataSection.cs
- ManifestSignatureInformation.cs
- RijndaelManaged.cs
- InputLanguageEventArgs.cs
- RangeBaseAutomationPeer.cs
- DebugView.cs
- WebPartUtil.cs
- StatusBarItemAutomationPeer.cs
- CmsUtils.cs
- OdbcCommandBuilder.cs
- HScrollProperties.cs
- TransformDescriptor.cs
- DataColumnMapping.cs
- TransformerTypeCollection.cs
- HandleExceptionArgs.cs
- PeerContact.cs
- TypeContext.cs
- EntityDataSourceValidationException.cs
- SchemaCollectionPreprocessor.cs
- CommandTreeTypeHelper.cs
- EventSetter.cs
- EncryptedHeader.cs
- JsonEncodingStreamWrapper.cs
- NativeMethods.cs
- Win32.cs
- DefaultAsyncDataDispatcher.cs
- MappingModelBuildProvider.cs
- XmlSchemaComplexContentRestriction.cs
- DataGridTextBox.cs
- DataErrorValidationRule.cs