예제 #1
0
 public WyamFileProvider(IReadOnlyFileSystem fileSystem)
 {
     if (fileSystem == null)
     {
         throw new ArgumentNullException(nameof(fileSystem));
     }
     _fileSystem = fileSystem;
 }
예제 #2
0
파일: ZipFile.cs 프로젝트: CH4Code/OpenRA
        public ZipFile(IReadOnlyFileSystem context, string filename, bool createOrClearContents = false)
        {
            Name = filename;

            if (createOrClearContents)
                pkg = SZipFile.Create(filename);
            else
                pkg = new SZipFile(filename);
        }
예제 #3
0
 public ReadOnlyChrootFileSystem(IReadOnlyFileSystem fileSystem, DirectoryName basePath)
 {
     if (fileSystem == null)
         throw new ArgumentNullException("fileSystem");
     if (basePath == null)
         throw new ArgumentNullException("basePath");
     this.fileSystem = fileSystem;
     this.basePath = basePath;
 }
예제 #4
0
        public VoxelLoader(IReadOnlyFileSystem fileSystem)
        {
            this.fileSystem = fileSystem;
            voxels = new Cache<Pair<string, string>, Voxel>(LoadFile);
            vertices = new List<Vertex[]>();
            totalVertexCount = 0;
            cachedVertexCount = 0;

            sheetBuilder = CreateSheetBuilder();
        }
예제 #5
0
        public static SolutionDescriptor CreateSolutionDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
        {
            SolutionDescriptor solutionDescriptor = new SolutionDescriptor(element.Attributes["name"].InnerText);

            if (element["Options"] != null && element["Options"]["StartupProject"] != null) {
                solutionDescriptor.startupProject = element["Options"]["StartupProject"].InnerText;
            }

            solutionDescriptor.mainFolder.Read(element, fileSystem);
            return solutionDescriptor;
        }
예제 #6
0
			internal void Read(XmlElement element, IReadOnlyFileSystem fileSystem)
			{
				name = element.GetAttribute("name");
				foreach (XmlNode node in element.ChildNodes) {
					switch (node.Name) {
						case "Project":
							projectDescriptors.Add(new ProjectDescriptor((XmlElement)node, fileSystem));
							break;
						case "SolutionFolder":
							solutionFoldersDescriptors.Add(new SolutionFolderDescriptor((XmlElement)node, fileSystem));
							break;
					}
				}
			}
예제 #7
0
 public TemplateBase LoadTemplate(Stream stream, IReadOnlyFileSystem fileSystem)
 {
     try {
         XmlDocument doc = new XmlDocument();
         doc.Load(stream);
         if (doc.DocumentElement["Files"] != null)
             return new FileTemplateImpl(doc, fileSystem);
         else if (doc.DocumentElement["Project"] != null || doc.DocumentElement["Solution"] != null)
             return new ProjectTemplateImpl(doc, fileSystem);
         else
             throw new TemplateLoadException("Unknown file format");
     } catch (XmlException ex) {
         throw new TemplateLoadException(ex.Message, ex);
     }
 }
예제 #8
0
        internal AssemblyLoader(IReadOnlyFileSystem fileSystem, IAssemblyCollection assemblyCollection, AssemblyResolver assemblyResolver)
        {
            _fileSystem = fileSystem;
            _assemblyCollection = assemblyCollection;
            _assemblyResolver = assemblyResolver;

            // Get the location of the entry assembly
            string entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location;
            DirectoryPath entryAssemblyPath = entryAssemblyLocation == null
                ? new DirectoryPath(Environment.CurrentDirectory)
                : new FilePath(entryAssemblyLocation).Directory;
            _entryAssemblyDirectory = _fileSystem.GetDirectory(entryAssemblyPath);

            // Add the Core modules
            DirectAssemblies.Add(Assembly.GetAssembly(typeof(Engine)));
        }
예제 #9
0
		public FileDescriptionTemplate(XmlElement xml, IReadOnlyFileSystem fileSystem)
		{
			TemplateLoadException.AssertAttributeExists(xml, "name");
			
			this.FileSystem = fileSystem;
			name = xml.GetAttribute("name");
			language = xml.GetAttribute("language");
			if (xml.HasAttribute("buildAction")) {
				itemType = xml.GetAttribute("buildAction");
			}
			foreach (XmlAttribute attribute in xml.Attributes) {
				string attributeName = attribute.Name;
				if (!knownAttributes.Contains(attributeName)) {
					if (attributeName == "copyToOutputDirectory") {
						ProjectTemplateImpl.WarnObsoleteAttribute(xml, attributeName, "Use upper-case attribute names for MSBuild metadata values!");
						attributeName = "CopyToOutputDirectory";
					}
					if (attributeName == "dependentUpon") {
						ProjectTemplateImpl.WarnObsoleteAttribute(xml, attributeName, "Use upper-case attribute names for MSBuild metadata values!");
						attributeName = "DependentUpon";
					}
					if (attributeName == "subType") {
						ProjectTemplateImpl.WarnObsoleteAttribute(xml, attributeName, "Use upper-case attribute names for MSBuild metadata values!");
						attributeName = "SubType";
					}
					
					metadata[attributeName] = attribute.Value;
				}
			}
			if (xml.HasAttribute("src")) {
				FileName fileName = FileName.Create(StringParser.Parse(xml.GetAttribute("src")));
				try {
					if (xml.HasAttribute("binary") && bool.Parse(xml.GetAttribute("binary"))) {
						binaryFileName = fileName;
					} else {
						content = fileSystem.ReadAllText(fileName);
					}
				} catch (Exception e) {
					content = "Error reading content from " + fileName + ":\n" + e.ToString();
					LoggingService.Warn(content);
				}
			} else {
				content = xml.InnerText;
			}
		}
예제 #10
0
파일: ZipFile.cs 프로젝트: pchote/OpenRA
        public ZipFile(IReadOnlyFileSystem context, string filename)
        {
            string name;
            IReadOnlyPackage p;
            if (!context.TryGetPackageContaining(filename, out p, out name))
                throw new FileNotFoundException("Unable to find parent package for " + filename);

            Name = name;
            Parent = p as IReadWritePackage;

            // SharpZipLib breaks when asked to update archives loaded from outside streams or files
            // We can work around this by creating a clean in-memory-only file, cutting all outside references
            pkgStream = new MemoryStream();
            using (var sourceStream = p.GetStream(name))
                sourceStream.CopyTo(pkgStream);
            pkgStream.Position = 0;

            pkg = new SZipFile(pkgStream);
        }
예제 #11
0
		/// <summary>
		/// Creates a project descriptor for the project node specified by the xml element.
		/// </summary>
		/// <param name="element">The &lt;Project&gt; node of the xml template file.</param>
		/// <param name="fileSystem">The file system from which referenced files are loaded. Use a ChrootFileSystem to specify the base directory for relative paths.</param>
		public ProjectDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
		{
			if (element == null)
				throw new ArgumentNullException("element");
			if (fileSystem == null)
				throw new ArgumentNullException("fileSystem");
			
			if (element.HasAttribute("name")) {
				name = element.GetAttribute("name");
			} else {
				name = "${ProjectName}";
			}
			languageName = element.GetAttribute("language");
			if (string.IsNullOrEmpty(languageName)) {
				ProjectTemplateImpl.WarnAttributeMissing(element, "language");
			}
			defaultPlatform = element.GetAttribute("defaultPlatform");
			
			LoadElementChildren(element, fileSystem);
		}
예제 #12
0
 public FileSystemFileProvider(IReadOnlyFileSystem fileSystem)
 {
     StatiqFileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
 }
예제 #13
0
		void LoadElement(XmlElement node, IReadOnlyFileSystem fileSystem)
		{
			switch (node.Name) {
				case "Options":
					ProjectTemplateImpl.WarnObsoleteNode(node, "Options are no longer supported, use properties instead.");
					break;
				case "CreateActions":
					LoadCreateActions(node);
					break;
				case "PreCreateActions":
					LoadPreCreateActions(node);
					break;
				case "ProjectItems":
					LoadProjectItems(node);
					break;
				case "Files":
					LoadFiles(node, fileSystem);
					break;
				case "Imports":
					LoadImports(node);
					break;
				case "PropertyGroup":
					LoadPropertyGroup(node);
					break;
				case "Include":
					TemplateLoadException.AssertAttributeExists(node, "src");
					FileName includeFileName = FileName.Create(node.GetAttribute("src"));
					try {
						XmlDocument doc = new XmlDocument();
						using (var stream = fileSystem.OpenRead(includeFileName)) {
							doc.Load(stream);
						}
						doc.DocumentElement.SetAttribute("fileName", includeFileName);
						var fileSystemForInclude = new ReadOnlyChrootFileSystem(fileSystem, includeFileName.GetParentDirectory());
						if (doc.DocumentElement.Name == "Include") {
							LoadElementChildren(doc.DocumentElement, fileSystemForInclude);
						} else {
							LoadElement(doc.DocumentElement, fileSystemForInclude);
						}
					} catch (XmlException ex) {
						throw new TemplateLoadException("Error loading include file " + includeFileName, ex);
					}
					break;
				default:
					throw new TemplateLoadException("Unknown node in <Project>: " + node.Name);
			}
		}
예제 #14
0
 public SolutionFolderDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
 {
     Read(element, fileSystem);
 }
예제 #15
0
 public SolutionFolderDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
 {
     Read(element, fileSystem);
 }
예제 #16
0
 public ITerrainInfo ParseTerrain(IReadOnlyFileSystem fileSystem, string path)
 {
     return(new DefaultTerrain(fileSystem, path));
 }
예제 #17
0
        public FrameCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders)
        {
            TypeDictionary metadata;

            frames = new Cache <string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out metadata));
        }
예제 #18
0
		public FileTemplateImpl(XmlDocument doc, IReadOnlyFileSystem fileSystem)
		{
			author = doc.DocumentElement.GetAttribute("author");
			
			XmlElement config = doc.DocumentElement["Config"];
			name         = config.GetAttribute("name");
			icon         = SD.ResourceService.GetImage(config.GetAttribute("icon"));
			category     = config.GetAttribute("category");
			defaultName  = config.GetAttribute("defaultname");
			languagename = config.GetAttribute("language");
			
			if (config.HasAttribute("subcategory")) {
				subcategory = config.GetAttribute("subcategory");
			}

			string newFileDialogVisibleAttr  = config.GetAttribute("newfiledialogvisible");
			if (newFileDialogVisibleAttr != null && newFileDialogVisibleAttr.Length != 0) {
				if (newFileDialogVisibleAttr.Equals("false", StringComparison.OrdinalIgnoreCase))
					newFileDialogVisible = false;
			}

			if (doc.DocumentElement["Description"] != null) {
				description  = doc.DocumentElement["Description"].InnerText;
			}
			
			if (config["Wizard"] != null) {
				wizardpath = config["Wizard"].Attributes["path"].InnerText;
			}
			
			if (doc.DocumentElement["Properties"] != null) {
				XmlNodeList propertyList = doc.DocumentElement["Properties"].SelectNodes("Property");
				foreach (XmlElement propertyElement in propertyList) {
					properties.Add(new TemplateProperty(propertyElement));
				}
			}
			
			if (doc.DocumentElement["Types"] != null) {
				XmlNodeList typeList = doc.DocumentElement["Types"].SelectNodes("Type");
				foreach (XmlElement typeElement in typeList) {
					customTypes.Add(new TemplateType(typeElement));
				}
			}
			
			if (doc.DocumentElement["References"] != null) {
				XmlNodeList references = doc.DocumentElement["References"].SelectNodes("Reference");
				foreach (XmlElement reference in references) {
					if (!reference.HasAttribute("include"))
						throw new InvalidDataException("Reference without 'include' attribute!");
					ReferenceProjectItem item = new ReferenceProjectItem(null, reference.GetAttribute("include"));
					item.SetMetadata("HintPath", reference.GetAttribute("hintPath"));
					var requiredTargetFramework = reference.GetElementsByTagName("RequiredTargetFramework").OfType<XmlElement>().FirstOrDefault();
					if (requiredTargetFramework != null) {
						item.SetMetadata("RequiredTargetFramework", requiredTargetFramework.Value);
					}
					requiredAssemblyReferences.Add(item);
				}
			}
			
			if (doc.DocumentElement["Actions"] != null) {
				foreach (XmlElement el in doc.DocumentElement["Actions"]) {
					Action<FileTemplateResult> action = ReadAction(el);
					if (action != null)
						actions += action;
				}
			}
			
			fileoptions = doc.DocumentElement["AdditionalOptions"];
			
			// load the files
			XmlElement files  = doc.DocumentElement["Files"];
			XmlNodeList nodes = files.ChildNodes;
			foreach (XmlNode filenode in nodes) {
				if (filenode is XmlElement) {
					this.files.Add(new FileDescriptionTemplate((XmlElement)filenode, fileSystem));
				}
			}
		}
예제 #19
0
 public EmbeddedResourceFiles()
 {
     FileSystem = new ActualFileSystem("../../Resources/");
 }
예제 #20
0
 public GitDirectory(IReadOnlyFileSystem fileSystem, in Path path, Tree tree)
 /// <summary>
 /// Returns an enumerable collection of <see cref="ReadOnlyFileSystemEntry"/> that match a search pattern in a specified path.
 /// </summary>
 /// <param name="fileSystem">The file system.</param>
 /// <param name="path">The path of the directory to look for files and directories.</param>
 /// <param name="searchPattern">The search string to match against the names of directories in path. This parameter can contain a combination
 /// of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.</param>
 /// <param name="searchOption">One of the enumeration values that specifies whether the search operation should include only the current directory
 /// or should include all subdirectories.
 /// The default value is TopDirectoryOnly.</param>
 /// <param name="searchTarget">The search target either <see cref="SearchTarget.Both"/> or only <see cref="SearchTarget.Directory"/> or <see cref="SearchTarget.File"/>. Default is <see cref="SearchTarget.Both"/></param>
 /// <returns>An enumerable collection of <see cref="ReadOnlyFileSystemEntry"/> that match a search pattern in a specified path.</returns>
 public static IEnumerable <ReadOnlyFileSystemEntry> EnumerateFileSystemEntries(this IReadOnlyFileSystem fileSystem, UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget = SearchTarget.Both)
 {
     if (searchPattern == null)
     {
         throw new ArgumentNullException(nameof(searchPattern));
     }
     foreach (var subPath in fileSystem.EnumeratePaths(path, searchPattern, searchOption, searchTarget))
     {
         yield return(fileSystem.DirectoryExists(subPath) ? (ReadOnlyFileSystemEntry) new ReadOnlyDirectoryEntry(fileSystem, subPath) : new ReadOnlyFileEntry(fileSystem, subPath));
     }
 }
 /// <summary>
 /// Returns an enumerable collection of <see cref="ReadOnlyFileSystemEntry"/> that match a search pattern in a specified path.
 /// </summary>
 /// <param name="fileSystem">The file system.</param>
 /// <param name="path">The path of the directory to look for files and directories.</param>
 /// <param name="searchPattern">The search string to match against the names of directories in path. This parameter can contain a combination
 /// of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.</param>
 /// <returns>An enumerable collection of <see cref="ReadOnlyFileSystemEntry"/> that match a search pattern in a specified path.</returns>
 public static IEnumerable <ReadOnlyFileSystemEntry> EnumerateFileSystemEntries(this IReadOnlyFileSystem fileSystem, UPath path, string searchPattern = "*")
 {
     if (searchPattern == null)
     {
         throw new ArgumentNullException(nameof(searchPattern));
     }
     return(EnumerateFileSystemEntries(fileSystem, path, searchPattern, SearchOption.TopDirectoryOnly));
 }
예제 #23
0
 public FrameCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders)
 {
     frames = new Cache <string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out _));
 }
예제 #24
0
        IEnumerable <MessageContext> GetMessageContext(string language, string[] translations, IReadOnlyFileSystem fileSystem)
        {
            var backfall = translations.Where(t => t.EndsWith("en.ftl"));
            var paths    = translations.Where(t => t.EndsWith(language + ".ftl"));

            foreach (var path in paths.Concat(backfall))
            {
                var stream = fileSystem.Open(path);
                using (var reader = new StreamReader(stream))
                {
                    var options = new MessageContextOptions {
                        UseIsolating = false
                    };
                    var messageContext = new MessageContext(language, options);
                    var errors         = messageContext.AddMessages(reader);
                    foreach (var error in errors)
                    {
                        Log.Write("debug", error.ToString());
                    }

                    yield return(messageContext);
                }
            }
        }
예제 #25
0
 public FileImporter(IReadOnlyFileSystem fileSystem)
 {
     _fileSystem = fileSystem;
 }
예제 #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileSystem"></param>
 /// <param name="filename"></param>
 /// <param name="loaders"></param>
 /// <param name="sheetBuilder"></param>
 /// <returns></returns>
 public static Sprite[] GetSprites(IReadOnlyFileSystem fileSystem, string filename, ISpriteLoader[] loaders, SheetBuilder sheetBuilder)
 {
     return(GetFrames(fileSystem, filename, loaders).Select(a => sheetBuilder.Add(a)).ToArray());
 }
예제 #27
0
 public SpriteCache(IReadOnlyFileSystem fileSystem, SpriteLoaderBase[] loaders, SheetBuilder2D sheetBuilder)
 {
     SheetBuilder2D  = sheetBuilder;
     this.fileSystem = fileSystem;
     this.loaders    = loaders;
 }
예제 #28
0
 public FileImporter(IReadOnlyFileSystem fileSystem, Func <string, string> importPathFunc)
 {
     _fileSystem     = fileSystem;
     _importPathFunc = importPathFunc;
 }
예제 #29
0
 ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem)
 {
     return(new ImmutablePalette(new Dat(fileSystem.Open(Filename)).Colors[Index]));
 }
예제 #30
0
 public SpriteCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders, SheetBuilder sheetBuilder)
 {
     SheetBuilder    = sheetBuilder;
     this.fileSystem = fileSystem;
     this.loaders    = loaders;
 }
예제 #31
0
파일: Model.cs 프로젝트: Mete0/anki-OpenRA
 public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary <string, MiniYamlNode> modelDefinitions)
 {
     return(new PlaceholderModelCache());
 }
예제 #32
0
        public SpriteCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders, SheetBuilder sheetBuilder)
        {
            SheetBuilder = sheetBuilder;

            sprites = new Cache<string, Sprite[]>(filename => SpriteLoader.GetSprites(fileSystem, filename, loaders, sheetBuilder));
        }
예제 #33
0
 public FileSystemReader(IReadOnlyFileSystem fileSystem)
 {
     _fileSystem = fileSystem;
 }
예제 #34
0
 public ProjectDirectoryListingProvider([NotNull] MetadataJson metadata, [NotNull] IReadOnlyFileSystem readOnlyFileSystem)
 {
     this.metadata           = metadata;
     this.readOnlyFileSystem = readOnlyFileSystem;
 }
예제 #35
0
파일: Sound.cs 프로젝트: OpenRA/OpenRA
 public void Initialize(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem)
 {
     sounds = new Cache<string, ISoundSource>(s => LoadSound(loaders, fileSystem, s));
     currentSounds = new Dictionary<uint, ISound>();
     music = null;
     currentMusic = null;
     video = null;
 }
예제 #36
0
		void LoadElementChildren(XmlElement parentElement, IReadOnlyFileSystem fileSystem)
		{
			foreach (XmlElement node in ChildElements(parentElement)) {
				LoadElement(node, fileSystem);
			}
		}
예제 #37
0
        public static SolutionDescriptor CreateSolutionDescriptor(XmlElement element, IReadOnlyFileSystem fileSystem)
        {
            SolutionDescriptor solutionDescriptor = new SolutionDescriptor(element.Attributes["name"].InnerText);

            if (element["Options"] != null && element["Options"]["StartupProject"] != null)
            {
                solutionDescriptor.startupProject = element["Options"]["StartupProject"].InnerText;
            }

            solutionDescriptor.mainFolder.Read(element, fileSystem);
            return(solutionDescriptor);
        }
예제 #38
0
		void LoadFiles(XmlElement filesElement, IReadOnlyFileSystem fileSystem)
		{
			foreach (XmlElement fileElement in ChildElements(filesElement)) {
				files.Add(new FileDescriptionTemplate(fileElement, fileSystem));
			}
		}
예제 #39
0
        public void Draw2()
        {
            //вызовы SetPalette в Draw для UI элементов, конкурируют с RefreshPalette в World.Draw.
            //Game.Renderer.SetPalette(hardwarePalette); //теперь не нужно, так как обнаружен файл palettes.yaml, в котором все палитры есть и сделано через него.

            if (String.IsNullOrEmpty(cachedVideo))
            {
                return;
            }
            //if (video==null)
            //{
            //    return;
            //}
            //Game.RunTime MilliSeconds 1s=1000ms=50ms*20times
            var deltaScale = Game.RunTime - lastDrawTime;

            CountForWaitNextFrameMs += deltaScale;

            //if we need pause wait it

            if (CountForPause > PauseInSeconds * 1000)
            {
                if (VideoStackList != null)
                {//only move next, first video must be dequed from PlayVideoStack
                    if (VideoStackList.Count > 0)
                    {
                        CountForPause           = 0;
                        CountForWaitNextFrameMs = 0;
                        Load(VideoStackList.Dequeue());
                        lastDrawTime = Game.RunTime;
                        stopped      = paused = false;
                        return;
                    }
                    //stop video
                }
                //нужно остановить медиа=сцену и передать контроль дальше
                cachedVideo = null;
                Exit();
                return;
            }
            if (CountForWaitNextFrameMs < DrawPrevFrameEveryXMs) //code runs every tick before Next Video frame to fill the gap
            {
                if (prevSprite != null)
                {
                    //just draw the same frame
                    Game.Renderer.SpriteRenderer.DrawSprite(prevSprite, videoOrigin, pr, videoSize);
                }
                if (prevText != null)
                {
                    DrawWsaText(prevText);
                }
                return;
            }
            else
            {
                if (video != null && prevSprite != null)
                {
                    if (video.CurrentFrame >= video.Length - 1) //this code runs every DrawFrameEveryXMilliseconds when video is ended.
                    {
                        //on video last frame draw always last frame
                        Game.Renderer.SpriteRenderer.DrawSprite(prevSprite, videoOrigin, pr, videoSize);
                        CountForPause += deltaScale; //incerease CountForPause to enter at if (CountForPause > PauseInSeconds * 1000)
                        lastDrawTime   = Game.RunTime;
                        if (prevText != null)
                        {
                            DrawWsaText(prevText);
                        }

                        return;
                    }

                    //if not last frame of video, move next frame
                    video.AdvanceFrame();
                }
                if (image != null && prevSprite != null)
                {
                    Game.Renderer.SpriteRenderer.DrawSprite(prevSprite, videoOrigin, pr, videoSize);
                    CountForPause += deltaScale; //incerease CountForPause to enter at if (CountForPause > PauseInSeconds * 1000)
                    lastDrawTime   = Game.RunTime;
                    return;
                }

                if (prevText != null)
                {
                    DrawWsaText(prevText);
                }
                //||
                //\/
            }

            if (video != null)
            {
                if (frameSoundLine == null)
                {
                }

                else
                {
                    if (frameSoundLine.Contains(new FrameSoundLine()
                    {
                        WSAfilename = cachedVideo, FrameNumber = video.CurrentFrame
                    }))
                    {
                        var vocfilename = frameSoundLine.Find(x => x.WSAfilename.Contains(cachedVideo) && x.FrameNumber == video.CurrentFrame).VOCfilename;
                        if (vocfilename.Contains("ADL"))
                        {
                            IReadOnlyFileSystem fileSystem = Game.ModData.DefaultFileSystem;

                            if (!fileSystem.Exists(vocfilename))
                            {
                                Log.Write("sound", "LoadSound, file does not exist: {0}", vocfilename);
                            }
                            DuneMusic.Quit();
                            DuneMusic.Init(44100, "", DuneMusic.DuneMusicOplEmu.kOplEmuNuked);

                            using (var stream = fileSystem.Open(vocfilename))
                            {
                                DuneMusic.InsertMemoryFile("test", stream.ReadAllBytes());
                                byte[] temp = new byte[28106880];

                                UIntPtr temp3;
                                temp3 = (UIntPtr)1000000;
                                temp3 = DuneMusic.SynthesizeAudio("test", 52, -1, temp, (UIntPtr)temp.Length);
                                ISoundSource soundSource;
                                soundSource = Game.Sound.soundEngine.AddSoundSourceFromMemory(temp, 2, 16, 44100);
                                ISound temp2 = Game.Sound.soundEngine.Play2D(Game.LocalTick, soundSource, false, true, WPos.Zero, 100, false);
                            }
                        }
                        else
                        {
                            Game.Sound.Play(SoundType.UI, vocfilename);
                        }
                    }
                }
                if (frameTextLine == null)
                {
                    prevText = new FrameTextLine()
                    {
                        Text = ""
                    };
                    DrawWsaText(prevText);
                }

                else
                {
                    if (frameTextLine.Contains(new FrameTextLine()
                    {
                        WSAfilename = cachedVideo, FrameNumber = video.CurrentFrame
                    }))
                    {
                        FrameTextLine ft = frameTextLine.Find(x => x.WSAfilename.Contains(cachedVideo) && x.FrameNumber == video.CurrentFrame);

                        DrawWsaText(ft);
                        prevText = ft;
                    }
                }
            }
            var sheetBuilder = new SheetBuilder(SheetType.Indexed, 512);

            //router for WSA  frame or CPS frame
            Sprite videoSprite = null;

            if (cachedVideo.Contains("WSA"))
            {
                videoSprite = sheetBuilder.Add(video.Frame);
            }
            else
            {
                //videoSprite = new Sprite(sheetBuilder.Current, new Rectangle(0, 0, 320, 200), TextureChannel.RGBA);
                videoSprite = sheetBuilder.Add(imageSprite[0]);
                //дампинг ресурсов игры в png
                //videoSprite.Sheet.CreateBuffer();
                //videoSprite.Sheet.ReleaseBuffer();
                ////videoSprite.Sheet.AsPng().Save("VIRGIN.png");
                //IPalette exppal;
                //try
                //{
                //    exppal = hardwarePalette.GetPalette(cachedVideo);
                //}
                //catch (Exception)
                //{

                //    exppal = null;
                //}

                //if (exppal==null)
                //{
                //    LoadPalette();
                //    videoSprite.Sheet.AsPng(TextureChannel.Blue, hardwarePalette.GetPalette("chrome")).Save(cachedVideo + ".png");
                //}
                //else
                //{
                //    videoSprite.Sheet.AsPng(TextureChannel.Blue, exppal).Save(cachedVideo + ".png");
                //}
            }
            prevSprite = videoSprite;


            Game.Renderer.SpriteRenderer.DrawSprite(videoSprite, videoOrigin, pr, videoSize);


            CountForWaitNextFrameMs = 0;
            lastDrawTime            = Game.RunTime;
        }
예제 #40
0
 public SpriteCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders, SheetBuilder sheetBuilder)
 {
     SheetBuilder = sheetBuilder;
     this.fileSystem = fileSystem;
     this.loaders = loaders;
 }
예제 #41
0
 public static Sprite[] GetSprites(IReadOnlyFileSystem fileSystem, string filename, ISpriteLoader[] loaders, SheetBuilder sheetBuilder)
 {
     return GetFrames(fileSystem, filename, loaders).Select(a => sheetBuilder.Add(a)).ToArray();
 }
예제 #42
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileSystem"></param>
 public void InitializeLoaders(IReadOnlyFileSystem fileSystem)
 {
     ChromeMetrics.Initialize(this);
     ChromeProvider.Initialize(this);
     WarGame.Sound.Initialize(SoundLoaders, fileSystem);
 }
        /// <summary>
        /// Adds all services required for the <see cref="RenderRazor"/> module.
        /// </summary>
        /// <param name="serviceCollection">The service collection to register services in.</param>
        /// <param name="fileSystem">The file system or <c>null</c> to skip.</param>
        /// <param name="classCatalog">An existing class catalog or <c>null</c> to scan assemblies during registration.</param>
        /// <returns>The service collection.</returns>
        public static IServiceCollection AddRazor(this IServiceCollection serviceCollection, IReadOnlyFileSystem fileSystem, ClassCatalog classCatalog = null)
        {
            // Register the file system if we're not expecting one from an engine
            if (fileSystem != null)
            {
                serviceCollection.TryAddSingleton(fileSystem);
            }

            // Register some of our own types if not already registered
            serviceCollection.TryAddSingleton <Microsoft.Extensions.FileProviders.IFileProvider, FileSystemFileProvider>();
            serviceCollection.TryAddSingleton <DiagnosticSource, SilentDiagnosticSource>();
            serviceCollection.TryAddSingleton(new DiagnosticListener("Razor"));
            serviceCollection.TryAddSingleton <IWebHostEnvironment, HostEnvironment>();
            serviceCollection.TryAddSingleton <ObjectPoolProvider, DefaultObjectPoolProvider>();
            serviceCollection.TryAddSingleton <StatiqRazorProjectFileSystem>();
            serviceCollection.TryAddSingleton <RazorProjectFileSystem, StatiqRazorProjectFileSystem>();

            // Register the view location expander if not already registered
            serviceCollection.Configure <RazorViewEngineOptions>(x =>
            {
                if (!x.ViewLocationExpanders.OfType <ViewLocationExpander>().Any())
                {
                    x.ViewLocationExpanders.Add(new ViewLocationExpander());
                }
            });

            // Add the default services _after_ adding our own
            // (most default registration use .TryAdd...() so they skip already registered types)
            IMvcCoreBuilder builder = serviceCollection
                                      .AddMvcCore()
                                      .AddRazorViewEngine()
                                      .AddRazorRuntimeCompilation();

            // Add all loaded assemblies
            CompilationReferencesProvider referencesProvider = new CompilationReferencesProvider();

            referencesProvider.Assemblies.AddRange((classCatalog ?? new ClassCatalog()).GetAssemblies());

            // And a couple needed assemblies that might not be loaded in the AppDomain yet
            referencesProvider.Assemblies.Add(typeof(IHtmlContent).Assembly);
            referencesProvider.Assemblies.Add(Assembly.Load(new AssemblyName("Microsoft.CSharp")));

            // Add the reference provider as an ApplicationPart
            builder.ConfigureApplicationPartManager(x => x.ApplicationParts.Add(referencesProvider));

            return(serviceCollection);
        }
예제 #44
0
        public static void Initialize(ModData modData)
        {
            Deinitialize();

            fileSystem = modData.DefaultFileSystem;
            collections = new Dictionary<string, Collection>();
            cachedSheets = new Dictionary<string, Sheet>();
            cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();

            var chrome = MiniYaml.Merge(modData.Manifest.Chrome
                .Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));

            foreach (var c in chrome)
                LoadCollection(c.Key, c.Value);
        }
예제 #45
0
 public VoxelModelCache(IReadOnlyFileSystem fileSystem)
 {
     loader = new VoxelLoader(fileSystem);
 }
예제 #46
0
파일: Sound.cs 프로젝트: OpenRA/OpenRA
        ISoundSource LoadSound(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem, string filename)
        {
            if (!fileSystem.Exists(filename))
            {
                Log.Write("sound", "LoadSound, file does not exist: {0}", filename);
                return null;
            }

            using (var stream = fileSystem.Open(filename))
            {
                ISoundFormat soundFormat;
                foreach (var loader in Game.ModData.SoundLoaders)
                {
                    stream.Position = 0;
                    if (loader.TryParseSound(stream, out soundFormat))
                        return soundEngine.AddSoundSourceFromMemory(
                            soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate);
                }
            }

            throw new InvalidDataException(filename + " is not a valid sound file!");
        }
예제 #47
0
        ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem)
        {
            using (var s = fileSystem.Open(Filename))
            {
                var colors = new uint[Palette.Size];
                using (var lines = s.ReadAllLines().GetEnumerator())
                {
                    if (!lines.MoveNext() || (lines.Current != "GIMP Palette" && lines.Current != "JASC-PAL"))
                    {
                        throw new InvalidDataException("File `{0}` is not a valid GIMP or JASC palette.".F(Filename));
                    }

                    byte a;
                    a = 255;
                    var i = 0;

                    while (lines.MoveNext() && i < Palette.Size)
                    {
                        // Skip until first color. Ignore # comments, Name/Columns and blank lines as well as JASC header values.
                        if (string.IsNullOrEmpty(lines.Current) || !char.IsDigit(lines.Current.Trim()[0]) || lines.Current == "0100" || lines.Current == "256")
                        {
                            continue;
                        }

                        var rgba = lines.Current.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        if (rgba.Length < 3)
                        {
                            throw new InvalidDataException("Invalid RGB(A) triplet/quartet: ({0})".F(string.Join(" ", rgba)));
                        }

                        if (!byte.TryParse(rgba[0], out var r))
                        {
                            throw new InvalidDataException("Invalid R value: {0}".F(rgba[0]));
                        }

                        if (!byte.TryParse(rgba[1], out var g))
                        {
                            throw new InvalidDataException("Invalid G value: {0}".F(rgba[1]));
                        }

                        if (!byte.TryParse(rgba[2], out var b))
                        {
                            throw new InvalidDataException("Invalid B value: {0}".F(rgba[2]));
                        }

                        // Check if color has a (valid) alpha value.
                        // Note: We can't throw on "rgba.Length > 3 but parse failed", because in GIMP palettes the 'invalid' value is probably a color name string.
                        var noAlpha = rgba.Length > 3 ? !byte.TryParse(rgba[3], out a) : true;

                        // Index should be completely transparent/background color
                        if (i == TransparentIndex)
                        {
                            colors[i] = 0;
                        }
                        else if (noAlpha)
                        {
                            colors[i] = (uint)Color.FromArgb(r, g, b).ToArgb();
                        }
                        else if (Premultiply)
                        {
                            colors[i] = (uint)Color.FromArgb(a, r * a / 255, g * a / 255, b * a / 255).ToArgb();
                        }
                        else
                        {
                            colors[i] = (uint)Color.FromArgb(a, r, g, b).ToArgb();
                        }

                        i++;
                    }
                }

                return(new ImmutablePalette(colors));
            }
        }
 public FileSystemReader(IReadOnlyFileSystem fileSystem)
 {
     _fileSystem = fileSystem;
 }
예제 #49
0
        // Adds all specified assemblies and those in packages path, finds all modules, and adds their namespaces and all assembly references to the options
        public void Initialize(AssemblyCollection assemblyCollection, PackagesCollection packages, IReadOnlyFileSystem fileSystem)
        {
            // Add all module namespaces from Wyam.Core
            _namespaces.AddRange(typeof(Engine).Assembly.GetTypes()
                                 .Where(x => typeof(IModule).IsAssignableFrom(x))
                                 .Select(x => x.Namespace));

            // Also include all Wyam.Common namespaces
            _namespaces.AddRange(typeof(IModule).Assembly.GetTypes()
                                 .Where(x => !string.IsNullOrWhiteSpace(x.Namespace))
                                 .Select(x => x.Namespace));

            // Get path to all assemblies (except those specified by name)
            List <FilePath> assemblyPaths = new List <FilePath>();

            assemblyPaths.AddRange(packages.GetCompatibleAssemblyPaths());
            assemblyPaths.AddRange(Directory.GetFiles(new FilePath(typeof(Config).Assembly.Location).Directory.FullPath, "*.dll", SearchOption.AllDirectories).Select(x => new FilePath(x)));
            assemblyPaths.AddRange(assemblyCollection.Directories
                                   .Select(x => new Tuple <DirectoryPath, SearchOption>(fileSystem.RootPath.Combine(x.Item1), x.Item2))
                                   .Where(x => Directory.Exists(x.Item1.FullPath))
                                   .SelectMany(x => Directory.GetFiles(x.Item1.FullPath, "*.dll", x.Item2).Select(y => new FilePath(y))));
            assemblyPaths.AddRange(assemblyCollection.ByFile
                                   .Select(x => new Tuple <FilePath, FilePath>(x, fileSystem.RootPath.CombineFile(x)))
                                   .Select(x => File.Exists(x.Item2.FullPath) ? x.Item2 : x.Item1));

            // Add all paths to the PrivateBinPath search location (to ensure they load in the default context)
            AppDomain.CurrentDomain.SetupInformation.PrivateBinPath =
                string.Join(";",
                            new[] { AppDomain.CurrentDomain.SetupInformation.PrivateBinPath }
                            .Concat(assemblyPaths.Select(x => x.Directory.FullPath))
                            .Distinct());

            // Iterate assemblies by path (making sure to add them to the current path if relative), add them to the script, and check for modules
            // If this approach causes problems, could also try loading assemblies in custom app domain:
            // http://stackoverflow.com/questions/6626647/custom-appdomain-and-privatebinpath
            foreach (string assemblyPath in assemblyPaths.Select(x => x.FullPath).Distinct())
            {
                try
                {
                    Trace.Verbose("Loading assembly file {0}", assemblyPath);
                    AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyPath);
                    Assembly     assembly     = Assembly.Load(assemblyName);
                    if (!AddAssembly(assembly))
                    {
                        Trace.Verbose("Skipping assembly file {0} because it was already added", assemblyPath);
                    }
                    else
                    {
                        LoadReferencedAssemblies(assembly.GetReferencedAssemblies());
                    }
                }
                catch (Exception ex)
                {
                    Trace.Verbose("{0} exception while loading assembly file {1}: {2}", ex.GetType().Name, assemblyPath, ex.Message);
                }
            }

            // Also iterate assemblies specified by name
            foreach (string assemblyName in assemblyCollection.ByName)
            {
                try
                {
                    Trace.Verbose("Loading assembly {0}", assemblyName);
                    Assembly assembly = Assembly.Load(assemblyName);
                    if (!AddAssembly(assembly))
                    {
                        Trace.Verbose("Skipping assembly {0} because it was already added", assemblyName);
                    }
                    else
                    {
                        LoadReferencedAssemblies(assembly.GetReferencedAssemblies());
                    }
                }
                catch (Exception ex)
                {
                    Trace.Verbose("{0} exception while loading assembly {1}: {2}", ex.GetType().Name, assemblyName, ex.Message);
                }
            }
        }
예제 #50
0
        public static ISpriteFrame[] GetFrames(IReadOnlyFileSystem fileSystem, string filename, ISpriteLoader[] loaders)
        {
            using (var stream = fileSystem.Open(filename))
            {
                var spriteFrames = GetFrames(stream, loaders);
                if (spriteFrames == null)
                    throw new InvalidDataException(filename + " is not a valid sprite file!");

                return spriteFrames;
            }
        }
예제 #51
0
 ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem)
 {
     return(new ImmutablePalette(fileSystem.Open(Filename), TransparentIndex, ShadowIndex));
 }
예제 #52
0
 public FrameCache(IReadOnlyFileSystem fileSystem, ISpriteLoader[] loaders)
 {
     frames = new Cache<string, ISpriteFrame[]>(filename => SpriteLoader.GetFrames(fileSystem, filename, loaders));
 }
예제 #53
0
        public static Ruleset Load(ModData modData, IReadOnlyFileSystem fileSystem, string tileSet,
                                   MiniYaml mapRules, MiniYaml mapWeapons, MiniYaml mapVoices, MiniYaml mapNotifications,
                                   MiniYaml mapMusic, MiniYaml mapSequences, MiniYaml mapModelSequences)
        {
            var m  = modData.Manifest;
            var dr = modData.DefaultRules;

            Ruleset ruleset = null;
            Action  f       = () =>
            {
                var actors = MergeOrDefault("Rules", fileSystem, m.Rules, mapRules, dr.Actors,
                                            k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value));

                var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
                                             k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));

                var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices,
                                            k => new SoundInfo(k.Value));

                var notifications = MergeOrDefault("Notifications", fileSystem, m.Notifications, mapNotifications, dr.Notifications,
                                                   k => new SoundInfo(k.Value));

                var music = MergeOrDefault("Music", fileSystem, m.Music, mapMusic, dr.Music,
                                           k => new MusicInfo(k.Key, k.Value));

                // TODO: Add support for merging custom tileset modifications
                var ts = modData.DefaultTileSets[tileSet];

                // TODO: Top-level dictionary should be moved into the Ruleset instead of in its own object
                var sequences = mapSequences == null ? modData.DefaultSequences[tileSet] :
                                new SequenceProvider(fileSystem, modData, ts, mapSequences);

                var modelSequences = dr.ModelSequences;
                if (mapModelSequences != null)
                {
                    modelSequences = MergeOrDefault("ModelSequences", fileSystem, m.ModelSequences, mapModelSequences, dr.ModelSequences,
                                                    k => k);
                }

                ruleset = new Ruleset(actors, weapons, voices, notifications, music, ts, sequences, modelSequences);
            };

            if (modData.IsOnMainThread)
            {
                modData.HandleLoadingProgress();

                var loader = new Task(f);
                loader.Start();

                // Animate the loadscreen while we wait
                while (!loader.Wait(40))
                {
                    modData.HandleLoadingProgress();
                }
            }
            else
            {
                f();
            }

            return(ruleset);
        }
예제 #54
0
파일: TileSet.cs 프로젝트: CH4Code/OpenRA
        public TileSet(IReadOnlyFileSystem fileSystem, string filepath)
        {
            var yaml = MiniYaml.DictFromStream(fileSystem.Open(filepath));

            // General info
            FieldLoader.Load(this, yaml["General"]);

            // TerrainTypes
            TerrainInfo = yaml["Terrain"].ToDictionary().Values
                .Select(y => new TerrainTypeInfo(y))
                .OrderBy(tt => tt.Type)
                .ToArray();

            if (TerrainInfo.Length >= byte.MaxValue)
                throw new InvalidDataException("Too many terrain types.");

            for (byte i = 0; i < TerrainInfo.Length; i++)
            {
                var tt = TerrainInfo[i].Type;

                if (terrainIndexByType.ContainsKey(tt))
                    throw new InvalidDataException("Duplicate terrain type '{0}' in '{1}'.".F(tt, filepath));

                terrainIndexByType.Add(tt, i);
            }

            defaultWalkableTerrainIndex = GetTerrainIndex("Clear");

            // Templates
            Templates = yaml["Templates"].ToDictionary().Values
                .Select(y => new TerrainTemplateInfo(this, y)).ToDictionary(t => t.Id).AsReadOnly();
        }
예제 #55
0
        ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem)
        {
            var sequence = (ISpriteSequence)Game.ModData.DefaultSequences.Values.First().GetSequence(Image, Sequence);

            return(new ImmutablePalette(sequence.EmbeddedPalette));
        }
예제 #56
0
		public ProjectTemplateImpl(XmlDocument doc, IReadOnlyFileSystem fileSystem)
		{
			var templateElement = doc.DocumentElement;
			originator   = templateElement.GetAttribute("originator");
			created      = templateElement.GetAttribute("created");
			lastmodified = templateElement.GetAttribute("lastModified");
			
			string newProjectDialogVisibleAttr  = templateElement.GetAttribute("newprojectdialogvisible");
			if (string.Equals(newProjectDialogVisibleAttr, "false", StringComparison.OrdinalIgnoreCase))
				newProjectDialogVisible = false;
			
			XmlElement config = templateElement["TemplateConfiguration"];
			
			name         = config["Name"].InnerText;
			category     = config["Category"].InnerText;
			
			if (config["LanguageName"] != null) {
				languagename = config["LanguageName"].InnerText;
				WarnObsoleteNode(config["LanguageName"], "use language attribute on the project node instead");
			}
			
			if (config["Subcategory"] != null) {
				subcategory = config["Subcategory"].InnerText;
			}
			
			if (config["Description"] != null) {
				description  = config["Description"].InnerText;
			}
			
			if (config["Icon"] != null) {
				icon = SD.ResourceService.GetImage(config["Icon"].InnerText);
			}
			
			if (config["SupportedTargetFrameworks"] != null) {
				var specifiedTargetFrameworks =
					config["SupportedTargetFrameworks"].InnerText.Split(';')
					.Select<string,TargetFramework>(TargetFramework.GetByName).ToArray();
				
				supportedTargetFrameworks = TargetFramework.TargetFrameworks.Where(fx => specifiedTargetFrameworks.Any(s => fx.IsBasedOn(s))).ToArray();
			} else {
				supportedTargetFrameworks = new TargetFramework[0];
			}
			
			if (templateElement["Solution"] != null) {
				solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor(templateElement["Solution"], fileSystem);
			} else if (templateElement["Combine"] != null) {
				solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor(templateElement["Combine"], fileSystem);
				WarnObsoleteNode(templateElement["Combine"], "Use <Solution> instead!");
			}
			
			if (templateElement["Project"] != null) {
				projectDescriptor = new ProjectDescriptor(templateElement["Project"], fileSystem);
			}
			
			if (solutionDescriptor == null && projectDescriptor == null
			    || solutionDescriptor != null && projectDescriptor != null)
			{
				throw new TemplateLoadException("Template must contain either Project or Solution node!");
			}
			
			// Read Actions;
			if (templateElement["Actions"] != null) {
				foreach (XmlElement el in templateElement["Actions"]) {
					Action<ProjectTemplateResult> action = ReadAction(el);
					if (action != null)
						openActions.Add(action);
				}
			}
		}
예제 #57
0
        public FileTemplateImpl(XmlDocument doc, IReadOnlyFileSystem fileSystem)
        {
            author = doc.DocumentElement.GetAttribute("author");

            XmlElement config = doc.DocumentElement["Config"];

            name         = config.GetAttribute("name");
            icon         = SD.ResourceService.GetImage(config.GetAttribute("icon"));
            category     = config.GetAttribute("category");
            defaultName  = config.GetAttribute("defaultname");
            languagename = config.GetAttribute("language");

            if (config.HasAttribute("subcategory"))
            {
                subcategory = config.GetAttribute("subcategory");
            }

            string newFileDialogVisibleAttr = config.GetAttribute("newfiledialogvisible");

            if (newFileDialogVisibleAttr != null && newFileDialogVisibleAttr.Length != 0)
            {
                if (newFileDialogVisibleAttr.Equals("false", StringComparison.OrdinalIgnoreCase))
                {
                    newFileDialogVisible = false;
                }
            }

            if (doc.DocumentElement["Description"] != null)
            {
                description = doc.DocumentElement["Description"].InnerText;
            }

            if (config["Wizard"] != null)
            {
                wizardpath = config["Wizard"].Attributes["path"].InnerText;
            }

            if (doc.DocumentElement["Properties"] != null)
            {
                XmlNodeList propertyList = doc.DocumentElement["Properties"].SelectNodes("Property");
                foreach (XmlElement propertyElement in propertyList)
                {
                    properties.Add(new TemplateProperty(propertyElement));
                }
            }

            if (doc.DocumentElement["Types"] != null)
            {
                XmlNodeList typeList = doc.DocumentElement["Types"].SelectNodes("Type");
                foreach (XmlElement typeElement in typeList)
                {
                    customTypes.Add(new TemplateType(typeElement));
                }
            }

            if (doc.DocumentElement["References"] != null)
            {
                XmlNodeList references = doc.DocumentElement["References"].SelectNodes("Reference");
                foreach (XmlElement reference in references)
                {
                    if (!reference.HasAttribute("include"))
                    {
                        throw new InvalidDataException("Reference without 'include' attribute!");
                    }
                    ReferenceProjectItem item = new ReferenceProjectItem(null, reference.GetAttribute("include"));
                    item.SetMetadata("HintPath", reference.GetAttribute("hintPath"));
                    var requiredTargetFramework = reference.GetElementsByTagName("RequiredTargetFramework").OfType <XmlElement>().FirstOrDefault();
                    if (requiredTargetFramework != null)
                    {
                        item.SetMetadata("RequiredTargetFramework", requiredTargetFramework.Value);
                    }
                    requiredAssemblyReferences.Add(item);
                }
            }

            if (doc.DocumentElement["Actions"] != null)
            {
                foreach (XmlElement el in doc.DocumentElement["Actions"])
                {
                    Action <FileTemplateResult> action = ReadAction(el);
                    if (action != null)
                    {
                        actions += action;
                    }
                }
            }

            fileoptions = doc.DocumentElement["AdditionalOptions"];

            // load the files
            XmlElement  files = doc.DocumentElement["Files"];
            XmlNodeList nodes = files.ChildNodes;

            foreach (XmlNode filenode in nodes)
            {
                if (filenode is XmlElement)
                {
                    this.files.Add(new FileDescriptionTemplate((XmlElement)filenode, fileSystem));
                }
            }
        }