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


C# ITypeDefinition.GetDelegateInvokeMethod方法代码示例

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


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

示例1: 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

示例2: ConvertTypeDefinition

        EntityDeclaration ConvertTypeDefinition(ITypeDefinition typeDefinition)
        {
            Modifiers modifiers = Modifiers.None;
            if (this.ShowAccessibility) {
                modifiers |= ModifierFromAccessibility(typeDefinition.Accessibility);
            }
            if (this.ShowModifiers) {
                if (typeDefinition.IsStatic) {
                    modifiers |= Modifiers.Static;
                } else if (typeDefinition.IsAbstract) {
                    modifiers |= Modifiers.Abstract;
                } else if (typeDefinition.IsSealed) {
                    modifiers |= Modifiers.Sealed;
                }
                if (typeDefinition.IsShadowing) {
                    modifiers |= Modifiers.New;
                }
            }

            ClassType classType;
            switch (typeDefinition.Kind) {
                case TypeKind.Struct:
                    classType = ClassType.Struct;
                    modifiers &= ~Modifiers.Sealed;
                    break;
                case TypeKind.Enum:
                    classType = ClassType.Enum;
                    modifiers &= ~Modifiers.Sealed;
                    break;
                case TypeKind.Interface:
                    classType = ClassType.Interface;
                    modifiers &= ~Modifiers.Abstract;
                    break;
                case TypeKind.Delegate:
                    IMethod invoke = typeDefinition.GetDelegateInvokeMethod();
                    if (invoke != null) {
                        return ConvertDelegate(invoke, modifiers);
                    } else {
                        goto default;
                    }
                default:
                    classType = ClassType.Class;
                    break;
            }

            var decl = new TypeDeclaration();
            decl.ClassType = classType;
            decl.Modifiers = modifiers;
            decl.Name = typeDefinition.Name;

            int outerTypeParameterCount = (typeDefinition.DeclaringTypeDefinition == null) ? 0 : typeDefinition.DeclaringTypeDefinition.TypeParameterCount;

            if (this.ShowTypeParameters) {
                foreach (ITypeParameter tp in typeDefinition.TypeParameters.Skip(outerTypeParameterCount)) {
                    decl.TypeParameters.Add(ConvertTypeParameter(tp));
                }
            }

            if (this.ShowBaseTypes) {
                foreach (IType baseType in typeDefinition.DirectBaseTypes) {
                    decl.BaseTypes.Add(ConvertType(baseType));
                }
            }

            if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
                foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
                    var constraint = ConvertTypeParameterConstraint(tp);
                    if (constraint != null)
                        decl.Constraints.Add(constraint);
                }
            }
            return decl;
        }
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:73,代码来源:TypeSystemAstBuilder.cs

示例3: ProcessDelegate

		private void ProcessDelegate(ITypeDefinition delegateDefinition) {
			bool bindThisToFirstParameter = AttributeReader.HasAttribute<BindThisToFirstParameterAttribute>(delegateDefinition);
			bool expandParams = AttributeReader.HasAttribute<ExpandParamsAttribute>(delegateDefinition);

			if (bindThisToFirstParameter && delegateDefinition.GetDelegateInvokeMethod().Parameters.Count == 0) {
				Message(Messages._7147, delegateDefinition, delegateDefinition.FullName);
				bindThisToFirstParameter = false;
			}
			if (expandParams && !delegateDefinition.GetDelegateInvokeMethod().Parameters.Any(p => p.IsParams)) {
				Message(Messages._7148, delegateDefinition, delegateDefinition.FullName);
				expandParams = false;
			}

			_delegateSemantics[delegateDefinition] = new DelegateScriptSemantics(expandParams: expandParams, bindThisToFirstParameter: bindThisToFirstParameter);
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:15,代码来源:MetadataImporter.cs

示例4: ConvertTypeDefinition

		AttributedNode ConvertTypeDefinition(ITypeDefinition typeDefinition)
		{
			Modifiers modifiers = ModifierFromAccessibility(typeDefinition.Accessibility);
			if (this.ShowModifiers) {
				if (typeDefinition.IsStatic) {
					modifiers |= Modifiers.Static;
				} else if (typeDefinition.IsAbstract) {
					modifiers |= Modifiers.Abstract;
				} else if (typeDefinition.IsSealed) {
					modifiers |= Modifiers.Sealed;
				}
				if (typeDefinition.IsShadowing) {
					modifiers |= Modifiers.New;
				}
			}
			
			ClassType classType;
			switch (typeDefinition.Kind) {
				case TypeKind.Struct:
					classType = ClassType.Struct;
					break;
				case TypeKind.Enum:
					classType = ClassType.Enum;
					break;
				case TypeKind.Interface:
					classType = ClassType.Interface;
					break;
				case TypeKind.Delegate:
					IMethod invoke = typeDefinition.GetDelegateInvokeMethod();
					if (invoke != null)
						return ConvertDelegate(invoke, modifiers);
					else
						goto default;
				default:
					classType = ClassType.Class;
					break;
			}
			
			TypeDeclaration decl = new TypeDeclaration();
			decl.Modifiers = modifiers;
			decl.ClassType = classType;
			decl.Name = typeDefinition.Name;
			
			if (this.ShowTypeParameters) {
				foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
					decl.TypeParameters.Add(ConvertTypeParameter(tp));
				}
			}
			
			if (this.ShowBaseTypes) {
				foreach (ITypeReference baseType in typeDefinition.BaseTypes) {
					decl.BaseTypes.Add(ConvertTypeReference(baseType));
				}
			}
			
			if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
				foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
					var constraint = ConvertTypeParameterConstraint(tp);
					if (constraint != null)
						decl.Constraints.Add(constraint);
				}
			}
			return decl;
		}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:64,代码来源:TypeSystemAstBuilder.cs


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