本文整理汇总了C#中TypeBase.AddMember方法的典型用法代码示例。如果您正苦于以下问题:C# TypeBase.AddMember方法的具体用法?C# TypeBase.AddMember怎么用?C# TypeBase.AddMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeBase
的用法示例。
在下文中一共展示了TypeBase.AddMember方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadNestedTypesOfType
void LoadNestedTypesOfType(
TypeBase moduleType
) {
uint currentClassRowId = moduleType.TypeDefRowId;
uint numberOfNestedClassRows = this.PEFileReader.NestedClassTable.NumberOfRows;
var moduleTypeArray = this.ModuleTypeDefArray;
uint firstNestedClassRow = 0;
uint nestedClassCounter = 0;
for (uint i = 1; i <= numberOfNestedClassRows; ++i) {
NestedClassRow nestedClassRow = this.PEFileReader.NestedClassTable[i];
if (nestedClassRow.EnclosingClass != currentClassRowId) continue;
if (firstNestedClassRow == 0) firstNestedClassRow = i;
nestedClassCounter++;
// Check if its already created by someone else
NestedType/*?*/ currType = moduleTypeArray[nestedClassRow.NestedClass] as NestedType;
if (currType == null) {
currType = this.CreateModuleNestedType(nestedClassRow.NestedClass, this.PEFileReader.TypeDefTable[nestedClassRow.NestedClass], moduleType);
var redirectedType = this.ModuleReader.metadataReaderHost.Redirect(this.Module, currType);
if (redirectedType == currType) moduleType.AddMember(currType);
moduleTypeArray[nestedClassRow.NestedClass] = currType;
this.RedirectedTypeDefArray[nestedClassRow.NestedClass] = redirectedType;
this.ModuleTypeDefLoadState[nestedClassRow.NestedClass] = LoadState.Loaded;
}
}
if (nestedClassCounter > 0) {
var nestedTypes = new INestedTypeDefinition[nestedClassCounter];
uint j = 0;
for (uint i = firstNestedClassRow; j < nestedClassCounter && i <= numberOfNestedClassRows; ++i) {
NestedClassRow nestedClassRow = this.PEFileReader.NestedClassTable[i];
if (nestedClassRow.EnclosingClass != currentClassRowId) continue;
nestedTypes[j++] = (INestedTypeDefinition)moduleTypeArray[nestedClassRow.NestedClass];
Contract.Assume(nestedTypes[j-1] != null);
}
Contract.Assume(j == nestedClassCounter);
moduleType.nestedTypes = IteratorHelper.GetReadonly(nestedTypes);
}
}
示例2: CreateEvent
EventDefinition CreateEvent(
uint eventDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(eventDefRowId > 0 && eventDefRowId <= this.PEFileReader.EventTable.NumberOfRows);
EventRow eventRow = this.PEFileReader.EventTable[eventDefRowId];
IName eventName = this.GetNameFromOffset(eventRow.Name);
EventDefinition moduleEvent = new EventDefinition(this, eventName, parentModuleType, eventDefRowId, eventRow.Flags);
parentModuleType.AddMember(moduleEvent);
return moduleEvent;
}
示例3: CreateProperty
PropertyDefinition CreateProperty(
uint propertyDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(propertyDefRowId > 0 && propertyDefRowId <= this.PEFileReader.PropertyTable.NumberOfRows);
PropertyRow propertyRow = this.PEFileReader.PropertyTable[propertyDefRowId];
IName propertyName = this.GetNameFromOffset(propertyRow.Name);
PropertyDefinition moduleProperty = new PropertyDefinition(this, propertyName, parentModuleType, propertyDefRowId, propertyRow.Flags);
parentModuleType.AddMember(moduleProperty);
return moduleProperty;
}
示例4: CreateMethod
IMethodDefinition CreateMethod(
uint methodDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(methodDefRowId > 0 && methodDefRowId <= this.PEFileReader.MethodTable.NumberOfRows);
MethodRow methodRow = this.PEFileReader.MethodTable[methodDefRowId];
IName methodName = this.GetNameFromOffset(methodRow.Name);
if ((methodRow.Flags & MethodFlags.AccessMask) == MethodFlags.CompilerControlledAccess) {
//Methods that are compiler controlled access are excempted from duplicate checking and may thus have names that cause
//their intern keys to clash with other methods. Avoid this by mangling the names of such methods.
//compiler controlled methods are always referred to via their tokens, so this renaming is safe to do.
methodName = NameTable.GetNameFor(methodName.Value+"$PST"+((int)TableIndices.Method+methodDefRowId));
}
uint genericParamRowIdStart;
uint genericParamRowIdEnd;
this.GetGenericParamInfoForMethod(methodDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd);
IMethodDefinition moduleMethod;
if (genericParamRowIdStart == 0) {
moduleMethod = new NonGenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags);
} else {
moduleMethod = new GenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags, genericParamRowIdStart, genericParamRowIdEnd);
}
if (methodName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
moduleMethod = this.ModuleReader.metadataReaderHost.Rewrite(this.Module, moduleMethod);
parentModuleType.AddMember(moduleMethod);
}
return moduleMethod;
}
示例5: CreateField
FieldDefinition CreateField(
uint fieldDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(fieldDefRowId > 0 && fieldDefRowId <= this.PEFileReader.FieldTable.NumberOfRows);
FieldRow fieldRow = this.PEFileReader.FieldTable[fieldDefRowId];
IName fieldName = this.GetNameFromOffset(fieldRow.Name);
if ((fieldRow.Flags & FieldFlags.AccessMask) == FieldFlags.CompilerControlledAccess) {
//Methods that are compiler controlled access are excempted from duplicate checking and may thus have names that cause
//their intern keys to clash with other methods. Avoid this by mangling the names of such methods.
//compiler controlled methods are always referred to via their tokens, so this renaming is safe to do.
fieldName = NameTable.GetNameFor(fieldName.Value+"$PST"+((int)TableIndices.Field+fieldDefRowId));
}
FieldDefinition moduleField = new FieldDefinition(this, fieldName, parentModuleType, fieldDefRowId, fieldRow.Flags);
if (fieldName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
parentModuleType.AddMember(moduleField);
}
return moduleField;
}
示例6: CreateMethod
MethodDefinition CreateMethod(
uint methodDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(methodDefRowId > 0 && methodDefRowId <= this.PEFileReader.MethodTable.NumberOfRows);
MethodRow methodRow = this.PEFileReader.MethodTable[methodDefRowId];
IName methodName = this.GetNameFromOffset(methodRow.Name);
uint genericParamRowIdStart;
uint genericParamRowIdEnd;
this.GetGenericParamInfoForMethod(methodDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd);
MethodDefinition moduleMethod;
if (genericParamRowIdStart == 0) {
moduleMethod = new NonGenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags);
} else {
moduleMethod = new GenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags, genericParamRowIdStart, genericParamRowIdEnd);
}
if (methodName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
parentModuleType.AddMember(moduleMethod);
}
return moduleMethod;
}
示例7: CreateField
FieldDefinition CreateField(
uint fieldDefRowId,
TypeBase parentModuleType
) {
Debug.Assert(fieldDefRowId > 0 && fieldDefRowId <= this.PEFileReader.FieldTable.NumberOfRows);
FieldRow fieldRow = this.PEFileReader.FieldTable[fieldDefRowId];
IName fieldName = this.GetNameFromOffset(fieldRow.Name);
FieldDefinition moduleField = new FieldDefinition(this, fieldName, parentModuleType, fieldDefRowId, fieldRow.Flags);
if (fieldName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
parentModuleType.AddMember(moduleField);
}
return moduleField;
}
示例8: CreateModuleNestedType
NestedType CreateModuleNestedType(
uint typeDefRowId,
TypeDefRow typeDefRow,
TypeBase parentModuleType
) {
IName typeName = this.GetNameFromOffset(typeDefRow.Name);
if (typeDefRow.Namespace != 0) {
IName namespaceName = this.GetNameFromOffset(typeDefRow.Namespace);
typeName = this.NameTable.GetNameFor(namespaceName.Value+"."+typeName.Value);
}
uint genericParamRowIdStart;
uint genericParamRowIdEnd;
this.GetGenericParamInfoForType(typeDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd);
NestedType type;
if (genericParamRowIdStart == 0) {
type = new NonGenericNestedType(this, typeName, typeDefRowId, typeDefRow.Flags, parentModuleType);
} else {
IName unmangledTypeName = this.GetUnmangledNameFromOffset(typeDefRow.Name);
type = new GenericNestedType(this, unmangledTypeName, typeDefRowId, typeDefRow.Flags, parentModuleType, typeName, genericParamRowIdStart, genericParamRowIdEnd);
}
parentModuleType.AddMember(type);
return type;
}