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 7667573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:08:21+00:00 2026-05-31T15:08:21+00:00

As a part of my bigger project I’m developing a parser for the web,

  • 0

As a part of my bigger project I’m developing a parser for the web, which, according to predefined rules, will get the data from web pages and put it into objects. I write in C# using .Net 4.0 and SQL Server 2008.

Idea is like this:

Suppose I have a Car { Power, Weight, Price } object (which is a POCO used in EF to store data).
I create rules for my parser, so when it scan some site, it will try to fill properties of the object.

For example: Car { Power=100Hp, Weight=1000kg, Price=7000$ }
All of this is working. But since all sites are different and even on one site data can be structured in a different way, I need some way to verify my parsing rules.

I want to create a tester app, that will:

  1. Take list of URLs of items. Download them, store in some format.
  2. I will manually check which properties of items are parsed correctly and mark them as correct.
  3. Will run tester in verification mode. Where it should again load everything from the net and now compare with the data that I marked as correct.

This way I can have a sort of unit tests for rules, while I improve them.

Now goes the actual question: in order to implement all of this, I don’t want to modify my entities, I would like to have some wrapper like:

Car { 
   Power { Value, IsCorrect}, 
   Weight {Value, IsCorrect}, 
   Price {Value, IsCorrect}}

So all my existing code can work as before, and only my test code, can use that annotation info. Also, of course, I want this info to be serializable, either to the database or XML.

Right now my general idea is to serialize Car into Xml, and then manually add annotation properties, and check them. By manually here I mean by using XmlDocument methods. This should work, but I did not come to a conclusion on how to store and access the annotations in memory (I don’t like the idea to do all validation via XmlDocument)

Perhaps, in some dynamic language, like javascript I would simply add annotations like this

Car c = { Power = 1, Weight=2 ...};
c["Power_IsCorrect"] = true;
c["Weight_IsCorrect"] = true;
///... etc

I can’t imagine somehting like this in C# 🙁

  • 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-05-31T15:08:23+00:00Added an answer on May 31, 2026 at 3:08 pm

    You could create a little wrapper class that either uses strings to identify the properties or expression trees.

    Example for a class that uses strings:

    class AnnotatedObject<T>
    {
        private Dictionary<string, bool> _propertyMap =
            new Dictionary<string, bool>();
    
        public AnnotatedObject(T originalObject) { OriginalObject = originalObject; }
    
        public T OriginalObject { get; private set; }
        public bool IsCorrect[string property]
        {
            get
            {
                bool result;
                if(!_propertyMap.TryGetValue(property, out result))
                    result = false;
                return result;
            }
            set { _propertyMap[property] = value; }
        }
    }
    

    You could then use it like this:

    var annotatedCar = new AnnotatedObject<Car>(car);
    annotatedCar.IsCorrect["Power"] = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I copied a part of a bigger project i'm working on, I didn't wrote
I'm currently coding, as the part of a bigger project, a webmail client. I'd
I have a reference to a XML node which is part of a bigger
I have a few issues with the following php functions (part of a bigger
Part of my app caches web pages for offline viewing. To do that, I
Part of my code I get the OuterHTML propery <LI onclick=TabClicked(this, 'SearchName', 'TabGroup1');>Name so
Part-time reluctant DBA here. I want to change an existing primary key index from
How would you evaluate project size? Part A: Before you start a project. Part
I have a simple data structure which is serialized and deserialized. Upon deserialization, I
this script is a part of a bigger one, when I run this script

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.