marshalling

Passing a Structure to C++ API using Marshal.StructureToPtr in C#

别等时光非礼了梦想. 提交于 2019-12-20 11:55:57
问题 I am using API written in C++ in my code (writting in C#). API requires a parameter as Pointer to Structure. The Structure consists of "Int"s and Char Arrays: for example unsafe public struct ToBePassed { Int32 Num1; Int32 Num2; Char[] Data; // or fixed Char Data[255]; } I can not directly pass the structure pointer to API because in that case, I am getting error as "Pointers cannot reference Marshaled structures". Code get compiled successfully but this Error comes when I execute (Debug) the

What's the most efficient way to deep copy an object in Ruby?

跟風遠走 提交于 2019-12-20 09:53:48
问题 I know that serializing an object is (to my knowledge) the only way to effectively deep-copy an object (as long as it isn't stateful like IO and whatnot), but is one way particularly more efficient than another? For example, since I'm using Rails, I could always use ActiveSupport::JSON , to_xml - and from what I can tell marshalling the object is one of the most accepted ways to do this. I'd expect that marshalling is probably the most efficient of these since it's a Ruby internal, but am I

Understanding JAXB @XmlRootElement annotation

给你一囗甜甜゛ 提交于 2019-12-20 09:38:34
问题 I am using the tutorial here for understanding JAXB. When the writer comes to create the root of the document, the writer begins as below: //This statement means that class "Bookstore.java" is the root-element of our example @XmlRootElement(namespace = "de.vogella.xml.jaxb.model") public class Bookstore { ... } Although I will be manually generating my classes rather than letting Eclipse do it, I will supply an XSD with my jar file (not packed inside but rather in the folder containing jar

How to marshal empty string to a single tag

别来无恙 提交于 2019-12-20 06:37:09
问题 I've my object, configured with the code: object.setName(""); marshaled into following XML: <object> <name></name> </object> But I want single tag: <object> <name/> </object> Is it easy to do with JAXB for all my objects at once? UPDATE Similar question: How to instantiate an empty element with JAXB It's suggested to use prettifier javax.xml.transform.TransformerFactory.newTransformer(), but without explanation how to use it. Ideally my goal is to get exact code to configure JAXB to get the

How to marshal an unknown length C++ string to C# using its pointer?

痞子三分冷 提交于 2019-12-20 06:27:45
问题 I'm trying to marshal a dynamically allocated char array in a struct to C#. The struct has a pointer to the array. The problem is the char array contains multiple null terminated strings and the last string is terminated by two consecutive null chars. If I try to marshal it as LPStr I will get only de first string in the "list". I tried using UnmanagedMemoryStream but it requires to know the length of the array. Is there a way to read the bytes as a stream without knowing the length of the

jaxb when xsi:nil=true if any child element exists it is still showing

前提是你 提交于 2019-12-20 06:11:04
问题 I have the below xml output, how can we hide the child element (endDate) when parent element has attribute xsi:nil=true even child element is nillable=true? //XML Output <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <snapshots xmlns:xsi="w3.org/2001/XMLSchema-instance"; xmlns:ns3="ws.mycompany.com"; mask="PAC"> <Offers> <Offer xsi:type="wsMarketingOfferOP" entityId="1234" xsi:nil="true"> <endDate xsi:nil="true"/> </Offer> </Offers> </snapshots> // Snapshots class @XmlAccessorType

Specifying root and child nodes with JAXB

試著忘記壹切 提交于 2019-12-20 05:56:47
问题 Staying within JAXB how would I refactor MyNote so that it conforms to: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Which is well formed but not valid, to my understanding. Current output: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <MyNotes> <Note> <note>XY3Z1RGEO9W79LALCS</note> <to>LJAY9RNMUGGENGNND9</to> <from>GOVSHVZ3GJWC864L7X</from> <heading>EX6LGVE5LGY4A6B9SK</heading> <body>L95WYQNMEU1MFDRBG4</body>

Marshal returns empty json of my struct

為{幸葍}努か 提交于 2019-12-20 05:43:07
问题 I'm working on a code that scan a repertory into a struct in order to export it to json. Currently, my code scans finely a repertory with the ScanDir function, but when I try to Marshal my struct it only returns {} . // file's struct type Fic struct { nom string `json:"fileName"` lon int64 `json:"size"` tim time.Time `json:"lastFileUpdate"` md5hash []byte `json:"md5"` } // folder's struct type Fol struct { subFol []Fol `json:"listFolders"` files []Fic `json:"listFiles"` nom string `json:

SendInput Keys in Win32 & Win64 machines

北城余情 提交于 2019-12-20 05:19:29
问题 I have used sendInput() under xp 32bits using webservices to push F5 of current focused windows. Now under Vista win64 i can´t obtain this result. Some articles point uint problems using 4bits or 8bits but this is not fixing the problem under vista with differential compilation and FieldOffset(4)or(8). Others speak about no more interaction beetween Vista screen and the window using this SendInput() method. Can someone point the solution to push F5 in win32 and win64 machines. Thanks. uint

Marshall a List to XML works - but how to unmarshall?

久未见 提交于 2019-12-20 03:51:25
问题 I can marshall a ObservableList using a "Wrapper"-class like below. But I cannot unmarshall it back to the wrapperclass it was before. The idea is: I have an ObservableList of "Expenses". I put this List into a wrapper-class and save this class to XML. The result looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <List> <root> <category>[none]</category> <period>Year</period> <title>asd</title> <value>354</value> </root> </List> I cannot bring it back to the wrapper