Ejemplo n.º 1
0
        public static void Configure(String fileName)
        {
            try
            {
                XmlSerializer s  = new XmlSerializer(typeof(XMLContextRoot));
                FileStream    fs = File.Open(fileName, FileMode.Open);
                IContextRoot  r  = (IContextRoot)s.Deserialize(fs);
                fs.Close();

                IConfigurationElementVisitor v = new XMLParentInitializationVisitor();
                r.Accept(v);

                v = new ConfigurationCheckVisitor();
                r.Accept(v);

                foreach (IContext context in r.Contexts)
                {
                    ContextManager.Instance.RegisterContext(context);
                }
            }
            catch (Exception ex)
            {
                throw new ContextCorruptedException("Context couldn't be configured. (" + ex.Message + ")");
            }
        }
        public static void Configure(String fileName)
        {
            try
            {
                XmlSerializer s = new XmlSerializer(typeof(XMLContextRoot));
                FileStream fs = File.Open(fileName, FileMode.Open);
                IContextRoot r = (IContextRoot)s.Deserialize(fs);
                fs.Close();

                IConfigurationElementVisitor v = new XMLParentInitializationVisitor();
                r.Accept(v);

                v = new ConfigurationCheckVisitor();
                r.Accept(v);

                foreach (IContext context in r.Contexts)
                {
                    ContextManager.Instance.RegisterContext(context);
                }
            }
            catch (Exception ex)
            {
                throw new ContextCorruptedException("Context couldn't be configured. (" + ex.Message + ")");
            }
        }