serialization

Serialize a class that implements IEnumerable

倖福魔咒の 提交于 2020-01-17 05:31:25
问题 I want to serialize this class I have no idea how to do it: Public Class colCustomRecurringClaims Implements IEnumerable #Region "Declarations" Private mobjColl As New Collection Private mobjSys As LifeCO.clsSys #End Region 'Declarations #Region "Framework Functions" Public Sub New(pobjSys As LifeCO.clsSys) mobjSys = pobjSys End Sub Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator Return mobjColl.GetEnumerator End Function Private Function GetUC() As MIH

C# image binary serialization

对着背影说爱祢 提交于 2020-01-17 04:30:12
问题 I am struggling to binary serialize a class with image inside but I'm getting an exception: "Type 'System.Windows.Controls.Image' in Assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable." this is my serializer public static bool FileSerializer<T>(string filePath, T objectToWrite,out string strError, bool append = false) { using (Stream fileStream = File.Open(filePath, append ? FileMode.Append : FileMode.Create)) {

Can I serialize a BitArray to XML?

会有一股神秘感。 提交于 2020-01-17 03:24:05
问题 I have a business class which I need to serialize to xml. It has a BitArray property. I have decorated it with [XmlAttribute] but the serialization is failing with To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Boolean) at all levels of their inheritance hierarchy. System.Collections.BitArray does not implement Add(System.Boolean). I am not sure whether its possible to serialize to xml? If not what would be an efficient means of

Send NSArray Via AirDrop

醉酒当歌 提交于 2020-01-17 03:20:30
问题 I have an NSMutableArray self.certificates This array is made up of saved strings and core data. I want to send this through AirDrop. I have checked out serialization and and im trying to send it with the folowing - (void)send{ NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:self.certificates options:NSJSONWritingPrettyPrinted error:nil]; NSString *jsonString = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding]; NSLog(@"Electrical Certificates List:\n%@",

Build a Custom Serialization as String in System.Xml.Serialization

Deadly 提交于 2020-01-17 02:21:11
问题 Hi guys I have 2 classes like this: [XmlRoot("Config")] public class ConfigClass { [XmlElement("Configuration1")] public string Config1 { get; set; } [XmlArray("Infos")] [XmlArrayItem("Info")] public OtherInfo[] OtherInfos { get; set; } } public class OtherInfo { public string Info1 { get; set; } public string Info2 { get; set; } } When I serialize the root class the XML result is like this: <?xml version="1.0"?> <Config> <Configuration1>Text</Configuration1> <Infos> <Info> <Info1>Test 2<

cPickle class with data save to file

谁说胖子不能爱 提交于 2020-01-16 18:17:16
问题 I've big class in Python it's "DataBase-like" class. I want to save it to file - all including data. This is input(example to show the issue, in script database is like 10000 records): import cPickle # DataBase-like class class DataBase: class Arrays: pass class Zones: pass class Nodes: class CR: pass class Links: class CR: pass class Turns: class CR: pass class OrigConnectors: pass class DestConnectors: pass class Paths: pass pass # some basic input into database DataBase.Arrays.Data=[] for

XML members initialization for XmlSerializer using C#

放肆的年华 提交于 2020-01-16 17:28:33
问题 I have below XML and need to deserialized to get the value of "ThreadGroup.num_threads","ThreadGroup.ramp_time","HTTPSampler.path" and "HTTPSampler.domain". <TestPlan> <hashTree> <hashTree> <ThreadGroup> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <stringProp name="ThreadGroup.num_threads">10</stringProp> <stringProp name="ThreadGroup.ramp_time">1</stringProp> <longProp name="ThreadGroup.start_time">1517853259000</longProp> <longProp name="ThreadGroup.end_time"

C++ Boost binary serialization of std::map containing pointers constructed from Boost object_pool

廉价感情. 提交于 2020-01-16 16:58:49
问题 My application has a class "MyClass". It's objects are being constructed from the Boost Object_pool. I need to serialized/de serialize a std::map containing these objects as value via Boost Binary Serialization. For Serialization - I take a pointer from the pool, do some operations, insert it in the std::map and serialize it via Boost binary serialization. For De-serialization - I fetch that serialized buffer and de-serialize it with Boost binary serialization. De-serialization happens

Kryo Serialization not registering even after registering the class in conf

烂漫一生 提交于 2020-01-16 13:58:32
问题 I made a class Person and registered it but on runtime, it shows class not registered.Why is it showing so? Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Failed to serialize task 0, not attempting to retry it. Exception during serialization: java.io.IOException: java.lang.IllegalArgumentException: Class is not registered: KyroExample$Person[] Note: To register this class use: kryo.register(KyroExample$Person[].class); Here is the sample code :

Serialize only those properties of an Interface that exist in the Interface

自古美人都是妖i 提交于 2020-01-16 08:19:31
问题 So I'm trying to serialize only those properties of an interface that exist in the interface, not the underlying type itself. To that end, by following this, I've written the following code: public static IEnumerable<T> ToInterfacedObjects<T>(this IEnumerable<T> data) where T : class { var list = new List<T>(); var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var datum in data) { var moq = new Mock<T>(); foreach (var propertyInfo in properties) {