Esempio n. 1
0
        IWidget IApplicationDefinition.CreateWidget(string name, IWidgetInfo widgetInfo)
        {
            var wparams = widgetInfo.Parameters;

            IWidget widget = null;

            if (widgetInfo.StandardUi)
            {
                widget = new UiWidgetType()
                {
                    Disabled = "false", //NOXLATE
                    Extension = new CustomContentType() { Any = new XmlElement[0] },
                    ImageClass = widgetInfo.ImageClass ?? string.Empty, //Required to satisfy content model
                    ImageUrl = widgetInfo.ImageUrl ?? string.Empty, //Required to satisfy content model
                    Label = widgetInfo.Label ?? string.Empty, //Required to satisfy content model
                    Location = widgetInfo.Location ?? string.Empty, //Required to satisfy content model
                    Name = name,
                    StatusText = widgetInfo.StatusText ?? string.Empty, //Required to satisfy content model
                    Tooltip = widgetInfo.Tooltip ?? string.Empty, //Required to satisfy content model
                    Type = widgetInfo.Type
                };
            }
            else
            {
                widget = new WidgetType()
                {
                    Extension = new CustomContentType() { Any = new XmlElement[0] },
                    Location = widgetInfo.Location ?? string.Empty, //Required to satisfy content model
                    Name = name,
                    Type = widgetInfo.Type,
                };
            }

            NameValueCollection extProperties = new NameValueCollection();

            foreach (var wp in widgetInfo.Parameters)
            {
                if (!string.IsNullOrEmpty(wp.DefaultValue))
                {
                    extProperties.Add(wp.Name, wp.DefaultValue);
                }
                else
                {
                    extProperties.Add(wp.Name, string.Empty);
                }
            }

            widget.SetAllValues(extProperties);

            return widget;
        }
 public static bool Deserialize(string xml, out WidgetType obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 public static bool LoadFromFile(string fileName, out WidgetType obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an WidgetType object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output WidgetType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out WidgetType obj, out System.Exception exception) {
     exception = null;
     obj = default(WidgetType);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
 /// <summary>
 /// Deserializes xml markup from file into an WidgetType object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output WidgetType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out WidgetType obj, out System.Exception exception) {
     exception = null;
     obj = default(WidgetType);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }