本文整理汇总了C#中OpenTagCache.OpenCacheRead方法的典型用法代码示例。如果您正苦于以下问题:C# OpenTagCache.OpenCacheRead方法的具体用法?C# OpenTagCache.OpenCacheRead怎么用?C# OpenTagCache.OpenCacheRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenTagCache
的用法示例。
在下文中一共展示了OpenTagCache.OpenCacheRead方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditVFilesList
private static void EditVFilesList(CommandContext context, OpenTagCache info, TagInstance tag)
{
VFilesList vfsl;
using (var stream = info.OpenCacheRead())
vfsl = info.Deserializer.Deserialize<VFilesList>(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag));
VFilesContextFactory.Populate(context, info, tag, vfsl);
}
示例2: Execute
public override bool Execute(List<string> args)
{
if (args.Count < 2)
return false;
var outputPath = args[0];
// Load each file and do version detection
var infos = new List<OpenTagCache>();
foreach (var path in args.Skip(1))
{
Console.WriteLine("Loading {0}...", path);
// Load the cache file
var info = new OpenTagCache { CacheFile = new FileInfo(path) };
using (var stream = info.OpenCacheRead())
info.Cache = new TagCache(stream);
// Do version detection, and don't accept the closest version
// because that might not work
EngineVersion closestVersion;
info.Version = VersionDetection.DetectVersion(info.Cache, out closestVersion);
if (info.Version == EngineVersion.Unknown)
{
Console.WriteLine("- Unrecognized version! Ignoring.");
continue;
}
info.Deserializer = new TagDeserializer(info.Version);
infos.Add(info);
}
var result = new TagVersionMap();
using (var baseStream = _info.OpenCacheRead())
{
// Get the scenario tags for this cache
Console.WriteLine("Finding base scenario tags...");
var baseScenarios = FindScenarios(_info, baseStream);
var baseVersion = _info.Version;
var baseTagData = new Dictionary<int, object>();
foreach (var scenario in baseScenarios)
baseTagData[scenario.Tag.Index] = scenario.Data;
// Now compare with each of the other caches
foreach (var info in infos)
{
using (var stream = info.OpenCacheRead())
{
Console.WriteLine("Finding scenario tags in {0}...", info.CacheFile.FullName);
// Get the scenario tags and connect them to the base tags
var scenarios = FindScenarios(info, stream);
var tagsToCompare = new Queue<QueuedTag>();
for (var i = 0; i < scenarios.Count; i++)
{
tagsToCompare.Enqueue(scenarios[i]);
result.Add(baseVersion, baseScenarios[i].Tag.Index, info.Version, scenarios[i].Tag.Index);
}
// Process each tag in the queue, enqueuing all of its dependencies as well
while (tagsToCompare.Count > 0)
{
// Get the tag and its data
var tag = tagsToCompare.Dequeue();
TagPrinter.PrintTagShort(tag.Tag);
var data = tag.Data;
if (data == null)
{
// No data yet - deserialize it
var context = new TagSerializationContext(stream, info.Cache, info.StringIds, tag.Tag);
var type = TagStructureTypes.FindByGroupTag(tag.Tag.Group.Tag);
data = info.Deserializer.Deserialize(context, type);
}
// Now get the data for the base tag
var baseTag = result.Translate(info.Version, tag.Tag.Index, baseVersion);
if (baseTag == -1 || _info.Cache.Tags[baseTag].Group.Tag != tag.Tag.Group.Tag)
continue;
object baseData;
if (!baseTagData.TryGetValue(baseTag, out baseData))
{
// No data yet - deserialize it
var context = new TagSerializationContext(baseStream, _info.Cache, _info.StringIds, _info.Cache.Tags[baseTag]);
var type = TagStructureTypes.FindByGroupTag(tag.Tag.Group.Tag);
baseData = _info.Deserializer.Deserialize(context, type);
baseTagData[baseTag] = baseData;
}
// Compare the two blocks
CompareBlocks(baseData, baseVersion, data, info.Version, result, tagsToCompare);
}
}
}
}
// Write out the CSV
Console.WriteLine("Writing results...");
using (var writer = new StreamWriter(File.Open(outputPath, FileMode.Create, FileAccess.Write)))
result.WriteCsv(writer);
Console.WriteLine("Done!");
return true;
//.........这里部分代码省略.........
示例3: EditMultilingualUnicodeStringList
private static void EditMultilingualUnicodeStringList(CommandContext context, OpenTagCache info, TagInstance tag)
{
MultilingualUnicodeStringList unic;
using (var stream = info.OpenCacheRead())
unic = info.Deserializer.Deserialize<MultilingualUnicodeStringList>(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag));
UnicodeContextFactory.Populate(context, info, tag, unic);
}
示例4: EditScenario
private static void EditScenario(CommandContext context, OpenTagCache info, TagInstance tag)
{
Scenario scenario;
using (var stream = info.OpenCacheRead())
scenario = info.Deserializer.Deserialize<Scenario>(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag));
ScnrContextFactory.Populate(context, info, tag, scenario);
}
示例5: Create
public static CommandContext Create(CommandContextStack stack, OpenTagCache info, TagInstance tag)
{
var groupName = info.StringIds.GetString(tag.Group.Name);
var context = new CommandContext(stack.Context,
string.Format("0x{0:X4}.{1}", tag.Index, groupName));
switch (tag.Group.Tag.ToString())
{
case "vfsl": // vfiles_list
EditVFilesList(context, info, tag);
break;
case "unic": // multilingual_unicode_string_list
EditMultilingualUnicodeStringList(context, info, tag);
break;
case "bitm": // bitmap
EditBitmap(context, info, tag);
break;
case "hlmt": // model
EditModel(context, info, tag);
break;
case "mode": // render_model
EditRenderModel(context, info, tag);
break;
case "rm ": // render_method
case "rmsh": // shader
case "rmd ": // shader_decal
case "rmfl": // shader_foliage
case "rmhg": // shader_halogram
case "rmss": // shader_screen
case "rmtr": // shader_terrain
case "rmw ": // shader_water
case "rmzo": // shader_zonly
case "rmcs": // shader_custom
EditRenderMethod(context, info, tag);
break;
case "scnr":
EditScenario(context, info, tag);
break;
}
object value = null;
using (var stream = info.OpenCacheRead())
value = info.Deserializer.Deserialize(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag),
TagStructureTypes.FindByGroupTag(tag.Group.Tag));
var structure = new TagStructureInfo(
TagStructureTypes.FindByGroupTag(tag.Group.Tag));
context.AddCommand(new ListFieldsCommand(info, structure, value));
context.AddCommand(new SetFieldCommand(stack, info, tag, structure, value));
context.AddCommand(new EditBlockCommand(stack, info, tag, value));
context.AddCommand(new AddToBlockCommand(stack, info, tag, structure, value));
context.AddCommand(new RemoveFromBlockCommand(stack, info, tag, structure, value));
context.AddCommand(new SaveChangesCommand(info, tag, value));
context.AddCommand(new ExitToCommand(stack));
return context;
}
示例6: EditRenderModel
private static void EditRenderModel(CommandContext context, OpenTagCache info, TagInstance tag)
{
RenderModel renderModel;
using (var stream = info.OpenCacheRead())
renderModel = info.Deserializer.Deserialize<RenderModel>(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag));
RenderModelContextFactory.Populate(context, info, tag, renderModel);
}
示例7: EditBitmap
private static void EditBitmap(CommandContext context, OpenTagCache info, TagInstance tag)
{
Bitmap bitmap;
using (var stream = info.OpenCacheRead())
bitmap = info.Deserializer.Deserialize<Bitmap>(
new TagSerializationContext(stream, info.Cache, info.StringIds, tag));
BitmapContextFactory.Populate(context, info, tag, bitmap);
}
示例8: Create
public static CommandContext Create(CommandContextStack stack, OpenTagCache info, TagInstance tag)
{
var groupName = info.StringIDs.GetString(tag.Group.Name);
var tagName = $"0x{tag.Index:X4}";
if (info.TagNames.ContainsKey(tag.Index))
{
tagName = info.TagNames[tag.Index];
tagName = $"(0x{tag.Index:X4}) {tagName.Substring(tagName.LastIndexOf('\\') + 1)}";
}
var context = new CommandContext(stack.Context,
string.Format("{0}.{1}", tagName, groupName));
object value = null;
using (var stream = info.OpenCacheRead())
value = info.Deserializer.Deserialize(
new TagSerializationContext(stream, info.Cache, info.StringIDs, tag),
TagStructureTypes.FindByGroupTag(tag.Group.Tag));
switch (tag.Group.Tag.ToString())
{
case "vfsl": // vfiles_list
VFilesContextFactory.Populate(context, info, tag, (VFilesList)value);
break;
case "unic": // multilingual_unicode_string_list
UnicodeContextFactory.Populate(context, info, tag, (MultilingualUnicodeStringList)value);
break;
case "bitm": // bitmap
BitmapContextFactory.Populate(context, info, tag, (Bitmap)value);
break;
case "hlmt": // model
ModelContextFactory.Populate(context, info, tag, (Model)value);
break;
case "mode": // render_model
RenderModelContextFactory.Populate(context, info, tag, (RenderModel)value);
break;
case "jmad":
AnimationContextFactory.Populate(context, info, tag, (ModelAnimationGraph)value);
break;
case "rm ": // render_method
case "rmsh": // shader
case "rmd ": // shader_decal
case "rmfl": // shader_foliage
case "rmhg": // shader_halogram
case "rmss": // shader_screen
case "rmtr": // shader_terrain
case "rmw ": // shader_water
case "rmzo": // shader_zonly
case "rmcs": // shader_custom
RenderMethodContextFactory.Populate(context, info, tag, (RenderMethod)value);
break;
case "scnr":
ScnrContextFactory.Populate(context, info, tag, (Scenario)value);
break;
case "sbsp":
BSPContextFactory.Populate(context, info, tag, (ScenarioStructureBsp)value);
break;
}
var structure = new TagStructureInfo(
TagStructureTypes.FindByGroupTag(tag.Group.Tag));
context.AddCommand(new ListFieldsCommand(info, structure, value));
context.AddCommand(new SetFieldCommand(stack, info, tag, structure, value));
context.AddCommand(new EditBlockCommand(stack, info, tag, value));
context.AddCommand(new AddToCommand(stack, info, tag, structure, value));
context.AddCommand(new RemoveFromCommand(stack, info, tag, structure, value));
context.AddCommand(new CopyElementsCommand(stack, info, tag, structure, value));
context.AddCommand(new PasteElementsCommand(stack, info, tag, structure, value));
context.AddCommand(new SaveChangesCommand(info, tag, value));
context.AddCommand(new ExitToCommand(stack));
return context;
}