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


C# IType.GetProperties方法代码示例

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


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

示例1: IndexerParameterDataProvider

		public IndexerParameterDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType type, AstNode resolvedExpression)
		{
			this.startOffset = startOffset;
//			this.ext = ext;
		
			this.resolvedExpression = resolvedExpression;
			indexers = new List<IProperty> (type.GetProperties (p => p.IsIndexer));
		}
开发者ID:head-thrash,项目名称:monodevelop,代码行数:8,代码来源:IndexerParameterDataProvider.cs

示例2: AddImplementation

        static void AddImplementation(RefactoringContext context, TypeDeclaration result, IType guessedType)
        {
            foreach (var property in guessedType.GetProperties ()) {
                if (!property.IsAbstract)
                    continue;
                if (property.IsIndexer) {
                    var indexerDecl = new IndexerDeclaration {
                        ReturnType = context.CreateShortType(property.ReturnType),
                        Modifiers = GetModifiers(property),
                        Name = property.Name
                    };
                    indexerDecl.Parameters.AddRange(ConvertParameters(context, property.Parameters));
                    if (property.CanGet)
                        indexerDecl.Getter = new Accessor();
                    if (property.CanSet)
                        indexerDecl.Setter = new Accessor();
                    result.AddChild(indexerDecl, Roles.TypeMemberRole);
                    continue;
                }
                var propDecl = new PropertyDeclaration {
                    ReturnType = context.CreateShortType(property.ReturnType),
                    Modifiers = GetModifiers (property),
                    Name = property.Name
                };
                if (property.CanGet)
                    propDecl.Getter = new Accessor();
                if (property.CanSet)
                    propDecl.Setter = new Accessor();
                result.AddChild(propDecl, Roles.TypeMemberRole);
            }

            foreach (var method in guessedType.GetMethods ()) {
                if (!method.IsAbstract)
                    continue;
                var decl = new MethodDeclaration {
                    ReturnType = context.CreateShortType(method.ReturnType),
                    Modifiers = GetModifiers (method),
                    Name = method.Name,
                    Body = new BlockStatement {
                        new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException")))
                    }
                };
                decl.Parameters.AddRange(ConvertParameters(context, method.Parameters));
                result.AddChild(decl, Roles.TypeMemberRole);
            }

            foreach (var evt in guessedType.GetEvents ()) {
                if (!evt.IsAbstract)
                    continue;
                var decl = new EventDeclaration {
                    ReturnType = context.CreateShortType(evt.ReturnType),
                    Modifiers = GetModifiers (evt),
                    Name = evt.Name
                };
                result.AddChild(decl, Roles.TypeMemberRole);
            }
        }
开发者ID:artifexor,项目名称:NRefactory,代码行数:57,代码来源:CreateClassDeclarationAction.cs

示例3: ParseMinimalProperties

 internal static void ParseMinimalProperties(SDType sdType, IType type)
 {
     var properties = type.GetProperties(null, GetMemberOptions.IgnoreInheritedMembers);
     foreach (var property in properties)
     {
         var parsedProperty = GetMinimalParsedProperty(property);
         if (sdType.Properties.SingleOrDefault(p => p.Name == parsedProperty.Name) == null)
         {
             sdType.Properties.Add(parsedProperty);
         }
     }
 }
开发者ID:llenroc,项目名称:sharpDox,代码行数:12,代码来源:PropertyParser.cs

示例4: CollectMembersToImplement

        public static List<IMember> CollectMembersToImplement(ITypeDefinition implementingType, IType abstractType)
        {
            //			var def = abstractType.GetDefinition();
            var toImplement = new List<IMember>();
            bool alreadyImplemented;

            // Stub out non-implemented events defined by @iface
            foreach (var ev in abstractType.GetEvents (e => !e.IsSynthetic && e.IsAbstract)) {
                alreadyImplemented = implementingType.GetAllBaseTypeDefinitions().Any(
                    x => x.Kind != TypeKind.Interface && x.Events.Any (y => y.Name == ev.Name)
                    );

                if (!alreadyImplemented)
                    toImplement.Add(ev);
            }

            // Stub out non-implemented methods defined by @iface
            foreach (var method in abstractType.GetMethods (d => !d.IsSynthetic  && d.IsAbstract)) {
                alreadyImplemented = false;

                var allBaseTypes = method.DeclaringType.GetAllBaseTypes().ToList ();
                foreach (var cmet in implementingType.GetMethods (d => !d.IsAbstract && d.Name == method.Name)) {
                    if (allBaseTypes.Contains(cmet.DeclaringType))
                        continue;
                    if (ImplementInterfaceAction.CompareMethods(method, cmet)) {
                        alreadyImplemented = true;
                        break;
                    }
                }
                if (!alreadyImplemented)
                    toImplement.Add(method);
            }

            // Stub out non-implemented properties defined by @iface
            foreach (var prop in abstractType.GetProperties (p => !p.IsSynthetic && p.IsAbstract)) {
                alreadyImplemented = false;
                foreach (var t in implementingType.GetAllBaseTypeDefinitions ()) {
                    if (t.Kind == TypeKind.Interface)
                        continue;
                    foreach (IProperty cprop in t.Properties) {
                        if (!cprop.IsAbstract && cprop.Name == prop.Name) {
                            alreadyImplemented = true;
                        }
                    }
                }
                if (!alreadyImplemented)
                    toImplement.Add(prop);
            }
            return toImplement;
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:50,代码来源:ImplementAbstractMembersAction.cs

示例5: ParseProperties

 internal void ParseProperties(SDType sdType, IType type)
 {
     var properties = type.GetProperties(null, GetMemberOptions.IgnoreInheritedMembers);
     foreach (var property in properties)
     {
         if (!IsMemberExcluded(property.GetIdentifier(), property.Accessibility.ToString()))
         {
             var parsedProperty = GetParsedProperty(property);
             if (sdType.Properties.SingleOrDefault(p => p.Name == parsedProperty.Name) == null)
             {
                 sdType.Properties.Add(parsedProperty);
             }
         }
     }
 }
开发者ID:llenroc,项目名称:sharpDox,代码行数:15,代码来源:PropertyParser.cs

示例6: CreateCtorParams

		IEnumerable<PropertyOrFieldWrapper> CreateCtorParams(IType sourceType)
		{
			int i = 0;
			
			foreach (var f in sourceType.GetFields().Where(field => !field.IsConst
			                                               && field.IsStatic == sourceType.GetDefinition().IsStatic
			                                               && field.DeclaringType.FullName == sourceType.FullName
			                                               && field.ReturnType != null)) {
				yield return new PropertyOrFieldWrapper(f) { Index = i };
				i++;
			}
			
			foreach (var p in sourceType.GetProperties().Where(prop => prop.CanSet && !prop.IsIndexer
			                                                   && prop.IsAutoImplemented()
			                                                   && prop.IsStatic == sourceType.GetDefinition().IsStatic
			                                                   && prop.DeclaringType.FullName == sourceType.FullName
			                                                   && prop.ReturnType != null)) {
				yield return new PropertyOrFieldWrapper(p) { Index = i };
				i++;
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:21,代码来源:InsertCtorDialog.xaml.cs

示例7: GetAccessibleIndexers

		IEnumerable<IProperty> GetAccessibleIndexers(IType type)
		{
			var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
			var properties = new List<IProperty>();
			foreach (var property in type.GetProperties ()) {
				if (!property.IsIndexer)
					continue;
				if (!lookup.IsAccessible (property, true))
					continue;
				if (property.IsShadowing) {
					for (int j = 0; j < properties.Count; j++) {
						if (ParameterListComparer.Instance.Equals(properties[j].Parameters, property.Parameters)) {
							properties.RemoveAt (j);
							j--;
						}
					}
				}

				properties.Add (property);
			}
			return properties;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:22,代码来源:CSharpParameterCompletionEngine.cs

示例8: Lookup

		/// <summary>
		/// Performs a member lookup.
		/// </summary>
		public ResolveResult Lookup(IType type, string name, IList<IType> typeArguments, bool isInvocation)
		{
			int typeArgumentCount = typeArguments.Count;
			
			List<IType> types = new List<IType>();
			List<IMember> members = new List<IMember>();
			if (!isInvocation) {
				// Consider nested types only if it's not an invocation. The type parameter count must match in this case.
				Predicate<ITypeDefinition> typeFilter = delegate (ITypeDefinition d) {
					return d.TypeParameterCount == typeArgumentCount && d.Name == name && IsAccessible(d, true);
				};
				types.AddRange(type.GetNestedTypes(context, typeFilter));
			}
			
			bool allowProtectedAccess = IsProtectedAccessAllowed(type);
			
			if (typeArgumentCount == 0) {
				Predicate<IMember> memberFilter = delegate(IMember member) {
					return !member.IsOverride && member.Name == name && IsAccessible(member, allowProtectedAccess);
				};
				members.AddRange(type.GetMethods(context, memberFilter.SafeCast<IMember, IMethod>()).SafeCast<IMethod, IMember>());
				members.AddRange(type.GetProperties(context, memberFilter.SafeCast<IMember, IProperty>()).SafeCast<IProperty, IMember>());
				members.AddRange(type.GetFields(context, memberFilter.SafeCast<IMember, IField>()).SafeCast<IField, IMember>());
				members.AddRange(type.GetEvents(context, memberFilter.SafeCast<IMember, IEvent>()).SafeCast<IEvent, IMember>());
				if (isInvocation)
					members.RemoveAll(m => !IsInvocable(m, context));
			} else {
				// No need to check for isInvocation/isInvocable here:
				// we filter out all non-methods
				Predicate<IMethod> memberFilter = delegate(IMethod method) {
					return method.TypeParameters.Count == typeArgumentCount
						&& !method.IsOverride && method.Name == name && IsAccessible(method, allowProtectedAccess);
				};
				members.AddRange(type.GetMethods(context, memberFilter).SafeCast<IMethod, IMember>());
			}
			
			// TODO: can't members also hide types?
			
			RemoveTypesHiddenByOtherTypes(types);
			// remove members hidden by types
			for (int i = 0; i < types.Count; i++) {
				ITypeDefinition d = GetDeclaringTypeDef(types[i]);
				if (d != null)
					members.RemoveAll(m => d.IsDerivedFrom(m.DeclaringTypeDefinition, context));
			}
			// remove members hidden by other members
			for (int i = members.Count - 1; i >= 0; i--) {
				ITypeDefinition d = members[i].DeclaringTypeDefinition;
				IMethod mi = members[i] as IMethod;
				// nested loop depends on the fact that the members of more derived classes appear later in the list
				for (int j = i + 1; j < members.Count; j++) {
					if (mi != null) {
						IMethod mj = members[j] as IMethod;
						if (mj != null && !ParameterListComparer.Instance.Equals(mi, mj))
							continue;
					}
					ITypeDefinition s = members[j].DeclaringTypeDefinition;
					if (s != null && s != d && s.IsDerivedFrom(d, context)) {
						// members[j] hides members[i]
						members.RemoveAt(i);
						break;
					}
				}
			}
			// remove interface members hidden by class members
			if (type is ITypeParameter) {
				// this can happen only with type parameters
				for (int i = members.Count - 1; i >= 0; i--) {
					ITypeDefinition d = members[i].DeclaringTypeDefinition;
					if (d.ClassType != ClassType.Interface)
						continue;
					IMethod mi = members[i] as IMethod;
					for (int j = 0; j < members.Count; j++) {
						if (mi != null) {
							IMethod mj = members[j] as IMethod;
							if (mj != null && !ParameterListComparer.Instance.Equals(mi, mj))
								continue;
						}
						ITypeDefinition s = members[j].DeclaringTypeDefinition;
						if (s != null && IsNonInterfaceType(s)) {
							// members[j] hides members[i]
							members.RemoveAt(i);
							break;
						}
					}
				}
			}
			
			if (types.Count > 0) {
				bool isAmbiguous = !(types.Count == 1 && members.Count == 0);
				return CreateTypeResolveResult(types[0], isAmbiguous, typeArguments);
			}
			if (members.Count == 0)
				return new UnknownMemberResolveResult(type, name, typeArguments);
			IMember firstNonMethod = members.FirstOrDefault(m => !(m is IMethod));
			if (members.Count == 1 && firstNonMethod != null)
				return new MemberResolveResult(firstNonMethod, context);
//.........这里部分代码省略.........
开发者ID:constructor-igor,项目名称:cudafy,代码行数:101,代码来源:MemberLookup.cs

示例9: DoNamedArgsCompletion

		void DoNamedArgsCompletion(XamlCompletionItemList list, XamlCompletionContext context, IType type, MarkupExtensionInfo markup)
		{
			if (markup.NamedArguments.Count > 0 && !context.Editor.GetWordBeforeCaret().StartsWith(",", StringComparison.OrdinalIgnoreCase)) {
				int lastStart = markup.NamedArguments.Max(i => i.Value.StartOffset);
				var item = markup.NamedArguments.First(p => p.Value.StartOffset == lastStart);
				
				if (context.RawAttributeValue.EndsWith("=", StringComparison.OrdinalIgnoreCase) ||
				    (item.Value.IsString && item.Value.StringValue.EndsWith(context.Editor.GetWordBeforeCaretExtended(), StringComparison.Ordinal))) {
					var resolver = new XamlResolver(compilation);
					MemberResolveResult mrr = resolver.ResolveAttributeValue(item.Key, context) as MemberResolveResult;
					if (mrr != null && mrr.Member != null && mrr.Member.ReturnType != null) {
						IType memberType = mrr.Member.ReturnType;
						list.Items.AddRange(MemberCompletion(context, memberType, string.Empty));
					}
					return;
				}
			}
			
			list.Items.AddRange(type.GetProperties().Where(p => p.CanSet && p.IsPublic).Select(p => new XamlCompletionItem(p.Name + "=", p)));
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:20,代码来源:CompletionDataGenerator.cs

示例10: AddAttributes

		void AddAttributes(IType type, IList<ICompletionItem> list, bool includeEvents)
		{
			if (type.Kind == TypeKind.Unknown)
				return;
			
			foreach (IProperty p in type.GetProperties(up => up.IsPublic)) {
				if ((p.CanSet && p.Setter.IsPublic) || p.ReturnType.IsCollectionType())
					list.Add(new XamlCompletionItem(p));
			}
			
			if (includeEvents) {
				foreach (IEvent e in type.GetEvents(ue => ue.IsPublic)) {
					list.Add(new XamlCompletionItem(e));
				}
			}
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:16,代码来源:CompletionDataGenerator.cs

示例11: GetProperties

 protected IEnumerable<IProperty> GetProperties(IType type)
 {
     IList<IProperty> properties = new List<IProperty> ();
     foreach (IProperty property in type.GetProperties()) {
         if (!AttributeHelper.HasAttribute (property, Constants.IBOUTLET)) {
             continue;
         }
         if (!AttributeHelper.HasAttribute (property, Constants.OBJECTIVE_C_IVAR)) {
             continue;
         }
         properties.Add (property);
     }
     return properties;
 }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:14,代码来源:ObjectiveCWriter.cs

示例12: CreateEqualsOverrides

		List<MethodDeclaration> CreateEqualsOverrides(IType currentClass)
		{
			List<MethodDeclaration> methods = new List<MethodDeclaration>();
			
			AstType boolReference = ConvertType(KnownTypeCode.Boolean);
			AstType objectReference = ConvertType(KnownTypeCode.Object);
			
			MethodDeclaration method = new MethodDeclaration {
				Name = "Equals",
				Modifiers = Modifiers.Public | Modifiers.Override,
				ReturnType = boolReference
			};
			method.Parameters.Add(new ParameterDeclaration(objectReference, "obj"));
			method.Body = new BlockStatement();
			
			AstType currentType = ConvertType(currentClass);
			Expression expr = null;
			
			if (currentClass.Kind == TypeKind.Struct) {
				// return obj is CurrentType && Equals((CurrentType)obj);
				expr = new IsExpression() {
					Expression = new IdentifierExpression("obj"),
					Type = currentType.Clone()
				};
				expr = new ParenthesizedExpression(expr);
				expr = new BinaryOperatorExpression(
					expr, BinaryOperatorType.ConditionalAnd,
					new InvocationExpression(
						new IdentifierExpression("Equals"),
						new List<Expression> {
							new CastExpression(currentType.Clone(), new IdentifierExpression("obj"))
						}));
				method.Body.Add(new ReturnStatement(expr));
				
				methods.Add(method);
				
				// IEquatable implementation:
				method = new MethodDeclaration {
					Name = "Equals",
					Modifiers = Modifiers.Public,
					ReturnType = boolReference.Clone()
				};
				method.Parameters.Add(new ParameterDeclaration(currentType, "other"));
				method.Body = new BlockStatement();
			} else {
				method.Body.Add(new VariableDeclarationStatement(
					currentType.Clone(),
					"other",
					new IdentifierExpression("obj").CastAs(currentType.Clone())));
				method.Body.Add(new IfElseStatement(
					new BinaryOperatorExpression(new IdentifierExpression("other"), BinaryOperatorType.Equality, new PrimitiveExpression(null, "null")),
					new ReturnStatement(new PrimitiveExpression(false, "false"))));
			}
			
			expr = null;
			foreach (IField field in currentClass.GetFields()) {
				if (field.IsStatic) continue;
				
				if (expr == null) {
					expr = TestEquality("other", field);
				} else {
					expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ConditionalAnd,
					                                    TestEquality("other", field));
				}
			}
			
			foreach (IProperty property in currentClass.GetProperties()) {
				if (property.IsStatic || !property.IsAutoImplemented()) continue;
				if (expr == null) {
					expr = TestEquality("other", property);
				} else {
					expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ConditionalAnd,
					                                    TestEquality("other", property));
				}
			}
			
			method.Body.Add(new ReturnStatement(expr ?? new PrimitiveExpression(true, "true")));
			
			methods.Add(method);
			
			return methods;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:82,代码来源:OverrideEqualsGetHashCodeMethodsDialog.xaml.cs

示例13: CreateIndexerParameterDataProvider

			public IParameterDataProvider CreateIndexerParameterDataProvider(int startOffset, IType type, AstNode resolvedNode)
			{
				Assert.IsTrue(type.Kind != TypeKind.Unknown);
				if (type.Kind == TypeKind.Array)
					return new ArrayProvider ();
				return new IndexerProvider () {
					Data = type.GetProperties (p => p.IsIndexer)
				};
			}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:9,代码来源:ParameterCompletionTests.cs

示例14: GetObjectChildren

		IEnumerable<TreeNode> GetObjectChildren(IType shownType)
		{
			IEnumerable<IMember> fields = shownType.GetFields(f => !f.IsConst, GetMemberOptions.IgnoreInheritedMembers);
			IEnumerable<IMember> properties = shownType.GetProperties(p => p.CanGet && p.Parameters.Count == 0, GetMemberOptions.IgnoreInheritedMembers);
			IEnumerable<IMember> fieldsAndProperties = fields.Concat(properties).ToList();
			
			IEnumerable<IMember> publicStatic      = fieldsAndProperties.Where(m =>  m.IsPublic &&  m.IsStatic);
			IEnumerable<IMember> publicInstance    = fieldsAndProperties.Where(m =>  m.IsPublic && !m.IsStatic);
			IEnumerable<IMember> nonPublicStatic   = fieldsAndProperties.Where(m => !m.IsPublic &&  m.IsStatic);
			IEnumerable<IMember> nonPublicInstance = fieldsAndProperties.Where(m => !m.IsPublic && !m.IsStatic);
			
			IType baseType = shownType.DirectBaseTypes.FirstOrDefault(t => t.Kind != TypeKind.Interface);
			if (baseType != null) {
				yield return new TreeNode(
					ClassBrowserIconService.Class,
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"),
					baseType.Name,
					string.Empty,
					baseType.FullName == "System.Object" ? (Func<IEnumerable<TreeNode>>) null : () => GetObjectChildren(baseType)
				);
			}
			
			if (nonPublicInstance.Any()) {
				yield return new TreeNode(
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicMembers}"),
					() => GetMembers(nonPublicInstance)
				);
			}
			
			if (publicStatic.Any() || nonPublicStatic.Any()) {
				yield return new TreeNode(
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.StaticMembers}"),
					() => {
						var children = GetMembers(publicStatic).ToList();
						if (nonPublicStatic.Any()) {
							children.Insert(0, new TreeNode(
								StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicStaticMembers}"),
								() => GetMembers(nonPublicStatic)
							));
						}
						return children;
					}
				);
			}
			
			// IList
			if (shownType.GetAllBaseTypeDefinitions().Any(t => t.IsKnownType(KnownTypeCode.IList))) {
				yield return new TreeNode(
					"IList",
					() => GetIListChildren(GetValue)
				);
			}
			
			// IEnumberable<T> (pottentially several of them)
			var ienumerableTypes = shownType.GetAllBaseTypes().OfType<ParameterizedType>().Where(p => p.IsKnownType(KnownTypeCode.IEnumerableOfT));
			foreach(var ienumerableType in ienumerableTypes) {
				var ienumerableTypeCopy = ienumerableType;
				yield return new TreeNode(
					null,
					ienumerableType.Name,
					ienumerableType.ReflectionName,
					string.Empty,
					() => {
						// Note that this will bind to the current content forever and it will not reeveluate
						Value list = CreateListFromIEnumerable(ienumerableTypeCopy, GetValue()).GetPermanentReferenceOfHeapValue();
						return GetIListChildren(() => list);
					}
				);
			}
			
			foreach(TreeNode node in GetMembers(publicInstance)) {
				yield return node;
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:74,代码来源:ValueNode.cs

示例15: FindMember

		IMember FindMember(IType type, string propertyName)
		{
			IMember member = type.GetProperties(p => p.Name == propertyName).FirstOrDefault();
			if (member != null)
				return member;
			return type.GetEvents(e => e.Name == propertyName).FirstOrDefault();
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:7,代码来源:XamlAstResolver.cs


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