render xml with dynamic resolution of name element?

Mar 20, 2014 at 2:11 PM
Edited Mar 20, 2014 at 2:11 PM
Is there any way to model this type of xml .
<Placement>
  <Place Parts_Intelli_SiteSettings="Content:1"/>
  <Place Parts_IntelliContentItemId_Edit="Content:after"/>
  <Place Parts_IntelliAssetItemId_Edit="Content:after"/>
  <Place Parts_IntelliListReportWidget_Edit="Content:after"/>
  
  <Place Parts_IntelliListReportWidget="Content:1"/>
  <Place Parts_IntelliChartReportWidget="Content:1"/>
  <Place Parts_IntelliPivotReportWidget="Content:1"/>
  <Place Parts_IntelliSchedulerReportWidget="Content:1"/>

  <Place Parts_sectiontest2="Content:1"/>
  <Place Parts_sectiontest2_Edit="Content:1"/>
  <Place Parts_sectiontest6="Content:1"/>
  <Place Parts_sectiontest6_Edit="Content:1"/>
</Placement>
My c# classes look like this
 [YAXSerializeAs("Placement")]
    public class PlacementRoot
    {
        private List<PlacementElement> _placementElements;

        [YAXErrorIfMissed(YAXExceptionTypes.Ignore)]
        [YAXCollection(YAXCollectionSerializationTypes.RecursiveWithNoContainingElement, EachElementName = "Place")]
        public List<PlacementElement> PlacementElements
        {
            get { return _placementElements ?? (_placementElements = new List<PlacementElement>()); }
            set { _placementElements = value; }
        }
    }
    [YAXSerializeAs("Place")]
    public class PlacementElement
    {
       

        [YAXAttributeForClass]
        [YAXErrorIfMissed(YAXExceptionTypes.Ignore)]
        public string Name { get ; set; }

 
    }
Is there any way to make the name attribute of placement element dynamic so that it is rendered as the xml shown above .
Thanks
Giannis
Coordinator
Mar 21, 2014 at 2:15 AM
I'm not exactly sure how your desired serialization is supposed to work, but see if custom serializers are what you want. Here's a sample:
http://yaxlib.codeplex.com/SourceControl/latest#YAXLibTests/SampleClasses/CustomSerializationTests.cs

You can also run the demo application and click on CustomSerializationTests to see the serialized XML.

I think you can create a custom serializer for your PlacementElement class for this purpose; but you are going to be responsible for serizalizing and deserializing the content.
Mar 21, 2014 at 9:36 AM
Thanks for the pointers.
Giannis