当前位置: 首页>>代码示例>>C#>>正文


C# MiniYaml.ToDictionary方法代码示例

本文整理汇总了C#中MiniYaml.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# MiniYaml.ToDictionary方法的具体用法?C# MiniYaml.ToDictionary怎么用?C# MiniYaml.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MiniYaml的用法示例。


在下文中一共展示了MiniYaml.ToDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

 static Dictionary<string, string[]> Load(MiniYaml y, string name)
 {
     var nd = y.ToDictionary();
     return nd.ContainsKey(name)
         ? nd[name].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
         : new Dictionary<string, string[]>();
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:SoundInfo.cs

示例2: LoadVersus

		static object LoadVersus(MiniYaml y)
		{
			var nd = y.ToDictionary();
			return nd.ContainsKey("Versus")
				? nd["Versus"].ToDictionary(my => FieldLoader.GetValue<float>("(value)", my.Value))
				: new Dictionary<string, float>();
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:WeaponInfo.cs

示例3: ValidateMods

        static Dictionary<string, ModMetadata> ValidateMods()
        {
            var basePath = Platform.ResolvePath(".", "mods");
            var mods = Directory.GetDirectories(basePath)
                .Select(x => x.Substring(basePath.Length + 1));

            var ret = new Dictionary<string, ModMetadata>();
            foreach (var m in mods)
            {
                var yamlPath = Platform.ResolvePath(".", "mods", m, "mod.yaml");
                if (!File.Exists(yamlPath))
                    continue;

                var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
                var nd = yaml.ToDictionary();
                if (!nd.ContainsKey("Metadata"))
                    continue;

                var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
                mod.Id = m;

                ret.Add(m, mod);
            }

            return ret;
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:26,代码来源:ModMetadata.cs

示例4: CursorProvider

		public CursorProvider(ModData modData)
		{
			var sequenceFiles = modData.Manifest.Cursors;

			cursors = new Dictionary<string, CursorSequence>();
			palettes = new Cache<string, PaletteReference>(CreatePaletteReference);
			var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
			var shadowIndex = new int[] { };

			var nodesDict = sequences.ToDictionary();
			if (nodesDict.ContainsKey("ShadowIndex"))
			{
				Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
				Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
					out shadowIndex[shadowIndex.Length - 1]);
			}

			palette = new HardwarePalette();
			foreach (var p in nodesDict["Palettes"].Nodes)
				palette.AddPalette(p.Key, new ImmutablePalette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);

			var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));
			foreach (var s in nodesDict["Cursors"].Nodes)
				LoadSequencesForCursor(spriteLoader, s.Key, s.Value);
			spriteLoader.SheetBuilder.Current.ReleaseBuffer();

			palette.Initialize();
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:28,代码来源:CursorProvider.cs

示例5: CursorProvider

		public CursorProvider(ModData modData)
		{
			var sequenceFiles = modData.Manifest.Cursors;
			var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
			var shadowIndex = new int[] { };

			var nodesDict = sequences.ToDictionary();
			if (nodesDict.ContainsKey("ShadowIndex"))
			{
				Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
				Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
					out shadowIndex[shadowIndex.Length - 1]);
			}

			var palettes = new Dictionary<string, ImmutablePalette>();
			foreach (var p in nodesDict["Palettes"].Nodes)
				palettes.Add(p.Key, new ImmutablePalette(GlobalFileSystem.Open(p.Value.Value), shadowIndex));

			Palettes = palettes.AsReadOnly();

			var frameCache = new FrameCache(modData.SpriteLoaders);
			var cursors = new Dictionary<string, CursorSequence>();
			foreach (var s in nodesDict["Cursors"].Nodes)
				foreach (var sequence in s.Value.Nodes)
					cursors.Add(sequence.Key, new CursorSequence(frameCache, sequence.Key, s.Key, s.Value.Value, sequence.Value));

			Cursors = cursors.AsReadOnly();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:28,代码来源:CursorProvider.cs

示例6: TerrainTemplateInfo

        public TerrainTemplateInfo(TileSet tileSet, MiniYaml my)
        {
            FieldLoader.Load(this, my);

            var nodes = my.ToDictionary()["Tiles"].Nodes;

            if (!PickAny)
            {
                tileInfo = new TerrainTileInfo[Size.X * Size.Y];
                foreach (var node in nodes)
                {
                    int key;
                    if (!int.TryParse(node.Key, out key) || key < 0 || key >= tileInfo.Length)
                        throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

                    tileInfo[key] = LoadTileInfo(tileSet, node.Value);
                }
            }
            else
            {
                tileInfo = new TerrainTileInfo[nodes.Count];

                var i = 0;
                foreach (var node in nodes)
                {
                    int key;
                    if (!int.TryParse(node.Key, out key) || key != i++)
                        throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

                    tileInfo[key] = LoadTileInfo(tileSet, node.Value);
                }
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:33,代码来源:TileSet.cs

示例7: LoadFilesToExtract

        public static Dictionary<string, string[]> LoadFilesToExtract(MiniYaml yaml)
        {
            var md = yaml.ToDictionary();

            return md.ContainsKey("ExtractFilesFromCD")
                ? md["ExtractFilesFromCD"].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
                : new Dictionary<string, string[]>();
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:8,代码来源:InstallUtils.cs

示例8: LoadProjectile

		static object LoadProjectile(MiniYaml yaml)
		{
			MiniYaml proj;
			if (!yaml.ToDictionary().TryGetValue("Projectile", out proj))
				return null;
			var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
			FieldLoader.Load(ret, proj);
			return ret;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:9,代码来源:WeaponInfo.cs

示例9: LoadVoxelsForUnit

		static void LoadVoxelsForUnit(string unit, MiniYaml sequences)
		{
			Game.ModData.LoadScreen.Display();
			try
			{
				var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));
				units.Add(unit, seq);
			}
			catch (FileNotFoundException) { } // Do nothing; we can crash later if we actually wanted art
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:10,代码来源:VoxelProvider.cs

示例10: GetParent

		static MiniYaml GetParent( MiniYaml node, Dictionary<string, MiniYaml> allUnits )
		{
			MiniYaml inherits;
			node.ToDictionary().TryGetValue( "Inherits", out inherits );
			if( inherits == null || string.IsNullOrEmpty( inherits.Value ) )
				return null;

			MiniYaml parent;
			allUnits.TryGetValue( inherits.Value, out parent );
			if (parent == null)
				throw new InvalidOperationException(
					"Bogus inheritance -- actor type {0} does not exist".F(inherits.Value));

			return parent;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:15,代码来源:ActorInfo.cs

示例11: CursorSequence

		public CursorSequence(SpriteLoader loader, string cursorSrc, string palette, MiniYaml info)
		{
			sprites = loader.LoadAllSprites(cursorSrc);
			var d = info.ToDictionary();

			start = Exts.ParseIntegerInvariant(d["start"].Value);
			this.palette = palette;

			if ((d.ContainsKey("length") && d["length"].Value == "*") || (d.ContainsKey("end") && d["end"].Value == "*"))
				length = sprites.Length - start;
			else if (d.ContainsKey("length"))
				length = Exts.ParseIntegerInvariant(d["length"].Value);
			else if (d.ContainsKey("end"))
				length = Exts.ParseIntegerInvariant(d["end"].Value) - start;
			else
				length = 1;

			if (d.ContainsKey("x"))
				Exts.TryParseIntegerInvariant(d["x"].Value, out Hotspot.X);
			if (d.ContainsKey("y"))
				Exts.TryParseIntegerInvariant(d["y"].Value, out Hotspot.Y);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:22,代码来源:CursorSequence.cs

示例12: ValidateMods

		public static Dictionary<string, ModMetadata> ValidateMods(string[] mods)
		{
			var ret = new Dictionary<string, ModMetadata>();
			foreach (var m in mods)
			{
				var yamlPath = new[] { "mods", m, "mod.yaml" }.Aggregate(Path.Combine);
				if (!File.Exists(yamlPath))
					continue;

				var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
				var nd = yaml.ToDictionary();
				if (!nd.ContainsKey("Metadata"))
					continue;

				var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
				mod.Id = m;

				ret.Add(m, mod);
			}

			return ret;
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:22,代码来源:ModMetadata.cs

示例13: LoadTiles

		int[] LoadTiles(TileSet tileSet, MiniYaml y)
		{
			var nodes = y.ToDictionary()["Tiles"].Nodes;

			if (!PickAny)
			{
				var tiles = new int[Size.X * Size.Y];

				for (var i = 0; i < tiles.Length; i++)
					tiles[i] = -1;

				foreach (var node in nodes)
				{
					int key;
					if (!int.TryParse(node.Key, out key) || key < 0 || key >= tiles.Length)
						throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

					tiles[key] = tileSet.GetTerrainIndex(node.Value.Value);
				}

				return tiles;
			}
			else
			{
				var tiles = new int[nodes.Count];
				var i = 0;

				foreach (var node in nodes)
				{
					int key;
					if (!int.TryParse(node.Key, out key) || key != i++)
						throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

					tiles[key] = tileSet.GetTerrainIndex(node.Value.Value);
				}

				return tiles;
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:39,代码来源:TileSet.cs

示例14: ValidateMods

		static Dictionary<string, ModMetadata> ValidateMods()
		{
			var basePath = Platform.ResolvePath(".", "mods");
			var mods = Directory.GetDirectories(basePath)
				.Select(x => x.Substring(basePath.Length + 1));

			var ret = new Dictionary<string, ModMetadata>();
			foreach (var m in mods)
			{
				try
				{
					var yamlPath = Platform.ResolvePath(".", "mods", m, "mod.yaml");
					if (!File.Exists(yamlPath))
						continue;

					var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
					var nd = yaml.ToDictionary();
					if (!nd.ContainsKey("Metadata"))
						continue;

					var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
					mod.Id = m;

					if (nd.ContainsKey("ContentInstaller"))
						mod.Content = FieldLoader.Load<ContentInstaller>(nd["ContentInstaller"]);

					ret.Add(m, mod);
				}
				catch (Exception ex)
				{
					Console.WriteLine("An exception occured when trying to load ModMetadata for `{0}`:".F(m));
					Console.WriteLine(ex.Message);
				}
			}

			return ret;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:37,代码来源:ModMetadata.cs

示例15: CursorSequence

        public CursorSequence(FrameCache cache, string name, string cursorSrc, string palette, MiniYaml info)
        {
            var d = info.ToDictionary();

            Start = Exts.ParseIntegerInvariant(d["Start"].Value);
            Palette = palette;
            Name = name;

            if ((d.ContainsKey("Length") && d["Length"].Value == "*") || (d.ContainsKey("End") && d["End"].Value == "*"))
                Length = Frames.Length - Start;
            else if (d.ContainsKey("Length"))
                Length = Exts.ParseIntegerInvariant(d["Length"].Value);
            else if (d.ContainsKey("End"))
                Length = Exts.ParseIntegerInvariant(d["End"].Value) - Start;
            else
                Length = 1;

            Frames = cache[cursorSrc]
                .Skip(Start)
                .Take(Length)
                .ToArray();

            if (d.ContainsKey("X"))
            {
                int x;
                Exts.TryParseIntegerInvariant(d["X"].Value, out x);
                Hotspot = Hotspot.WithX(x);
            }

            if (d.ContainsKey("Y"))
            {
                int y;
                Exts.TryParseIntegerInvariant(d["Y"].Value, out y);
                Hotspot = Hotspot.WithY(y);
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:36,代码来源:CursorSequence.cs


注:本文中的MiniYaml.ToDictionary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。