Search Results

Search found 1974 results on 79 pages for 'mfc serialization'.

Page 1/79 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • XML Serialization and Soap Serialization

    - by Costa
    Hi I think even if we will not need interoperability between applications, and even we do not communicate with web services, it is easier to serialize using SoapFormatter than XmlSerializer because SOAP will serialize the private members by default, while XmlSerializer will work on public properties and fields. actually I cannot find a reason for using XmlSerializer, do I miss something? what is disadvantages of SoapFormatter. or what is advantage of XML serialization over Soap? (xsd) thanks

    Read the article

  • Binary serialization/de-serialization in C++ and C#

    - by 6pack kid
    Hello. I am working on a distributed application which has two components. One is written in standard C++ (not managed C++) and the other one is written in C#. Both are communicating via a message bus. I have a situation in which I need to pass objects from C++ to C# application and for this I need to serialize those objects in C++ and de-serialize them in C# (something like marshaling/un-marshaling in .NET). I need to perform this serialization in binary and not in XML (due to performance reasons). I have used Boost.Serialization to do this when both ends were implemented in C++ but now that I have a .NET application on one end, Boost.Serialization is not a viable solution. I am looking for a solution that allows me to perform (de)serialization across C++ and .NET boundary i.e., cross platform binary serialization. I know I can implement the (de)serialization code in a C++ dll and use P/Invoke in the .NET application, but I want to keep that as a last resort. Also, I want to know if I use some standard like gzip, will that be efficient? Are there any other alternatives to gzip? What are the pros/cons of them? Thanks

    Read the article

  • Insert some data at later point once serialization(binary serialization) is done for a class

    - by coolcake
    My application is written in C# and I am a newbie to C#. I am facing with a problem during serialization. The problem is as follows. There are many classes in my project and when serialization is called on one of the main class object it serializes itself and during this process many of the member objects are also get serialized. This whole serialization is done in to a file with extension say ".bin". This bin file size should be of size max 20MB. In this process of serialization one of my other class also gets serialized to a stream, this class is having a big array. The size of this array or list can be of 80 MB or more. So during serialization i have serialize all the objects other than this array and depending upon the size left in the 20MB I need to add in between the serialization the number of array elements which can fit in the remaining memory. For the other array elements left out I have to create a similar kind of .bin file with all the objects serialized and in between need to insert the number of array elements that can fit there. The main problem here is the array elements get inserted at runtime and this list keeps on increasing. So i should be creating .bin files continuously until my application runs. Any ideas how can i implement a solution for this problem? Thanks in Advance.

    Read the article

  • .NET XML serialization

    - by ShdNx
    I would like to serialize and deserialize mixed data into XML. After some searches I found out that there were two ways of doing it: System.Runtime.Serialization.Formatters.Soap.SoapFormatter and System.Xml.Serialization.XmlSerializer. However, neither turned out to match my requirements, since: SoapFormatter doesn't support serialization of generic types XmlSerializer refuses to serialize types that implement IDictionary, not to mention that it's far less easy-to-use than "normal" serialization (e.g. see this SO question) I'm wondering if there exists an implementation that doesn't have these limitations? I have found attempts (for example CustomXmlSerializer and YAXLib as suggested in a related SO question), but they don't seem to work either. I was thinking about writing such serializer myself (though it certainly doesn't seem to be a very easy task), but then I find myself limited by the CLR, as I cannot create object instances of types that won't have a paramaterless constructor, even if I'm using reflection. I recall having read somewhere that implementations in System.Runtime.Serialization somehow bypass the normal object creation mechanism when deserializing objects, though I'm not sure. Any hints of how could this be done? Could somebody please point me to the right direction with this?

    Read the article

  • Qt/MFC Migration Framework tool: properly exiting DLL?

    - by User
    I'm using the Qt/MFC Migration Framework tool following this example: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html The dll I build is loaded by a 3rd party MFC-based application. The 3rd party app basically calls one of my exported DLL functions to startup my plugin and another function to shutdown my application. Currently I'm doing nothing in my shutdown function. When I load my DLL in the 3rd party app the startup function is called and my DLL starts successfully and I can see my message box. However if I shutdown my plugin and then try to start it again I get the following error: Debug Error! Program: <my 3rd party app> Module: 4.7.1 File: global\qglobal.cpp Line: 2262 ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file kernel\qwidget.cpp line 1233 (Press Retry to debug the application) Abort Retry Ignore This makes me think I'm not doing something to properly shutdown my plugin. What do I need to do to shut it down properly? UPDATE: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-walkthrough.html says: The DLL also has to make sure that it can be loaded together with other Qt based DLLs in the same process (in which case a QApplication object will probably exist already), and that the DLL that creates the QApplication object remains loaded in memory to avoid other DLLs using memory that is no longer available to the process. So I wonder if there is some problem where I need to somehow keep the original DLL loaded no matter what?

    Read the article

  • MFC SDI Application without a default "New Document" on Startup

    - by Jd
    My application is an SDI with multiple views. By default, it creates a new document when the application starts. I want to modify this behavior so that a new document is created only when user explicitly clicks on "New". Or at least mimic this behavior. Any ideas? I am using Visual Studio 2008 with MFC feature pack. I googled and found some solution to this problem in an old MS Journal article. But unfortunately it doesn't seem to work now. Any workarounds or solutions? In short, I need to differentiate between framework call to OnFileNew() and User Click on New.

    Read the article

  • C++ Serialization Clean XML Similar to XSTREAM

    - by disown
    I need to write a linux c++ app which saves it settings in XML format (for easy hand editing) and also communicates with existing apps through XML messages over sockets and HTTP. Problem is that I haven't been able to find any intelligent libs to help me, I don't particular feel like writing DOM or SAX code just to write and read some very simple messages. Boost Serialization was almost a match, but it adds a lot of boost-specific data to the xml it generates. This obviously doesn't work well for interchange formats. I'm wondering if it is possible to make Boost Serialization or some other c++ serialization library generate clean xml. I don't mind if there are some required extra attributes - like a version attribute, but I'd really like to be able to control their naming and also get rid of 'features' that I don't use - tracking_level and class_id for instance. Ideally I would just like to have something similar to xstream in Java. I am aware of the fact that c++ lacks introspection and that it is therefore necessary to do some manual coding - but it would be nice if there was a clean solution to just read and write simple XML without kludges! If this cannot be done I am also interested in tools where the XML schema is the canonical resource (contract first) - a good JAXB alternative to C++. So far I have only found commercial solutions like CodeSynthesis XSD. I would prefer open source solutions. I have tried gSoap - but it generates really ugly code and it is also SOAP-specific. In desperation I also started looking at alternative serialization formats for protobuffers. This exists - but only for Java! It really surprises me that protocol buffers seems to be a better supported data interchange format than XML. I'm going mad just finding libs for this app and I really need some new ideas. Anyone?

    Read the article

  • boost::serialization with mutable members

    - by redmoskito
    Using boost::serialization, what's the "best" way to serialize an object that contains cached, derived values in mutable members, such that cached members aren't serialized, but on deserialization, they are initialized the their appropriate default. A definition of "best" follows later, but first an example: class Example { public: Example(float n) : num(n), sqrt_num(-1.0) {} float get_num() const { return num; } // compute and cache sqrt on first read float get_sqrt() const { if(sqrt_num < 0) sqrt_num = sqrt(num); return sqrt_num; } template <class Archive> void serialize(Archive& ar, unsigned int version) { ... } private: float num; mutable float sqrt_num; }; On serialization, only the "num" member should be saved. On deserialization, the sqrt_num member must be initialized to its sentinel value indicating it needs to be computed. What is the most elegant way to implement this? In my mind, an elegant solution would avoid splitting serialize() into separate save() and load() methods (which introduces maintenance problems). One possible implementation of serialize: template <class Archive> void serialize(Archive& ar, unsigned int version) { ar & num; sqrt_num = -1.0; } This handles the deserialization case, but in the serialization case, the cached value is killed and must be recomputed. Also, I've never seen an example of boost::serialize that explicitly sets members inside of serialize(), so I wonder if this is generally not recommended. Some might suggest that the default constructor handles this, for example: int main() { Example e; { std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); ia >> e; } cout << e.get_sqrt() << endl; return 0; } which works in this case, but I think fails if the object receiving the deserialized data has already been initialized, as in the example below: int main() { Example ex1(4); Example ex2(9); cout << ex1.get_sqrt() << endl; // outputs 2; cout << ex2.get_sqrt() << endl; // outputs 3; // the following two blocks should implement ex2 = ex1; // save ex1 to archive { std::ofstream ofs("filename"); boost::archive::text_oarchive oa(ofs); oa << ex1; } // read it back into ex2 { std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); ia >> ex2; } // these should be equal now, but aren't, // since Example::serialize() doesn't modify num_sqrt cout << ex1.get_sqrt() << endl; // outputs 2; cout << ex2.get_sqrt() << endl; // outputs 3; return 0; } I'm sure this issue has come up with others, but I have struggled to find any documentation on this particular scenario. Thanks!

    Read the article

  • Applying SoapIgnore attribute doesn't take any effect to serialization result

    - by the_V
    I'm trying to figure out .NET serialization stuff and experiencing a problem. I've made a simple program to test it and got stuck with using attributes. Here's the code: [Serializable] public class SampleClass { [SoapIgnore] public Guid InstanceId { get; set; } } class Program { static void Main() { SampleClass cl = new SampleClass { InstanceId = Guid.NewGuid() }; SoapFormatter fm = new SoapFormatter(); using (FileStream stream = new FileStream(string.Format("C:\\Temp\\{0}.inv", Guid.NewGuid().ToString().Replace("-", "")), FileMode.Create)) { fm.Serialize(stream, cl); } } } The problem is that InstanceId is not ignored while serialization is done. What I get in .inv file is something like this: <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <a1:SampleClass id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/TestConsoleApp/TestConsoleApp%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull"> <_x003C_InstanceId_x003E_k__BackingField> <_a>769807168</_a> <_b>27055</_b> <_c>16408</_c> <_d>141</_d> <_e>210</_e> <_f>171</_f> <_g>30</_g> <_h>252</_h> <_i>196</_i> <_j>246</_j> <_k>159</_k> </_x003C_InstanceId_x003E_k__BackingField> </a1:SampleClass> </SOAP-ENV:Body> </SOAP-ENV:Envelope> As I can understand from documentation InstanceId property is not supposed to be serialized since SoapIgnore attribute is applied to it. Am I missing something?

    Read the article

  • Which is the best alternative for Java Serialization?

    - by Alotor
    I'm currently working on a project which needs to persist any kind of objects (of which implementation we don't have any control) so these objects could be recovered afterwards. We can't implement a ORM because we can't restrict the users of our library at development time. Our first alternative was to serialize it with the Java default serialization but we had a lot of trouble recovering the objects when the users started to pass different versions of the same object (attributes changed types, names, ...). We have tried with the XMLEncoder class (transforms an object into a XML), but we have found that there is a lack of functionality (doesn't support Enums for example). Finally, we also tried JAXB but this impose our users to annotate their classes. Any good alternative?

    Read the article

  • How to analyse contents of binary serialization stream?

    - by Tao
    I'm using binary serialization (BinaryFormatter) as a temporary mechanism to store state information in a file for a relatively complex (game) object structure; the files are coming out much larger than I expect, and my data structure includes recursive references - so I'm wondering whether the BinaryFormatter is actually storing multiple copies of the same objects, or whether my basic "number of objects and values I should have" arithmentic is way off-base, or where else the excessive size is coming from. Searching on stack overflow I was able to find the specification for Microsoft's binary remoting format: http://msdn.microsoft.com/en-us/library/cc236844(PROT.10).aspx What I can't find is any existing viewer that enables you to "peek" into the contents of a binaryformatter output file - get object counts and total bytes for different object types in the file, etc; I feel like this must be my "google-fu" failing me (what little I have) - can anyone help? This must have been done before, right??

    Read the article

  • Obtaining MFC Feature Pack GUI elements in .NET WinForms

    - by Cody Gray
    The MFC Feature Pack (and VS 2010) adds out-of-the-box support for several "modern" GUI elements (such as MDI with tabbed documents, the ribbon, and a Visual Studio-style interface with docking panels). These are a boon to those of us that have to support legacy MFC-based applications and want to update their look-and-feel, and a sign that Microsoft has not completely abandoned unmanaged C++ development. However, with the push so strongly in favor of .NET, WinForms, and managed code (and for plenty of good reasons), there seems little reason to develop new applications in unmanaged C++/MFC. The question then becomes how does one obtain these GUI elements in a WinForms application. Almost all of the add-ons and libraries I have found so far cost money, and introduce additional dependencies. I don't have a budget to buy third-party libraries, and the controls provided by Microsoft in MFC for free seem sufficient for our needs. But I still have reservations about learning MFC to develop a new application. Not only does the investment in time seem significant (by all accounts, MFC seems particularly difficult to learn, even for experienced .NET developers--although I am willing to try), but the question of MFC's lifespan is raised as well. Certainly, given the millions of lines of code and existing apps written in native C++, it will be around for some time, but the handwriting seems to be on the wall, so to speak, that it's no longer Microsoft's touted development platform. It seems like these features should be available by now in WinForms without the need for third-party add-ons, or devoting a lot of time and resources to custom-drawing EVERYTHING. Am I just missing something? I find very little online that compares these new features of MFC to what is available in WinForms, mainly because most everything written on MFC pre-dated its most recent update, before which it looked admitted "dated," and with its other flaws, was hardly an appealing platform for new development. With the very recent release of VS 2010, we have a while to wait before WinForms gets updated again. What routes are you guys taking for applications whose customers demand a modern-looking UI on a budget?

    Read the article

  • FormatException with IsolatedStorageSettings

    - by Jurgen Camilleri
    I have a problem when serializing a Dictionary<string,Person> to IsolatedStorageSettings. I'm doing the following: public Dictionary<string, Person> Names = new Dictionary<string, Person>(); if (!IsolatedStorageSettings.ApplicationSettings.Contains("Names")) { //Add to dictionary Names.Add("key", new Person(false, new System.Device.Location.GeoCoordinate(0, 0), new List<GeoCoordinate>() { new GeoCoordinate(35.8974, 14.5099), new GeoCoordinate(35.8974, 14.5099), new GeoCoordinate(35.8973, 14.5100), new GeoCoordinate(35.8973, 14.5099) })); //Serialize dictionary to IsolatedStorage IsolatedStorageSettings.ApplicationSettings.Add("Names", Names); IsolatedStorageSettings.ApplicationSettings.Save(); } Here is my Person class: [DataContract] public class Person { [DataMember] public bool Unlocked { get; set; } [DataMember] public GeoCoordinate Location { get; set; } [DataMember] public List<GeoCoordinate> Bounds { get; set; } public Person(bool unlocked, GeoCoordinate location, List<GeoCoordinate> bounds) { this.Unlocked = unlocked; this.Location = location; this.Bounds = bounds; } } The code works the first time, however on the second run I get a System.FormatException at the if condition. Any help would be highly appreciated thanks. P.S.: I tried an IsolatedStorageSettings.ApplicationSettings.Clear() but the call to Clear also gives a FormatException. I have found something new...the exception occurs twenty-five times, or at least that's how many times it shows up in the Output window. However after that, the data is deserialized perfectly. Should I be worried about the exceptions if they do not stop the execution of the program? EDIT: Here's the call stack when the exception occurs: mscorlib.dll!double.Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider) + 0x17 bytes System.Xml.dll!System.Xml.XmlConvert.ToDouble(string s) + 0x4b bytes System.Xml.dll!System.Xml.XmlReader.ReadContentAsDouble() + 0x1f bytes System.Runtime.Serialization.dll!System.Xml.XmlDictionaryReader.XmlWrappedReader.ReadContentAsDouble() + 0xb bytes System.Runtime.Serialization.dll!System.Xml.XmlDictionaryReader.ReadElementContentAsDouble() + 0x35 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsDouble() + 0x19 bytes mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi, object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark) mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x168 bytes mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj, object[] parameters) + 0xa bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlFormatReader.ReadValue(System.Type type, string name, string ns, System.Runtime.Serialization.XmlObjectSerializerReadContext context, System.Runtime.Serialization.XmlReaderDelegator xmlReader) + 0x138 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlFormatReader.ReadMemberAtMemberIndex(System.Runtime.Serialization.ClassDataContract classContract, ref object objectLocal, System.Runtime.Serialization.DeserializedObject desObj) + 0xc4 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlFormatReader.ReadClass(System.Runtime.Serialization.DeserializedObject desObj, System.Runtime.Serialization.ClassDataContract classContract, int membersRead) + 0xf3 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlFormatReader.Deserialize(System.Runtime.Serialization.XmlObjectSerializerReadContext context) + 0x36 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlFormatReader.InitializeCallStack(System.Runtime.Serialization.DataContract clContract, System.Runtime.Serialization.XmlReaderDelegator xmlReaderDelegator, System.Runtime.Serialization.XmlObjectSerializerReadContext xmlObjContext, System.Xml.XmlDictionaryString[] memberNamesColl, System.Xml.XmlDictionaryString[] memberNamespacesColl) + 0x77 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.XmlObjectSerializerReadContext context) + 0x5d bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlReaderDelegator reader) + 0x3 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator reader, string name, string ns, ref System.Runtime.Serialization.DataContract dataContract) + 0x10e bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Type declaredType, System.Runtime.Serialization.DataContract dataContract, string name, string ns) + 0xb bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.DataContractSerializer.InternalReadObject(System.Runtime.Serialization.XmlReaderDelegator xmlReader, bool verifyObjectName) + 0x124 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator reader, bool verifyObjectName) + 0xe bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializer.ReadObject(System.Xml.XmlDictionaryReader reader) + 0x7 bytes System.Runtime.Serialization.dll!System.Runtime.Serialization.XmlObjectSerializer.ReadObject(System.IO.Stream stream) + 0x17 bytes System.Windows.dll!System.IO.IsolatedStorage.IsolatedStorageSettings.Reload() + 0xa3 bytes System.Windows.dll!System.IO.IsolatedStorage.IsolatedStorageSettings.IsolatedStorageSettings(bool useSiteSettings) + 0x20 bytes System.Windows.dll!System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.get() + 0xd bytes

    Read the article

  • How do I implement Unreal-like object serialization?

    - by MrWiggels
    Recently, I've been working on the core of my engine, and as I'm moving forward I find myself developing throwaway code to read files and simple data into the engine. This got me thinking about how I should implement a file management system. After a bit of googleing I came across the Unreal Package format, and boy does it look like the perfect one. I think it's good because the way how it allows you to separate different assets into different packages and allow something like a level to reference the different packages. I was just wondering, is this possible with C#? Because the built-in serialization API in .NET does not seem to support any form of this, only reading and writing to a single file.

    Read the article

  • Control XML serialization of Dictionary<K, T>

    - by Luca
    I'm investigating about XML serialization, and since I use lot of dictionary, I would like to serialize them as well. I found the following solution for that (I'm quite proud of it! :) ). [XmlInclude(typeof(Foo))] public class XmlDictionary<TKey, TValue> { /// <summary> /// Key/value pair. /// </summary> public struct DictionaryItem { /// <summary> /// Dictionary item key. /// </summary> public TKey Key; /// <summary> /// Dictionary item value. /// </summary> public TValue Value; } /// <summary> /// Dictionary items. /// </summary> public DictionaryItem[] Items { get { List<DictionaryItem> items = new List<DictionaryItem>(ItemsDictionary.Count); foreach (KeyValuePair<TKey, TValue> pair in ItemsDictionary) { DictionaryItem item; item.Key = pair.Key; item.Value = pair.Value; items.Add(item); } return (items.ToArray()); } set { ItemsDictionary = new Dictionary<TKey,TValue>(); foreach (DictionaryItem item in value) ItemsDictionary.Add(item.Key, item.Value); } } /// <summary> /// Indexer base on dictionary key. /// </summary> /// <param name="key"></param> /// <returns></returns> public TValue this[TKey key] { get { return (ItemsDictionary[key]); } set { Debug.Assert(value != null); ItemsDictionary[key] = value; } } /// <summary> /// Delegate for get key from a dictionary value. /// </summary> /// <param name="value"></param> /// <returns></returns> public delegate TKey GetItemKeyDelegate(TValue value); /// <summary> /// Add a range of values automatically determining the associated keys. /// </summary> /// <param name="values"></param> /// <param name="keygen"></param> public void AddRange(IEnumerable<TValue> values, GetItemKeyDelegate keygen) { foreach (TValue v in values) ItemsDictionary.Add(keygen(v), v); } /// <summary> /// Items dictionary. /// </summary> [XmlIgnore] public Dictionary<TKey, TValue> ItemsDictionary = new Dictionary<TKey,TValue>(); } The classes deriving from this class are serialized in the following way: <FooDictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Items> <DictionaryItemOfInt32Foo> <Key/> <Value/> </DictionaryItemOfInt32XmlProcess> <Items> This give me a good solution, but: How can I control the name of the element DictionaryItemOfInt32Foo What happens if I define a Dictionary<FooInt32, Int32> and I have the classes Foo and FooInt32? Is it possible to optimize the class above? THank you very much!

    Read the article

  • Class instance clustering in object reference graph for multi-entries serialization

    - by Juh_
    My question is on the best way to cluster a graph of class instances (i.e. objects, the graph nodes) linked by object references (the -directed- edges of the graph) around specifically marked objects. To explain better my question, let me explain my motivation: I currently use a moderately complex system to serialize the data used in my projects: "marked" objects have a specific attributes which stores a "saving entry": the path to an associated file on disc (but it could be done for any storage type providing the suitable interface) Those object can then be serialized automatically (eg: obj.save()) The serialization of a marked object 'a' contains implicitly all objects 'b' for which 'a' has a reference to, directly s.t: a.b = b, or indirectly s.t.: a.c.b = b for some object 'c' This is very simple and basically define specific storage entries to specific objects. I have then "container" type objects that: can be serialized similarly (in fact their are or can-be "marked") they don't serialize in their storage entries the "marked" objects (with direct reference): if a and a.b are both marked, a.save() calls b.save() and stores a.b = storage_entry(b) So, if I serialize 'a', it will serialize automatically all objects that can be reached from 'a' through the object reference graph, possibly in multiples entries. That is what I want, and is usually provides the functionalities I need. However, it is very ad-hoc and there are some structural limitations to this approach: the multi-entry saving can only works through direct connections in "container" objects, and there are situations with undefined behavior such as if two "marked" objects 'a'and 'b' both have a reference to an unmarked object 'c'. In this case my system will stores 'c' in both 'a' and 'b' making an implicit copy which not only double the storage size, but also change the object reference graph after re-loading. I am thinking of generalizing the process. Apart for the practical questions on implementation (I am coding in python, and use Pickle to serialize my objects), there is a general question on the way to attach (cluster) unmarked objects to marked ones. So, my questions are: What are the important issues that should be considered? Basically why not just use any graph parsing algorithm with the "attach to last marked node" behavior. Is there any work done on this problem, practical or theoretical, that I should be aware of? Note: I added the tag graph-database because I think the answer might come from that fields, even if the question is not.

    Read the article

  • ReflectionTypeLoadException with Silverlight serialization attributes

    - by RPS
    Hi all, I´m trying to inspect the types in a silverlight 4 assembly from a .NET 3.5 application. I have loaded the silverlight assembly with a Assembly.ReflectionOnlyLoadFrom sentence. contractsAssembly = Assembly.ReflectionOnlyLoadFrom(contractsAssemblyPath); When the .NET application tries to perform a call to GetTypes(), it throws a ReflectionTypeLoadException. Type[] types = contractsAssembly.GetTypes(); The LoaderExceptions property in the ReflectionTypeLoadException contains a list of exceptions, all of them regarding a problem loading a type that has serialization attributes. Type 'XXXX' in assembly 'YYYY' has method 'OnSerializing' with an incorrect signature for the serialization attribute that it is decorated with. The type XXXX has the following definitions in it: [System.Runtime.Serialization.OnSerializing] public void OnSerializing(System.Runtime.Serialization.StreamingContext context) [System.Runtime.Serialization.OnSerialized] public void OnSerialized(System.Runtime.Serialization.StreamingContext context) [System.Runtime.Serialization.OnDeserializing] public void OnDeserializing(System.Runtime.Serialization.StreamingContext context) [System.Runtime.Serialization.OnDeserialized] public void OnDeserialized(System.Runtime.Serialization.StreamingContext context) I have tried changing the method signature to internal or private, but with no luck. When I perform a GetTypes() call in a silverlight application that inspects this assembly I have no problems, so I thought that this was due to an incompatibility between .NET Framework and Silverlight. However, I see that .NET tools such as Reflector can inspect this Silverlight assembly, so there is a way to inspect Silverlight assemblies with serialization attributes from a .NET applciation. Could someone shed me some light on this? Many thanks in advance. Jose Antonio

    Read the article

  • XML serialization query

    - by David Neale
    I have the following XML which needs deserializing/serializing: <instance> <dog> <items> <item> <label>Spaniel</label> </item> </items> </dog> <cat> <items> <item> <label>Tabby</label> </item> </items> </cat> </instance> I cannot change the XML structure. I need to map this to the following class: [Serializable, XmlRoot("instance")] public class AnimalInstance { public string Dog { get; set; } public string Cat { get; set; } } I'm not really sure where to start on this one without manually parsing the XML. I'd like to keep the code as brief as possible. Any ideas? (and no, my project doesn't actually involve cats and dogs).

    Read the article

  • Advantages And Disadvantages Of Resource Serialization

    - by CPP_Person
    A good example is let's say I'm making a pong game. I have a PNG image for the ball and another PNG image for the paddles. Now which would be better, loading the PNG images with a PNG loader, or loading them in a separate program, serializing it, and de-serializing it in the game itself for use? The reason why this may be good to know is because it seems like game companies (or anyone in the long run) build all of their resources into some sort of file. For example, in the game Fallout: New Vegas the DLCs are loaded as a .ESM file, which includes everything it needs, all the game does is find it, serialize it, and it has the resources. Games like Penumbra: Black Plague take a different approch and add a folder which contains all the textures, sounds, scrips, ect that it needs, but not serialized (it does this with the game itself, and the DLC). Which is the better approch and why?

    Read the article

  • Compilation error when using boost serialization library

    - by Shakir
    I have been struggling with this error for a long time. The following is my code snippet. //This is the header file template<typename TElem> class ArrayList { public: /** An accessible typedef for the elements in the array. */ typedef TElem Elem; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & ptr_; ar & size_; ar & cap_; } Elem *ptr_; // the stored or aliased array index_t size_; // number of active objects index_t cap_; // allocated size of the array; -1 if alias }; template <typename TElem> class gps_position { public: typedef TElem Elem; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & degrees; ar & minutes; ar & seconds; } private: Elem degrees; index_t minutes; index_t seconds; }; // This is the .cc file #include #include #include #include #include #include #include #include #include "arraylist.h" int main() { // create and open a character archive for output std::ofstream ofs("filename"); // create class instance // gps_position<int> g(35.65, 59, 24.567f); gps_position<float> g; // save data to archive { boost::archive::text_oarchive oa(ofs); // write class instance to archive //oa << g; // archive and stream closed when destructors are called } // ... some time later restore the class instance to its orginal state /* gps_position<int> newg; { // create and open an archive for input std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); // read class state from archive ia >> newg; // archive and stream closed when destructors are called }*/ ArrayList<float> a1; ArrayList<int> a2; a1.Init(22); a2.Init(21); // a1.Resize(30); // a1.Resize(12); // a1.Resize(22); // a2.Resize(22); a1[21] = 99.0; a1[20] = 88.0; for (index_t i = 0; i < a1.size(); i++) { a1[i] = i; a1[i]++; } std::ofstream s("test.txt"); { boost::archive::text_oarchive oa(s); oa << a1; } return 0; } The following is the compilation error i get. In file included from /usr/include/boost/serialization/split_member.hpp:23, from /usr/include/boost/serialization/nvp.hpp:33, from /usr/include/boost/serialization/serialization.hpp:17, from /usr/include/boost/archive/detail/oserializer.hpp:61, from /usr/include/boost/archive/detail/interface_oarchive.hpp:24, from /usr/include/boost/archive/detail/common_oarchive.hpp:20, from /usr/include/boost/archive/basic_text_oarchive.hpp:32, from /usr/include/boost/archive/text_oarchive.hpp:31, from demo.cc:4: /usr/include/boost/serialization/access.hpp: In static member function ‘static void boost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’: /usr/include/boost/serialization/serialization.hpp:74: instantiated from ‘void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’ /usr/include/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’ /usr/include/boost/archive/detail/oserializer.hpp:140: instantiated from ‘void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::text_oarchive, T = float]’ demo.cc:105: instantiated from here /usr/include/boost/serialization/access.hpp:109: error: request for member ‘serialize’ in ‘t’, which is of non-class type ‘float’ Please help me out.

    Read the article

  • Problem with serialization of svcutil synthetized classes

    - by user295502
    I used svcutil to generate classes to access the web service. I need to serialize them. The class is quite simple, here is how it looks [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="cosemAttributeDescriptor", Namespace="http://www.energiened.nl/Content/Publications/dsmr/P32")] public partial class cosemAttributeDescriptor : object, System.Runtime.Serialization.IExtensibleDataObject { private System.Runtime.Serialization.ExtensionDataObject extensionDataField; private ushort ClassIdField; private string InstanceIdField; private sbyte AttributeIdField; public System.Runtime.Serialization.ExtensionDataObject ExtensionData { get { return this.extensionDataField; } set { this.extensionDataField = value; } } [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)] public ushort ClassId { get { return this.ClassIdField; } set { this.ClassIdField = value; } } [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false)] public string InstanceId { get { return this.InstanceIdField; } set { this.InstanceIdField = value; } } [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, Order=2)] public sbyte AttributeId { get { return this.AttributeIdField; } set { this.AttributeIdField = value; } } } Now, the problem is I can't serialize the class. Here is the serialization code: cosemAttributeDescriptor cAttrD = new cosemAttributeDescriptor(); cAttrD.ClassId = 3; cAttrD.InstanceId = "0100010800FF"; cAttrD.AttributeId = 0; DataContractSerializer dSer = new DataContractSerializer(typeof(cosemAttributeDescriptor)); StringBuilder sb = new StringBuilder(); XmlWriter xW = XmlWriter.Create(sb); dSer.WriteObject(xW, cAttrD); When I try to serialize the class, I get empty string. Any thoughts?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >