本文整理汇总了C#中Mono.Cecil.TypeDefinition.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.ToString方法的具体用法?C# TypeDefinition.ToString怎么用?C# TypeDefinition.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
/// <summary>
/// Starts the state class extraction from the given role class.
/// </summary>
/// <param name="sourceType">The role class to extract the state class from.</param>
public override void Visit(TypeDefinition sourceType)
{
Tracer.TraceVerbose("Extract state class: {0} => {1}", sourceType.ToString(), TargetTypeName);
TargetType = new TypeDefinition(
string.Empty,
TargetTypeName,
TypeAttributes.NestedPublic |
TypeAttributes.Sealed |
TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit,
sourceType.Module.Import(typeof(object))
);
TargetType.CopyGenericParametersFrom(sourceType);
AddStateProperty();
CreateDefaultConstructor();
}
示例2: Visit
/// <summary>
/// Starts the code class extraction from the given role class.
/// </summary>
/// <param name="sourceType">The role class to extract the code class from.</param>
public override void Visit(TypeDefinition sourceType)
{
Tracer.TraceVerbose("Extract code class: {0} => {1}", sourceType.ToString(), TargetTypeName);
TargetType = new TypeDefinition(
string.Empty,
TargetTypeName,
TypeAttributes.NestedPublic |
TypeAttributes.Abstract | TypeAttributes.Sealed |
TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit,
sourceType.Module.Import(typeof(object))
);
//CreateConstructor(); // TODO: create a constructor for the static class? make it private?
if (!SourceType.Methods.Any(method => method.IsConstructor && !method.IsStatic)) {
// there are no constructors in the source type, but to be consistent, and to enable compatibility on new versions,
// we still need to have an Init method in the static class
CreateDefaultInitMethod();
}
}
示例3: ComposeRoles
public RoleComposerResult ComposeRoles(MutationParameters parameters)
{
parameters.Validate();
_targetType = parameters.SourceType;
if (_targetType == null) throw new ArgumentException("parameters must contain a SourceType", "parameters");
Tracer.TraceVerbose("Compose class: {0}", _targetType.ToString());
var result = new RoleComposerResult();
CheckComposition(result);
if (!result.Success) { return result; }
var roles = RetrieveRoles();
var conflictDetector = new ConflictDetector(_targetType);
{
var memberProcessResult = conflictDetector.Process(roles);
result.AddResult(memberProcessResult);
if (!memberProcessResult.Success) {
return result;
}
}
if (_targetType.IsRole()) {
// roles are not composed
return result;
}
{
_container = conflictDetector.Container;
var composeResult = ComposeRoles(roles);
result.AddResult(composeResult);
if (!composeResult.Success) {
return result;
}
}
return result;
}
示例4: RecompileClass
private XNodeOut RecompileClass(TypeDefinition classDef, XNodeOut fileNode)
{
if (!Build.TrackAnon && classDef.Name.StartsWith("<>"))
return null;
var classNode = SignatureToClass(classDef.ToString(), fileNode);
if(classDef.BaseType != null)
SetClassDependency(classNode, classDef.BaseType);
// add fields
if (Build.TrackFields && classDef.HasFields)
foreach (var fieldDef in classDef.Fields)
{
var fieldNode = classNode.AddField(fieldDef);
SetClassDependency(classNode, fieldDef.DeclaringType);
if (fieldDef.FieldType.IsGenericParameter)
Debug.WriteLine("Generic parameter ignored - " + fieldDef.FieldType.ToString());
else
fieldNode.ReturnID = GetClassRef(fieldDef.FieldType).ID;
}
// save source code for methods
foreach (var method in classDef.Methods)
SaveCode(classNode, method);
// track method creation/destruction
if (Build.TrackInstances && !classDef.IsValueType)
AddInstanceTracking(classDef, classNode);
// add enter/exit info to method and call tracking
List<MethodDefinition> addMethods = new List<MethodDefinition>();
foreach (var method in classDef.Methods.ToArray()) // toarray because recompile method may add new methods
RecompileMethod(classNode, classDef, method);
// recompile sub classes
foreach (var nestedDef in classDef.NestedTypes)
if (nestedDef.MetadataType == MetadataType.Class || nestedDef.MetadataType == MetadataType.ValueType)
RecompileClass(nestedDef, fileNode);
else
Debug.WriteLine("Ignored nested type - " + nestedDef.ToString());
return classNode;
}
示例5: OnTypeSelection
private void OnTypeSelection (TypeDefinition td)
{
objectLabel.Text = td.ToString ();
// very useful for debugging
textview.Buffer.Text = String.Empty;
}
示例6: SizeOfEnum
private static long SizeOfEnum (TypeDefinition type)
{
foreach (FieldDefinition field in type.Fields) {
// we looking for the special value__
// padding, if required, will be computed by caller
if (!field.IsStatic)
return SizeOf (field.FieldType);
}
throw new NotSupportedException (type.ToString () + " should not be usable as an enum type.");
}
示例7: RecompileClass
private XNodeOut RecompileClass(TypeDefinition classDef, XNodeOut fileNode)
{
if ( !TrackAnon && classDef.Name.StartsWith("<>") )
return null;
var classNode = SignatureToClass(classDef.ToString(), fileNode);
if(classDef.BaseType != null)
SetClassDependency(classNode, classDef.BaseType);
RecompileMethods(classDef, classNode);
foreach (var nestedDef in classDef.NestedTypes)
if (nestedDef.MetadataType == MetadataType.Class || nestedDef.MetadataType == MetadataType.ValueType)
RecompileClass(nestedDef, fileNode);
else
Debug.WriteLine("Ignored nested type - " + nestedDef.ToString());
return classNode;
}