當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。