16,007,126 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13348717 (Top 5 by date)
Member 13348717
8-Aug-17 22:19pm
View
I accepted the first XSLT solution as I liked the idea of being able to keep the translation separate to the code. Don't know why but it seemed a more elegant solution to me rather than having to expose more properties than I really needed to. Now comes the hard part of actually implementing it and adapting is across my range of classes :)
Member 13348717
8-Aug-17 22:16pm
View
Has been interesting following this conversation. My initial requirement was just serialization and I chose XML because it seemed easiest but I will also have a need for JSON ( I think as the project will move forward with a web data requirement as well ). All this of course means I need to do a lot more reading
Member 13348717
8-Aug-17 22:15pm
View
I need access to the class 2 instances. I really only need access to the ID members for serialization purposes. The issue is that the ID properties have t be public to be serialized meaning I have to have both the instance and the separate property declared as public.
Member 13348717
7-Aug-17 3:33am
View
Thanks Bill,
Unless I am missing something, this approach then introduces a problem with keeping the ID and object list in sync
Both lists must be exposed publicly to allow access to the member lists. the List<class2> property for access to the actual data and List<class2id> property so that the ID lists gets serialized. Although there may be a separate public method that add new or existing Class2 objects as list members under Class1, there is nothing to prevent developers (either purposely or mistakenly) from adding items to 1 of these lists independently which will then throw the lists (and subsequent serialization) out of sync. I tried adding code originally to sync the ID list with the object list and tag it with the [OnSerialized] attribute but it never fired. I could also place code within the Serialize method to sync these properties but in the real world application (not just the example above) this involves numerous nested iteration loops to achieve this syncing.
Of course nested iterations must then be performed to resync the object lists with the deserialized ID lists once the XML has been deserialized.
Member 13348717
7-Aug-17 2:33am
View
Thanks Graeme for the detailed response and the references. I am picking through it now to try to adapt it to meet requirements.
The issue I have is with the Material member property object, bnot the root Categoty class. When the Category objects get serialized, the Categories[x].Items[y].Materials list members that get serialized are the ones that I need just the ID, not the full Material class object.
I have edited the original question to show the XML I was getting with the original code and also what I am trying to achieve. I am trying to adapt your solution from working on a root object ( Category ) the a member property within a list item ( Category[x].Items[y].Material ) but not entirely sure how to make this work on a member rather than the root class.