[英]How to check whether an object has certain method/property of particular type within it?
I have DInfo class present in two different namespaces ie ABC.Domain
and ABC.Common
I am getting xml body as a record from database from which I am deserializing to respective type. 我在两个不同的命名空间(即ABC.Domain
和ABC.Common
存在DInfo类。我从数据库ABC.Common
xml正文作为记录进行记录,从该记录中我反序列化为相应的类型。 I have to find out all the records which are using properties with name/names of properties of type ABC.Domain.DInfo
and just ignore of type ABC.Common.DInfo
我必须找出所有使用属性的名称/名称为ABC.Domain.DInfo
类型的属性的ABC.Domain.DInfo
而忽略ABC.Common.DInfo
类型的ABC.Common.DInfo
As a I am getting record of type IEvent ie may be FSubmitted
or GSubmitted
作为我正在获取IEvent类型的记录,即可能是FSubmitted
或GSubmitted
namespace ABC.Domain
{
public class DInfo
{
public DateTime? Date { get; set; }
public URef User { get; set; }
public Decimal? L1 { get; set; }
public Decimal? L2 { get; set; }
}
}
namespace ABC.Common
{
public class DInfo
{
public DateTime? Date { get; set; }
public URef User { get; set; }
public Decimal? L1 { get; set; }
public Decimal? L2 { get; set; }
}
}
public class Event : IEvent
{
public Guid Id { get; set; }
public Event() { }
public int Number { get; set; }
}
public interface IEvent : IRBase
{
Guid Id { get; set; }
int Number { get; set; }
}
public interface IRBase
{
string RUser { get; set; }
string Sub { get; set; }
}
public abstract class REventBase : Event
{
public Guid Id { get; set; }
}
public class FSubmitted : REventBase
{
public RSummary NewForm { get; set; }
}
public class GSubmitted : REventBase
{
public FRef NewForm { get; set; }
}
public class RSummary
{
public Guid ID { get; set; }
public FRef FRef { get; set; }
public ABC.Common.DInfo Submitted { get; set; }
public ABC.Common.DInfo Saved { get; set; }
public ABC.Domain.DInfo Signed { get; set; }
}
public class FRef : NIdentifier<Guid>
{
public FormType Type { get; set; }
public Version Version { get; set; }
public ABC.Common.DInfo Submitted { get; set; }
public ABC.Domain.DInfo Saved { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.