Apr 22, 2011, 11:38 AM
[CLOSED] How to add Guid[] property to the component?
Hello!
I need to add array of GUID to some components. I had override property:
How add similar (array of GUID) property correctly?
At this time I use workaround:
Thanks!
I need to add array of GUID to some components. I had override property:
....
public Guid[] Guids
{
get; set;
}
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[XmlIgnore]
[JsonIgnore]
public override ConfigOptionsCollection ConfigOptions
{
get
{
ConfigOptionsCollection list = base.ConfigOptions;
list.Add("guids", null, this.Guids));
return list;
}
}
....
I expect get JS of constructor like:new Ext.Component({
...
guids: ["E5224141-DECE-444C-AA53-629C04880339", "EA3020DD-D8D3-4264-934D-A56111D61E08", "0BB07B1D-F955-48E5-B888-5AD9D9F47BBD"]
...
})
But my new property wasn't setted. All that I get the error:Unsupported type: System.Guid[]. Use the JsonSerializer class to get the object's JSON representation.
It's happend at line:var script = panel.ToScript(RenderMode.AddTo, modalEditor ? "Viewport1" : "TabPanel1");
I am sure that property has been setted and value wasn't Null. I create component from code and get them JS code by method this.ToScript().How add similar (array of GUID) property correctly?
At this time I use workaround:
var guidArray = JsonConvert.SerializeObject(this.LinkedItems);
list.Add("linkedItems",
new ConfigOption("linkedItems",
new SerializationOptions("linkedItems", JsonMode.Raw),
null,
guidArray));
I think it's bad practice.Thanks!
Last edited by Daniil; May 02, 2011 at 10:29 AM.
Reason: [CLOSED]