Page 1 of 1

Beta 12.1 of C#/XAML for HTML5 released (DataContractSerializer)

Posted: Wed Sep 27, 2017 8:17 am
by JS-Support
Dear users,

We are pleased to inform you that the Beta 12.1 of C#/XAML for HTML5 - the extension for Visual Studio that lets you build cross-platform HTML5 apps in standard C# and XAML - is available for download!



DOWNLOAD:
CSharpXamlForHtml5_v1_0_public_beta12_1.zip
(25.52 MiB) Downloaded 60 times

Learn More about C#/XAML for HTML5.




Here is what's new (since Beta 12.0):
  • Initial implementation of the DataContractSerializer! It is lighter, faster, and more powerful than the XmlSerializer.

    Notes:
    • Read below for sample code
    • Coming soon features (not yet supported): null values and nullable types, inheritance, specifying a custom Name with the DataMember attribute, and more.
    • Please note that, at the moment, if you wish to specify a custom namespace, you should use the following syntax: [DataContract2(Namespace: "http://...")] instead of: [DataContract(Namespace="http://...")]
    • Coming soon: revamped WCF stack, much lighter, faster, and with fewer limitations.
  • Improved Linq to XML (XDocument, XElement, etc.)
  • Added support for XNamespace
  • Added more overloads for "String.LastIndexOf" that take a "startIndex" as parameter


Here is some sample code for the new DataContractSerializer:

Code: Select all

[DataContract]
public class Person
{
    public void Init()
    {
        this.FullName = "John Doe";
        this.Age = 30;
        this.MailingAddress = "mailing@mail.com";
        this.TelephoneNumber = "0123456789";
    }

    // This member is serialized.
    [DataMember]
    internal string FullName;

    // This is serialized even though it is private.
    [DataMember]
    private int Age;

    // This is not serialized because the DataMemberAttribute
    // has not been applied.
    private string MailingAddress;

    // This is not serialized, but the property is.
    private string telephoneNumberValue;

    [DataMember]
    public string TelephoneNumber
    {
        get { return telephoneNumberValue; }
        set { telephoneNumberValue = value; }
    }
}

public void Serialize()
{
    var person = new Person();
    person.Init();

    var dataContractSerializer = new DataContractSerializer(typeof(Person));
    var xml = dataContractSerializer.SerializeToString(person);
    MessageBox.Show(xml);
}

public void Deserialize()
{
    string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<Person xmlns=""http://schemas.datacontract.org/2004/07/"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
<Age>30</Age>
<FullName>John Doe</FullName>
<TelephoneNumber>0123456789</TelephoneNumber>
</Person>";
    var dataContractSerializer = new DataContractSerializer(typeof(Person));
    var person = (Person)dataContractSerializer.DeserializeFromString(xml);
    MessageBox.Show("Person name: " + person.FullName + Environment.NewLine + "Person phone number: " + person.TelephoneNumber);
}




We are also working on many other features and we will release them as soon as they are ready.


You may also be interested to read:


Notes about installation:
  • Before installing this update, it is recommended that you close all the open instances of Visual Studio.
  • If for some reason you need to revert to the previous Beta, simply uninstall this one (from the Control Panel) and reinstall the previous Beta.


We hope you will enjoy this build! If you find any issues, please post them on the forums or send an email to support@cshtml5.com

Thank you.
Regards,
JS-Support

Re: New Beta 12.1 released! [Download] (DataContractSerializer)

Posted: Thu Sep 28, 2017 9:31 am
by Nick
When a property is Null, when try to DeserializeFromString(objectString) an error occure.

Re: New Beta 12.1 released! [Download] (DataContractSerializer)

Posted: Fri Sep 29, 2017 6:21 am
by JS-Support
Nick wrote:When a property is Null, when try to DeserializeFromString(objectString) an error occure.

Thanks Nick. We are aware of this issue and we are fixing it right now.