Example #1
0
        /// <summary>
        /// Tries to load a component from specifed xml node.
        /// </summary>
        /// <param name="node">XML node.</param>
        /// <param name="component">Loaded component.</param>
        /// <returns>True for sucessfull load, otherwise false.</returns>
        private bool TryLoadComponenet(XmlNode node, out UIComponent component)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            component = null;

            //check if there is attributes, if no attributes exists (eg invalid configuration or commented node) we cant proceed so return false
            if (node.Attributes == null || node.Attributes.Count == 0)
                return false;

            //check if all required parameters present
            if (node.Attributes["Assembly"] == null ||
                node.Attributes["Type"] == null ||
                node.Attributes["GUID"] == null)
            {
                return false;
            }

            //validate parameters
            if (!this.IsValidGUID(node.Attributes["GUID"].Value))
                return false;

            //create new ui component
            var uiComponent = new UIComponent(this);
            uiComponent.AssemblyName = node.Attributes["Assembly"].Value;
            uiComponent.Type = node.Attributes["Type"].Value;
            uiComponent.GUID = node.Attributes["GUID"].Value;

            if (node.Attributes["Title"] != null)
                uiComponent.Title = node.Attributes["Title"].Value;

            if (node.Attributes["Description"] != null)
                uiComponent.Description = node.Attributes["Description"].Value;

            //assign out value
            component = uiComponent;

            return true;
        }
Example #2
0
 /// <summary>
 /// Adds UI component to internal collection.
 /// </summary>
 /// <param name="Componenet"></param>
 private void InternalAdd(UIComponent Componenet)
 {
     this.ComponentDictionary.Add(Componenet.GUID, Componenet);
     this.Components.Add(Componenet);
 }