Example #1
0
        public void Create(Bill obj)
        {
            var bills = reader.Read <Bill>();

            bills.Add(obj);
            writer.Write(bills);
        }
Example #2
0
        public void Create(Product obj)
        {
            var products = reader.Read <Product>();

            products.Add(obj);
            writer.Write(products);
        }
Example #3
0
 public override void doSerialize(IDataWriter state)
 {
     base.doSerialize(state);
     state.Write(m_scale.X);
     state.Write(m_scale.Y);
     state.Write(m_scale.Z);
 }
Example #4
0
        public static void WriteTexts(IDataWriter textDataWriter, List <string> texts, char[] trimChars)
        {
            if (texts == null)
            {
                textDataWriter.Write((ushort)0);
                return;
            }

            textDataWriter.Write((ushort)texts.Count);

            var trimmedTexts = texts.Select(text =>
            {
                if (trimChars?.Length > 0)
                {
                    text = text.Trim(trimChars);
                }

                if (!text.Contains('\0'))
                {
                    text += "\0";
                }

                return(text);
            });

            foreach (var text in trimmedTexts)
            {
                textDataWriter.Write((ushort)text.Length);
            }

            foreach (var text in trimmedTexts)
            {
                textDataWriter.WriteWithoutLength(text);
            }
        }
Example #5
0
        public void Create(Category obj)
        {
            var categories = reader.Read <Category>();

            categories.Add(obj);
            writer.Write(categories);
        }
Example #6
0
 public static void WriteItemSlot(ItemSlot itemSlot, IDataWriter dataWriter)
 {
     dataWriter.Write((byte)itemSlot.Amount);
     dataWriter.Write((byte)itemSlot.NumRemainingCharges);
     dataWriter.Write((byte)itemSlot.RechargeTimes);
     dataWriter.WriteEnumAsByte(itemSlot.Flags);
     dataWriter.Write((ushort)itemSlot.ItemIndex);
 }
        public void WriteTextDictionary(TextDictionary textDictionary, IDataWriter dataWriter)
        {
            dataWriter.Write((ushort)textDictionary.Entries.Count);

            foreach (var entry in textDictionary.Entries)
            {
                dataWriter.Write(entry);
            }
        }
Example #8
0
 public override void GetData(IDataWriter writer)
 {
     writer.Write(UserList.Count());
     foreach (UserListEntry ent in UserList)
     {
         writer.Write(ent.UserName);
         writer.Write(ent.HostName);
     }
 }
Example #9
0
 public virtual void Write()
 {
     //SetSaveSetting(m_SaveSetting);
     if (m_SaveSetting == null)
     {
         SetSaveSetting(typeof(T).FullName);
     }
     m_DataWriter.Write(Data, m_SaveSetting);
     Data.ResetDataDirty();
 }
Example #10
0
File: PIN.cs Project: swetllana/ATM
        public void ChangePIN()
        {
            dataWriter.Write(Constants.ENTER_CURRENT_PIN_MESSAGE);
            var currentPIN = dataReader.ReadLine();
            var newPIN     = string.Empty;

            do
            {
                dataWriter.WriteLine(Constants.NOTE_PIN_MESSAGE);
                dataWriter.Write(Constants.ENTER_NEW_PIN_MESSAGE);
                newPIN = dataReader.ReadLine();
            } while (newPIN.Length != 4 || !IsDigitsOnly(newPIN));
        }
Example #11
0
        public void WriteChest(Chest chest, IDataWriter dataWriter)
        {
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 6; ++x)
                {
                    ItemSlotWriter.WriteItemSlot(chest.Slots[x, y], dataWriter);
                }
            }

            dataWriter.Write((ushort)chest.Gold);
            dataWriter.Write((ushort)chest.Food);
        }
        /// <summary>
        /// Writes message to the writer
        /// </summary>
        /// <param name="obj">Message to write</param>
        /// <param name="writer">Writer used to write the message</param>
        void IStreamingCodec <MapInputWithControlMessage <TMapInput> > .Write(MapInputWithControlMessage <TMapInput> obj,
                                                                              IDataWriter writer)
        {
            switch (obj.ControlMessage)
            {
            case MapControlMessage.AnotherRound:
                writer.Write(new byte[] { 0 }, 0, 1);
                _baseCodec.Write(obj.Message, writer);
                break;

            case MapControlMessage.Stop:
                writer.Write(new byte[] { 1 }, 0, 1);
                break;
            }
        }
        private byte[] Compress(byte[] data)
        {
            //note that page size numbers do not include header size by spec

            _ph.Uncompressed_page_size = data.Length;
            byte[] result;

            if (_compressionMethod != CompressionMethod.None)
            {
                IDataWriter writer = DataFactory.GetWriter(_compressionMethod);
                using (var ms = new MemoryStream())
                {
                    writer.Write(data, ms);
                    result = ms.ToArray();
                }
                _ph.Compressed_page_size = result.Length;
            }
            else
            {
                _ph.Compressed_page_size = _ph.Uncompressed_page_size;
                result = data;
            }

            return(result);
        }
Example #14
0
        public void Execute(string id, int firstPaymentId, DateTime dueDate, string inputPath, string outputPath)
        {
            var inputData  = reader.Read(inputPath);
            var outputData = inputDataProcessor.GetOutputData(id, firstPaymentId, dueDate, inputData);

            writer.Write(outputData, outputPath);
        }
Example #15
0
 public override void serialize(IDataWriter writer)
 {
     foreach (bool b in m_value)
     {
         writer.Write(b);
     }
 }
Example #16
0
        public void Write(T obj, IDataWriter writer)
        {
            var byteArr = _codec.Encode(obj);

            writer.WriteInt32(byteArr.Length);
            writer.Write(byteArr, 0, byteArr.Length);
        }
 public void Export(ICollection <Pupil> pupils)
 {
     foreach (Pupil p in pupils)
     {
         _writer.Write(p);
     }
 }
Example #18
0
        /// <summary>
        /// Saves the <paramref name="dataPacket"/> sequentially to a single file with
        /// given <paramref name="filePath"/>.
        /// </summary>
        /// <param name="dataPacket">The data packet to save</param>
        /// <param name="detectors">The detectors used to create data packet</param>
        /// <param name="dataReaderPool">The shared pool of file data readers</param>
        /// <param name="filePath">The path name of the file to write to</param>
        /// <param name="progressReporter">For reporting progress and checking cancellation</param>
        /// <param name="createForensicIntegrityLog">Create a forensic integrity log file along with the normal output</param>
        /// <exception cref="ArgumentNullException">If any argument is <c>null</c></exception>
        /// <exception cref="IOException">On error writing the output file</exception>
        public void Save(IDataPacket dataPacket, IEnumerable <IDetector> detectors, IDataReaderPool dataReaderPool, string filePath, IProgressReporter progressReporter, bool createForensicIntegrityLog)
        {
            PreConditions.Argument("dataPacket").Value(dataPacket).IsNotNull();
            PreConditions.Argument("detectors").Value(detectors).IsNotNull().And.DoesNotContainNull();
            PreConditions.Argument("dataReaderPool").Value(dataReaderPool).IsNotNull();
            PreConditions.Argument("filePath").Value(filePath).IsNotNull().And.IsNotEmpty();
            PreConditions.Argument("progressReporter").Value(progressReporter).IsNotNull();

            if (progressReporter.CancellationPending)
            {
                return;
            }

            using (IDataWriter dataWriter = _createDataWriter(filePath))
            {
                using (IDataReader dataReader = dataReaderPool.CreateDataReader(dataPacket, progressReporter))
                {
                    dataWriter.Write(dataReader);
                }
            }
            if (createForensicIntegrityLog)
            {
                string logFileName = string.Format("{0}.csv", filePath);
                using (FileStream fs = new FileStream(logFileName, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    _forensicIntegrityLog.Log(dataPacket, detectors, filePath, fs, ForensicLogType.CopiedData);
                }
            }
        }
        public void WriteDataOneByteAtATime()
        {
            IDataReader dataReader = CreateFakeDataReader(ShortDataReaderLength, ReadOneByte);

            _dataWriter.Write(dataReader);
            _dataWriter.Dispose();

            AssertFileDataIsCorrect(AssertReadFileData(ShortDataReaderLength));
        }
Example #20
0
 public void Save(IDataWriter writer)
 {
     //JsonFileIO.Write(filename, DataList.ToList(data));
     lock (dbLock)
     {
         writer.Write(data);
     }
 }
Example #21
0
 public static IObserver <T> ToObserver <T>(this IDataWriter writer)
 {
     return(System.Reactive.Observer.Create <T>
            (
                onNext: data => writer.Write(data),
                onError: _ => writer.Close(),
                onCompleted: () => writer.Close()
            ));
 }
Example #22
0
        public static void WriteEvents(IDataWriter dataWriter,
                                       List <Event> events, List <Event> eventList)
        {
            dataWriter.Write((ushort)eventList.Count);

            foreach (var @event in eventList)
            {
                dataWriter.Write((ushort)events.IndexOf(@event));
            }

            dataWriter.Write((ushort)events.Count);

            foreach (var @event in events)
            {
                dataWriter.WriteEnumAsByte(@event.Type);
                SaveEvent(dataWriter, @event);
                dataWriter.Write((ushort)(@event.Next == null ? 0xffff : events.IndexOf(@event.Next)));
            }
        }
 public static IDataWriter WriteIPv6Address(this IDataWriter writer, IPAddress addr)
 {
     if (addr.AddressFamily != AddressFamily.InterNetworkV6)
     {
         throw new ArgumentException("Expecting IPv6 address");
     }
     byte[] a = addr.GetAddressBytes();
     writer.Write(a);
     return(writer);
 }
Example #24
0
 protected void UpdateBestPrices()
 {
     var(bid, ask) = GetBestPrices();
     if (bid != _bestBid || ask != _bestAsk)
     {
         _bestBid = bid;
         _bestAsk = ask;
         _dataWriter.Write(GetResultData());
     }
 }
Example #25
0
        public void WriteDataMoqTest()
        {
            var mockDataWriter = new Mock <IDataWriter <object> >();

            IDataWriter <object> dataWriter = mockDataWriter.Object;

            dataWriter.Write(new object[] { });

            mockDataWriter.Verify();
        }
Example #26
0
        /// <summary>
        /// Writes the class fields.
        /// </summary>
        /// <param name="obj">The message to write</param>
        /// <param name="writer">The writer to which to write</param>
        public void Write(GroupCommunicationMessage <T> obj, IDataWriter writer)
        {
            byte[] encodedMetadata = GenerateMetaDataEncoding(obj);
            byte[] encodedInt      = BitConverter.GetBytes(encodedMetadata.Length);
            byte[] totalEncoding   = encodedInt.Concat(encodedMetadata).ToArray();
            writer.Write(totalEncoding, 0, totalEncoding.Length);

            foreach (var data in obj.Data)
            {
                _codec.Write(data, writer);
            }
        }
        public void WriteAllTrainingDatas(string fileName)
        {
            Rectangle     rectangle = new Rectangle(m_Chess);
            BoardIterator iterator  = new BoardIterator(rectangle);
            var           chess     = GetChess();

            iterator.GetBroad((temp) =>
            {
                var isValid = IsValid(temp);
                m_Writer.Write(fileName, temp, chess, isValid);
            });
        }
Example #28
0
        /// <summary>
        /// Writes the integer array to the writer.
        /// </summary>
        /// <param name="obj">The integer array to be encoded</param>
        /// <param name="writer">The writer to which to write</param>
        public void Write(int[] obj, IDataWriter writer)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj", "integer array is null");
            }

            writer.WriteInt32(obj.Length);
            byte[] buffer = new byte[sizeof(int) * obj.Length];
            Buffer.BlockCopy(obj, 0, buffer, 0, buffer.Length);
            writer.Write(buffer, 0, buffer.Length);
        }
Example #29
0
        //TODO
        private bool WithdrawalMenu(ref int startSum)
        {
            int choice = AmountAvailableOptions();

            switch (choice)
            {
            case (int)SwitchOptions.One:
                return(Validate(ref startSum, Constants.MONEY_OPTION_ONE));

            case (int)SwitchOptions.Two:
                return(Validate(ref startSum, Constants.MONEY_OPTION_TWO));

            case (int)SwitchOptions.Three:
                return(Validate(ref startSum, Constants.MONEY_OPTION_THREE));

            case (int)SwitchOptions.Four:
                return(Validate(ref startSum, Constants.MONEY_OPTION_FOUR));

            case (int)SwitchOptions.Five:
                return(Validate(ref startSum, Constants.MONEY_OPTION_FIVE));

            case (int)SwitchOptions.Six:
                dataWriter.Write(Constants.MONEY_TO_WITHDRAWAL_MESSAGE);
                var wanted = int.Parse(dataReader.ReadLine());
                return(Validate(ref startSum, wanted));

            case (int)SwitchOptions.Seven:
                return(false);

            default:
                dataWriter.WriteLine(Constants.ERROR_MESSAGE);
                return(false);
            }
        }
        public static IDataWriter WriteUTF8(this IDataWriter writer, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                writer.WriteByte(0);
                return(writer);
            }

            byte[] bytes = Encoding.UTF8.GetBytes(text);
            writer.WriteInt(bytes.Length);
            writer.Write(bytes);
            return(writer);
        }
Example #31
0
        /// <summary>
        /// Writes the class fields to the writer.
        /// </summary>
        /// <param name="obj">The object of type NsMessage<T></T> to be encoded</param>
        /// <param name="writer">The writer to which to write</param>
        public void Write(NsMessage <T> obj, IDataWriter writer)
        {
            byte[] encodedMetadata = GenerateMetaDataEncoding(obj);
            byte[] encodedInt      = BitConverter.GetBytes(encodedMetadata.Length);
            byte[] totalEncoding   = encodedInt.Concat(encodedMetadata).ToArray();
            writer.Write(totalEncoding, 0, totalEncoding.Length);

            Type messageType    = obj.Data[0].GetType();
            var  codecWriteFunc = _codecFunctionsCache.WriteFunction(messageType);

            foreach (var data in obj.Data)
            {
                codecWriteFunc(data, writer);
            }
        }
Example #32
0
        public void WriteMonster(Monster monster, IDataWriter dataWriter)
        {
            WriteCharacter(monster, dataWriter);

            foreach (var animation in monster.Animations)
            {
                dataWriter.Write(animation.FrameIndices);
            }

            foreach (var animation in monster.Animations)
            {
                dataWriter.Write((byte)animation.UsedAmount);
            }

            dataWriter.Write(monster.UnknownAdditionalBytes1);
            dataWriter.Write(monster.MonsterPalette);
            dataWriter.Write(monster.UnknownAdditionalBytes2);
            dataWriter.Write((ushort)monster.FrameWidth);
            dataWriter.Write((ushort)monster.FrameHeight);
            dataWriter.Write((ushort)monster.MappedFrameWidth);
            dataWriter.Write((ushort)monster.MappedFrameHeight);
        }
Example #33
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="state"></param>
 public override void doSerialize(IDataWriter state)
 {
     base.doSerialize(state);
     state.Write(m_collisionGroupId.ToString());
     state.Write(m_collisionGroupIds.Count);
     foreach (XnaScrapId collId in m_collisionGroupIds)
     {
         state.Write(collId.ToString());
     }
     state.Write(m_relativePos.X);
     state.Write(m_relativePos.Y);
     state.Write(m_relativePos.Z);
 }
Example #34
0
 public override void serialize(IDataWriter writer)
 {
     writer.Write(m_id.ToString());
 }
Example #35
0
 public override void doSerialize(IDataWriter state)
 {
     state.Write(m_visible);
     state.Write(m_layer);
 }
Example #36
0
 public override void serialize(IDataWriter writer)
 {
     writer.Write(m_parameters.Count);
     foreach (Parameter p in m_parameters)
     {
         p.serialize(writer);
     }
 }
Example #37
0
 public override void serialize(IDataWriter writer)
 {
     foreach (int i in m_values)
     {
         writer.Write(i);
     }
 }
Example #38
0
 public override void doSerialize(IDataWriter state)
 {
     base.doSerialize(state);
     state.Write(m_fontName);
     state.Write(m_text);
 }
Example #39
0
 public override void serialize(IDataWriter writer)
 {
     writer.Write(m_value);
 }
Example #40
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="state"></param>
        public override void doSerialize(IDataWriter state)
        {
            base.doSerialize(state);
            state.Write(m_lastKeybaord);
            state.Write(m_lastMouse);
            state.Write(m_lastTouch);
            state.Write(m_lastGamepad);

            state.Write(m_playerIndex.ToString());

            state.Write(m_keyMappings.Count);
            foreach (KeyValuePair<Keys, InputMapping> pair in m_keyMappings)
            {
                state.Write(pair.Key.ToString());
                pair.Value.serialize(state);
            }

            state.Write(m_gamepadMappings.Count);
            foreach (KeyValuePair<Buttons, InputMapping> pair in m_gamepadMappings)
            {
                state.Write(pair.Key.ToString());
                pair.Value.serialize(state);
            }
        }
Example #41
0
 public void serialize(IDataWriter state)
 {
     state.Write(m_bIsPressed);
     m_downMsg.serialize(state);
     m_upMsg.serialize(state);
     m_targetId.serialize(state);
     state.Write(m_message);
 }
Example #42
0
 public void serialize(IDataWriter writer)
 {
     // serialise all children of root
     foreach (Parameter p in m_root.Parameters.Values)
     {
         writer.Write(p.getTypeName());
         p.serialize(writer);
     }
 }
Example #43
0
 public override void doSerialize(IDataWriter state)
 {
     // TODO convert rad to grad
     //state.Write(Math.Atan2(2.0f * (m_orientation.Y * m_orientation.Z + m_orientation.W * m_orientation.X), m_orientation.W * m_orientation.W - m_orientation.X * m_orientation.X - m_orientation.Y * m_orientation.Y + m_orientation.Z * m_orientation.Z));
     //state.Write(Math.Asin(-2.0f*(m_orientation.X*m_orientation.Z - m_orientation.W*m_orientation.Y)));
     //state.Write(Math.Atan2(2.0f * (m_orientation.X * m_orientation.Y + m_orientation.W * m_orientation.Z), m_orientation.W * m_orientation.W + m_orientation.X * m_orientation.X - m_orientation.Y * m_orientation.Y - m_orientation.Z * m_orientation.Z));
     state.Write(m_x);
     state.Write(m_y);
     state.Write(m_z);
     //state.Write(m_orientation.W);
     base.doSerialize(state);
 }
Example #44
0
 public override void doSerialize(IDataWriter state)
 {
     state.Write(m_position.X);
     state.Write(m_position.Y);
     state.Write(m_position.Z);
     base.doSerialize(state);
 }
Example #45
0
 public void serialize(IDataWriter state)
 {
     state.Write(x);
     state.Write(y);
     state.Write(w);
     state.Write(h);
 }
Example #46
0
 public void Save(IDataWriter writer)
 {
     writer.Write(Data.Array, Data.Offset, Data.Count);
     writer.Channel["BODY_COMPLETED"] = Eof;
 }
Example #47
0
 public override void doSerialize(IDataWriter state)
 {
     state.Write(m_path.Count);
     foreach (Vector3 v in m_path)
     {
         state.Write(v.X);
         state.Write(v.Y);
         state.Write(v.Z);
     }
     base.doSerialize(state);
 }
Example #48
0
        public override void doSerialize(IDataWriter state)
        {
            base.doSerialize(state);
            state.Write(Center.X);
            state.Write(Center.Y);
            state.Write(Center.Z);

            state.Write(HalfExtent.X);
            state.Write(HalfExtent.Y);
            state.Write(HalfExtent.Z);

            state.Write(Orientation.X);
            state.Write(Orientation.Y);
            state.Write(Orientation.Z);
            state.Write(Orientation.W);
        }
Example #49
0
        public override void doSerialize(IDataWriter state)
        {
            state.Write(m_renderTargetId.ToString());
            state.Write(m_fovy);
            state.Write(m_near);
            state.Write(m_far);
            state.Write(m_aspect);

            m_viewport.serialize(state);
        }
 /// <summary>
 /// Serialises this ProjectInvocationRule.
 /// </summary>
 /// <param name="writer">An IDataWriter to which field values are written.</param>
 public void Write(IDataWriter writer)
 {
     writer.Write(Id);
     writer.Write(UsesInput);
     writer.Write(InputSheetKey);
     writer.Write(InputCellRange);
     writer.Write(InputRangeOrder.ToString());
     writer.Write(TimeLimit);
     writer.Write(Unit.ToString());
     writer.Write(UsesOutput);
     writer.Write(OutputSheetKey);
     writer.Write(OutputCellRange);
     writer.Write(OutputRangeOrder.ToString());
     writer.Write(ProjectPath);
     writer.Write(ReloadProjectBeforeExecuting);
     writer.Write(Enabled);
     writer.Write(LastExecutionResult.ToString());
 }