Ejemplo n.º 1
0
        /// <summary>Parses a component profile </summary>
        private AbstractComponent parseComponentProfile(System.Xml.XmlElement elem, bool isSubComponent)
        {
            AbstractComponent comp = null;

            if (isSubComponent)
            {
                comp = new SubComponent();
            }
            else
            {
                comp = new Component();

                int childIndex = 1;
                System.Xml.XmlNodeList children = elem.ChildNodes;
                for (int i = 0; i < children.Count; i++)
                {
                    System.Xml.XmlNode n = children.Item(i);
                    if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element)
                    {
                        System.Xml.XmlElement child = (System.Xml.XmlElement)n;
                        if (child.Name.ToUpper().Equals("SubComponent".ToUpper()))
                        {
                            SubComponent subcomp = (SubComponent)parseComponentProfile(child, true);
                            ((Component)comp).setSubComponent(childIndex++, subcomp);
                        }
                    }
                }
            }

            parseAbstractComponentData(comp, elem);

            return(comp);
        }
Ejemplo n.º 2
0
        /// <summary>Parses a field profile </summary>
        private Field parseFieldProfile(System.Xml.XmlElement elem)
        {
            Field field = new Field();

            field.Usage = elem.GetAttribute("Usage");
            System.String itemNo = elem.GetAttribute("ItemNo");
            System.String min    = elem.GetAttribute("Min");
            System.String max    = elem.GetAttribute("Max");

            try
            {
                if (itemNo.Length > 0)
                {
                    field.ItemNo = System.Int16.Parse(itemNo);
                }
            }
            catch (System.FormatException e)
            {
                throw new NuGenProfileException("Invalid ItemNo: " + itemNo + "( for name " + elem.GetAttribute("Name") + ")", e);
            }             // try-catch

            try
            {
                field.Min = System.Int16.Parse(min);
                if (max.IndexOf('*') >= 0)
                {
                    field.Max = (short)(-1);
                }
                else
                {
                    field.Max = System.Int16.Parse(max);
                }
            }
            catch (System.FormatException e)
            {
                throw new NuGenProfileException("Min and max must be short integers: " + min + ", " + max, e);
            }

            parseAbstractComponentData(field, elem);

            int childIndex = 1;

            System.Xml.XmlNodeList children = elem.ChildNodes;
            for (int i = 0; i < children.Count; i++)
            {
                System.Xml.XmlNode n = children.Item(i);
                if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element)
                {
                    System.Xml.XmlElement child = (System.Xml.XmlElement)n;
                    if (child.Name.ToUpper().Equals("Component".ToUpper()))
                    {
                        Component comp = (Component)parseComponentProfile(child, false);
                        field.setComponent(childIndex++, comp);
                    }
                }
            }

            return(field);
        }
Ejemplo n.º 3
0
		/// <summary>Parses a component profile </summary>
		private AbstractComponent parseComponentProfile(System.Xml.XmlElement elem, bool isSubComponent)
		{
			AbstractComponent comp = null;
			if (isSubComponent)
			{
				comp = new SubComponent();
			}
			else
			{
				comp = new Component();
				
				int childIndex = 1;
				System.Xml.XmlNodeList children = elem.ChildNodes;
				for (int i = 0; i < children.Count; i++)
				{
					System.Xml.XmlNode n = children.Item(i);
					if (System.Convert.ToInt16(n.NodeType) == (short) System.Xml.XmlNodeType.Element)
					{
						System.Xml.XmlElement child = (System.Xml.XmlElement) n;
						if (child.Name.ToUpper().Equals("SubComponent".ToUpper()))
						{
							SubComponent subcomp = (SubComponent) parseComponentProfile(child, true);
							((Component) comp).setSubComponent(childIndex++, subcomp);
						}
					}
				}
			}
			
			parseAbstractComponentData(comp, elem);
			
			return comp;
		}