예제 #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));
        }
예제 #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));
        }
예제 #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);
        }
예제 #4
0
 private void pf_RecordComment(char c)
 {
     if (c == '#')
     {
         CurrentProcessFunc = pf_ExpectEndOfComment;
     }
 }
예제 #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;
     }
 }
예제 #6
0
 public void ProcessRecords(ProcessRecordsInput input)
 {
     if (ProcessFunc != null)
     {
         ProcessFunc.Invoke(input);
     }
 }
예제 #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;
        }
예제 #8
0
 private void pf_Default(char c)
 {
     if (c == '{')
     {
         CurrentProcessFunc = pf_StartOfCurlyBracketsExpression;
     }
     else
     {
         Buffer.Append(c);
     }
 }
예제 #9
0
 private void pf_ExpectEndOfVariableLookup(char c)
 {
     if (c == '}')
     {
         CurrentProcessFunc = pf_Default;
     }
     else
     {
         throw new Exception(SyntaxError("Expected }}, got }%c instead", c));
     }
 }
예제 #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)));
 }
예제 #11
0
 private void pf_RecordGenericExpression(char c)
 {
     if (c == '%')
     {
         FeedGenericExpression();
         CurrentProcessFunc = pf_ExpectEndOfVariableLookup;
     }
     else
     {
         Buffer.Append(c);
     }
 }
예제 #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;
     }
 }
예제 #13
0
 private void pf_RecordFilterFunc(char c)
 {
     if (c == '}')
     {
         FeedVariableFilterFunc();
         CurrentProcessFunc = pf_ExpectEndOfVariableLookup;
     }
     else if (c == '|')
     {
         FeedVariableFilterFunc();
     }
     else
     {
         Buffer.Append(c);
     }
 }
예제 #14
0
 public string Decrypt(string cipher) =>
 ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(cipher)(EncryptionAlgorithmMode.Decrypt);
예제 #15
0
 public string Encrypt(string plainText) =>
 ProcessFunc()(AlphabetShuffled)(AlphabetShuffledReverse)(plainText)(EncryptionAlgorithmMode.Encrypt);
예제 #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));
        }
예제 #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;
 }
예제 #18
0
 public void addProcessFunc(ProcessFunc pFunc)
 {
     inDataFunc += pFunc;
 }
예제 #19
0
 public ProxySelectExprProcessor(ProcessFunc procProcess)
 {
     ProcProcess = procProcess;
 }
예제 #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);
        }
예제 #21
0
 /// <summary>
 ///  型'<see cref="ExapisSOP.Core.PipelineExtensions.ProcessFuncWrapper"/>'の新しいインスタンスを生成します。
 /// </summary>
 /// <param name="func">処理を表すデリゲートです。</param>
 public ProcessFuncWrapper(ProcessFunc func)
 {
     _func = func;
 }