Xml Literals in C#
Hi,
I dont know if someone already answered this question but, how come c#'s version of xlinq (, or c#3.0, or c# orcas, or whatever it's called now) does not include xml literals! I cant imagine a reason not to include thins functionality beyond being too hard to do in c# or something like than.
Answers
- The C# design team has prioritized language changes like XML literals down quite a bit, believing that the XLinq constructors offer an equivalent degree of functionality. However, we are generally open on these sorts of things. If we get a lot of feedback from the community like yours we may reconsider our position.
The LINQ CTP includes a Visual Studio Add-in for this. It's pretty easy to use. Just copy some XML onto the clipboard. Then use "Paste XML as XElement" on the Edit menu and you'll get the XLinq code required to create that XML.
Anders
All Replies
- The C# design team has prioritized language changes like XML literals down quite a bit, believing that the XLinq constructors offer an equivalent degree of functionality. However, we are generally open on these sorts of things. If we get a lot of feedback from the community like yours we may reconsider our position.
There is also an XML-paster feature in the latest preview that you may want to try out.
Thanks.
Dinesh
- Can you point me in the right direction to see this
The LINQ CTP includes a Visual Studio Add-in for this. It's pretty easy to use. Just copy some XML onto the clipboard. Then use "Paste XML as XElement" on the Edit menu and you'll get the XLinq code required to create that XML.
Anders
- Hi,
Where I can find this in VS.Net 2008?
Kind Regards,
Lennie De Villiers In VS 2008, from the main menu: Help/Samples/LocalSamplesFolder/CSharpSamples/LinqSamples/PasteXmlAsLinq.
Ion
- That's very nice (honestly), but it doesn't handle something like this (from Beth Massey's dynamic Xaml example - http://code.msdn.microsoft.com/dynamicWPF/Release/ProjectReleases.aspx?ReleaseId=1201). So, my vote is for adding XML Literals to C#.
<
Grid xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="Grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="200*"/>
</Grid.ColumnDefinitions>
<StackPanel Name="StackLabels" Margin="3">
<%= From column In Me.TableSchema _
Where column.IsPrimaryKey = 0 AndAlso column.DataType <> "timestamp" _
Select <Label Height="28" Name=<%= column.ColumnName & "Label" %>
HorizontalContentAlignment="Right">
<%= column.ColumnName %>:</Label> %>
</StackPanel>
<StackPanel Grid.Column="1" Name="StackFields" Margin="3">
<%= From column In Me.TableSchema _
Where column.IsPrimaryKey = 0 AndAlso column.DataType <> "timestamp" _
Select GetUIElement(column) %>
</StackPanel>
</Grid>

