by jNayden | Sep 13, 2009 | .net, Aggregated
When I first hear about XML serialization in C# I thought that it is like Java serialization but the result is XML character stream instead of the default serialization in Java/.net.But the things are not so great. The XML serialization in C# is good but it is not the best. In Java the easiest way to make normal serialization is to implement interface Serializable and to be sure that all fields in your custom class are serializable. If you want to Serialize ArrayList of this objects you dont have problems because ArrayList implements Serializable. But when you use XML serialization you dont care about Serializable interface. In Java you can make XML serialization this way : http://www.javablogging.com/serialization-to-xml/. You can see that it is simple I thought that in C# the situation is the same but it is not.To read about serialiization in C# there is tones of info but I didn’t found answer like this one in this post: I will notice only some important aspects of this because when I try C# serialization I have missed some points of this article and i loose 30mins of searching what the problem is. If you need to serialize ArrayList of strings no problem you can make it this way: // SerializationXmlSerializer s = new XmlSerializer( typeof( ArrayList) );TextWriter w = new StreamWriter( @"c:list.xml" );s.Serialize( w, myList );w.Close(); You can notice that you pass the type of ArrayList to XmlSerializer right? That is the difference.In Java you don’t need to specify what you pass it is “founded” automaticly. But in C# you need to pass all classes that you serialize or...
by jNayden | Sep 13, 2009 | .net, Aggregated
When I first hear about XML serialization in C# I thought that it is like Java serialization but the result is XML character stream instead of the default serialization in Java/.net.But the things are not so great. The XML serialization in C# is good but it is not the best. In Java the easiest way to make normal serialization is to implement interface Serializable and to be sure that all fields in your custom class are serializable. If you want to Serialize ArrayList of this objects you dont have problems because ArrayList implements Serializable. But when you use XML serialization you dont care about Serializable interface. In Java you can make XML serialization this way : http://www.javablogging.com/serialization-to-xml/. You can see that it is simple I thought that in C# the situation is the same but it is not.To read about serialiization in C# there is tones of info but I didn’t found answer like this one in this post: I will notice only some important aspects of this because when I try C# serialization I have missed some points of this article and i loose 30mins of searching what the problem is. If you need to serialize ArrayList of strings no problem you can make it this way: // SerializationXmlSerializer s = new XmlSerializer( typeof( ArrayList) );TextWriter w = new StreamWriter( @"c:list.xml" );s.Serialize( w, myList );w.Close(); You can notice that you pass the type of ArrayList to XmlSerializer right? That is the difference.In Java you don’t need to specify what you pass it is “founded” automaticly. But in C# you need to pass all classes that you serialize or...
by jNayden | Sep 13, 2009 | .net, Aggregated
When I first hear about XML serialization in C# I thought that it is like Java serialization but the result is XML character stream instead of the default serialization in Java/.net.But the things are not so great. The XML serialization in C# is good but it is not the best. In Java the easiest way to make normal serialization is to implement interface Serializable and to be sure that all fields in your custom class are serializable. If you want to Serialize ArrayList of this objects you dont have problems because ArrayList implements Serializable. But when you use XML serialization you dont care about Serializable interface. In Java you can make XML serialization this way : http://www.javablogging.com/serialization-to-xml/. You can see that it is simple I thought that in C# the situation is the same but it is not.To read about serialiization in C# there is tones of info but I didn’t found answer like this one in this post: I will notice only some important aspects of this because when I try C# serialization I have missed some points of this article and i loose 30mins of searching what the problem is. If you need to serialize ArrayList of strings no problem you can make it this way: // SerializationXmlSerializer s = new XmlSerializer( typeof( ArrayList) );TextWriter w = new StreamWriter( @"c:list.xml" );s.Serialize( w, myList );w.Close(); You can notice that you pass the type of ArrayList to XmlSerializer right? That is the difference.In Java you don’t need to specify what you pass it is “founded” automaticly. But in C# you need to pass all classes that you serialize or...
by jNayden | Sep 12, 2009 | .net, Aggregated
Hello all, today I will post a simple code snippet manager created using C# and WPF. The idea of the app is to be used when making presentations and you need to paste all kind of code snippets (html, xaml, C#, java ). The similar tool is used by Karen Corby in MIX09 presentation about creating silverlight controls.This is my first .net application so you will see all kind of C# strangeness like using “Object” instead of “object” and String instead of “string”. Because this was my first application I choose to use WPF not WinForms because WinForms is a lot like Swing and I’ve wanted to see “how declarative XML for the UI is better” and I can say: “hmm ok there is some big pluses”. Anyway I have little experience with Flex’s MXML too and if you ask me the MXML is a lot than XAML. The code snipper manager application lokks like this : The view is very simple and I can say that XAML is perfect for creating a simple views and there is tones of snippets in internet for all kinds of examples like popup for example. The application XAML looks like this : <Window x:Class="CodeSnippetManager.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Snipper Manager" Height="355" Width="177" Topmost="True" ResizeMode="NoResize" > <Grid Height="309"> <ListBox Margin="0,-8,0,38" Name="listSnippets" HorizontalContentAlignment="Left" MouseRightButtonDown="listSnippets_MouseRightButtonDown" SelectionMode="Single" SelectionChanged="listSnippets_SelectionChanged" MouseDoubleClick="listSnippets_MouseDoubleClick"> </ListBox> <Popup Placement="Mouse" Name="popupHint" HorizontalAlignment="Left" VerticalAlignment="Top" IsOpen="False" AllowsTransparency="True"> <Border BorderBrush="Black" BorderThickness="1"> <Grid Background="White"> <TextBlock Background="White" x:Name="PopupTxt" TextAlignment="Center" VerticalAlignment="Center"> </TextBlock> </Grid> </Border> </Popup> <WrapPanel Height="40" Name="wrapPanel1" VerticalAlignment="Bottom" HorizontalAlignment="Center"> <Button Height="26" Name="menu" Width="65" Margin="5" Click="menu_Click">Menu</Button> <Button Height="26" Name="clear" Width="65" Margin="5" Click="new_Click">Clear</Button> </WrapPanel> </Grid></Window> Maybe you can notice that code is short...
by jNayden | Sep 12, 2009 | .net, Aggregated
Hello all, today I will post a simple code snippet manager created using C# and WPF. The idea of the app is to be used when making presentations and you need to paste all kind of code snippets (html, xaml, C#, java ). The similar tool is used by Karen Corby in MIX09 presentation about creating silverlight controls.This is my first .net application so you will see all kind of C# strangeness like using “Object” instead of “object” and String instead of “string”. Because this was my first application I choose to use WPF not WinForms because WinForms is a lot like Swing and I’ve wanted to see “how declarative XML for the UI is better” and I can say: “hmm ok there is some big pluses”. Anyway I have little experience with Flex’s MXML too and if you ask me the MXML is a lot than XAML. The code snipper manager application lokks like this : The view is very simple and I can say that XAML is perfect for creating a simple views and there is tones of snippets in internet for all kinds of examples like popup for example. The application XAML looks like this : <Window x:Class="CodeSnippetManager.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Snipper Manager" Height="355" Width="177" Topmost="True" ResizeMode="NoResize" > <Grid Height="309"> <ListBox Margin="0,-8,0,38" Name="listSnippets" HorizontalContentAlignment="Left" MouseRightButtonDown="listSnippets_MouseRightButtonDown" SelectionMode="Single" SelectionChanged="listSnippets_SelectionChanged" MouseDoubleClick="listSnippets_MouseDoubleClick"> </ListBox> <Popup Placement="Mouse" Name="popupHint" HorizontalAlignment="Left" VerticalAlignment="Top" IsOpen="False" AllowsTransparency="True"> <Border BorderBrush="Black" BorderThickness="1"> <Grid Background="White"> <TextBlock Background="White" x:Name="PopupTxt" TextAlignment="Center" VerticalAlignment="Center"> </TextBlock> </Grid> </Border> </Popup> <WrapPanel Height="40" Name="wrapPanel1" VerticalAlignment="Bottom" HorizontalAlignment="Center"> <Button Height="26" Name="menu" Width="65" Margin="5" Click="menu_Click">Menu</Button> <Button Height="26" Name="clear" Width="65" Margin="5" Click="new_Click">Clear</Button> </WrapPanel> </Grid></Window> Maybe you can notice that code is short...
by jNayden | Sep 12, 2009 | .net, Aggregated
Hello all, today I will post a simple code snippet manager created using C# and WPF. The idea of the app is to be used when making presentations and you need to paste all kind of code snippets (html, xaml, C#, java ). The similar tool is used by Karen Corby in MIX09 presentation about creating silverlight controls.This is my first .net application so you will see all kind of C# strangeness like using “Object” instead of “object” and String instead of “string”. Because this was my first application I choose to use WPF not WinForms because WinForms is a lot like Swing and I’ve wanted to see “how declarative XML for the UI is better” and I can say: “hmm ok there is some big pluses”. Anyway I have little experience with Flex’s MXML too and if you ask me the MXML is a lot than XAML. The code snipper manager application lokks like this : The view is very simple and I can say that XAML is perfect for creating a simple views and there is tones of snippets in internet for all kinds of examples like popup for example. The application XAML looks like this : <Window x:Class="CodeSnippetManager.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Snipper Manager" Height="355" Width="177" Topmost="True" ResizeMode="NoResize" > <Grid Height="309"> <ListBox Margin="0,-8,0,38" Name="listSnippets" HorizontalContentAlignment="Left" MouseRightButtonDown="listSnippets_MouseRightButtonDown" SelectionMode="Single" SelectionChanged="listSnippets_SelectionChanged" MouseDoubleClick="listSnippets_MouseDoubleClick"> </ListBox> <Popup Placement="Mouse" Name="popupHint" HorizontalAlignment="Left" VerticalAlignment="Top" IsOpen="False" AllowsTransparency="True"> <Border BorderBrush="Black" BorderThickness="1"> <Grid Background="White"> <TextBlock Background="White" x:Name="PopupTxt" TextAlignment="Center" VerticalAlignment="Center"> </TextBlock> </Grid> </Border> </Popup> <WrapPanel Height="40" Name="wrapPanel1" VerticalAlignment="Bottom" HorizontalAlignment="Center"> <Button Height="26" Name="menu" Width="65" Margin="5" Click="menu_Click">Menu</Button> <Button Height="26" Name="clear" Width="65" Margin="5" Click="new_Click">Clear</Button> </WrapPanel> </Grid></Window> Maybe you can notice that code is short...
Recent Comments