mercredi 20 avril 2016

How to check whether an object has certain method/property of particular type within it?

I have DInfo class present in two different namespaces i.e. ABC.Domain and ABC.Common I am getting xml body as a record from database from which I am deserializing to respective type. 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

As a I am getting record of type IEvent i.e may be FSubmitted or 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; }
}





Aucun commentaire:

Enregistrer un commentaire