Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MedakaApplication"/> class.
 /// </summary>
 /// <param name="xml">The configuration XML file.</param>
 /// <param name="appName">Name of the application.</param>
 public MedakaApplication(XNpc xml, String appName) :
     base(GetRoot(xml, appName))
 {
     this.Xml             = xml;
     this.ApplicationName = appName;
     this.InitAttributes();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the root XElement
 /// </summary>
 /// <param name="xml">The XML.</param>
 /// <param name="appName">Name of the application.</param>
 /// <returns>The root XElement</returns>
 private static XElement GetRoot(XNpc xml, string appName)
 {
     if (GetStatus(xml.Document, appName) == ConfigStatus.Damage)
     {
         xml.CreateDocument();
     }
     return(xml.Document.Elements(appName).FirstOrDefault());
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationMedaka"/> class.
        /// </summary>
        /// <param name="config_File">The configuration file.</param>
        /// <param name="appName">Name of the application.</param>
        public ConfigurationMedaka(IoFileInfo config_File, string appName)
        {
            string aName = appName.ToXmlName();

            try
            {
                //1: Checamos la existencia del archivo, en caso de no existir lo creamos
                this.CheckFile(config_File.FullName);
                //2: Se carga el xml de memoria
                var xml = new XNpc(aName, config_File);
                this.MedakaApp = new MedakaApplication(xml, aName);
            }
            catch (Exception exc)
            {
                throw exc.CreateNamelessException <BlackMateriaException>(ERR_INIT_MEDAKA);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates access to a configuration file, a configuration file doesn't allow duplicate
        /// nodes, each configuration category must be unique
        /// </summary>
        /// <param name="config_File">The configuration file, path</param>
        /// <param name="appName">The application name is the name for the root xml element</param>
        public ConfigMedaka(IoFileInfo config_File, string appName)
        {
            this.aName = appName.ToXmlName();
            //1: Checamos la existencia del archivo, en caso de no existir lo creamos
            this.CheckFile(config_File.FullName);
            //2: Generamos el Xml NPC
            this.Xml      = new XNpc(this.aName, config_File);
            this.App_Node = new MedakaApplication(this.Xml, this.aName);
            //3: Inicializamos la colección
            this.categories = new Dictionary <string, ConfigCategory>();
            switch (GetConfigFileStatus())
            {
            case ConfigStatus.Damage:
                this.Xml.CreateDocument();
                break;

            default:
                FillCategory();
                break;
            }
        }