Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:31:09+00:00 2026-06-05T22:31:09+00:00

Okay, so I want to have a generic method that can read data from

  • 0

Okay, so I want to have a generic method that can read data from an unknown data class given a razor type property pointer.

I.E. I want to be able to pass in a string containing a template and a object and then extract the data from the object given the string in the template.

String template = "@Model.Basket";
var results = parse(template, data);

the parse method should have no knowledge of the specific model being passed to it, so its method signature should be something like:

public var parse(String template, object model)

where data is something like

public class Receipt
{
    public String Firstname { get; set; }
    public String Surname { get; set; }
    public DateTime TransactionDateTime { get; set; }
    public Boolean ReturnCustomer { get; set; }
    public LineItem[] Basket { get; set; }


    public class LineItem
    {
        public Product product { get; set; }
        public int Units { get; set; }

        public class Product
        {
            public int ProductId { get; set; }
            public String ProductName { get; set; }
            public double Cost { get; set; }
        }
    }
}

In this case parse should return an array of line items, but if my template was equal to “@Model.Firstname” it should simply return a string containing the the name stored in that property.

Does anyone have any good ideas.

Note that for this given solution, I can not make use of the Razor engine as my templates are not in a format that the razor engine can understand.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:31:11+00:00Added an answer on June 5, 2026 at 10:31 pm

    If you want to do this, you want to look at the System.Reflection namespace – in particular, PropertyInfo. I’m not sure that it is a good idea, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I want to have an app that takes phone numbers from an online
Okay, so I have a UITableView that I want to apply themes to. I
Okay all, I have a form that I want users to fill out. When
I want a generic function that would work with types that have Top ,
Okay, let's say that I have b.exe, which takes a string argument. I want
I have a generic Repository<T> class I want to use with an ObjectDataSource. Repository<T>
We have XML generated from an external program that needs to be read into
Okay I have the following problem. I want to get the current dateTime and
Okay. So I have about 250,000 high resolution images. What I want to do
Okay so I want to make an application that launches other applications. However, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.