mardi 1 septembre 2015

c# Get Class Propertiy List With String Value

I have a class following message.I need get property list from here of runtime with string.For exmaple

var classObject = System.Reflection.Assembly.GetExecutingAssembly().CreateInstance("edifactProdat.PRODAT");
var unhTypeNames = classObject.GetType().GetProperty("UNH").GetType().GetProperties();

But this code not return my UNH object properties,its return all properties.

Pls help

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace edifactProdat
{
    public class PRODAT
    {
        public UNH UNH { get; set; }
        public BGM BGM { get; set; }
        public DTM DTM { get; set; }
        public NAD NAD { get; set; }
    }

    public class UNH
    {
        public string MessageReferenceNumber { get; set; }
        public string MessageTypeIdentifier { get; set; }
        public string MessageTypeVersionNumber { get; set; }
        public string MessageTypeReleaseNumber { get; set; }
        public string ControllingAgency { get; set; }
        public string AssociationAssignedCode { get; set; }
    }

    public class BGM
    {
        public string DocumentMessageNameCoded { get; set; }
        public string CodeListQualifier { get; set; }
        public string CodeListResponsibleAgencyCoded { get; set; }
        public string DocumentMessageNumber { get; set; }
        public string MessageFunctionCoded { get; set; }
    }

    public class DTM
    {
        public string DateTimePeriodQualifier { get; set; }
        public string DateTimePeriod { get; set; }
        public string DateTimePeriodFormatQualifier { get; set; }
    }

    public class NAD
    {
        public string PartyQualifier { get; set; }
        public string PartyIdIdentification { get; set; }
        public string CodeListQualifier { get; set; }
        public string CodeListResponsibleAgencyCoded { get; set; }
    }
}





Aucun commentaire:

Enregistrer un commentaire