473,384 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,384 software developers and data experts.

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.
Feb 21 '08 #1
2 1179
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
DataContractSerializer; 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
Feb 21 '08 #2
You know what I mean ;-p

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

Marc
Feb 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob Shafer | last post by:
Is it possible to create dynamic enumerators in Visual Basic .Net? For example, an enumurator that provides a dropdown of available SQL servers?
6
by: Matt Taylor | last post by:
I'm trying to write an x86 assembler in C++ for use in a debugger. What I'd like do is to use template specialization to prevent invalid combinations from compiling. Thus one could not accidentally...
1
by: Dave | last post by:
I have several enums that are generated by a code generator (and I have no control over the code generator), the problem is that the names are pretty long enum VeryLoooooooongEnumName {...
2
by: Peter Rilling | last post by:
A design pattern question. As you know, an enumerator in .NET is broken into two interface (IEnumerable and IEnumerator). Is there a benefit in having two interfaces? Why not just have the...
2
by: Andrew Quine | last post by:
Hi Short one: looking for a good example and an explanation of such enumerators. I know MessageEnumerator and ResourceReader do this, for example, but what is the implementation of the...
5
by: juan | last post by:
hi i have an arraylist that has doctor objects with various properties, members and methods. i want to enumerate this arraylist object. but i dont understand how. this is what i have done ...
6
by: Tim Davis | last post by:
I am currently writing a class which I would like to make "enumerable" by inheriting from IEnumerable. The documentation says that the IEnumerator.MoveNext method should throw an exception if the...
1
muaddubby
by: muaddubby | last post by:
Hello all and happy new year. I've seen several posts floating around asking about string enumerators in C#, and generally speaking, they're not supported. I've come up with a way around it...
1
nitindel
by: nitindel | last post by:
Hi All, May i have an in depth article of enumerators in C#..that explains the Enumerators in C# very precisely.... Thanks, Nitin
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.