Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Saving Part of Class to a File...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Location
    My World
    Posts
    77

    Resolved [RESOLVED] [2005] Saving Part of Class to a File...

    Hello all. I'm trying to finish up the last finishing touches on this project i've been working on. I'm reworking my file saving method to use a binary method of saving rather than simply serializing my class as I was doing before.

    My problem comes in when I get into the more complex areas of my class. Up until this point i'm basically using a FileStream to create a file for saving to, and then saving out all of the info in my class by looping through all the objects that have my class type in the app. So far it's been pretty easy b/c i've only been saving integers and strings.

    To begin let me explain my basic class structure for the app:
    Code:
    Namespace Crystal
      Enum ColumnType
      Enum PriorityType
    
      Public Class Design
    
      Public Class Field
          Property Columns as ArrayList
          Property Name as String
          Property Nodes as ArrayList
      Public Class FieldCollection
          Inherits CollectionBase
      Public Class FieldColumn
      Public Class FieldNode
          Property FieldParent as Field
          Property ListItemInfo as ListViewItem
          Property CategoryList as String
          Property Notes as String
          Property Images as ArrayList
      Public Class FieldNodeCollection
          Inherits CollectionBase
    
      Public Class Category
      Public Class CategoryCollection
          Inherits CollectionBase
      Public Class Image
    End Namespace
    I won't trouble you with the full source, b/c i don't think its necessary. Just so you understand the hierarchy, i'm trying now to save a FieldNode, that is i'm trying to save:

    FieldCollection-->Field-->FieldNodeCollection-->FieldNode

    I'm not sure whether or not I should save the actual full FieldParent field that the first property is referring to within my FieldNode, or whether I should some how save a type of reference to the Field it refers to in the program. The latter seems improbable to me since VB doesn't seem to use pointers as a language like c++ would. Does anyone have any ideas how I could save a parent property that is meant to reference a Field object inside of a FieldNode in my app?

    Thanks in advance.
    Let your mind run free and your sword will follow.

  2. #2
    Frenzied Member ntg's Avatar
    Join Date
    Sep 2004
    Posts
    1,449

    Re: [2005] Saving Part of Class to a File...

    It's late and I'm confused so this may not make sense. How about adding string properties ID and FieldParentID to the FieldNode class? You can then recreate the Field reference at runtime. I'm assuming that you will recreate all FieldNode objects starting from FieldNode that has no parent.
    "Feel the force...read the source..."
    Utilities: POPFileDebugViewProcess ExplorerWiresharkKeePassUltraVNCPic2Ascii
    .Net tools & open source: DotNetNukelog4NetCLRProfiler
    My open source projects: Thales SimulatorEFT CalculatorSystem Info ReporterVSS2SVNIBAN Functions
    Customer quote: "If the server has a RAID array, why should we bother with backups?"
    Programmer quote: "I never comment my code. Something that is hard to write should be impossible to comprehend."
    Ignorant quote: "I have no respect for universities, as they teach not practicle stuff, and charge money for"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Location
    My World
    Posts
    77

    Re: [2005] Saving Part of Class to a File...

    Actually, i'm starting with the fields and going inward with for loops to save the data down to the nodes within the field. I guess this means that I would have to wait to assign each of the parent references within the nodes until all the fields have been recreated when I load my file back into the program. That way it won't try to put a field in for the parent property that hasn't been created yet.
    Let your mind run free and your sword will follow.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Location
    My World
    Posts
    77

    Re: [2005] Saving Part of Class to a File...

    Come to think of it though, all of the nodes that i'm saving within the fields will all have a field parent of the current field that i'm saving, so all I really have to do is keep track of that parent when i'm loading the file into the program and loop through the nodes assigning each one's parent field the value of the field that was just loaded into the program. I know this probably sounds a little confusing, but I think i've solved my own problem. Thanks guys, you've been a big help!
    Let your mind run free and your sword will follow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width