private void WriteToFileStream(FileStream fs, RecMsDay rec) { GCHandle gcHandle = GCHandle.Alloc((object)_msDayBuff, GCHandleType.Pinned); Marshal.StructureToPtr((object)rec, gcHandle.AddrOfPinnedObject(), true); fs.Write(_msDayBuff, 0, 28); gcHandle.Free(); }
public MsMkt(int periodicityIndex, string dataFilePath, string ticker) { _periodicity = (EnumPeriodicity)periodicityIndex; _datFilePath = dataFilePath; clearROAttribute(_datFilePath); _baseRec = new RecMsDay(); Ticker = ticker; }
private void ReadFromFileStream(FileStream fs, ref RecMsDay rec) { int offset = 0; while (offset < _msDayBuff.Length) { offset += fs.Read(_msDayBuff, offset, _msDayBuff.Length - offset); } GCHandle gcHandle = GCHandle.Alloc((object)_msDayBuff, GCHandleType.Pinned); rec = (RecMsDay)Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(), typeof(RecMsDay)); gcHandle.Free(); }
public RecMktDay() { dtd = new RecDay(); msd = new RecMsDay(); }
public RecMktDay(RecDay day) { dtd = new RecDay(day.d, day.o, day.h, day.l, day.c, day.v, day.i); msd = new RecMsDay(); }
private void LoadDailyData(int?fjd, int?ljd) { _dlyList = new MsMktList(); if (File.Exists(_datFilePath)) { bool flag = false; if (!fjd.HasValue && !ljd.HasValue) { flag = true; } else { if (!fjd.HasValue) { fjd = new int?(-99999); } if (!ljd.HasValue) { ljd = new int?(99999); } } _fs = new FileStream(_datFilePath, FileMode.Open, FileAccess.Read, FileShare.None); if (_fs.Length > 0L) { _baseRec = new RecMsDay(); int num = (int)(_fs.Length / 28L) - 1; ReadFromFileStream(_fs, ref _baseRec); for (int index = 0; index < num; ++index) { RecMktDay day = new RecMktDay(); ReadFromFileStream(_fs, ref day.msd); day.MakeDtd(); if (!flag) { int d1 = day.dtd.d; int?nullable = fjd; int valueOrDefault1 = nullable.GetValueOrDefault(); if ((d1 >= valueOrDefault1 ? (nullable.HasValue ? 1 : 0) : 0) != 0) { int d2 = day.dtd.d; nullable = ljd; int valueOrDefault2 = nullable.GetValueOrDefault(); if ((d2 <= valueOrDefault2 ? (nullable.HasValue ? 1 : 0) : 0) == 0) { continue; } } else { continue; } } _dlyList.Add(ref day); } } _fs.Close(); _dlyList.Reset(); } _loaded = true; }