public static void CombineFormats(FormatVersion generation, TypeTree origin) { if (TypeTreeNode.IsFormat5(generation)) { Dictionary <uint, string> customTypes = new Dictionary <uint, string>(); using (MemoryStream stream = new MemoryStream(origin.StringBuffer)) { using (EndianReader reader = new EndianReader(stream, EndianType.LittleEndian)) { while (stream.Position < stream.Length) { uint position = (uint)stream.Position; string name = reader.ReadStringZeroTerm(); customTypes.Add(position, name); } } } foreach (TypeTreeNode node in origin.Nodes) { node.Type = GetTypeName(customTypes, node.TypeStrOffset); node.Name = GetTypeName(customTypes, node.NameStrOffset); } } }
internal void LoadVersion(BinaryReader bamlBinaryReader) { #if DEBUG long posStart = bamlBinaryReader.BaseStream.Position; #endif BamlVersion = FormatVersion.LoadFromStream(bamlBinaryReader.BaseStream); #if DEBUG long posEnd = bamlBinaryReader.BaseStream.Position; Debug.Assert((posEnd - posStart) == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); #endif // We're assuming that only major versions are significant for compatibility, // so if we have a major version in the file that is higher than that in // the code, we can't read it. if (BamlVersion.ReaderVersion != BamlWriterVersion) { throw new InvalidOperationException(SR.Get(SRID.ParserBamlVersion, (BamlVersion.ReaderVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlVersion.ReaderVersion.Minor.ToString(CultureInfo.CurrentCulture)), (BamlWriterVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlWriterVersion.Minor.ToString(CultureInfo.CurrentCulture)))); } }
public PAKFileSystem() { mBaseStream = null; mOwnsStream = true; mEntryMap = new Dictionary <string, IEntry>(); Version = FormatVersion.Version1; }
internal override void Read(BinaryReader reader) { FileType = reader.ReadByte(); FileFormat = reader.ReadByte(); UserID = reader.ReadInt16(); //FileSize = reader.ReadInt32(); reader.FSkip(4); //FileSize is set using a setter MagicCode = reader.ReadChars(4); //Console.WriteLine(MagicCode); ExpandSize = reader.ReadInt32(); int typeTablecnt = reader.ReadInt32(); //= TypeTableCount Version = (FormatVersion)reader.ReadInt32(); //Console.WriteLine("PMD File Ver.{0}", Version); Reserve2 = reader.ReadInt32(); Reserve3 = reader.ReadInt32(); TypeTable = new List <Types.TypeTable>(); for (int i = 0; i < typeTablecnt; i++) { Types.TypeTable typeTable = new(reader, Version); typeTable.Version = Version; TypeTable.Add(typeTable); } return; }
/// <summary> /// Constructs a new instance of <see cref="MessageScriptCompiler"/> which will compile to the specified format. /// </summary> /// <param name="version">The version of the format to compile the output to.</param> /// <param name="encoding">The encoding to use for non-ASCII characters. If not specified, non-ASCII characters will be ignored unless they are stored as [x XX YY] tags.</param> public MessageScriptCompiler(FormatVersion version, Encoding encoding = null) { mVersion = version; mEncoding = encoding; mLogger = new Logger(nameof(MessageScriptCompiler)); LoggerManager.RegisterLogger(mLogger); }
/// <summary> /// Creates a new instance of <see cref="MessageScript"/> initialized with default values. /// </summary> public MessageScript(FormatVersion version, Encoding encoding = null) { Id = 0; FormatVersion = version; Encoding = encoding; Dialogs = new List <IDialog>(); }
public static void CombineFormats(FormatVersion generation, ref SerializedType origin) { if (origin.OldType != null) { TypeTreeConverter.CombineFormats(generation, origin.OldType); } }
/// <summary> /// Reads header from binary reader and returns it. /// </summary> /// <param name="br"></param> /// <returns></returns> public static PmgHeader ReadFrom(BinaryReader br) { var result = new PmgHeader(); result.Signature = br.ReadString(4); if (result.Signature != "pmg") { throw new InvalidDataException("Expected 'pmg' signature."); } result.Version = FormatVersion.ReadFrom(br); result.HeaderSize = br.ReadInt32(); result.Name = br.ReadString(32); result.Unk1 = br.ReadBytes(96); var meshGroupCount = br.ReadInt32(); for (var i = 0; i < meshGroupCount; ++i) { var meshGroup = MeshGroup.ReadFrom(br); result.MeshGroups.Add(meshGroup); } return(result); }
public void WriteXml(XmlWriter writer) { writer.WriteAttribute(ATTR.format_version, FormatVersion.AsDouble()); writer.WriteAttribute(ATTR.time_stamp, TimeStamp.ToUniversalTime().ToString(CultureInfo.InvariantCulture)); writer.WriteAttribute(ATTR.user, User); writer.WriteAttribute(ATTR.insert_undo_redo, InsertUndoRedoIntoAllInfo); if (CountEntryType.HasValue) { writer.WriteAttribute(ATTR.count_type, CountEntryType); } if (!string.IsNullOrEmpty(Reason)) { writer.WriteElementString(EL.reason, Reason); } if (!string.IsNullOrEmpty(ExtraInfo)) { writer.WriteElementString(EL.extra_info, ExtraInfo.EscapeNonPrintableChars()); } writer.WriteElement(EL.message, UndoRedo); writer.WriteElement(EL.message, Summary); var startIndex = InsertUndoRedoIntoAllInfo ? 1 : 0; for (var i = startIndex; i < _allInfo.Count; ++i) { writer.WriteElement(EL.message, _allInfo[i]); } }
public void Load(Stream stream, bool ownsStream) { mBaseStream = stream; mOwnsStream = ownsStream; Version = DetectVersion(mBaseStream); ReadEntries(); }
internal static string FormatEvent(FormatVersion formatVersion, IFormatProvider provider, EventRecord eventRecord, string eventSourceName, string eventLevel, string eventTaskName, string opcodeName, string keywordsName, string type, string text) { switch (formatVersion) { case FormatVersion.TaskBasedFormatting: { return(string.Format( provider, "{0},{1},{2},{3},{4}.{5},{6}", EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp), eventLevel, eventRecord.EventHeader.ThreadId, eventRecord.EventHeader.ProcessId, eventTaskName, type, text)); } case FormatVersion.EventSourceBasedFormatting: { return(string.Format( provider, "{0},{1},{2},{3},{4}.{5},{6}", EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp), eventLevel, eventRecord.EventHeader.ThreadId, eventRecord.EventHeader.ProcessId, eventSourceName, type, text)); } default: { return(string.Format( provider, "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp), eventRecord.EventHeader.ThreadId, eventRecord.EventHeader.ProcessId, eventRecord.EventHeader.EventDescriptor.Id, eventRecord.EventHeader.ActivityId, GetRelatedActivityId(eventRecord), eventLevel, String.IsNullOrEmpty(eventTaskName) ? eventRecord.EventHeader.EventDescriptor.Task.ToString(provider) : eventTaskName, String.IsNullOrEmpty(opcodeName) ? eventRecord.EventHeader.EventDescriptor.Opcode.ToString(provider) : opcodeName, String.IsNullOrEmpty(keywordsName) ? eventRecord.EventHeader.EventDescriptor.Keyword.ToString("X", provider) : keywordsName, type, text)); } } }
private FlowScript FromFile_ResultNotNullAndFormatIsEqualToParameter(FormatVersion version, FormatVersion actualVersion) { var script = FlowScript.FromFile($"TestResources\\{actualVersion}.bf", null, version); Assert.IsNotNull(script, "Script object should not be null"); Assert.AreEqual((FormatVersion)actualVersion, script.FormatVersion); return(script); }
public static Type GetTypeFromVersion(FormatVersion version) { if (GetSupportedVersions().Contains(version)) { return(typeof(Frame)); } throw new System.NotImplementedException(); }
public static FrameInfo CreateFrameInfo(FrameInfoType infoType, FormatVersion version, BinaryReader reader = null) { Type factoryType = GetVersionFrameInfoFactory(version); MethodInfo method = factoryType.GetMethod("CreateInfo", BindingFlags.Static | BindingFlags.Public); object[] args = new object[] { infoType, reader }; return((FrameInfo)method.Invoke(null, args)); }
/// <summary> /// Constructs a new instance of <see cref="MessageScriptCompiler"/> which will compile to the specified format. /// </summary> /// <param name="version">The version of the format to compile the output to.</param> /// <param name="encoding">The encoding to use for non-ASCII characters. If not specified, non-ASCII characters will be ignored unless they are stored as [x XX YY] tags.</param> public MessageScriptCompiler(FormatVersion version, Encoding encoding = null) { mVersion = version; mEncoding = encoding; mLogger = new Logger(nameof(MessageScriptCompiler)); mVariables = new Dictionary <string, int>(); LoggerManager.RegisterLogger(mLogger); }
/// <inheritdoc /> public override int GetHashCode() { unchecked { int hashCode = FormatVersion.GetHashCode(); hashCode = (hashCode * 397) ^ CryptographyScheme.GetHashCode(); hashCode = (hashCode * 397) ^ (CryptographySchemeConfiguration != null ? CryptographySchemeConfiguration.GetHashCodeExt() : 0); return(hashCode); } }
/// <summary> /// Deserializes and creates a <see cref="MessageScript"/> from a file. /// </summary> public static MessageScript FromFile(string path, FormatVersion version = FormatVersion.Version1, Encoding encoding = null) { if (path == null) { throw new ArgumentNullException(nameof(path)); } var binary = MessageScriptBinary.FromFile(path); return(FromBinary(binary, version, encoding)); }
/// <summary> /// Deserializes and creates a <see cref="MessageScript"/> from a stream. /// </summary> public static MessageScript FromStream(Stream stream, FormatVersion version = FormatVersion.Version1, Encoding encoding = null, bool leaveOpen = false) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var binary = MessageScriptBinary.FromStream(stream, leaveOpen); return(FromBinary(binary, version, encoding)); }
// Token: 0x060020DD RID: 8413 RVA: 0x00096C44 File Offset: 0x00094E44 internal void LoadVersion(BinaryReader bamlBinaryReader) { this.BamlVersion = FormatVersion.LoadFromStream(bamlBinaryReader.BaseStream); if (this.BamlVersion.ReaderVersion != BamlVersionHeader.BamlWriterVersion) { throw new InvalidOperationException(SR.Get("ParserBamlVersion", new object[] { this.BamlVersion.ReaderVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + this.BamlVersion.ReaderVersion.Minor.ToString(CultureInfo.CurrentCulture), BamlVersionHeader.BamlWriterVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlVersionHeader.BamlWriterVersion.Minor.ToString(CultureInfo.CurrentCulture) })); } }
public static Type GetVersionFrameInfoFactory(FormatVersion version) { Type versionFrameInfoFactory = version switch { FormatVersion.v4_Nocturne => typeof(NocturneFrameFactory), FormatVersion.v12_Persona3_4 => typeof(Persona3_4FrameFactory), FormatVersion.v13_Persona3_4 => typeof(Persona3_4FrameFactory), _ => throw new NotImplementedException(), }; return(versionFrameInfoFactory); }
public static Type GetTypeFromVersion(FormatVersion version) { if (CutinfoPersona3_4.GetSupportedVersions().Contains(version)) { return(typeof(CutinfoPersona3_4)); } else if (CutinfoNocturne.GetSupportedVersions().Contains(version)) { return(typeof(CutinfoNocturne)); } throw new System.NotImplementedException(); }
public static Frame ReadJson(JsonReader reader, JsonSerializer serializer, FormatVersion version) { var jsonObject = JObject.Load(reader); var frame = new Frame(version); serializer.Populate(jsonObject.CreateReader(), frame); //serializer.Populate(jsonObject["DataTable"].CreateReader(), data); Type infoType = (Type)Frames.FrameInfoFactory.GetVersionFrameInfoFactory(version).GetMethod("GetFrameInfoFromType", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { frame.InfoType }); frame.FrameInfo = (FrameInfo)Activator.CreateInstance(infoType); serializer.Populate(jsonObject["FrameInfo"].CreateReader(), frame.FrameInfo); return(frame); }
/// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> /// <param name="version">Версия</param> /// <param name="checksym">Контрольная сумма</param> public File(string Name, string Quest, FormatVersion version, byte[] checksym) { Version = GetVersion(version); this.Name = Name; this.Quest = Quest; this.ReadOnly = false; this.DigitalSign = null; this.Author = Environment.UserName; Checksym = checksym; if (!Crc32.IsValidCRC(Crc32.CRC32(Name + Quest), checksym)) { throw new Exception("CRC32 не верный"); } }
/// <summary> /// Версия файла из перечисления /// </summary> /// <param name="Version">Перечисление</param> /// <returns></returns> public static byte[] GetVersion(FormatVersion Version) { if (Version == FormatVersion.One) { return(FileVersion.One); } else if (Version == FormatVersion.Two) { return(FileVersion.Two); } else { return new byte[] { 0x00, 0x00 } }; }
/// <summary> /// Create open location code with specified format version /// </summary> /// <param name="formatVersion"></param> public OpenLocationCode(FormatVersion formatVersion) { CurrentVersion = formatVersion; switch (formatVersion) { case FormatVersion.V1: _provider = new Providers.OpenLocationCodeV1(); break; case FormatVersion.VNext: _provider = new Providers.OpenLocationCodeVNext(); break; default: throw new NotSupportedException(string.Format(System.Globalization.CultureInfo.CurrentUICulture, Properties.Resources.NotSupportedOLCVersion, formatVersion)); } }
/// <summary> /// Reads header from binary reader and returns it. /// </summary> /// <param name="br"></param> /// <returns></returns> public static SetHeader ReadFrom(BinaryReader br) { var result = new SetHeader(); result.Signature = br.ReadString(4); if (result.Signature != "set") { throw new InvalidDataException("Expected 'set' signature."); } result.Version = FormatVersion.ReadFrom(br); result.HeaderSize = br.ReadInt32(); result.Unk1 = br.ReadBytes(result.HeaderSize - (int)br.BaseStream.Position); return(result); }
private static TokenText ParseSpeakerText(IReadOnlyList <byte> bytes, FormatVersion version, Encoding encoding) { var line = new TokenText(); int bufferIndex = 0; while (bufferIndex < bytes.Count) { if (!TryParseTokens(bytes, ref bufferIndex, out var tokens, version, encoding)) { break; } line.Tokens.AddRange(tokens); } return(line); }
public static void CombineFormats(FormatVersion generation, SerializedFileMetadata origin) { if (!SerializedFileMetadata.HasEnableTypeTree(generation)) { origin.EnableTypeTree = true; } for (int i = 0; i < origin.Types.Length; i++) { SerializedTypeConverter.CombineFormats(generation, ref origin.Types[i]); } if (generation >= FormatVersion.RefactorTypeData) { for (int i = 0; i < origin.Object.Length; i++) { ref ObjectInfo entry = ref origin.Object[i]; ref SerializedType type = ref origin.Types[entry.TypeID]; entry.ClassID = type.TypeID; entry.ScriptTypeIndex = type.ScriptTypeIndex; entry.Stripped = type.IsStrippedType; }
public string RunTest(FormatVersion version, string library, string source) { var compiler = new FlowScriptCompiler(version); compiler.Library = LibraryLookup.GetLibrary(library); compiler.EnableProcedureTracing = false; compiler.AddListener(new DebugLogListener()); if (!compiler.TryCompile(source, out var script)) { Console.WriteLine("Script failed to compile"); return(null); } var textOutput = new StringWriter(); var interpreter = new FlowScriptInterpreter(script); interpreter.TextOutput = textOutput; interpreter.Run(); return(textOutput.GetStringBuilder().ToString()); }
/// <summary> /// Объявление структуры /// </summary> /// <param name="Name">Имя</param> /// <param name="Quest">Квест</param> /// <param name="version">Версия</param> /// <param name="checksym">Контрольная сумма</param> /// <param name="ReadOnly">Только для чтения</param> /// <param name="DigitalSign">Цифровая подпись</param> public File(string Name, string Quest, FormatVersion version, byte[] checksym, byte ReadOnly, byte[] DigitalSign, string Author) { Version = GetVersion(version); this.Name = Name; this.Quest = Quest; this.DigitalSign = DigitalSign; Checksym = checksym; this.ReadOnly = ByteToBool(ReadOnly); this.Author = Author; if (!QuestLibrary.QuestFiles.Sign.Sign.CorrectSign(DigitalSign)) { throw new Exception("Цифровая подпись неверная"); } if (!Crc32.IsValidCRC(Crc32.CRC32(Name + Quest), checksym)) { throw new Exception("CRC32 не верный"); } }
/// <summary> /// Create a new custom character. /// </summary> /// <param name="name">The name of the custom character, containing only alphanumericals, underscores, and spaces.</param> /// <param name="version">The version this mod was first built with.</param> /// <param name="useSpawns"> /// The character to copy creatures and world state from. /// The value should be 0 (survivor), 1 (monk) or 2 (hunter). /// Values outside of this range are allowed, but the vanilla game's world files are not set up to use them correctly. /// </param> /// <remarks> /// The name of this character must be unique; other mods that add a character of this same name will throw an exception /// when registering their character. If your name is likely to cause conflicts (such as any of the vanilla achievement /// names), then consider prefixing your player's name with some other text, like the author's name. /// </remarks> /// <exception cref="ArgumentNullException">Thrown when input name is null.</exception> /// <exception cref="ArgumentException">Thrown when input name is empty or contains illegal characters.</exception> public SlugBaseCharacter(string name, FormatVersion version, int useSpawns = 0) { Name = "NULL"; if (name == null) { throw new ArgumentNullException("Name may not be null.", nameof(name)); } if (name == "") { throw new ArgumentException("Name may not be empty.", nameof(name)); } if (!Regex.IsMatch(name, "^[\\w ]+$")) { throw new ArgumentException("Name must contain only alphanumericals, underscores, and spaces.", nameof(name)); } Name = name; this.useSpawns = useSpawns; this.version = version; }
/// <summary> /// Create from latitude, longitude coordinates /// </summary> /// <param name="latitude"></param> /// <param name="longitude"></param> /// <param name="formatVersion"></param> public OpenLocationCode(decimal latitude, decimal longitude, FormatVersion formatVersion = DefaultFormatVersion) : this(latitude, longitude, null, formatVersion) { }
/// <summary> /// Create from open location code /// </summary> /// <param name="code"></param> /// <param name="formatVersion"></param> public OpenLocationCode(string code, FormatVersion formatVersion = DefaultFormatVersion) : this(formatVersion) { _code = code; }
/// <summary> /// Convert Open location code to another version /// </summary> /// <param name="targetVersion"></param> /// <returns></returns> public OpenLocationCode ConvertToFormatVersion(FormatVersion targetVersion) { return new OpenLocationCode(Latitude, Longitude, CodeLength, targetVersion); }
/// <summary> /// Create from latitude, longitude coordinates with specified code length /// </summary> /// <param name="latitude"></param> /// <param name="longitude"></param> /// <param name="codeLength">(Optional) The number of significant digits in the output code, not including any separator characters</param> /// <param name="formatVersion"></param> public OpenLocationCode(decimal latitude, decimal longitude, int? codeLength = default(int?), FormatVersion formatVersion = DefaultFormatVersion) : this(formatVersion) { _latitude = latitude; _longitude = longitude; _codeLength = codeLength; }