Example #1
0
 public Core(ILogicController controller, IReader reader, IWriter writer, IGameInstance game)
 {
     this.controller = controller;
     this.reader = reader;
     this.writer = writer;
     this.game = game;
 }
Example #2
0
 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();
        }
Example #5
0
 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;
 }
Example #12
0
 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);
        }
Example #14
0
 public AddChips(IWriter writer)
 {
     this.InitializeComponent();
     this.ControlBox = false;
     this.outOfChipsLabel.BorderStyle = BorderStyle.FixedSingle;
     this.writer = writer;
 }
Example #15
0
		public static void WritePatch(Patch patch, IWriter writer)
		{
			var container = new ContainerWriter(writer);
			container.StartBlock("asmp", 0);
			WriteBlocks(patch, container, writer);
			container.EndBlock();
		}
Example #16
0
        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;
        }
Example #18
0
        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();
        }
Example #19
0
 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);
 }
Example #21
0
        /// <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;
            }
        }
Example #22
0
        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;
        }
Example #23
0
        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();
            }
        }
Example #24
0
        public ExecSQLRenderTarget(SqlConnection _conn, IWriter _writer, ExecSQLRenderTargetOptions _options)
        {
            conn = _conn;
            writer = _writer;
            options = _options;

            buf = new StringBuilder(options.BufSize);
        }
Example #25
0
 /// <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);
     }
 }
Example #26
0
        public void Export(IWriter writer, IQuoteFormatter formatter, DateTime start, DateTime end)
        {
            writer.ThrowIfNull("writer");
            formatter.ThrowIfNull("formatter");

            _formatter = formatter;
            DoExport(writer, start, end);
        }
Example #27
0
 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);
     }
 }
Example #29
0
 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()));
 }
Example #30
0
 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;
 }
Example #32
0
 protected override void DoWrite(IWriter writer)
 {
     Assert(!string.IsNullOrWhiteSpace(Name));
     writer.Write(Name);
 }
Example #33
0
 public Faculty(IWriter writer)
 {
     Specialty = new List <Specialty>();
     Teachers  = new List <Teacher>();
     _writer   = writer;
 }
Example #34
0
 public Engine()
 {
     this.pizza  = null;
     this.reader = new ConsoleReader();
     this.writer = new ConsoleWriter();
 }
 public override void Serialize(IWriter writer)
 {
     writer.WriteBoolean(allowed);
 }
Example #36
0
 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()}");
 }
Example #37
0
 private void PrintOutput(IWriter writer)
 {
     writer.WriteLine($"{pizza.Name} - {pizza.CalcTotalCalories():F2} Calories.");
 }
Example #38
0
 public Boat(string registration, int enginePower, int maxSpeed, int netWeight, IWriter writer)
 {
     Registration = registration;
     EnginePower  = enginePower;
     MaxSpeed     = maxSpeed;
     NetWeight    = netWeight;
     _logger      = writer;
 }
Example #39
0
 public Engine(IReader reader, IWriter writer, IParser parser)
 {
     this.reader = reader;
     this.writer = writer;
     this.parser = parser;
 }
Example #40
0
 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;
 }
Example #42
0
 public override void Serialize(IWriter writer)
 {
     writer.WriteUTF(uid);
     writer.WriteSByte(failure);
 }
Example #43
0
 public AnimalFactory()
 {
     this.writer = new Writer();
 }
Example #44
0
 public Engine(IReader reader, IWriter writer)
     : this()
 {
     this.reader = reader;
     this.writer = writer;
 }
Example #45
0
 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);
Example #47
0
 //[Inject]
 public void Write(IWriter write)
 {
     _writer = write;
     Console.WriteLine("Prepare writer");
 }
Example #48
0
 public override void Serialize(IWriter writer)
 {
     writer.WriteVarInt((int)skillId);
 }
 public override void Serialize(IWriter writer)
 {
     writer.WriteVarInt((int)nuggetsForPrism);
     writer.WriteVarInt((int)nuggetsForPlayer);
 }
Example #50
0
 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)
 {
 }
Example #52
0
 public VariableTypedMemberWriter(ISpecification <Type> type, ISerializer runtime, IWriter body,
                                  IProperty <TypeInfo> property)
 {
     _type     = type;
     _runtime  = runtime;
     _body     = body;
     _property = property;
     _property = property;
 }
Example #53
0
 public Analyzer(List <IReader> readers, IComparator comparator, IWriter writer)
 {
     _readers    = readers;
     _comparator = comparator;
     _writer     = writer;
 }
Example #54
0
 public VariableTypedMemberWriter(ISpecification <Type> type, ISerializer runtime, IWriter body)
     : this(type, runtime, body, ExplicitTypeProperty.Default)
 {
 }
Example #55
0
 public override void OnBridgeSetup(IBridge bridge)
 {
     Bridge      = bridge;
     ImageWriter = bridge.AddWriter <ImageData>(Topic);
 }
Example #56
0
 protected override void WriteData(IWriter writer)
 {
     writer.WriteUInt32(this.Value);
 }
Example #57
0
 public Engine(IReader reader, IWriter writer)
 {
     this.reader        = reader;
     this.writer        = writer;
     this.storageMaster = new StorageMaster();
 }
Example #58
0
 public override void Serialize(IWriter writer)
 {
     base.Serialize(writer);
     writer.WriteBoolean(isDungeon);
 }
 public override void Serialize(IWriter writer)
 {
     base.Serialize(writer);
 }
Example #60
0
 public Engine()
 {
     this.writer     = new FileWriter();
     this.reader     = new Reader();
     this.controller = new Controller();
 }