Serialization and Enumerators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmV1YmVu?=

    #1

    Serialization and Enumerators

    Hi,
    I've been trying to rewrite some code which can run as a single method so
    that I can save its state - that way I can resume processing the data when I
    start the program back up. The data isn't actually stored in an array, due to
    memory issues, instead it's generated at runtime by an Enumerator (I used the
    yield statement to generate it). The idea was that I could serialize the
    Enumerator and save it, so I wouldn't have to regenerate the data. The
    problem is that the generated Enumerator object isn't serializable, and
    doesn't have any constructors (public or private), which means I can't
    perform custom serialization, since I have no way of recreating the object. I
    know that if this works, it would be of great use to many people.

    Does anyone know how to serialize custom enumerators?
    Please reply if you have any ideas at all - I'm really at a dead end.
  • Marc Gravell

    #2
    Re: Serialization and Enumerators

    An enumerator doesn't really *hold* state - it simply walks over it... I'm
    not sure that this is the right approach.

    First question: have you looked at XmlSerializer, BinaryFormatter , and/or
    DataContractSer ializer; serialization is built deeply into the framework -
    you shouldn't have to (or want to) re-invent everything here...

    If you can describe what problem(s) you had/have with any of the above, we
    may be able to help...

    Marc


    Comment

    • Marc Gravell

      #3
      Re: Serialization and Enumerators

      You know what I mean ;-p

      It doesn't (as a rule) hold the actual state of the underlying objects...

      Marc


      Comment

      Working...