public Core(ILogicController controller, IReader reader, IWriter writer, IGameInstance game) { this.controller = controller; this.reader = reader; this.writer = writer; this.game = game; }
public int Encode(int b, IWriter output) { if (b < 0) { return this.finalized ? (-1) : this.FinalizeEncoding(output); } b &= 0xff; var count = 0; if (this.lenientLineBreaks) { if (b == 0x0d) { // CR this.haveCR = true; count += this.AddByteInternal(output, (byte)0x0d); count += this.AddByteInternal(output, (byte)0x0a); return count; } if (b == 0x0a && !this.haveCR) { // bare LF if (this.haveCR) { // Do nothing, this is an LF that follows CR this.haveCR = false; } else { count += this.AddByteInternal(output, (byte)0x0d); count += this.AddByteInternal(output, (byte)0x0a); this.haveCR = false; } return count; } } count += this.AddByteInternal(output, (byte)b); this.haveCR = false; return count; }
private int IncrementAndAppend(IWriter output, string appendStr) { var count = 0; if (!this.unlimitedLineLength) { if (this.lineCount + appendStr.Length > 75) { // 76 including the final '=' output.WriteByte(0x3d); output.WriteByte(0x0d); output.WriteByte(0x0a); this.lineCount = 0; count += 3; } } for (int i = 0; i < appendStr.Length; ++i) { if (i==0 && this.lineCount == 0 && appendStr[i] == '.') { output.WriteByte((byte)'='); output.WriteByte((byte)'2'); output.WriteByte((byte)'E'); this.lineCount += 2; count += 2; } else { output.WriteByte((byte)appendStr[i]); } ++count; } this.lineCount += appendStr.Length; return count; }
public void SetUp() { _reader = MockRepository.GenerateStub<IReader<Artist>>(); _writer = MockRepository.GenerateStub<IWriter<Artist>>(); _operationOutput = new ExceptionOperationOutput(); }
protected override void RenderChildren(IWriter writer) { foreach(Section section in this.Sections) { section.Render(writer); } }
private int IncrementAndAppendChars( IWriter output, char b1, char b2, char b3) { var count = 0; if (!this.unlimitedLineLength) { if (this.lineCount + 3 > 75) { // 76 including the final '=' output.WriteByte(0x3d); output.WriteByte(0x0d); output.WriteByte(0x0a); this.lineCount = 0; count += 3; } } if (this.lineCount==0 && b1=='.') { output.WriteByte((byte)'='); output.WriteByte((byte)'2'); output.WriteByte((byte)'E'); this.lineCount += 2; count += 2; } else { output.WriteByte((byte)b1); } output.WriteByte((byte)b2); output.WriteByte((byte)b3); this.lineCount += 3; count += 3; return count; }
public static void ParseCommand(string input, IWriter output, BlobDatabase database) { var tokens = input.Split(' ').ToArray(); var commandType = tokens[0]; switch (commandType) { case "create": CreateCommand(database, tokens); break; case "attack": AttackCommand(database, tokens); break; case "pass": break; case "status": StatusCommand(output, database); break; case "report-events": //todo: report events break; default: throw new InvalidOperationException("Invalid Command."); } foreach (var blob in database) { if (blob.BlobBehavior.HasBeenTriggered) { blob.BlobBehavior.EndTurnAction(blob); } } }
public Engine() { this.writer = new ConsoleWriter(); this.reader = new ConsoleReader(); this.foodFactory = new FoodFactory(); this.moodFactory = new MoodFactory(); }
private static void EndBlock(IWriter writer, long headerPos) { var endPos = writer.Position; writer.SeekTo(headerPos + 4); writer.WriteUInt32((uint)(endPos - headerPos)); writer.SeekTo(endPos); }
public EventEngine(IReader reader, IWriter writer, IEventHolder eventHolder, IEventLogger eventLogger) { this.reader = reader; this.writer = writer; this.eventHolder = eventHolder; this.eventLogger = eventLogger; }
private static long WriteBlockHeader(IWriter writer, int magic) { var startPos = writer.Position; writer.WriteInt32(magic); writer.WriteUInt32(0); // Size filled in later return startPos; }
public Nav(IWriter writer, string activeIdentifier, NavSettings settings = null) : base(writer) { _activeIdentifier = activeIdentifier; _settings = settings ?? new NavSettings(); WriteOpening(); }
private static void WriteLocaleChanges(Patch patch, IWriter writer) { if (patch.LanguageChanges.Count == 0) return; long startPos = writer.Position; writer.WriteInt32(AssemblyPatchBlockID.Locl); writer.WriteUInt32(0); // Size filled in later writer.WriteByte(0); // Version 0 // Write change data for each language writer.WriteByte((byte)patch.LanguageChanges.Count); foreach (LanguageChange language in patch.LanguageChanges) { writer.WriteByte(language.LanguageIndex); // Write the change data for each string in the language writer.WriteInt32(language.LocaleChanges.Count); foreach (LocaleChange change in language.LocaleChanges) { writer.WriteUInt16((ushort)change.Index); writer.WriteUTF8(change.NewValue); } } // Fill in the block size long endPos = writer.Position; writer.SeekTo(startPos + 4); writer.WriteUInt32((uint)(endPos - startPos)); writer.SeekTo(endPos); }
public AddChips(IWriter writer) { this.InitializeComponent(); this.ControlBox = false; this.outOfChipsLabel.BorderStyle = BorderStyle.FixedSingle; this.writer = writer; }
public static void WritePatch(Patch patch, IWriter writer) { var container = new ContainerWriter(writer); container.StartBlock("asmp", 0); WriteBlocks(patch, container, writer); container.EndBlock(); }
public static void WriteElement(IScope scope, IWriter writer, object obj, IElementDef def, XName name) { if (name == null) name = def.Name; var attributes = from attr in def.Attributes let value = attr.GetValue(obj) where value != null && !attr.IsDefaultValue(value) let stringValue = ToString(scope, value) where !string.IsNullOrEmpty(stringValue) select new { attr.Name, Value = stringValue }; var elements = from elem in def.Elements let value = elem.GetValue(obj) where value != null && !elem.IsDefaultValue(value) select new { elem.Name, Value = value, Definition = elem }; // TODO do not write non-root empty elements writer.WriteStartElement(name); foreach (var attr in attributes) { writer.WriteAttributeString(attr.Name, attr.Value); } foreach (var elem in elements) { WriteValue(scope, writer, elem.Definition, elem.Name, elem.Value); } writer.WriteEndElement(); }
public CSVReaderWriter(IWriter writerStream) { ReaderStream = null; writerStream.ThrowIfNull("writerStream"); WriterStream = writerStream; }
public static void WriteElement(IScope scope, IWriter writer, object obj) { var type = obj.GetType(); var xmlWriter = writer as XmlWriterImpl; if (xmlWriter != null) { var surrogate = scope.GetSurrogate(type); if (surrogate != null) { surrogate.Write(xmlWriter.XmlWriter, obj); return; } } var def = scope.GetElementDef(type); if (def != null) { var subScope = def as IScope ?? scope; WriteElement(subScope, writer, obj, def, def.Name); return; } throw new NotSupportedException(); }
public CityBuilder(ICity city, IRenderer renderer, IWriter writer) { this.City = city; this.Renderer = renderer; this.Writer = writer; this.IsRunning = false; }
protected AzureService(string subscriptionId, X509Certificate certificate, IWriter writer) { this.subscriptionId = subscriptionId; this.certificate = certificate; Writer = writer; ServiceUri = new ServiceUri(subscriptionId); }
/// <summary> /// Fills a section of a stream with a repeating byte. /// </summary> /// <param name="writer">The IWriter to fill a section of.</param> /// <param name="b">The byte to fill the section with.</param> /// <param name="size">The size of the section to fill.</param> public static void Fill(IWriter writer, byte b, int size) { if (size == 0) return; if (size < 0) throw new ArgumentException("The size of the data to insert must be >= 0"); if (writer.Position == writer.Length) return; const int BufferSize = 0x1000; byte[] buffer = new byte[BufferSize]; long length = writer.Length; long pos = writer.Position; int filled = 0; // Fill the buffer for (int i = 0; i < buffer.Length; i++) buffer[i] = b; // Write it while (filled < size) { writer.WriteBlock(buffer, 0, (int)Math.Min(length - pos, BufferSize)); filled += BufferSize; pos += BufferSize; } }
private long _offset; // The offset that the writer is currently at #endregion Fields #region Constructors private StructureWriter(StructureValueCollection values, IWriter writer) { _writer = writer; _baseOffset = writer.Position; _offset = _baseOffset; _collection = values; }
private static void WriteResourcePages(TagContainer tags, ContainerWriter container, IWriter writer) { foreach (ResourcePage page in tags.ResourcePages) { container.StartBlock("rspg", 1); writer.WriteInt32(page.Index); writer.WriteUInt16(page.Salt); writer.WriteByte(page.Flags); writer.WriteAscii(page.FilePath ?? ""); writer.WriteInt32(page.Offset); writer.WriteInt32(page.UncompressedSize); writer.WriteByte((byte) page.CompressionMethod); writer.WriteInt32(page.CompressedSize); writer.WriteUInt32(page.Checksum); WriteByteArray(page.Hash1, writer); WriteByteArray(page.Hash2, writer); WriteByteArray(page.Hash3, writer); writer.WriteInt32(page.Unknown1); writer.WriteInt32(page.Unknown2); writer.WriteInt32(page.Unknown3); container.EndBlock(); } }
public ExecSQLRenderTarget(SqlConnection _conn, IWriter _writer, ExecSQLRenderTargetOptions _options) { conn = _conn; writer = _writer; options = _options; buf = new StringBuilder(options.BufSize); }
/// <summary> /// Applies a set of data changes to a stream. /// </summary> /// <param name="changes">The data changes to apply.</param> /// <param name="baseOffset">The offset of the start of the area where the changes should be applied.</param> /// <param name="writer">The stream to write changes to.</param> public static void PatchData(IEnumerable<DataChange> changes, uint baseOffset, IWriter writer) { foreach (var change in changes) { writer.SeekTo(baseOffset + change.Offset); writer.WriteBlock(change.Data); } }
public void Export(IWriter writer, IQuoteFormatter formatter, DateTime start, DateTime end) { writer.ThrowIfNull("writer"); formatter.ThrowIfNull("formatter"); _formatter = formatter; DoExport(writer, start, end); }
public GitOutput(Process process, StreamReader streamReader, IWriter writer) { _process = process; _streamReader = streamReader; _writer = writer; _streamReaderThread = new Thread(ReadStreamOutput) {IsBackground = true}; _streamReaderThread.Start(); }
public static void Copy(IReader reader, IWriter writer) { if (reader != null && writer != null) { string data = reader.Read(); writer.Write(data); } }
public Copy(Container container) { _container = container; _reader = _container.Resolve<IReader>(); _writer = _container.Resolve<IWriter>(); Console.WriteLine(string.Format("Reader Created On: {0}.", _reader.GetCreatedOn())); Console.WriteLine(string.Format("Writer Created On: {0}.", _writer.GetCreatedOn())); }
public void AddWriter(IWriter writer) { if (writer == null) { throw new ArgumentNullException("cannot add null as writer"); } this.writers.Add(writer); }
public ListCharactersController(IWoWDbContext dbContext, IReader reader, IWriter writer) { this.dbContext = dbContext; this.reader = reader; this.writer = writer; }
protected override void DoWrite(IWriter writer) { Assert(!string.IsNullOrWhiteSpace(Name)); writer.Write(Name); }
public Faculty(IWriter writer) { Specialty = new List <Specialty>(); Teachers = new List <Teacher>(); _writer = writer; }
public Engine() { this.pizza = null; this.reader = new ConsoleReader(); this.writer = new ConsoleWriter(); }
public override void Serialize(IWriter writer) { writer.WriteBoolean(allowed); }
public void Introduce(IWriter writer) { writer.WriteLine($"{this.Name} - \"I am {this.Age} years old!\""); writer.WriteLine($"{this.Name} - \"And I am {this.FurType.ToString().SplitToSeparateWordsByUppercaseLetter()}"); }
private void PrintOutput(IWriter writer) { writer.WriteLine($"{pizza.Name} - {pizza.CalcTotalCalories():F2} Calories."); }
public Boat(string registration, int enginePower, int maxSpeed, int netWeight, IWriter writer) { Registration = registration; EnginePower = enginePower; MaxSpeed = maxSpeed; NetWeight = netWeight; _logger = writer; }
public Engine(IReader reader, IWriter writer, IParser parser) { this.reader = reader; this.writer = writer; this.parser = parser; }
public FileAppender(ILayout layout, Level level, IFile file) : base(layout, level) { this.File = file; this.writer = new FileWriter(this.File.Path); }
public Service(IReader reader, IWriter writer) { _reader = reader; _writer = writer; }
public override void Serialize(IWriter writer) { writer.WriteUTF(uid); writer.WriteSByte(failure); }
public AnimalFactory() { this.writer = new Writer(); }
public Engine(IReader reader, IWriter writer) : this() { this.reader = reader; this.writer = writer; }
public Engine(IReader reader, IWriter writer) { this.reader = reader; this.writer = writer; this.dungeonMaster = new DungeonMaster(); }
void IBasicTypeSerializer.Serialize(IWriter writer, object value) => writer.WriteShort((short)value);
//[Inject] public void Write(IWriter write) { _writer = write; Console.WriteLine("Prepare writer"); }
public override void Serialize(IWriter writer) { writer.WriteVarInt((int)skillId); }
public override void Serialize(IWriter writer) { writer.WriteVarInt((int)nuggetsForPrism); writer.WriteVarInt((int)nuggetsForPlayer); }
public Engine(IChampionshipController championshipController, IReader reader, IWriter writer) { this.controller = championshipController; this.reader = reader; //this.writer = writer; this.writer = new FilerWriter(@"c:\temp\MyTest.txt"); }
public override void Serialize(IWriter writer) { }
public VariableTypedMemberWriter(ISpecification <Type> type, ISerializer runtime, IWriter body, IProperty <TypeInfo> property) { _type = type; _runtime = runtime; _body = body; _property = property; _property = property; }
public Analyzer(List <IReader> readers, IComparator comparator, IWriter writer) { _readers = readers; _comparator = comparator; _writer = writer; }
public VariableTypedMemberWriter(ISpecification <Type> type, ISerializer runtime, IWriter body) : this(type, runtime, body, ExplicitTypeProperty.Default) { }
public override void OnBridgeSetup(IBridge bridge) { Bridge = bridge; ImageWriter = bridge.AddWriter <ImageData>(Topic); }
protected override void WriteData(IWriter writer) { writer.WriteUInt32(this.Value); }
public Engine(IReader reader, IWriter writer) { this.reader = reader; this.writer = writer; this.storageMaster = new StorageMaster(); }
public override void Serialize(IWriter writer) { base.Serialize(writer); writer.WriteBoolean(isDungeon); }
public override void Serialize(IWriter writer) { base.Serialize(writer); }
public Engine() { this.writer = new FileWriter(); this.reader = new Reader(); this.controller = new Controller(); }