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


C# ITypeDefinition.GetConstructors方法代码示例

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


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

示例1: AddTreeClassContents

		static void AddTreeClassContents (TreeStore store, TreeIter parent, ParsedDocument parsedDocument, ITypeDefinition cls, IUnresolvedTypeDefinition part)
		{
			List<object> items = new List<object> ();
			if (cls.Kind != TypeKind.Delegate) {
				foreach (var o in cls.GetMembers (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					items.Add (o);
				}
				foreach (var o in cls.GetNestedTypes (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					if (o.DeclaringType == cls)
						items.Add (o);
				}
				foreach (var o in cls.GetConstructors (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					if (o.IsSynthetic)
						continue;
					items.Add (o);
				}
			}
			items.Sort (ClassOutlineNodeComparer.CompareRegion);
			List<FoldingRegion> regions = new List<FoldingRegion> ();
			foreach (FoldingRegion fr in parsedDocument.UserRegions)
				//check regions inside class
				if (cls.BodyRegion.IsInside (fr.Region.Begin) && cls.BodyRegion.IsInside (fr.Region.End))
					regions.Add (fr);
			regions.Sort (delegate(FoldingRegion x, FoldingRegion y) { return x.Region.Begin.CompareTo (y.Region.Begin); });
			 
			IEnumerator<FoldingRegion> regionEnumerator = regions.GetEnumerator ();
			if (!regionEnumerator.MoveNext ())
				regionEnumerator = null;
			
			FoldingRegion currentRegion = null;
			TreeIter currentParent = parent;
			foreach (object item in items) {

				//no regions left; quick exit
				if (regionEnumerator != null) {
					DomRegion itemRegion = ClassOutlineNodeComparer.GetRegion (item);

					//advance to a region that could potentially contain this member
					while (regionEnumerator != null && !OuterEndsAfterInner (regionEnumerator.Current.Region, itemRegion))
						if (!regionEnumerator.MoveNext ())
							regionEnumerator = null;

					//if member is within region, make sure it's the current parent.
					//If not, move target iter back to class parent
					if (regionEnumerator != null && regionEnumerator.Current.Region.IsInside (itemRegion.Begin)) {
						if (currentRegion != regionEnumerator.Current) {
							currentParent = store.AppendValues (parent, regionEnumerator.Current);
							currentRegion = regionEnumerator.Current;
						}
					} else {
						currentParent = parent;
					}
				}
				
				TreeIter childIter = store.AppendValues (currentParent, item);
				if (item is ITypeDefinition)
					AddTreeClassContents (store, childIter, parsedDocument, (ITypeDefinition)item, part);
					
			} 
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:60,代码来源:ClassOutlineTextEditorExtension.cs

示例2: GetMembersToExport

        public List<IMember> GetMembersToExport(ITypeDefinition ce)
        {
            var members = ce.Members.Where(t => ShouldExportMember(t)).ToList();
            var fields = GeneratePropertyFields(ce, true).Concat(GeneratePropertyFields(ce, false));
            members = members.Concat(fields).ToList();

            var ctor = ce.Members.Where(t => t.SymbolKind == SymbolKind.Constructor && !t.IsStatic).FirstOrDefault();
            if (ctor == null && !Sk.OmitDefaultConstructor(ce))
            {
                ctor = GenerateDefaultConstructor(ce);
                if (ctor != null)
                    members.Add(ctor);
            }
            if (ctor != null && members.Contains(ctor))
            {
                var ctorIndex = 0;
                if (members.IndexOf(ctor) != ctorIndex)
                {
                    members.Remove(ctor);
                    members.Insert(ctorIndex, ctor);
                }
            }
            var inlineFields = Sk.InlineFields(ce);
            if (!inlineFields)
            {
                var vars = members.Where(t => t.SymbolKind == SymbolKind.Field).Cast<IField>();
                if (vars.Where(t => t.IsStatic()).FirstOrDefault() != null)
                {
                    var cctor = ce.GetConstructors(false, true).FirstOrDefault();
                    if (cctor == null)
                    {
                        cctor = CreateStaticCtor(ce);
                        members.Insert(1, cctor);
                    }
                }
                members.RemoveAll(t => t.SymbolKind == SymbolKind.Field);
            }

            return members;
        }
开发者ID:benbon,项目名称:SharpKit,代码行数:40,代码来源:MemberConverter.cs

示例3: GenerateDefaultConstructor

 protected IMethod GenerateDefaultConstructor(ITypeDefinition ce)
 {
     var compilerGeneratedCtor = ce.GetConstructors(true, false).FirstOrDefault(t => t.GetDeclarationBody() == null); //TODO: where is this phantom ctor coming from??? (dan-el)
     if (compilerGeneratedCtor == null)
     {
         var cePart = ce.Parts.First();
         var me2 = new DefaultUnresolvedMethod(cePart, ".ctor");
         me2.SymbolKind = SymbolKind.Constructor;
         me2.IsSynthetic = true;
         me2.UnresolvedFile = cePart.UnresolvedFile;
         var x = new DefaultResolvedMethod(me2, Compiler.Project.Compilation.TypeResolveContext.WithCurrentTypeDefinition(ce));
         compilerGeneratedCtor = x;
     }
     return compilerGeneratedCtor;
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:15,代码来源:MemberConverter.cs

示例4: ExportClassStructInterface

        private JsNode ExportClassStructInterface(ITypeDefinition ce)
        {
            var jsType = new JsClrType();
            jsType.Kind = GetJsTypeKind(ce);
            jsType.fullname = GetJsTypeName(ce);
            var baseClass = GetBaseClassIfValid(ce, true);
            if (baseClass != null)
            {
                var baseClassName = GetJsTypeName(baseClass);
                if (baseClassName != jsType.fullname)   //avoid object:object inheritance recursion
                    jsType.baseTypeName = baseClassName;
            }
            var globalCode = new List<JsUnit>();
            if (!ce.IsInterface() || Sk.NewInterfaceImplementation)
            {
                var members = GetMembersToExport(ce);
                var inlineFields = Sk.InlineFields(ce);
                var cctor = ce.GetConstructors(false, true).FirstOrDefault();
                if (cctor == null && !inlineFields && ce.GetFields().Where(t => t.IsStatic).FirstOrDefault() != null)
                {

                    cctor = CreateStaticCtor(ce);
                    if (ShouldExportConstructor(cctor))
                        members.Insert(0, cctor);
                }

                var mappings = members.Select(t => new EntityToJsNode { JsNode = Visit(t), Entity = t }).ToList();

                //Remove GlobalCode=True members from mappings
                for (var i = mappings.Count - 1; i >= 0; i--)
                {
                    if (mappings[i].JsNode is JsUnit)
                    { //Maybe more clean: Another way could be to check the IEntity for GlobalCode=True
                        globalCode.Add((JsUnit)mappings[i].JsNode);
                        mappings.RemoveAt(i);
                    }
                }

                ImportToType(jsType, mappings);
            }
            ExportImplementedInterfaces(ce, jsType);
            jsType.assemblyName = AssemblyName;
            var atts = ExportCustomAttributes(ce);
            if (atts.IsNotNullOrEmpty())
            {
                if (jsType.customAttributes == null)
                    jsType.customAttributes = new JsArray<JsClrAttribute>();
                jsType.customAttributes.AddRange(atts);
            }
            var unit = OnAfterExportType(ce, jsType);
            globalCode.ForEach(t => unit.Statements.AddRange(t.Statements));
            return unit;
        }
开发者ID:benbon,项目名称:SharpKit,代码行数:53,代码来源:MemberConverter_Clr.cs


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