public void TablesWithAutoDisplayNameShouldSucceed() { var a = new Extended <object>( new object(), new Dictionary <string, object?>() { { "a", "b" } } ); var fileInfo = GetXlsxTempFileInfo(); try { // Save using var s1 = new MagicSpreadsheet(fileInfo); s1.AddSheet(new List <Extended <object> > { a }, "Sheet A"); s1.AddSheet(new List <Extended <object> > { a }, "Sheet B"); s1.Save(); } finally { fileInfo.Delete(); } }
private Model(BinaryReader br) { var bSpecial = false; var header = Extended.UintLittleEndian(br.ReadUInt32()); if (header != 0x01000100) //those may be some switches, but I don't know what they mean { Memory.Log.WriteLine("WARNING- THIS STAGE IS DIFFERENT! It has weird object section. INTERESTING, TO REVERSE!"); bSpecial = true; } Vertices = Enumerable.Range(0, br.ReadUInt16()).Select(_ => Vertex.Read(br)).ToList().AsReadOnly(); if (bSpecial && Memory.Encounters.Scenario == 20) { Triangles = null; Quads = null; return; } br.BaseStream.Seek((br.BaseStream.Position % 4) + 4, SeekOrigin.Current); var trianglesCount = br.ReadUInt16(); var quadsCount = br.ReadUInt16(); br.BaseStream.Seek(4, SeekOrigin.Current); Triangles = Enumerable.Range(0, trianglesCount).Select(_ => Triangle.Read(br)).ToList().AsReadOnly(); Quads = Enumerable.Range(0, quadsCount).Select(_ => Quad.Read(br)).ToList().AsReadOnly(); }
public void TablesWithSameDisplayNameShouldNotFail() { var a = new Extended <object>( new object(), new Dictionary <string, object?>() { { "a", "b" } } ); var fileInfo = GetXlsxTempFileInfo(); try { // Save using var s1 = new MagicSpreadsheet(fileInfo); s1.AddSheet(new List <Extended <object> > { a }, "Sheet A", new AddSheetOptions { TableOptions = new TableOptions { DisplayName = "Table1" } }); s1.AddSheet(new List <Extended <object> > { a }, "Sheet B", new AddSheetOptions { TableOptions = new TableOptions { DisplayName = "Table1" } }); } finally { fileInfo.Delete(); } }
public void SavingWithExtendedObject_Succeeds() { var a = new Extended <object>( new object(), new Dictionary <string, object?>() { { "a", "b" } } ); var fileInfo = GetXlsxTempFileInfo(); try { // Save using (var s1 = new MagicSpreadsheet(fileInfo)) { s1.AddSheet(new List <Extended <object> > { a }); s1.Save(); } using var s2 = new MagicSpreadsheet(fileInfo); s2.Load(); var b = s2.GetExtendedList <object>(); b.Should().NotBeNullOrEmpty(); var firstItem = b[0]; firstItem.Properties.Keys.Should().Contain("a"); firstItem.Properties["a"].Should().Be("b"); } finally { fileInfo.Delete(); } }
/// <summary> /// Resets the checkout manager by removing persisted information. /// </summary> public override void Reset() { Customer.Reset(); Offer.Reset(); Extended.Reset(); Payment.Reset(); Shipping.Reset(); }
/// <summary> /// Parses camera data into BattleCamera struct. Main purpouse of this function is to /// actually read all the offsets and pointers to human readable form of struct. This /// function later calls ReadAnimation(n) where n is animation Id (i.e. 9 is camCollection=1 /// and cameraAnim=0) /// </summary> public static Camera Read(BinaryReader br) { Camera c = new Camera(); br.BaseStream.Seek(c.bs_cameraPointer, 0); uint cCameraHeaderSector = br.ReadUInt16(); uint pCameraSetting = br.ReadUInt16(); uint pCameraAnimationCollection = br.ReadUInt16(); uint sCameraDataSize = br.ReadUInt16(); //Camera settings parsing? BattleCameraSettings bcs = new BattleCameraSettings() { unk = br.ReadBytes(24) }; //end of camera settings parsing br.BaseStream.Seek(pCameraAnimationCollection + c.bs_cameraPointer, SeekOrigin.Begin); BattleCameraCollection bcc = new BattleCameraCollection { cAnimCollectionCount = br.ReadUInt16() }; BattleCameraSet[] bcset = new BattleCameraSet[bcc.cAnimCollectionCount]; bcc.battleCameraSet = bcset; for (int i = 0; i < bcc.cAnimCollectionCount; i++) { bcset[i] = new BattleCameraSet() { globalSetPointer = (uint)(br.BaseStream.Position + br.ReadUInt16() - i * 2 - 2) } } ; bcc.pCameraEOF = br.ReadUInt16(); for (int i = 0; i < bcc.cAnimCollectionCount; i++) { br.BaseStream.Seek(bcc.battleCameraSet[i].globalSetPointer, 0); bcc.battleCameraSet[i].animPointers = new uint[8]; for (int n = 0; n < bcc.battleCameraSet[i].animPointers.Length; n++) { bcc.battleCameraSet[i].animPointers[n] = (uint)(br.BaseStream.Position + br.ReadUInt16() * 2 - n * 2); } } CameraStruct cam = Extended.ByteArrayToStructure <CameraStruct>(new byte[Marshal.SizeOf(typeof(CameraStruct))]); //what about this kind of trick to initialize struct with a lot amount of fixed sizes in arrays? c.battleCameraCollection = bcc; c.battleCameraSettings = bcs; c.cam = cam; c.ReadAnimationById(c.GetRandomCameraN(Memory.Encounters.Current), br); c.EndOffset = c.bs_cameraPointer + sCameraDataSize; //br.BaseStream.Seek(c.EndOffset, 0); //step out return(c); } #endregion Methods }
public void TwoParamFunctionIsComposableWithParam2() { Func <string, int, string> testFunction = (p1, p2) => string.Format(p1, p2); var expected = testFunction("{0}", 3); var composedFunction = Extended.Compose(testFunction, 3); var actual = composedFunction("{0}"); Assert.AreEqual(expected, actual); }
/// <summary> /// Gets Vector3 translated to openviii coordinates from given track animation's frame id /// </summary> /// <param name="trackId"></param> /// <param name="frameId"></param> /// <returns></returns> public Vector3 GetTrackFrameVector(int trackId, int frameId) { Keypoint kp = railEntries[trackId].keypoints[frameId]; return(new Vector3(Extended.ConvertVanillaWorldXAxisToOpenVIII(kp.x), Extended.ConvertVanillaWorldYAxisToOpenVIII(kp.y), Extended.ConvertVanillaWorldZAxisToOpenVIII(kp.Z) )); }
public void ThreeParamFunctionIsComposableWithParam2And3() { Func <string, int, double, string> testFunction = (p1, p2, p3) => string.Format(p1, p2, p3); var expected = testFunction("{0}{1}", 3, 4.0); var composedFunction = Extended.Compose(testFunction, 3, 4.0); var actual = composedFunction("{0}{1}"); Assert.AreEqual(expected, actual); }
public ContentResult Sql(Context context) { var log = new SysLogModel(context: context); var result = context.Authenticated ? Extended.Sql(context: context) : ApiResults.Unauthorized(context: context); log.Finish(context: context, responseSize: result.Content.Length); return(result); }
public wm2field(byte[] buffer) { var structSize = Marshal.SizeOf(typeof(warpEntry)); warpEntries = new warpEntry[buffer.Length / structSize]; for (var i = 0; i < warpEntries.Length; i++) { warpEntries[i] = Extended.ByteArrayToStructure <warpEntry>(buffer.Skip(i * structSize).Take(structSize).ToArray()); } }
private Directories() { _directories = new [] { Extended.GetUnixFullPath(Path.Combine(Memory.FF8DirData, "movies")), //this folder has most movies Extended.GetUnixFullPath(Path.Combine(Memory.FF8DirDataLang, "movies")) //this folder has rest of movies }.Distinct().ToList().AsReadOnly(); foreach (var s in _directories) { Memory.Log.WriteLine($"{nameof(Movie)} :: {nameof(Directories)} :: {s} "); } }
public static void Save(IValueSink sink, Extended value) { sink.EnterSequence(); Value <uint> .Save(sink, value.VendorId); Value <uint> .Save(sink, value.ExtendedEventType); Value <ReadOnlyArray <ExtendedParameter> > .Save(sink, value.Parameters); sink.LeaveSequence(); }
/// <inheritdoc/> public override int GetHashCode() { unchecked { int result = base.GetHashCode(); result = (result * 397) ^ Name?.GetHashCode() ?? 0; result = (result * 397) ^ Command?.GetHashCode() ?? 0; result = (result * 397) ^ Arguments?.GetHashCode() ?? 0; result = (result * 397) ^ Extended.GetHashCode(); result = (result * 397) ^ Descriptions.GetUnsequencedHashCode(); return(result); } }
public object Invoke(Plugin creator) { Extended constructor = @base as Extended; if (constructor != null) { return(constructor.Invoke(creator)); } else { return((@base as Default)?.Invoke()); } }
/// <inheritdoc/> public override int GetHashCode() { unchecked { int result = base.GetHashCode(); result = (result * 397) ^ (Name ?? "").GetHashCode(); result = (result * 397) ^ (Command ?? "").GetHashCode(); result = (result * 397) ^ (Arguments ?? "").GetHashCode(); result = (result * 397) ^ Extended.GetHashCode(); result = (result * 397) ^ Descriptions.GetSequencedHashCode(); return(result); } }
/// <summary> /// This is the main class that reads given Stage geometry group. It stores the data into /// Model structure /// </summary> /// <param name="pointer">absolute pointer in buffer for given Stage geometry group</param> /// <returns></returns> public static Model Read(uint pointer, BinaryReader br) { bool bSpecial = false; br.BaseStream.Seek(pointer, System.IO.SeekOrigin.Begin); uint header = Extended.UintLittleEndian(br.ReadUInt32()); if (header != 0x01000100) //those may be some switches, but I don't know what they mean { Memory.Log.WriteLine("WARNING- THIS STAGE IS DIFFERENT! It has weird object section. INTERESTING, TO REVERSE!"); bSpecial = true; } ushort verticesCount = br.ReadUInt16(); Vertex[] vertices = new Vertex[verticesCount]; for (int i = 0; i < verticesCount; i++) { vertices[i] = Vertex.Read(br); } if (bSpecial && Memory.Encounters.Scenario == 20) { return(new Model()); } br.BaseStream.Seek((br.BaseStream.Position % 4) + 4, SeekOrigin.Current); ushort trianglesCount = br.ReadUInt16(); ushort quadsCount = br.ReadUInt16(); br.BaseStream.Seek(4, SeekOrigin.Current); Triangle[] triangles = new Triangle[trianglesCount]; Quad[] quads = new Quad[quadsCount]; if (trianglesCount > 0) { for (int i = 0; i < trianglesCount; i++) { triangles[i] = Triangle.Read(br); } } if (quadsCount > 0) { for (int i = 0; i < quadsCount; i++) { quads[i] = Quad.Read(br); } } return(new Model() { vertices = vertices, triangles = triangles, quads = quads }); }
private Directories() { if (_directories == null /*|| _directories.Count == 0*/) { _directories = new List <string> { Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata, "movies")), //this folder has most movies Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata_lang, "movies")) //this folder has rest of movies }; foreach (string s in _directories) { Memory.Log.WriteLine($"{nameof(Movie)} :: {nameof(Directories)} :: {s} "); } } }
private static void LoadWorld() { var aw = ArchiveWorker.Load(Memory.Archives.A_WORLD); // ReSharper disable once StringLiteralTypo var wmPath = $"wmset{Extended.GetLanguageShort(true)}.obj"; using (var worldMapSettings = new Wmset(aw.GetBinaryFile(wmPath))) { _worldEncounters = worldMapSettings.Encounters.SelectMany(x => x.Select(y => y)).Distinct().ToHashSet(); WorldEncountersLunar = worldMapSettings.EncountersLunar.SelectMany(x => x.Select(y => y)).Distinct().ToHashSet(); } //rail = new rail(aw.GetBinaryFile(railFile)); }
public void SendExtension(PeerHash peer, string extension, byte[] payload) { CoordinatorEntry entry = context.Collection.Find(peer); if (entry != null) { byte identifier = entry.More.Translate(extension); Extended extended = new Extended(identifier, payload); MoreHandler handler = context.Facts.GetHandler(extension); context.Hooks.SendExtended(entry.Peer, extended); context.Hooks.CallExtensionDataSent(entry.Peer, extension, payload.Length); handler.OnMessageSent(context.Parameters.Hash, entry.Peer, payload); } }
public async Task <HttpResponseMessage> Sql() { var body = await Request.Content.ReadAsStringAsync(); var context = new Context( sessionStatus: User?.Identity?.IsAuthenticated == true, sessionData: User?.Identity?.IsAuthenticated == true, apiRequestBody: body); var log = new SysLogModel(context: context); var result = context.Authenticated ? Extended.Sql(context: context) : ApiResults.Unauthorized(context: context); log.Finish(context: context, responseSize: result.Content.Length); return(result.ToHttpResponse(Request)); }
/// <summary> /// Setup Basic common needs for IMovieLibrary Extensions /// </summary> protected override void GivenThat() { base.GivenThat(); this.Critic = Mock <IMovieCritic>(); var movies = new List <IMovie>(); for (var i = 0; i < 10; i++) { movies.Add(Mock <IMovie>()); } Extended.Stub(ex => ex.Contents).Return(movies); Extended.Stub(ex => ex.ListNonViolent()).Return(movies.Take(5)); }
/// <summary> /// Возвращает словарь параметров. /// </summary> public Dictionary <string, string> GetParameters() { var parameters = new Dictionary <string, string>() { { "posts", Posts } }; if (Extended != 0) { parameters["extended"] = Extended.ToString(); } if (CopyHistoryDepth != 2) { parameters["copy_history_depth"] = CopyHistoryDepth.ToString(); } return(parameters); }
private RailEntry ParseBlock(byte[] block) { RailEntry entry = new RailEntry() { cKeypoints = block[0], unk = block[1], unk2 = BitConverter.ToUInt16(block, 2), trainStop1 = BitConverter.ToUInt32(block, 4), trainStop2 = BitConverter.ToUInt32(block, 8) }; entry.keypoints = new Keypoint[entry.cKeypoints]; for (int i = 0; i < entry.cKeypoints; i++) { entry.keypoints[i] = Extended.ByteArrayToStructure <Keypoint>(block.Skip(BLOCK_HEADER_SIZE + (i * 16)).Take(16).ToArray()); } return(entry); }
public void SavingWithExtendedModel_Succeeds() { const int carWeightKg = 2200; const string customPropertyName = "CustomPropertyName"; const string customPropertyValue = "CustomPropertyValue"; var car = new Extended <Car>(new Car { Id = 1, Name = "Yumyum", WheelCount = 4, WeightKg = carWeightKg }, new Dictionary <string, object?> { { customPropertyName, customPropertyValue } }); var fileInfo = GetXlsxTempFileInfo(); try { // Save using (var s1 = new MagicSpreadsheet(fileInfo)) { s1.AddSheet(new List <Extended <Car> > { car }); s1.Save(); } using var s2 = new MagicSpreadsheet(fileInfo); s2.Load(); var cars = s2.GetExtendedList <Car>(); cars.Should().NotBeNullOrEmpty(); var firstCar = cars[0]; firstCar.Item.Should().NotBeNull(); carWeightKg.Should().Be(firstCar.Item !.WeightKg); firstCar.Properties.Keys.Should().Contain(customPropertyName); firstCar.Properties[customPropertyName].Should().Be(customPropertyValue); } finally { fileInfo.Delete(); } }
private void _read() { _numFrames = m_io.ReadU4be(); _aiffSampleRate = m_io.ReadBytes(10); _markerChunk = m_io.ReadU4be(); if (M_Parent.SoundHeaderType == MacOsResourceSnd.SoundHeaderType.Extended) { _extended = new Extended(m_io, this, m_root); } if (M_Parent.SoundHeaderType == MacOsResourceSnd.SoundHeaderType.Compressed) { _compressed = new Compressed(m_io, this, m_root); } _bitsPerSample = m_io.ReadU2be(); if (M_Parent.SoundHeaderType == MacOsResourceSnd.SoundHeaderType.Extended) { _reserved = m_io.ReadBytes(14); } }
private Camera(BinaryReader br) : this() { br.BaseStream.Seek(_bsCameraPointer + 4, 0); //uint cCameraHeaderSector = br.ReadUInt16(); //uint pCameraSetting = br.ReadUInt16(); uint pCameraAnimationCollection = br.ReadUInt16(); uint sCameraDataSize = br.ReadUInt16(); //Camera settings parsing? //var battleCameraSettings = new BattleCameraSettings { unk = br.ReadBytes(24) }; //end of camera settings parsing br.BaseStream.Seek(pCameraAnimationCollection + _bsCameraPointer, SeekOrigin.Begin); _battleCameraCollection = new BattleCameraCollection { cAnimCollectionCount = br.ReadUInt16() }; var battleCameraSet = new BattleCameraSet[_battleCameraCollection.cAnimCollectionCount]; _battleCameraCollection.battleCameraSet = battleCameraSet; for (var i = 0; i < _battleCameraCollection.cAnimCollectionCount; i++) { battleCameraSet[i] = new BattleCameraSet { globalSetPointer = (uint)(br.BaseStream.Position + br.ReadUInt16() - i * 2 - 2) } } ; _battleCameraCollection.pCameraEOF = br.ReadUInt16(); for (var i = 0; i < _battleCameraCollection.cAnimCollectionCount; i++) { br.BaseStream.Seek(_battleCameraCollection.battleCameraSet[i].globalSetPointer, 0); _battleCameraCollection.battleCameraSet[i].animPointers = new uint[8]; for (var n = 0; n < _battleCameraCollection.battleCameraSet[i].animPointers.Length; n++) { _battleCameraCollection.battleCameraSet[i].animPointers[n] = (uint)(br.BaseStream.Position + br.ReadUInt16() * 2 - n * 2); } } Cam = Extended.ByteArrayToStructure <CameraStruct>(new byte[Marshal.SizeOf(typeof(CameraStruct))]); //what about this kind of trick to initialize struct with a lot amount of fixed sizes in arrays? ReadAnimationById(GetRandomCameraN(Memory.Encounters.Current), br); EndOffset = _bsCameraPointer + sCameraDataSize; //br.BaseStream.Seek(c.EndOffset, 0); //step out }
private void ExportFile() { try { const string target = @"d:\"; if (!Directory.Exists(target)) { return; } var drive = DriveInfo.GetDrives().Where(x => x.Name.IndexOf(Path.GetPathRoot(target), StringComparison.OrdinalIgnoreCase) >= 0).ToArray(); var di = new DirectoryInfo(target); if (!di.Attributes.HasFlag(FileAttributes.ReadOnly) && drive.Count() == 1 && drive[0].DriveType == DriveType.Fixed) { Extended.DumpBuffer(Buffer, Path.Combine(target, "out.dat")); } } catch (IOException) { } }
Coordinate[] GetCoordinates(BinaryReader binReader, Detail detail) { UInt32 size; Coordinate[] coordinate; switch (detail) { case Detail.Simple: case Detail.Extended: size = binReader.ReadUInt32() / (uint)Marshal.SizeOf(typeof(Coordinate)); coordinate = new Coordinate[size]; FileTools.BinaryToArray <Coordinate>(binReader, coordinate); return(coordinate); case Detail.Full: size = binReader.ReadUInt32() / (uint)Marshal.SizeOf(typeof(Extended)); coordinate = new Extended[size]; FileTools.BinaryToArray <Extended>(binReader, (Extended[])coordinate); return(coordinate); default: return(null); } }
public ExtendedWrapper(Extended item) { this.Item = item; }
public static void Save(IValueSink sink, Extended value) { sink.EnterSequence(); Value<uint>.Save(sink, value.VendorId); Value<uint>.Save(sink, value.ExtendedEventType); Value<ReadOnlyArray<ExtendedParameter>>.Save(sink, value.Parameters); sink.LeaveSequence(); }
public void EncodeRaw(Extended.Quote[] quotes) { throw new NotSupportedException(); }
private static byte GetClutId(ushort clut) { ushort bb = Extended.UshortLittleEndian(clut); return((byte)(((bb >> 14) & 0x03) | (bb << 2) & 0x0C)); }
Coordinate[] GetCoordinates(BinaryReader binReader, Detail detail) { UInt32 size; Coordinate[] coordinate; switch (detail) { case Detail.Simple: case Detail.Extended: size = binReader.ReadUInt32() / (uint)Marshal.SizeOf(typeof(Coordinate)); coordinate = new Coordinate[size]; FileTools.BinaryToArray<Coordinate>(binReader, coordinate); return coordinate; case Detail.Full: size = binReader.ReadUInt32() / (uint)Marshal.SizeOf(typeof(Extended)); coordinate = new Extended[size]; FileTools.BinaryToArray<Extended>(binReader, (Extended[])coordinate); return coordinate; default: return null; } }