当前位置: 首页>>代码示例>>C#>>正文


C# TypeDefinition.ToString方法代码示例

本文整理汇总了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();
            }
开发者ID:cessationoftime,项目名称:nroles,代码行数:20,代码来源:ExtractStateClassMutator.cs

示例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();
                }
            }
开发者ID:cessationoftime,项目名称:nroles,代码行数:24,代码来源:ExtractCodeClassMutator.cs

示例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;
        }
开发者ID:cessationoftime,项目名称:nroles,代码行数:40,代码来源:RoleComposerMutator.cs

示例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;
        }
开发者ID:dpvreony-forks,项目名称:CodePerspective,代码行数:46,代码来源:Decompile.cs

示例5: OnTypeSelection

		private void OnTypeSelection (TypeDefinition td)
		{
			objectLabel.Text = td.ToString ();
			// very useful for debugging
			textview.Buffer.Text = String.Empty;
		}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:6,代码来源:MainWindow.cs

示例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.");
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:10,代码来源:AvoidLargeStructureRule.cs

示例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;
        }
开发者ID:jkobtr,项目名称:CodePerspective,代码行数:20,代码来源:Decompile.cs


注:本文中的Mono.Cecil.TypeDefinition.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。