C# Portable class library and reflection with nested properties

I would like to know how to set property into a nested class with reflection on Xamarin portable class library.

I am working in a project with reflection on a Xamarin portable class library.

I have this code:

public class Customer {     public string Name { get; set; }     public string FirstName { get; set; }     public int Id { get; set; }         }  public class Invoice {     public string Description { get; set; }     public int Id { get; set; }      public Customer Person { get; set; } } 

on the other hand I have this function:

    public void TestCode()     {         var myCustomer = new Customer()         {             FirstName = "qwerty",             Name = "asdfgh",             Id = 1         };          var myInvoice = new Invoice()         {             Description = "chocos",             Id = 1,             Person = myCustomer,         };          var properties = myInvoice.GetType().GetRuntimeProperties();           foreach (var property in properties)         {             var value = property.GetValue(myInvoice);             if (value != null)             {                 if (property.PropertyType.IsGenericParameter)                 {                     //Have Generic parameters                 }                 else                 {                     //How I Know if my class == person???                 }             }         }     } 

When I have the string property and I use (for example) GetRuntimeProperties() this function returns about 8 properties so the question is:

How I know if the property it my class?

Other example: How I get person.Name value from the Invoice?

Thank you

Replay

Category: c# Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.291 (s). 12 q(s)