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


C# MiniYaml.ContainsKey方法代码示例

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


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

示例1: Manifest

		public Manifest(string mod)
		{
			var path = new[] { "mods", mod, "mod.yaml" }.Aggregate(Path.Combine);
			var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).ToDictionary();

			Mod = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
			Mod.Id = mod;

			// TODO: Use fieldloader
			Folders = YamlList(yaml, "Folders");
			MapFolders = YamlDictionary(yaml, "MapFolders");
			Packages = YamlDictionary(yaml, "Packages");
			Rules = YamlList(yaml, "Rules");
			ServerTraits = YamlList(yaml, "ServerTraits");
			Sequences = YamlList(yaml, "Sequences");
			VoxelSequences = YamlList(yaml, "VoxelSequences");
			Cursors = YamlList(yaml, "Cursors");
			Chrome = YamlList(yaml, "Chrome");
			Assemblies = YamlList(yaml, "Assemblies");
			ChromeLayout = YamlList(yaml, "ChromeLayout");
			Weapons = YamlList(yaml, "Weapons");
			Voices = YamlList(yaml, "Voices");
			Notifications = YamlList(yaml, "Notifications");
			Music = YamlList(yaml, "Music");
			Movies = YamlList(yaml, "Movies");
			Translations = YamlList(yaml, "Translations");
			TileSets = YamlList(yaml, "TileSets");
			ChromeMetrics = YamlList(yaml, "ChromeMetrics");
			PackageContents = YamlList(yaml, "PackageContents");
			LuaScripts = YamlList(yaml, "LuaScripts");
			Missions = YamlList(yaml, "Missions");

			LoadScreen = yaml["LoadScreen"];
			LobbyDefaults = yaml["LobbyDefaults"];

			if (yaml.ContainsKey("ContentInstaller"))
				ContentInstaller = FieldLoader.Load<InstallData>(yaml["ContentInstaller"]);

			Fonts = yaml["Fonts"].ToDictionary(my =>
				{
					var nd = my.ToDictionary();
					return Pair.New(nd["Font"].Value, Exts.ParseIntegerInvariant(nd["Size"].Value));
				});

			if (yaml.ContainsKey("TileSize"))
				TileSize = FieldLoader.GetValue<Size>("TileSize", yaml["TileSize"].Value);

			if (yaml.ContainsKey("TileShape"))
				TileShape = FieldLoader.GetValue<TileShape>("TileShape", yaml["TileShape"].Value);

			// Allow inherited mods to import parent maps.
			var compat = new List<string>();
			compat.Add(mod);

			if (yaml.ContainsKey("SupportsMapsFrom"))
				foreach (var c in yaml["SupportsMapsFrom"].Value.Split(','))
					compat.Add(c.Trim());

			MapCompatibility = compat.ToArray();
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:60,代码来源:Manifest.cs

示例2: CursorProvider

        public CursorProvider(ModData modData)
        {
            var fileSystem = modData.DefaultFileSystem;
            var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select(
                s => MiniYaml.FromStream(fileSystem.Open(s), s)));

            var shadowIndex = new int[] { };

            var nodesDict = new MiniYaml(null, sequenceYaml).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(fileSystem.Open(p.Value.Value), shadowIndex));

            Palettes = palettes.AsReadOnly();

            var frameCache = new FrameCache(fileSystem, 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:pchote,项目名称:OpenRA,代码行数:30,代码来源:CursorProvider.cs

示例3: Manifest

        public Manifest(string mod)
        {
            var path = Platform.ResolvePath(".", "mods", mod, "mod.yaml");
            var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).ToDictionary();

            Mod = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
            Mod.Id = mod;

            // TODO: Use fieldloader
            Folders = YamlList(yaml, "Folders", true);
            MapFolders = YamlDictionary(yaml, "MapFolders", true);
            Packages = YamlDictionary(yaml, "Packages", true);
            Rules = YamlList(yaml, "Rules", true);
            Sequences = YamlList(yaml, "Sequences", true);
            VoxelSequences = YamlList(yaml, "VoxelSequences", true);
            Cursors = YamlList(yaml, "Cursors", true);
            Chrome = YamlList(yaml, "Chrome", true);
            Assemblies = YamlList(yaml, "Assemblies", true);
            ChromeLayout = YamlList(yaml, "ChromeLayout", true);
            Weapons = YamlList(yaml, "Weapons", true);
            Voices = YamlList(yaml, "Voices", true);
            Notifications = YamlList(yaml, "Notifications", true);
            Music = YamlList(yaml, "Music", true);
            Movies = YamlList(yaml, "Movies", true);
            Translations = YamlList(yaml, "Translations", true);
            TileSets = YamlList(yaml, "TileSets", true);
            ChromeMetrics = YamlList(yaml, "ChromeMetrics", true);
            Missions = YamlList(yaml, "Missions", true);

            ServerTraits = YamlList(yaml, "ServerTraits");
            LoadScreen = yaml["LoadScreen"];
            LobbyDefaults = yaml["LobbyDefaults"];

            if (yaml.ContainsKey("ContentInstaller"))
                ContentInstaller = FieldLoader.Load<InstallData>(yaml["ContentInstaller"]);

            Fonts = yaml["Fonts"].ToDictionary(my =>
                {
                    var nd = my.ToDictionary();
                    return Pair.New(nd["Font"].Value, Exts.ParseIntegerInvariant(nd["Size"].Value));
                });

            if (yaml.ContainsKey("TileSize"))
                TileSize = FieldLoader.GetValue<Size>("TileSize", yaml["TileSize"].Value);

            if (yaml.ContainsKey("TileShape"))
                TileShape = FieldLoader.GetValue<TileShape>("TileShape", yaml["TileShape"].Value);

            if (yaml.ContainsKey("SubCells"))
            {
                var subcells = yaml["SubCells"].ToDictionary();

                // Read (x,y,z) offset (relative to cell center) pairs for positioning subcells
                if (subcells.ContainsKey("Offsets"))
                    SubCellOffsets = FieldLoader.GetValue<WVec[]>("Offsets", subcells["Offsets"].Value);

                if (subcells.ContainsKey("DefaultIndex"))
                    SubCellDefaultIndex = FieldLoader.GetValue<int>("DefaultIndex", subcells["DefaultIndex"].Value);
                else	// Otherwise set the default subcell index to the middle subcell entry
                    SubCellDefaultIndex = SubCellOffsets.Length / 2;
            }

            // Validate default index - 0 for no subcells, otherwise > 1 & <= subcell count (offset triples count - 1)
            if (SubCellDefaultIndex < (SubCellOffsets.Length > 1 ? 1 : 0) || SubCellDefaultIndex >= SubCellOffsets.Length)
                throw new InvalidDataException("Subcell default index must be a valid index into the offset triples and must be greater than 0 for mods with subcells");

            // Allow inherited mods to import parent maps.
            var compat = new List<string>();
            compat.Add(mod);

            if (yaml.ContainsKey("SupportsMapsFrom"))
                foreach (var c in yaml["SupportsMapsFrom"].Value.Split(','))
                    compat.Add(c.Trim());

            MapCompatibility = compat.ToArray();

            if (yaml.ContainsKey("SpriteFormats"))
                SpriteFormats = FieldLoader.GetValue<string[]>("SpriteFormats", yaml["SpriteFormats"].Value);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:79,代码来源:Manifest.cs


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