private void LoadParameterOptions(object o, MetaNode node)
 {
     if (o != null)
     {
         foreach (PropertyInfo prop in o.GetType().GetProperties())
         {
             // Recurse to get parameters.
             if (prop.CanWrite)
             {
                 object[] customAttributes = prop.GetCustomAttributes(typeof(ParameterFileAttribute), true);
                 for (int i = 0; i < customAttributes.Length; i++)
                 {
                     ParameterFileAttribute attr = customAttributes[i] as ParameterFileAttribute;
                     if (attr != null && attr.Name != "")
                     {
                         try
                         {
                             object val;
                             val = node.GetValue(attr.Name);
                             prop.SetValue(o, val, BindingFlags.SetProperty, null, null, null);
                         }
                         catch
                         {
                             //System.Windows.Forms.MessageBox.Show("Could not load " + attr.Description + " parameter. " + ex.Message);
                         }
                     }
                 }
             }
         }
         foreach (FieldInfo field in o.GetType().GetFields())
         {
             object[] customAttributes = field.GetCustomAttributes(typeof(ParameterFileAttribute), true);
             for (int i = 0; i < customAttributes.Length; i++)
             {
                 ParameterFileAttribute attr = customAttributes[i] as ParameterFileAttribute;
                 if (attr != null)
                 {
                     try
                     {
                         object val = node.GetValue(attr.Name);
                         if (val != null)
                         {
                             field.SetValue(o, val);
                         }
                     }
                     catch
                     {
                         //System.Windows.Forms.MessageBox.Show("Could not load " + attr.Description + " parameter. " + ex.Message);
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Reflects the object o for parameter options to load.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="node"></param>
        private void ReflectParameterOptions(object o, MetaNode node)
        {
            if (o != null)
            {
                ///
                /// Iterate all the properties
                ///
                foreach(PropertyInfo prop in o.GetType().GetProperties())
                {
                    // Recurse to get parameters.
                    if (prop.CanRead)
                    {
                        object[] customAttributes = prop.GetCustomAttributes(typeof(ParameterFileAttribute),true);
                        object potential = null;
                        if (customAttributes.Length > 0)
                            potential = prop.GetValue(o,
                                BindingFlags.GetProperty,
                                null,
                                null,
                                null);
                        for (int i = 0; i < customAttributes.Length; i++)
                        {

                            ParameterFileAttribute attr = customAttributes[i] as ParameterFileAttribute;

                            if (potential != null && attr != null && attr.Name != "")
                            {
                                try
                                {

                                    node.SetValue(attr.Name, potential);
                                }
                                catch(Exception ex)
                                {
                                    System.Diagnostics.Debug.WriteLine(ex.Message);
                                }
                            }
                        }
                    }
                }

                ///
                /// Iterate all the fields
                ///
                foreach(FieldInfo field in o.GetType().GetFields())
                {
                    object[] customAttributes	= field.GetCustomAttributes(typeof(ParameterFileAttribute),true);
                    object objectValue = null;
                    if (customAttributes.Length > 0)
                        objectValue	   = field.GetValue(o);
                    for (int i = 0; i < customAttributes.Length; i++)
                    {
                        ParameterFileAttribute attr = customAttributes[i] as ParameterFileAttribute ;
                        if (objectValue != null && attr != null)
                        {
                            try
                            {
                                node.SetValue(attr.Name, objectValue);
                            }
                            catch
                            {
                                // what?
                            }
                        }
                    }
                }
            }
        }
示例#3
0
文件: xmlIO.cs 项目: msdna/MultiAlign
        public MetaNode OpenChildFromArray(string id, int index)
        {
            XmlNode node = OpenXmlNodeFromArray(id, index);

            MetaNode retNode = new MetaNode(node, doc);
            return (retNode);
        }
示例#4
0
文件: xmlIO.cs 项目: msdna/MultiAlign
        public MetaNode OpenChild(string id, int index, bool createIfMissing)
        {
            XmlNode node = OpenXmlNode(id, "node", index, true, createIfMissing);

            if (node == null)
                return null;

            MetaNode retNode = new MetaNode(node, doc);
            return (retNode);
        }
示例#5
0
文件: xmlIO.cs 项目: msdna/MultiAlign
        public MetaNode OpenChild(string id, string childType, int index)
        {
            XmlNode node = OpenXmlNode(id, childType, index, true, true);

            MetaNode retNode = new MetaNode(node, doc);
            return (retNode);
        }