I'm writing some code for manipulating WiX XML.  For example  for 
Feature@Absent I create an enum: 

    public enum Absent { allow, disallow } 

then later I use: 

public Absent? Absent 

public Absent? Absent
        {
            get
            { 

                Absent? absent = null;
                string attributeValue = 
_featureElement.GetOptionalAttribute("Absent"); // Extension method that 
returns String.Empty if an attribute doesn't exist
                if (attributeValue != string.Empty)
                {
                    absent = (Absent)Enum.Parse(typeof(Absent), 
attributeValue, true);
                }
                return absent;
            }
            set
            {
                _featureElement.SetAttributeValue("Absent", value);
            }
        } 

Finally in another class I wrap it to be suitable for a PropertyGrid 
SelectedObject: 

[CategoryAttribute("General")]
[Description(@"This attribute determines if a user will have the option to 
set a feature to absent in the user interface.")]
public Absent? Absent { get; set; }
         

This gives me the exact behavior. The property grid has 3 choices.  null, 
allow and disallow and the XML writes exactly the way I want.  Null removes 
the attribute and allow/disallow creates and sets it to said value.  

Where it gets trick is Feature@Display.  This attribute is kind of like an 
enum ( collapse, hidden, exapand ) but also allows an integer for fine 
grained control.   Does anyone have any suggestions on how I might create a 
POCO class for representing that and presenting it to the property grid?  

  
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
WiX-devs mailing list
WiX-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-devs

Reply via email to