Exemplo n.º 1
0
        protected override ICryptoValue EncryptInternal(ArraySegment <byte> originalBytes, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var original = GetString(originalBytes, Encoding.UTF8);

            return(CreateCryptoValue(original,
                                     ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(original)(CryptoMode.Encrypt),
                                     CryptoMode.Encrypt));
        }
Exemplo n.º 2
0
        protected override ICryptoValue DecryptInternal(ArraySegment <byte> cipherBytes, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var cipher = GetString(cipherBytes, Encoding.UTF8);

            return(CreateCryptoValue(
                       ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(cipher)(CryptoMode.Decrypt),
                       cipher,
                       CryptoMode.Decrypt));
        }
Exemplo n.º 3
0
        public TemplateParser(string name, string content)
        {
            Result = new Representation.Template(name, null);
            Templates.Push(Result);
            CurrentProcessFunc = pf_Default;
            Buffer.Clear();
            LineNumber   = 1;
            ColumnNumber = 1;

            foreach (char c in content)
            {
                CurrentProcessFunc(c);
                if (c == '\n')
                {
                    ++LineNumber;
                    ColumnNumber = 1;
                }
                else
                {
                    ++ColumnNumber;
                }
            }
            StoreCurrentBuffer();
            Trace.Assert(Templates.Count == 1);
            Trace.Assert(Templates.Peek() == Result);
        }
Exemplo n.º 4
0
 private void pf_RecordComment(char c)
 {
     if (c == '#')
     {
         CurrentProcessFunc = pf_ExpectEndOfComment;
     }
 }
Exemplo n.º 5
0
 private void pf_StartOfCurlyBracketsExpression(char c)
 {
     if (c == '{')
     {
         StoreCurrentBuffer();
         CurrentVariableLookup = new Representation.VariableLookup(Templates.Peek());
         Templates.Peek().Items.Add(CurrentVariableLookup);
         CurrentProcessFunc = pf_RecordVariableLookup;
     }
     else if (c == '%')
     {
         StoreCurrentBuffer();
         CurrentVariableLookup = null;
         CurrentProcessFunc    = pf_RecordGenericExpression;
     }
     else if (c == '#')
     {
         StoreCurrentBuffer();
         CurrentVariableLookup = null;
         CurrentProcessFunc    = pf_RecordComment;
     }
     else
     {
         Buffer.Append('{');
         Buffer.Append(c);
         CurrentProcessFunc = pf_Default;
     }
 }
Exemplo n.º 6
0
 public void ProcessRecords(ProcessRecordsInput input)
 {
     if (ProcessFunc != null)
     {
         ProcessFunc.Invoke(input);
     }
 }
Exemplo n.º 7
0
        public virtual void AddProcessFunc(GameAction act, GameCmd cmd, ProcessFunc func)
        {
            int key = (((int)act) << 16) + (int)cmd;

            if (dictProcessFunc.ContainsKey(key))
            {
                throw new Exception("重复定义消息处理函数");
            }
            dictProcessFunc[key] = func;
        }
Exemplo n.º 8
0
 private void pf_Default(char c)
 {
     if (c == '{')
     {
         CurrentProcessFunc = pf_StartOfCurlyBracketsExpression;
     }
     else
     {
         Buffer.Append(c);
     }
 }
Exemplo n.º 9
0
 private void pf_ExpectEndOfVariableLookup(char c)
 {
     if (c == '}')
     {
         CurrentProcessFunc = pf_Default;
     }
     else
     {
         throw new Exception(SyntaxError("Expected }}, got }%c instead", c));
     }
 }
Exemplo n.º 10
0
 /// <summary>
 ///  指定された処理を表すデリゲートを指定されたパイプラインの末尾に追加します。
 /// </summary>
 /// <typeparam name="TParam">追加する処理の引数の種類です。</typeparam>
 /// <typeparam name="TResult">追加する処理の戻り値の種類です。</typeparam>
 /// <param name="pipeline">登録先のパイプラインです。</param>
 /// <param name="processFunc">追加する処理です。</param>
 /// <returns>
 ///  <paramref name="pipeline"/>そのもの、または、
 ///  指定された処理が追加された新しい<paramref name="pipeline"/>のコピーです。
 /// </returns>
 /// <exception cref="System.ArgumentNullException" />
 public static IPipeline Append <TParam, TResult>(this IPipeline pipeline, ProcessFunc <TParam, TResult> processFunc)
 {
     if (pipeline == null)
     {
         throw new ArgumentNullException(nameof(pipeline));
     }
     if (processFunc == null)
     {
         throw new ArgumentNullException(nameof(processFunc));
     }
     return(pipeline.Append(new ProcessFuncWrapper <TParam, TResult>(processFunc)));
 }
Exemplo n.º 11
0
 private void pf_RecordGenericExpression(char c)
 {
     if (c == '%')
     {
         FeedGenericExpression();
         CurrentProcessFunc = pf_ExpectEndOfVariableLookup;
     }
     else
     {
         Buffer.Append(c);
     }
 }
Exemplo n.º 12
0
 private void pf_ExpectEndOfComment(char c)
 {
     if (c == '}')
     {
         CurrentProcessFunc = pf_Default;
     }
     else
     {
         // ignore: we are in a comment, after all
         CurrentProcessFunc = pf_RecordComment;
     }
 }
Exemplo n.º 13
0
 private void pf_RecordFilterFunc(char c)
 {
     if (c == '}')
     {
         FeedVariableFilterFunc();
         CurrentProcessFunc = pf_ExpectEndOfVariableLookup;
     }
     else if (c == '|')
     {
         FeedVariableFilterFunc();
     }
     else
     {
         Buffer.Append(c);
     }
 }
Exemplo n.º 14
0
 public string Decrypt(string cipher) =>
 ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(cipher)(EncryptionAlgorithmMode.Decrypt);
Exemplo n.º 15
0
 public string Encrypt(string plainText) =>
 ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(plainText)(EncryptionAlgorithmMode.Encrypt);
Exemplo n.º 16
0
        /// Complete execution
        protected object ProcessComplete(IFileSystemInfo from, IFileSystemInfo to, bool skip, ProcessFunc func)
        {
            string pref = Context.TransformStr(Name, Transform);
            Vars   sv   = new Vars();

            sv[""] = sv["from"] = from;
            if (to != null)
            {
                sv["to"] = to;
            }
            sv["skip"] = skip;

            return(Context.ExecuteWithVars(delegate()
            {
                Context.CheckAbort();
                object ret = null;
                try
                {
                    ret = SequenceExecute();
                }
                catch (Exception ex)
                {
                    return ReturnValue.CreateException(ex);
                }
                try
                {
                    if (ret == null)
                    {
                        ret = Context.Execute(Try);
                    }
                    skip = Context.GetBool(pref + "skip", false);
                    if (ret == null)
                    {
                        ret = func(skip);
                    }
                }
                catch (Exception ex)
                {
                    ret = OnError(ex);
                }
                finally
                {
                    // Execute final portion
                    Context.Execute(Finally);
                }
                return ret;
            }, sv, pref));
        }
Exemplo n.º 17
0
 /// <summary>
 /// Initialises a new instance of the <see cref="AsyncProcessor{Tin, Tout}"/> class.
 /// </summary>
 /// <param name="processFunction">The process function handler.</param>
 /// <param name="maintainInputOrder">
 /// Whether to publish the processed input outputs in the order the inputs were
 /// published.
 /// </param>
 public AsyncProcessor(ProcessFunc processFunction, bool maintainInputOrder = false)
 {
     _processFunction    = processFunction;
     _maintainInputOrder = maintainInputOrder;
 }
Exemplo n.º 18
0
 public void addProcessFunc(ProcessFunc pFunc)
 {
     inDataFunc += pFunc;
 }
Exemplo n.º 19
0
 public ProxySelectExprProcessor(ProcessFunc procProcess)
 {
     ProcProcess = procProcess;
 }
Exemplo n.º 20
0
        /// Complete execution
        protected object ProcessComplete(IFileSystemInfo from, IFileSystemInfo to, bool skip, ProcessFunc func)
        {
            string pref = Context.TransformStr(Name, Transform);
            Vars sv=new Vars();
            sv[""]=sv["from"] = from;
            if (to != null)
                sv["to"] = to;
            sv["skip"] = skip;

            return Context.ExecuteWithVars(delegate()
                                               {
                                                   Context.CheckAbort();
                                                   object ret = null;
                                                   try
                                                   {
                                                       ret = SequenceExecute();
                                                   }
                                                   catch (Exception ex)
                                                   {
                                                       return ReturnValue.CreateException(ex);
                                                   }
                                                   try
                                                   {
                                                       if (ret == null)
                                                            ret = Context.Execute(Try);
                                                       skip=Context.GetBool(pref+"skip", false);
                                                       if (ret == null)
                                                           ret = func(skip);
                                                   }
                                                   catch (Exception ex)
                                                   {
                                                       ret = OnError(ex);
                                                   }
                                                   finally
                                                   {
                                                       // Execute final portion
                                                       Context.Execute(Finally);
                                                   }
                                                   return ret;
                                               }, sv, pref);
        }
Exemplo n.º 21
0
 /// <summary>
 ///  型'<see cref="ExapisSOP.Core.PipelineExtensions.ProcessFuncWrapper"/>'の新しいインスタンスを生成します。
 /// </summary>
 /// <param name="func">処理を表すデリゲートです。</param>
 public ProcessFuncWrapper(ProcessFunc func)
 {
     _func = func;
 }