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


C# ITypeDefinition类代码示例

本文整理汇总了C#中ITypeDefinition的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition类的具体用法?C# ITypeDefinition怎么用?C# ITypeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ITypeDefinition类属于命名空间,在下文中一共展示了ITypeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

		/// <summary>
		/// Creates the <see cref="Table"/> from the descriptor.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="type">The <see cref="ITypeDefinition"/>.</param>
		/// <returns>Returns the created <see cref="Table"/>.</returns>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		public Table Create(IMansionContext context, ITypeDefinition type)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (type == null)
				throw new ArgumentNullException("type");

			// invoke template method
			var table = DoCreate(context, type);

			// create the columns for this table
			foreach (var property in type.Properties)
			{
				ColumnDescriptor columnDescriptor;
				if (!property.TryGetDescriptor(out columnDescriptor))
					continue;

				// add the column to the table
				table.Add(columnDescriptor.Create(context, table, property));
			}

			// return the created table
			return table;
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:32,代码来源:TypeTableDescriptor.cs

示例2: CreateCodeTypeForTypeDefinition

 CodeType CreateCodeTypeForTypeDefinition(ITypeDefinition typeDefinition)
 {
     if (typeDefinition.Kind == TypeKind.Interface) {
         return new CodeInterface(context, typeDefinition);
     }
     return new CodeClass2(context, typeDefinition);
 }
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:7,代码来源:CodeModel.cs

示例3: GenerateCode

		protected override string GenerateCode(ITypeDefinition currentClass)
		{
//			string[] fields = listBox.SelectedItems.OfType<PropertyOrFieldWrapper>().Select(f2 => f2.MemberName).ToArray();
			string[] fields = parameterList.Where(f => f.IsIncluded).Select(f2 => f2.MemberName).ToArray();
			
			PrimitiveExpression formatString = new PrimitiveExpression(GenerateFormatString(currentClass, editor.Language.CodeGenerator, fields));
			List<Expression> param = new List<Expression>() { formatString };
			ReturnStatement ret = new ReturnStatement(new InvocationExpression(
				new MemberReferenceExpression(new TypeReferenceExpression(ConvertType(KnownTypeCode.String)), "Format"),
				param.Concat(fields.Select(f => new IdentifierExpression(f))).ToList()
			));
			
			if (baseCallNode != null) {
				MethodDeclaration insertedOverrideMethod = refactoringContext.GetNode().PrevSibling as MethodDeclaration;
				if (insertedOverrideMethod == null) {
					// We are not inside of a method declaration
					return null;
				}
				
				using (Script script = refactoringContext.StartScript()) {
					NewLineNode nextNewLineNode = insertedOverrideMethod.NextSibling as NewLineNode;
					
					// Find base method call and replace it by return statement
					script.AddTo(insertedOverrideMethod.Body, ret);
					AppendNewLine(script, insertedOverrideMethod, nextNewLineNode);
				}
			}
			
			return null;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:30,代码来源:OverrideToStringMethodDialog.xaml.cs

示例4: GetJsClass

		private JsClass GetJsClass(ITypeDefinition typeDefinition) {
			JsClass result;
			if (!_types.TryGetValue(typeDefinition, out result)) {
				var semantics = _metadataImporter.GetTypeSemantics(typeDefinition);
				if (semantics.GenerateCode) {
					var errors = Utils.FindTypeUsageErrors(typeDefinition.GetAllBaseTypes(), _metadataImporter);
					if (errors.HasErrors) {
						var oldRegion = _errorReporter.Region;
						try {
							_errorReporter.Region = typeDefinition.Region;
							foreach (var ut in errors.UsedUnusableTypes)
								_errorReporter.Message(Messages._7500, ut.FullName, typeDefinition.FullName);
							foreach (var t in errors.MutableValueTypesBoundToTypeArguments)
								_errorReporter.Message(Messages._7539, t.FullName);
						}
						finally {
							_errorReporter.Region = oldRegion;
						}
					}
					result = new JsClass(typeDefinition);
				}
				else {
					result = null;
				}
				_types[typeDefinition] = result;
			}
			return result;
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:28,代码来源:Compiler.cs

示例5: OverrideEqualsGetHashCodeMethodsDialog

		public OverrideEqualsGetHashCodeMethodsDialog(InsertionContext context, ITextEditor editor, ITextAnchor endAnchor,
		                                              ITextAnchor insertionPosition, ITypeDefinition selectedClass, IMethod selectedMethod, AstNode baseCallNode)
			: base(context, editor, insertionPosition)
		{
			if (selectedClass == null)
				throw new ArgumentNullException("selectedClass");
			
			InitializeComponent();
			
			this.selectedClass = selectedClass;
			this.insertionEndAnchor = endAnchor;
			this.selectedMethod = selectedMethod;
			this.baseCallNode = baseCallNode;
			
			addIEquatable.Content = string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddInterface}"),
			                                      "IEquatable<" + selectedClass.Name + ">");
			
			string otherMethod = selectedMethod.Name == "Equals" ? "GetHashCode" : "Equals";
			
			addOtherMethod.Content = StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddOtherMethod}", new StringTagPair("otherMethod", otherMethod));
			
			addIEquatable.IsEnabled = !selectedClass.GetAllBaseTypes().Any(
				type => {
					if (!type.IsParameterized || (type.TypeParameterCount != 1))
						return false;
					if (type.FullName != "System.IEquatable")
						return false;
					return type.TypeArguments.First().FullName == selectedClass.FullName;
				}
			);
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:31,代码来源:OverrideEqualsGetHashCodeMethodsDialog.xaml.cs

示例6: IsForwardable

 public bool IsForwardable(ITypeDefinition type)
 {
     INestedTypeDefinition nestedType = type as INestedTypeDefinition;
     if (nestedType != null)
         return false;
     return true;
 }
开发者ID:pgavlin,项目名称:ApiTools,代码行数:7,代码来源:TypeForwardWriter.cs

示例7: AddedBaseType

        private bool AddedBaseType(IDifferences differences, ITypeDefinition impl, ITypeDefinition contract)
        {
            // For interfaces we rely only on the AddedInterface check
            if (impl.IsInterface || contract.IsInterface)
                return false;

            // Base types must be in the same order so we have to compare them in order
            List<ITypeReference> implBaseTypes = new List<ITypeReference>(impl.GetAllBaseTypes());

            int lastIndex = 0;
            foreach (var contractBaseType in contract.GetAllBaseTypes())
            {
                lastIndex = implBaseTypes.FindIndex(lastIndex, item1BaseType => _typeComparer.Equals(item1BaseType, contractBaseType));

                if (lastIndex < 0)
                {
                    differences.AddIncompatibleDifference(this,
                        "Type '{0}' does not inherit from base type '{1}' in the implementation but it does in the contract.",
                        contract.FullName(), contractBaseType.FullName());
                    return true;
                }
            }

            return false;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:25,代码来源:CannotRemoveBaseTypeOrInterface.cs

示例8: MixinsWeaverStrategy

 public MixinsWeaverStrategy(ITypeDefinition typeDefinition, ITypeMapCollection mixinsMap, IEnumerable<IMethodWeaver> methodWeavers, INCopDependencyAwareRegistry registry)
 {
     this.registry = registry;
     this.mixinsMap = mixinsMap;
     this.methodWeavers = methodWeavers;
     this.typeDefinition = typeDefinition;
 }
开发者ID:sagifogel,项目名称:NCop,代码行数:7,代码来源:MixinsWeaverStrategy.cs

示例9: Unspecialize

 public static ITypeReference Unspecialize(ITypeDefinition type) {
   var sntd = type as ISpecializedNestedTypeDefinition;
   if (sntd != null) return sntd.UnspecializedVersion;
   var gti = type as IGenericTypeInstance;
   if (gti != null) return gti.GenericType;
   return type;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:MethodHelper.cs

示例10: FindDerivedSymbols

		static void FindDerivedSymbols (ITypeDefinition cls, IMember member)
		{
			var solution = IdeApp.ProjectOperations.CurrentSelectedSolution;
			if (solution == null)
				return;

			var sourceProject = TypeSystemService.GetProject (cls);
			if (sourceProject == null)
				return;

			var compilations = ReferenceFinder.GetAllReferencingProjects (solution, sourceProject)
				.Select (TypeSystemService.GetCompilation).Where (c => c != null).ToList ();

			using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, true)) {
				var label = member == null
					? GettextCatalog.GetString ("Searching for derived classes in solution...")
					: GettextCatalog.GetString ("Searching for derived members in solution...");
				monitor.BeginTask (label, compilations.Count);

				Parallel.ForEach (compilations, comp => {
					try {
						SearchCompilation (monitor, comp, cls, member);
					} catch (Exception ex) {
						LoggingService.LogInternalError (ex);
						monitor.ReportError ("Unhandled error while searching", ex);
					}
					monitor.Step (1);
				});

				monitor.EndTask ();
			};
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:32,代码来源:FindDerivedClassesHandler.cs

示例11: PrintDelegateDefinition

    public virtual void PrintDelegateDefinition(ITypeDefinition delegateDefinition) {
      PrintTypeDefinitionAttributes(delegateDefinition);
      PrintToken(CSharpToken.Indent);

      IMethodDefinition invokeMethod = null;
      foreach (var invokeMember in delegateDefinition.GetMatchingMembers(m => m.Name.Value == "Invoke")) {
        IMethodDefinition idef = invokeMember as IMethodDefinition;
        if (idef != null) { invokeMethod = idef; break; }
      }

      PrintTypeDefinitionVisibility(delegateDefinition);
      if (IsMethodUnsafe(invokeMethod))
        PrintKeywordUnsafe();

      PrintKeywordDelegate();
      PrintMethodDefinitionReturnType(invokeMethod);
      PrintToken(CSharpToken.Space);
      PrintTypeDefinitionName(delegateDefinition);
      if (delegateDefinition.GenericParameterCount > 0) {
        this.Traverse(delegateDefinition.GenericParameters);
      }
      if (invokeMethod != null)
        Traverse(invokeMethod.Parameters);

      PrintToken(CSharpToken.Semicolon);
    }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:26,代码来源:TypeDefinitionSourceEmitter.cs

示例12: PrintTypeDefinition

    public virtual void PrintTypeDefinition(ITypeDefinition typeDefinition) {
      if (typeDefinition.IsDelegate) {
        PrintDelegateDefinition(typeDefinition);
        return;
      }

      if (((INamedEntity)typeDefinition).Name.Value.Contains("PrivateImplementationDetails")) return;

      PrintTypeDefinitionAttributes(typeDefinition);
      PrintToken(CSharpToken.Indent);
      PrintTypeDefinitionVisibility(typeDefinition);
      PrintTypeDefinitionModifiers(typeDefinition);
      PrintTypeDefinitionKeywordType(typeDefinition);
      PrintTypeDefinitionName(typeDefinition);
      if (typeDefinition.IsGeneric) {
        this.Traverse(typeDefinition.GenericParameters);
      }
      PrintTypeDefinitionBaseTypesAndInterfaces(typeDefinition);

      PrintTypeDefinitionLeftCurly(typeDefinition);

      // Get the members in metadata order for each type
      // Note that it's important to preserve the metadata order here (eg. sequential layout fields,
      // methods in COMImport types, etc.).
      var members = new List<ITypeDefinitionMember>();
      foreach (var m in typeDefinition.Methods) members.Add(m);
      foreach (var m in typeDefinition.Events) members.Add(m);
      foreach (var m in typeDefinition.Properties) members.Add(m);
      foreach (var m in typeDefinition.Fields) members.Add(m);
      foreach (var m in typeDefinition.NestedTypes) members.Add(m);
      Traverse(members);

      PrintTypeDefinitionRightCurly(typeDefinition);
    }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:34,代码来源:TypeDefinitionSourceEmitter.cs

示例13: Visit

 public TsType Visit(ITypeDefinition ce)
 {
     var name = SkJs.GetEntityJsName(ce);
     var ce2 = new TsType
     {
         Name = name, Kind=(ce.IsInterface() || ce.IsDelegate()) ? TsTypeKind.Interface :  TsTypeKind.Class,
         TypeParameters = ce.TypeParameters.Select(Visit).ToList()
     };
     if (name.Contains("."))
     {
         var pair = name.SplitAt(name.LastIndexOf("."), true);
         ce2.Name = pair[1];
         ce2.ModuleName = pair[0];
         ce2.IsModuleExport = true;
     }
     if (ce.IsDelegate())
     {
         var func = Visit(ce.GetDelegateInvokeMethod());
         //func.IsCallSignature = true;
         func.Name = null;
         ce2.Members.Add(func);
     }
     else
     {
         var members = TypeConverter.ClrConverter.GetMembersToExport(ce);
         var members2 = members.Select(Visit).Where(t => t != null).ToList();
         ce2.Members.AddRange(members2);
         if (ce2.Kind == TsTypeKind.Class)
         {
             ce2.Members.OfType<TsFunction>().Where(t => !t.IsConstructor || !t.Type.IsNullOrVoid()).ForEach(t => t.Body = "return null;");
             ce2.Members.OfType<TsFunction>().Where(t => t.IsConstructor).ForEach(t => t.Body = "");
         }
     }
     return ce2;
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:35,代码来源:TsMemberConverter.cs

示例14: Diff

        public override DifferenceType Diff(IDifferences differences, ITypeDefinition impl, ITypeDefinition contract)
        {
            if (impl == null || contract == null)
                return DifferenceType.Unknown;

            return DiffConstraints(differences, impl, impl.GenericParameters, contract.GenericParameters);
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:CannotRemoveGenerics.cs

示例15: Include

        public bool Include(ITypeDefinition type)
        {
            string typeId = type.DocId();

            // include so long as it isn't in the exclude list.
            return !_docIds.Contains(typeId);
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:DocIdExcludeListFilter.cs


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