Click here to Skip to main content
15,886,584 members
Articles / Programming Languages / C#

UniversalSerializer

Rate me:
Please Sign up or sign in to vote.
4.97/5 (108 votes)
15 Apr 2018Ms-RL31 min read 258K   4K   299  
An universal and easy serialization library for .NET and .NET Core.
<UserControl x:Class="UniversalSerializerResourceTests.CommonOptions"
						 x:Name="ThisOptions"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<Border Margin="5" BorderBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" BorderThickness="2" CornerRadius="2">
		<StackPanel Margin="5">
		<ComboBox Name="Data" DataContext="{Binding ElementName=ThisOptions}" ItemsSource="{Binding DataCollection}" SelectedIndex="1" ToolTip="Select a data structure to be tested"/>
		<StackPanel Orientation="Horizontal">
			<!--<ComboBox Name="Serializer" DataContext="{Binding ElementName=ThisOptions}" ItemsSource="{Binding SerializersCollection}" SelectedIndex="0" ToolTip="Select a serializer"/>-->
			<ComboBox Name="StreamManagementChoice" DataContext="{Binding ElementName=ThisOptions}" ItemsSource="{Binding StreamManagementCollection}" SelectedIndex="1" Margin="-1,0,1.4,0" ToolTip="Select the stream"/>
				<TextBlock Text="File name" Margin="10,0,5,0" VerticalAlignment="Center"/>
			<TextBox Name="FileName" Text="R:\Serialized.data" ToolTip="Suggestion: use a FAT32-formatted RAM-Disk."/>
		</StackPanel>
		<StackPanel Orientation="Horizontal" >
				<TextBlock Text="Number of items:" Margin="0,0,10,0" VerticalAlignment="Center" />
			<TextBox Name="ItemCount" Text="1000000"/>
				<TextBlock Text="Number of loops:" Margin="10,0,10,0" VerticalAlignment="Center" />
			<TextBox Name="LoopCount" Text="10"/>
			<CheckBox Name="ShareTheDeSerializer" Content="Share the (de)serializer" Margin="10,0,10,0" ToolTip="When checked, we use one serializer instance for all loops, and one Serialize() call on each loop. When uncheckd we create an instance of the serializer on each loop."/>
		</StackPanel>
		<TextBox Name="TextBoxState"  TextWrapping="Wrap" Text="Click Start" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="60" HorizontalContentAlignment="Center" />
		<StackPanel Orientation="Horizontal">
			<TextBlock Text="Stream size:" Margin="0,0,10,0"/>
			<TextBlock Name="StreamSize"/>
			<TextBlock Text="bytes." Margin="5,0,0,0"/>
			<TextBlock Text="Average item size:" Margin="20,0,10,0"/>
			<TextBlock Name="ItemSize"/>
			<TextBlock Text="bytes." Margin="5,0,0,0"/>
		</StackPanel>
		<StackPanel Orientation="Horizontal">
			<TextBlock Text="Time:" Margin="0,0,10,0"/>
			<TextBlock Name="Time"/>
			<TextBlock Text="ms." Margin="5,0,0,0"/>
		</StackPanel>
		<StackPanel Orientation="Horizontal">
			<TextBlock Text="RAM:" Margin="0,0,10,0"/>
			<TextBlock Name="RAM"/>
			<TextBlock Text="MiB." Margin="5,0,0,0"/>
		</StackPanel>
	</StackPanel>
	</Border>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under Microsoft Reciprocal License


Written By
Software Developer (Senior) independent
France France
Hi !

I made my first program on a Sinclair ZX-81.
Since that day, I have the virus of computers. Smile | :)

Here is my website:
https://chrisbertrand.net

And my blog:
https://chrisbertrandprogramer.wordpress.com/

Comments and Discussions