/// <summary> /// Returns a particular symbol by id (uuid) for the provided application /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='symbolId'> /// The ID of the symbol (uuid of the symbol) /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> GetStatusAsync(this ISymbols operations, string symbolId, string ownerName, string appName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetStatusWithHttpMessagesAsync(symbolId, ownerName, appName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public LiteDbAccountDataRepository( string pathToDb, SecureString password, ICurrencies currencies, ISymbols symbols) { _pathToDb = pathToDb ?? throw new ArgumentNullException(nameof(pathToDb)); if (password == null) { throw new ArgumentNullException(nameof(password)); } if (currencies == null) { throw new ArgumentNullException(nameof(currencies)); } if (symbols == null) { throw new ArgumentNullException(nameof(symbols)); } _sessionPassword = SessionPasswordHelper.GetSessionPassword(password); _bsonMapper = CreateBsonMapper(currencies, symbols); }
private static FilterOperation GetOperation(string o, ISymbols symbols) { if (symbols.StartsWith == o) { return(FilterOperation.StartsWith); } if (symbols.Equal == o) { return(FilterOperation.Equal); } if (symbols.GreaterThan == o) { return(FilterOperation.GreaterThan); } if (symbols.LesserThan == o) { return(FilterOperation.LesserThan); } if (symbols.NotEqual == o) { return(FilterOperation.NotEqual); } if (symbols.Contains == o) { return(FilterOperation.Contains); } return(FilterOperation.StartsWith); }
/// <summary> /// Resolve a symbol that is either a module or function. /// </summary> /// <param name="symscope"></param> /// <param name="name"></param> /// <returns></returns> public static MemberAccess ResolveSymbol(ISymbols symscope, string name) { var symbol = symscope.GetSymbol(name); // Case 2: Module. if (symbol.Category == SymbolCategory.Module) { var msym = symbol as SymbolModule; var mem = new MemberAccess(MemberMode.Module); mem.Type = msym.DataType; mem.Scope = msym.Scope; return(mem); } // Case 3: Function. if (symbol.Category == SymbolCategory.Func) { var sfunc = symbol as SymbolFunction; var mem = new MemberAccess(MemberMode.FunctionScript); mem.MemberName = name; mem.Type = sfunc.DataType; mem.Expr = sfunc.FuncExpr as Expr; return(mem); } return(null); }
internal static IEnumerable <SortCommand> ParseCommands(string sortString, ISymbols symbols) { if (string.IsNullOrEmpty(sortString)) { yield break; } if (commandCache.TryGetValue(sortString.GetHashCode(), out var cached)) { foreach (var command in cached) { yield return(command); } } else { var cols = sortString.Split(new[] { symbols.ColumnSeparator }, StringSplitOptions.RemoveEmptyEntries); var list = new List <SortCommand>(); foreach (var col in cols) { var sort = col.Split(new[] { symbols.ValueSeparator }, StringSplitOptions.None); if (sort.Length == 2) { var command = new SortCommand() { Column = sort[0], Ascending = sort[1] == symbols.SortAscending }; list.Add(command); yield return(command); } } commandCache.TryAdd(sortString.GetHashCode(), list); } }
public ProtoSchemes(ICurrencies currencies, ISymbols symbols) { Currencies = currencies ?? throw new ArgumentNullException(nameof(currencies)); Symbols = symbols ?? throw new ArgumentNullException(nameof(symbols)); byte id = 0; AuthNonce = new AuthNonceScheme(messageId: id++); Auth = new AuthScheme(messageId: id++); AuthOk = new AuthOkScheme(messageId: id++); Error = new ErrorScheme(messageId: id++); Order = new OrderScheme(messageId: id++, currencies: currencies); OrderSend = new OrderSendScheme(messageId: id++, currencies: currencies); OrderCancel = new OrderCancelScheme(messageId: id++); OrderStatus = new OrderStatusScheme(messageId: id++); Orders = new OrdersScheme(messageId: id++); Swap = new SwapScheme(messageId: id++, currencies: currencies); SwapInitiate = new SwapInitiateScheme(messageId: id++); SwapAccept = new SwapAcceptScheme(messageId: id++); SwapPayment = new SwapPaymentScheme(messageId: id++); SwapStatus = new SwapStatusScheme(messageId: id++); Swaps = new SwapsScheme(messageId: id++); Subscribe = new SubscribeScheme(messageId: id++); Unsubscribe = new UnsubscribeScheme(messageId: id++); Quotes = new QuotesScheme(messageId: id++); Entries = new EntriesScheme(messageId: id++); Snapshot = new SnapshotScheme(messageId: id++); OrderLog = new OrderLogScheme(messageId: id); }
/// <summary> /// Push as function scope /// </summary> public void Push(ISymbols symbols, bool assignCurrentScopeAsParent) { if (assignCurrentScopeAsParent) { symbols.ParentScope = _current; } _current = symbols; }
public R( IBinary externalAuthRespData, ISymbols mrzInformation ) { _externalAuthRespData = externalAuthRespData; _mrzInformation = mrzInformation; }
public DecryptedExternalAuthenticateResponseData( IBinary externalAuthRespData, ISymbols mrzInformation ) { _externalAuthRespData = externalAuthRespData; _mrzInformation = mrzInformation; }
public SmartCardInsertEvents( ISymbols mrzInfo, ISource <IReader> smartCardReaderConnectEvents ) { _mrzInfo = mrzInfo; _smartCardReaderConnectEvents = smartCardReaderConnectEvents; }
/// <summary> /// Pop the current /// </summary> public void Pop() { if (_current == _global) { return; } _current = _current.ParentScope; }
public SecuredReader( ISymbols mrzInfo, IReader reader ) { _reader = reader; _sessionKeys = new SessionKeys(mrzInfo, reader); _selfIncrementedSsc = new SelfIncrementSSC(_sessionKeys.SSC()); }
public SmartCard(ISymbols mrzInfo, IReader connectedReader) { _bacReader = new BacReader( new SecuredReader( mrzInfo, connectedReader ) ); }
public static void ResetSymbolAsFunction(ISymbols symscope, string varname, LObject lobj) { // 1. Define the function in global symbol scope var lambda = lobj as LFunction; var funcExpr = lambda.Value as FunctionExpr; var symbol = new SymbolFunction(funcExpr.Meta); symbol.Name = varname; symbol.FuncExpr = funcExpr; symscope.Define(symbol); }
public Kenc(ISymbols mrzInformation) : this( new Kseed( new SHA1( new UTF8String(mrzInformation.ToString()) ) ) ) { }
public static ClientSwap ResolveSymbol(this ClientSwap swap, ISymbols symbols) { swap.Symbol = symbols.FirstOrDefault(s => s.Name == swap.Symbol?.Name); if (swap.Symbol == null) { throw new Exception("Symbol resolving error"); } return(swap); }
public ExternalAuthenticateCommandData( ISymbols mrzInformation, IBinary rndIc, IBinary rndIfd, IBinary kIfd) { _mrzInformation = mrzInformation; _rndIc = rndIc; _rndIfd = rndIfd; _kIfd = kIfd; }
public SessionKeys( ISymbols mrzInfo, IReader reader ) { _selectedMrtdApplication = new Cached( new ExecutedCommandApdu( new SelectMRTDApplicationCommandApdu(), reader ) ); var kIfd = new Cached(new Kifd()); var rndIc = new Cached(new RNDic(reader)); var rndIfd = new Cached(new RNDifd()); var externalAuthRespData = new ResponseApduData( new Cached( new ExecutedCommandApdu( new ExternalAuthenticateCommandApdu( new ExternalAuthenticateCommandData( mrzInfo, rndIc, rndIfd, kIfd ) ), reader ) ) ); var kSeedIc = new KseedIc( kIfd, new Kic( new R( externalAuthRespData, mrzInfo ) ) ); _cachedKSenc = new Cached(new KSenc(kSeedIc)); _cachedKSmac = new Cached(new KSmac(kSeedIc)); _ssc = new Cached( new SSC( rndIc, rndIfd ) ); }
private BsonMapper CreateBsonMapper( ICurrencies currencies, ISymbols symbols) { return(new BsonMapper() //.UseSerializer(new DateTimeToBsonSerializer()) .UseSerializer(new BigIntegerToBsonSerializer()) .UseSerializer(new JObjectToBsonSerializer()) .UseSerializer(new CurrencyToBsonSerializer(currencies)) .UseSerializer(new SymbolToBsonSerializer(symbols)) .UseSerializer(new WalletAddressToBsonSerializer()) .UseSerializer(new OrderToBsonSerializer()) .UseSerializer(new BitcoinBasedTransactionToBsonSerializer(currencies)) .UseSerializer(new BitcoinBasedTxOutputToBsonSerializer()) .UseSerializer(new EthereumTransactionToBsonSerializer()) .UseSerializer(new TezosTransactionToBsonSerializer()) .UseSerializer(new SwapToBsonSerializer(symbols))); }
/// <summary> /// Validates the AST node /// </summary> /// <param name="node"></param> /// <returns></returns> public bool Validate(AstNode node) { if (node is Expr) { _currentSymScope = ((Expr)node).SymScope; } int initialErrorCount = _errors.Count; string name = node.GetType().Name; if (!_validators.ContainsKey(name)) { return(true); } var rules = _validators[name]; foreach (var rule in rules) { rule(this, node); } return(initialErrorCount == _errors.Count); }
/// <summary> /// Initialize with name and paretn symbol scope. /// </summary> /// <param name="name"></param> /// <param name="parent"></param> public SymbolsBase(string name, ISymbols parent) { _name = name; _parent = parent; _symbols = new Dictionary <string, Symbol>(); }
/// <summary> /// Validates the AST node /// </summary> /// <param name="node"></param> /// <returns></returns> public bool Validate(AstNode node) { if (node is Expr) { _currentSymScope = ((Expr)node).SymScope; } OnNodeStart(node); int initialErrorCount = _errors.Count; string name = node.Nodetype; if(!_validators.ContainsKey(name)) return true; var rules = _validators[name]; foreach (var rule in rules) { rule(this, node); } return initialErrorCount == _errors.Count; }
/// <summary> /// Returns the list of all symbols for the provided application /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> public static object List(this ISymbols operations, string ownerName, string appName) { return(operations.ListAsync(ownerName, appName).GetAwaiter().GetResult()); }
/// <summary> /// Initialize default /// </summary> public Symbols() { _global = new SymbolsGlobal(); _current = _global; }
private void PushParametersInScope(FunctionExpr expr) { // 1. Validate : any arguments. if (expr.ArgumentValues == null || expr.ArgumentValues.Count == 0) { return; } if (expr.Meta.Arguments == null || expr.Meta.Arguments.Count == 0) { return; } // 2. Check if there is an parameter named "arguments" var hasParameterNamedArguments = false; if (expr.Meta.Arguments != null && expr.Meta.Arguments.Count > 0) { if (expr.Meta.ArgumentsLookup.ContainsKey("arguments")) { hasParameterNamedArguments = true; } } // 3. Get the symbolscope of the inside of the function and see if any statements. ISymbols symscope = null; var hasStatements = expr.Statements != null && expr.Statements.Count > 0; if (hasStatements) { symscope = expr.Statements[0].SymScope; } // 3. Add function arguments to scope for (var ndx = 0; ndx < expr.Meta.Arguments.Count; ndx++) { var val = expr.ArgumentValues[ndx] as LObject; var arg = expr.Meta.Arguments[ndx]; // 4. Clone primitive datatypes. if (val.Type.IsPrimitiveType()) { var copied = val.Clone(); expr.ArgumentValues[ndx] = copied; } // 5. Now, set the memory value of the parameter. this.Ctx.Memory.SetValue(arg.Name, val); // 6. Finally, update the symbol type if (hasStatements) { var sym = symscope.GetSymbol(arg.Name); if (sym != null && val.Type.TypeVal == TypeConstants.Function && sym.Category != SymbolCategory.Func) { SymbolHelper.ResetSymbolAsFunction(symscope, arg.Name, val); } } } // Finally add the arguments. // NOTE: Any extra arguments will be part of the implicit "arguments" array. if (!hasParameterNamedArguments) { var argArray = new LArray(expr.ArgumentValues); expr.Ctx.Memory.SetValue("arguments", argArray); } }
protected void SetSymbols(ISymbols symbols) { this.symbols = symbols ?? throw new ArgumentNullException(nameof(symbols)); }
public SwapToBsonSerializer(ISymbols symbols) { _symbols = symbols ?? throw new ArgumentNullException(nameof(symbols)); }
internal static IEnumerable <FilterCommand> ParseCommands(string filterString, ISymbols symbols) { if (string.IsNullOrEmpty(filterString)) { yield break; } if (commandCache.TryGetValue(filterString.GetHashCode(), out var cached)) { foreach (var command in cached) { yield return(command); } } else { var cols = filterString.Split(new[] { symbols.ColumnSeparator }, StringSplitOptions.RemoveEmptyEntries); var list = new List <FilterCommand>(); foreach (var col in cols) { var filter = col.Split(new[] { symbols.ValueSeparator }, StringSplitOptions.None); if (filter.Length == 2) { var command = new FilterCommand() { Column = filter[0], Filter = filter[1].Substring(1), Operation = GetOperation(filter[1][0].ToString(), symbols) }; list.Add(command); yield return(command); } } commandCache.TryAdd(filterString.GetHashCode(), list); } }
/// <summary> /// Initialize /// </summary> /// <param name="name">The name of the symbol scope</param> /// <param name="parentScope">The parent scope</param> public SymbolsFunction(string name, ISymbols parentScope) : base(name) { this.ParentScope = parentScope; }
public SmartCardContent(ISymbols mrzInfo) { _mrzInfo = mrzInfo; }
/// <summary> /// Gets the URL to download the symbol /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='symbolId'> /// The ID of the symbol (uuid of the symbol) /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> public static object GetLocation(this ISymbols operations, string symbolId, string ownerName, string appName) { return(operations.GetLocationAsync(symbolId, ownerName, appName).GetAwaiter().GetResult()); }
/// <summary> /// Resolve a symbol that is either a module or function. /// </summary> /// <param name="symscope"></param> /// <param name="name"></param> /// <returns></returns> public static MemberAccess ResolveSymbol(ISymbols symscope, string name) { var symbol = symscope.GetSymbol(name); // Case 2: Module. if (symbol.Category == SymbolCategory.Module) { var msym = symbol as SymbolModule; var mem = new MemberAccess(MemberMode.Module); mem.Type = msym.DataType; mem.Scope = msym.Scope; return mem; } // Case 3: Function. if (symbol.Category == SymbolCategory.Func) { var sfunc = symbol as SymbolFunction; var mem = new MemberAccess(MemberMode.FunctionScript); mem.MemberName = name; mem.Type = sfunc.DataType; mem.Expr = sfunc.FuncExpr as Expr; return mem; } return null; }