Exemple #1
0
        /// <summary>
        /// Load a dream configuration file
        /// </summary>
        /// <param name="buffer">a buffer containing the document to load</param>
        public void Load(string buffer)
        {
            ValidateConfiguration(new StringReader(buffer), Resources.DreamBuilderXSD);

            var document = new XmlDocument();

            document.Load(new StringReader(buffer));

            config = (DreamConfig)Deserialize(document, typeof(DreamConfig));
        }
Exemple #2
0
        /// <summary>
        /// Parse Dream XML definition file
        /// </summary>
        private void ParseDreamDefinition()
        {
            // Read data
            var configuration = new DreamConfiguration();

            string buffer = ReplaceDefines(File.ReadAllText(inputFile));

            try
            {
                configuration.Load(buffer);
            } catch (Exception e) {
                OutputError("Error loading configuration file", null, e);
            }

            DreamConfig dream = configuration.Config;

            name        = dream.name;
            description = dream.description;
            author      = dream.author;
            url         = dream.url;
            preview     = LoadPreview(dream.preview);

            copyright   = dream.copyright;
            permissions = dream.permissions;

            // Check that name is valid as a filename
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("Checking dream output name...");
            CheckForInvalidChars(name);
            Console.Write("\t[OK]\n");
            Console.ResetColor();

            Console.WriteLine("");
            switch (configuration.Type)
            {
            case DreamType.Video:
                LoadVideoDream(dream.data.video);
                break;

            case DreamType.Trigger:
                LoadTriggersDream(dream.data.triggers);
                break;

            case DreamType.Dynamic:
                LoadDynamicDream(dream.data.dynamic);
                break;

            case DreamType.Invalid:
                OutputError("Invalid dream!", "The Dream configuration file is invalid", null);
                break;
            }
        }