Update... References in XML?

Sep 6, 2013 at 2:04 AM
I recently updated sharpserializer for my project. I didn't read enough about the changes to know that the XML output is starting to reference the first time a duplicated item shows up instead of simply having it all throughout the output. While I like this change, I have downstream applications that use my output for analyzation of the data. They have already created the interface to the older way of the output. Is there anyway (other than reverting or maintaining two versions of the library) to add a configurable option to the settings that would allow me to output in the old manner as well?

I haven't dug into the code yet, but that's my next step if one of the developers here doesn't respond.

Thanks for your efforts!
Jarvis
Sep 6, 2013 at 2:07 AM
The downstream project is C++ and not using SharpSerializer so that would also be why I need to be able to output in both. I would like to keep the current output, but when I create the file to go to their system I could put it into the old version or something.

I'm trying to dig through the code now to see if I can figure anything out for better suggestion than my generic one above.

Thanks!
Jarvis
Sep 6, 2013 at 2:43 AM
I went from 2.13 to 2.18.
Coordinator
Sep 10, 2013 at 8:56 PM
hi, You mean - you went from v.1.13 not from 2.13

There is a very major difference between v.1.x and v.2.x... but with some changes I have just deactivated the reference caching.

The solution below is more a hack, than a real solution but it should work for complex objects not referencing themself.

1.
Delete _propertyCache from the class PropertyFactory

2.
Delete the following text from the PropertyFactory.CreateProperty()
-            // Search in Cache
-            ReferenceTargetProperty cachedTarget;
-            if (_propertyCache.TryGetValue(value, out cachedTarget))
-            {
-                // Value was already referenced
-                // Its reference will be used
-                cachedTarget.Reference.Count++;
-                referenceTarget.MakeFlatCopyFrom(cachedTarget);
-                return referenceTarget;
-            }
-
-            // Target was not found in cache
-            // it must be created
-
-            // Adding property to cache
3.
and any usings of _propertyCache

4.
From the RootContainer and HelloWorld delete all complex objects referencing itself (or make your own helloworld)

The above changes should deactivate reference caching and maybe could help you further.
Sep 11, 2013 at 2:59 AM
Polo,

I will attempt to build in an option for this to be turned on and off. I think that would be beneficial, do you? Also, you mentioned this is somewhat of a hack... do you have a preferred way of getting this done? I would much rather do the work to be included in the full source rather than having to maintain my own version and merge your changes carefully.

Thanks!

P.S. It was 2.13 to 2.18 according to your files I copy and pasted. :) See the screenshot.
Image

Here's the diff from that screen shot...
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("Polenter - Software Solutions")]
 [assembly: AssemblyProduct("Polenter.SharpSerializer.Compact")]
-[assembly: AssemblyCopyright("Copyright ©  2010, Pawel Idzikowski")]
+[assembly: AssemblyCopyright("Copyright ©  2010-2012, Pawel Idzikowski")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
 //
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
-[assembly: AssemblyVersion("2.13.0.0")]
+[assembly: AssemblyVersion("2.18.0.0")]
 
Coordinator
Sep 11, 2013 at 8:28 PM
I'm not sure if shutting the reference caching off is a such important feature to implement it... You can still make a fork.
Sep 11, 2013 at 11:59 PM
polo,

Okay fair enough. I can understand that to other people not using this as an actual output for 3rd parties to use wouldn't need this. Do you think people only use the serialized objects to go directly back into a C# project?

Is it possible for someone using C++ to use SharpSerializer's dll to retrieve the objects from the XML directly?

Thanks,
Jarvis