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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:04:22+00:00 2026-05-28T14:04:22+00:00

(using vb.Net 4.0) Say you have an object whose graph is fairly complex –

  • 0

(using vb.Net 4.0) Say you have an object whose graph is fairly complex – it has properties, arrays and other collections, subclasses with their own properties and collections, etc. I want to fully traverse the entire object graph and find all instances of a particular type T, to then perform a particular operation on these instances. Is there a bulletproof way to perform a full traversal of the object graph? Even with reflection, this seems a difficult task that is prone to error.

I was wondering about binary serialization, since that seems to clone an object, no matter how complicated, in a fairly robust manner. Is there any way to modify that technique, such that instead of serializing it instead returns a list of references to all sub-objects of given type T? But that is just pure speculation, I’m open to any feasible solution.

  • 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-28T14:04:23+00:00Added an answer on May 28, 2026 at 2:04 pm

    Well I figured out a method, though it probably isn’t the best. Because my object’s graph was pretty nested & complex, I decided to rely on binary serialization, since in my (limited) experience it offers the most thorough & robust graph traversal. The downside is binary serialization can impact performance significantly, but after benchmarking it doesn’t appear to be the limiting factor for my particular situation.

    Basically, I have my type T implement ISerializable, then I can handle the post-serialization by adding to the class:

     Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo,
                               ByVal context As System.Runtime.Serialization.StreamingContext)
    

    Another way (without implementing Iserializable) is create a post-serialized method with the “OnDeserialized” attribute.

    Anyways, you can put info into the streamingContext object, which I used to describe the operation I want performed on the Type T instances. So basically, serialize the parent object, which will find and serialize all sub-objects of type T, which can then be coded to perform any desired task upon deserialization. Going forward, you then deal only with the serialized objects.

    Obviously, serialization can have complications, and this method won’t work for all situations. Pretty inelegant performance-wise too. But I needed a hassle-free & thorough object graph traversal so there you go.

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

Sidebar

Related Questions

I'm using .NET 3.5. Say I have a method that accesses a specific file,
Say you create a form using ASP.NET MVC that has a dynamic number of
I am using VB.Net. I have an object class called clsA(of T as clsB).
I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object
I'm using MVVM in WPF in C#.NET. Say I have the following example model:
I'm working on an ASP.NET MVC app (using MVC3 RC2). Say I have 2
I have an object, that has many properties but the only two to worry
Using .NET 4, C# Let's say I have class Info that extends CustomTypeDescriptor .
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
Let's say I have 4 arrays: [1,3,54,4] [54,2,3,9] [3,2,9,54] [54,8,4,3] I need to get

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.