检索自定义属性的信息
来源:互联网 发布:insert mysql 编辑:程序博客网 时间:2024/06/03 23:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace ConsoleApplication1
{
[Developer("Bill","3")]
class Program
{
static void Main(string[] args)
{
//Call function to get and display the attribute.
GetAttribute(typeof(Program));
}
public static void GetAttribute(Type type)
{
//throw new NotImplementedException();
DeveloperAttribute MyAttribute =
(DeveloperAttribute)Attribute.GetCustomAttribute(type, typeof(DeveloperAttribute));
if(MyAttribute==null)
{
Console.WriteLine("This attribute was not found.");
}
Console.WriteLine("The name attribute is :{0}.",MyAttribute.Name);
Console.WriteLine("the level attribute is :{0}.", MyAttribute.Level);
Console.WriteLine("the reviewed attribute is :{0}.", MyAttribute.Reviewed);
Console.ReadKey();
}
}
class Test
{
public interface IObservableData<T> where T : class
{
Task<T> GetData();
}
}
[AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public class DeveloperAttribute : Attribute
{
//Private fields
private string name;
private string level;
private bool reviewed;
//This constructor defines two required parameters
public DeveloperAttribute(string name, string level)
{
this.name = name;
this.level = level;
this.reviewed = false;
}
//Define Name property.
//This is a read-only attribute
public virtual string Name
{
get
{
return name;
}
}
public virtual string Level
{
get { return level; }
}
//this is a read/write attribute
public virtual bool Reviewed
{
get { return reviewed; }
set { reviewed = value; }
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace ConsoleApplication1
{
[Developer("Bill","3")]
class Program
{
static void Main(string[] args)
{
//Call function to get and display the attribute.
GetAttribute(typeof(Program));
}
public static void GetAttribute(Type type)
{
//throw new NotImplementedException();
DeveloperAttribute MyAttribute =
(DeveloperAttribute)Attribute.GetCustomAttribute(type, typeof(DeveloperAttribute));
if(MyAttribute==null)
{
Console.WriteLine("This attribute was not found.");
}
Console.WriteLine("The name attribute is :{0}.",MyAttribute.Name);
Console.WriteLine("the level attribute is :{0}.", MyAttribute.Level);
Console.WriteLine("the reviewed attribute is :{0}.", MyAttribute.Reviewed);
Console.ReadKey();
}
}
class Test
{
public interface IObservableData<T> where T : class
{
Task<T> GetData();
}
}
[AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public class DeveloperAttribute : Attribute
{
//Private fields
private string name;
private string level;
private bool reviewed;
//This constructor defines two required parameters
public DeveloperAttribute(string name, string level)
{
this.name = name;
this.level = level;
this.reviewed = false;
}
//Define Name property.
//This is a read-only attribute
public virtual string Name
{
get
{
return name;
}
}
public virtual string Level
{
get { return level; }
}
//this is a read/write attribute
public virtual bool Reviewed
{
get { return reviewed; }
set { reviewed = value; }
}
}
}
1 0
- 检索自定义属性的信息
- 分类信息,商城商品自定义属性设计,数据入库,检索规则
- SharePoint 2013 全文检索的高级搜索里自定义属性检索不出结果
- 自定义属性信息
- 无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性
- 无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性
- 无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性。
- 信息检索领域的会议
- 信息检索的评价指标
- awk应用-信息的检索
- 信息检索的评价指标
- 【信息检索导论】第8章 信息检索的评价
- 信息检索-布尔检索
- 信息检索
- 信息检索
- 信息检索
- 信息检索
- 信息检索
- 小菜鸟初始java项目出错解决思路
- python 恶搞代码
- 浅谈移动应用测试
- python全角和半角之间的转换
- MySQL学习16:多表连接
- 检索自定义属性的信息
- 第六节 运算符与表达式
- Spring in action 03 -- 装配 Bean(xml配置)
- 定义自己的operator new和operator delete时注意点
- c#上传文件到服务器
- 组合数学证明
- OS X 和 IOS 的图像处理框架 (Core Image)
- 第13周项目1 (4)
- iOS 不同界面(ViewController)之间传值