Mercurial > hg > Database > Christie-sharp
view Test/RewritingTest/AttributeCheck.cs @ 30:96fc5e71274e
Run HelloWorld
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Apr 2021 22:02:23 +0900 |
parents | 0cd2684e401b |
children |
line wrap: on
line source
using System; using System.Reflection; using Christie_net.annotation; namespace Christie_net { public class AttributeCheck { [Take] private int num = 0; [Peek] public string name = "riono"; [PeekFrom("meme")] protected string nextName = "local"; public AttributeCheck() { nextName = "dsaql"; } private static void Main(string[] args) { AttributeCheck attributeCheck = new AttributeCheck(); foreach (var field in attributeCheck.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Instance)) { // if (attribute.GetType() == typeof(PeekFrom)) { // PeekFrom peekFrom = (PeekFrom) attribute; // // Console.WriteLine("val " + field.GetValue(attributeCheck) ); // } Console.WriteLine("name;" + field.Name + " check;" + Attribute.IsDefined(field, typeof(PeekFrom))); Console.WriteLine("type:" + field.FieldType); if (Attribute.IsDefined(field, typeof(PeekFrom))) { PeekFrom peekFrom = (PeekFrom) field.GetCustomAttribute(typeof(PeekFrom)); Console.WriteLine("param*" + peekFrom.name); } } } } }