コード例 #1
0
ファイル: MessageView.cs プロジェクト: bakaest/gmgard
        public IViewComponentResult Write()
        {
            WriteAction a        = ViewContext.TempData.ContainsKey("WriteAction") ? (WriteAction)ViewContext.TempData["WriteAction"] : WriteAction.none;
            Message     m        = Newtonsoft.Json.JsonConvert.DeserializeObject <Message>(ViewContext.TempData["WriteMessage"] as string ?? string.Empty);
            string      username = User.Identity.Name;

            switch (a)
            {
            case WriteAction.reply:
                if (username != m.Sender)
                {
                    m.Recipient = m.Sender;
                }
                m.MsgTitle   = "回复:" + m.MsgTitle;
                m.MsgContent = string.Format("\n\n---------{0}于{1}写道---------\n", m.Sender, m.MsgDate) + m.MsgContent;
                break;

            case WriteAction.forward:
                m.Recipient  = "";
                m.MsgTitle   = "转发:" + m.MsgTitle;
                m.MsgContent = string.Format("\n\n---------{0}于{1}写道---------\n", m.Sender, m.MsgDate) + m.MsgContent;
                break;

            default:
                m           = new Message();
                m.Recipient = ViewContext.TempData["WriteTo"] as string;
                break;
            }
            return(View("Write", m));
        }
コード例 #2
0
 private ParquetRowWriter(ParquetFileWriter parquetFileWriter, WriteAction writeAction)
 {
     _parquetFileWriter = parquetFileWriter;
     _rowGroupWriter    = _parquetFileWriter.AppendRowGroup();
     _writeAction       = writeAction;
     _rows = new TTuple[1024];
 }
コード例 #3
0
ファイル: Maze.cs プロジェクト: paulens12/BACKTRACK1
        public void Print(WriteAction wr)
        {
            wr("   ^ Y, V\n");
            StringBuilder sb    = new StringBuilder();
            List <object> args  = new List <object>();
            int           width = db.GetLength(1);

            for (int i = db.GetLength(0) - 1; i >= 0; i--)
            {
                sb.AppendFormat("{0,3}|", i + 1);
                for (int j = 0; j < width; j++)
                {
                    sb.Append("{" + j + ",5}");
                    args.Add(db[i, j]);
                }
                sb.Append("\n");
                wr(sb.ToString(), args.ToArray());
                sb.Clear();
                args.Clear();
            }
            sb.EnsureCapacity(width * 5 + 3);
            sb.Append("   ");
            for (int i = 0; i < width * 5 + 3; i++)
            {
                sb.Append("-");
            }
            sb.Append("> X, U\n    ");
            for (int i = 0; i < width; i++)
            {
                sb.Append(String.Format("{0,5}", i + 1));
            }
            sb.Append("\n");
            wr(sb.ToString());
        }
コード例 #4
0
 public WriteVariants(WriteAction info, WriteAction error, WriteAction warning, WriteAction noise)
 {
     WriteInfo    = info;
     WriteError   = error;
     WriteWarning = warning;
     WriteNoise   = noise;
 }
コード例 #5
0
        public void Run(WriteAction write = null)
        {
            if (write == null)
            {
                write = (s, colour) => Console.WriteLine(s, colour);
            }

            Action <(ConsoleColor, string)[]> writeColour = pairs => {
コード例 #6
0
        private string Translate(CompilationUnit typedCompilationUnit)
        {
            var         code  = new CodeWriter();
            WriteAction write = typedCompilationUnit.Visit(csTranslator);

            write(code);
            return(code.ToString());
        }
コード例 #7
0
 internal ParquetRowWriter(
     OutputStream outputStream,
     Column[] columns,
     WriterProperties writerProperties,
     IReadOnlyDictionary <string, string>?keyValueMetadata,
     WriteAction writeAction)
     : this(new ParquetFileWriter(outputStream, columns, writerProperties, keyValueMetadata), writeAction)
 {
 }
コード例 #8
0
 internal ParquetRowWriter(
     string path,
     Column[] columns,
     Compression compression,
     IReadOnlyDictionary <string, string>?keyValueMetadata,
     WriteAction writeAction)
     : this(new ParquetFileWriter(path, columns, compression, keyValueMetadata), writeAction)
 {
 }
コード例 #9
0
 internal ParquetRowWriter(
     OutputStream outputStream,
     Column[] columns,
     Compression compression,
     IReadOnlyDictionary <string, string> keyValueMetadata,
     WriteAction writeAction)
     : this(new ParquetFileWriter(outputStream, columns, compression, keyValueMetadata), writeAction)
 {
 }
コード例 #10
0
        private static string Translate <T>(Parser <T> parser, string rookSource)
            where T : SyntaxTree
        {
            var         code  = new CodeWriter();
            WriteAction write = parser.Parses(rookSource).Value.Visit(new CSharpTranslator());

            write(code);
            return(code.ToString());
        }
コード例 #11
0
        public Logger()
        {
            TextWriterTraceListener tr1 = new TextWriterTraceListener(System.Console.Out);

            Debug.Listeners.Add(tr1);

            this.Write           += new WriteAction(this.DebugWrite);
            this.InsertBlank     += new InsertBlankAction(this.DebugBlank);
            this.InsertSeparator += new InsertSeparatorAction(this.DebugSeparator);
        }
コード例 #12
0
        public static int Write(char[] chars, int index, int count, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(chars, index, count);
                return(TypeSizes.SIZE_CHAR * count);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #13
0
        public static int Write(char[] chars, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(chars);
                return(TypeSizes.SIZE_CHAR * chars.Length);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #14
0
        public static int Write(decimal value, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(value);
                return(TypeSizes.SIZE_DECIMAL);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #15
0
        public static int Write(byte[] buffer, int index, int count, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(buffer, index, count);
                return(TypeSizes.SIZE_BYTE * count);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #16
0
        public static int Write(byte[] buffer, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(buffer);
                return(TypeSizes.SIZE_BYTE * buffer.Length);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #17
0
        public static int Write(byte value, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(value);
                return(TypeSizes.SIZE_BYTE);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #18
0
        public static int Write(string value, long offset = 0)
        {
            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(value);
                int bytesCount = Encoding.Unicode.GetByteCount(value) + 1;
                return(bytesCount);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #19
0
 private static void WriteReadTest <T>(T[] data, WriteAction <T> write, ReadAction <T> read)
 {
     foreach (var value in data)
     {
         var underlyingStream = new MemoryStream();
         var output           = new DataOutputStream(underlyingStream);
         write(output, value);
         underlyingStream.Seek(0, SeekOrigin.Begin);
         var input = new DataInputStream(underlyingStream);
         Assert.AreEqual <T>(value, read(input));
     }
 }
コード例 #20
0
 public void Write(WriteAction action)
 {
     readerWriterLock.EnterWriteLock();
     try
     {
         action(Add, Remove);
     }
     finally
     {
         readerWriterLock.ExitWriteLock();
     }
 }
コード例 #21
0
 private static int ExecuteWrite(WriteAction writeAction, long offset)
 {
     using (MemoryMappedFile mmf = GetMMF())
     {
         using (MemoryMappedViewStream viewStream = CreateViewStream(mmf, offset))
         {
             using (BinaryWriter binWriter = new BinaryWriter(viewStream))
             {
                 return(writeAction(binWriter));
             }
         }
     }
 }
コード例 #22
0
ファイル: Maze.cs プロジェクト: paulens12/BACKTRACK1
        public void PrintNodes(WriteAction wr)
        {
            GetStepArray();
            Position current = _initialPos;

            wr("[X={0},Y={1}]", current.x + 1, current.y + 1);
            for (int i = 0; i < _stepArray.Length; i++)
            {
                current += _moves[_stepArray[i]];
                wr(", [X={0},Y={1}]", current.x + 1, current.y + 1);
            }
            wr(".\n");
        }
コード例 #23
0
ファイル: ImapStream.cs プロジェクト: Granikos/SMTPSimulator
        public WriteAction Write(string command, params object[] args)
        {
            var action = new WriteAction();

            _writer.WriteLine(curAction + " " + command, args);
            _writer.Flush();

            _actions.Add(curAction, action);

            Log(LogEventType.Outgoing, string.Format(command, args));

            return(action);
        }
コード例 #24
0
        public static int Write <T>(T obj, IBinarySerialization <T> serialization, long offset = 0)
        {
            byte[] bytes  = serialization.Serialize(obj);
            int    length = bytes.Length;

            WriteAction writeAction = (binaryWriter) =>
            {
                binaryWriter.Write(length);
                binaryWriter.Write(bytes);

                return(TypeSizes.SIZE_INT + length);
            };

            return(ExecuteWrite(writeAction, offset));
        }
コード例 #25
0
ファイル: Maze.cs プロジェクト: paulens12/BACKTRACK1
        public void PrintRules(WriteAction wr)
        {
            GetStepArray();
            bool first = true;

            for (int i = 0; i < _stepArray.Length; i++)
            {
                if (!first)
                {
                    wr(", ");
                }
                wr("R{0}", _stepArray[i] + 1);
                first = false;
            }
            wr(".\n");
        }
コード例 #26
0
ファイル: Maze.cs プロジェクト: paulens12/BACKTRACK1
        public void PrintNodes(WriteAction wr)
        {
            Position[] positions = GetPositions();

            bool first = true;

            foreach (Position pos in positions)
            {
                if (!first)
                {
                    wr(", ");
                }
                wr("[X={0},Y={1}]", pos.X + 1, pos.Y + 1);
                first = false;
            }
            wr(".\n");
        }
コード例 #27
0
ファイル: Maze.cs プロジェクト: paulens12/BACKTRACK1
        public void PrintRules(WriteAction wr)
        {
            int[] rules = GetRules();

            bool first = true;

            foreach (int rule in rules)
            {
                if (!first)
                {
                    wr(", ");
                }
                wr("R{0}", rule + 1);
                first = false;
            }
            wr(".\n");
        }
コード例 #28
0
ファイル: LockBox.cs プロジェクト: citizenmatt/gallio
        /// <summary>
        /// Acquires a write lock and invokes the action with the object inside the lock box.
        /// </summary>
        /// <param name="action">The action to invoke.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="action"/> is null.</exception>
        public void Write(WriteAction <T> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            @lock.AcquireWriterLock(Timeout.Infinite);
            try
            {
                action(obj);
            }
            finally
            {
                @lock.ReleaseWriterLock();
            }
        }
コード例 #29
0
        /// <inheritdoc />
        public void Write(WriteAction <IPreferenceSetWriter> writeAction)
        {
            if (writeAction == null)
            {
                throw new ArgumentNullException("writeAction");
            }

            dataLockBox.Write(data =>
            {
                data.Refresh();

                try
                {
                    writeAction(new PreferenceSetWriter(data));
                }
                finally
                {
                    data.Commit();
                }
            });
        }
コード例 #30
0
 //
 // - Methods -
 //
 /// <summary>
 /// Add a write action to the action queue.
 /// </summary>
 /// <param name="identifier">The identifier of the Thread.</param>
 /// <param name="text">The text to log.</param>
 /// <param name="color">The color of the text to log.</param>
 public void AddWriteActionToQueue(String identifier, String text, System.Drawing.Color color)
 {
     WriteAction writeAction = new WriteAction(identifier, text, color);
     this.actionQueue.Enqueue(writeAction);
 }
コード例 #31
0
 public IWriteQueryBuilderBuild Decision(Func <object, List <TTable>, WriteAction> decision)
 {
     _writeAction = new WriteActionDecisionList <TTable>(decision);
     return(this);
 }