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