コード例 #1
0
		public IProperty ReadProperty(PropertyDefinition property, ITypeDefinition parentType, EntityType propertyType = EntityType.Property)
		{
			if (property == null)
				throw new ArgumentNullException("property");
			if (parentType == null)
				throw new ArgumentNullException("parentType");
			DefaultProperty p = new DefaultProperty(parentType, property.Name);
			p.EntityType = propertyType;
			TranslateModifiers(property.GetMethod ?? property.SetMethod, p);
			p.ReturnType = ReadTypeReference(property.PropertyType, typeAttributes: property, entity: p);
			
			p.Getter = ReadAccessor(property.GetMethod);
			p.Setter = ReadAccessor(property.SetMethod);
			
			if (property.HasParameters) {
				foreach (ParameterDefinition par in property.Parameters) {
					p.Parameters.Add(ReadParameter(par, parentMember: p));
				}
			}
			AddAttributes(property, p);
			
			FinishReadMember(p);
			return p;
		}
コード例 #2
0
ファイル: ArrayType.cs プロジェクト: hduregger/monodevelop
		public override IEnumerable<IProperty> GetProperties(ITypeResolveContext context, Predicate<IProperty> filter = null)
		{
			ITypeDefinition arrayDef = systemArray.Resolve(context) as ITypeDefinition;
			if (arrayDef != null) {
				foreach (IProperty p in arrayDef.GetProperties(context, filter)) {
					yield return p;
				}
				DefaultProperty indexer = new DefaultProperty(arrayDef, "Items") {
					EntityType = EntityType.Indexer,
					ReturnType = elementType,
					Accessibility = Accessibility.Public,
					Getter = DefaultAccessor.GetFromAccessibility(Accessibility.Public),
					Setter = DefaultAccessor.GetFromAccessibility(Accessibility.Public),
					IsSynthetic = true
				};
				for (int i = 0; i < dimensions; i++) {
					indexer.Parameters.Add(indexerParam);
				}
				indexer.Freeze();
				if (filter == null || filter(indexer)) {
					yield return indexer;
				}
			}
		}