public virtual async Task <ICertificate> ResolveAsync(ResolverOptions options) { return(options switch { null => throw new ArgumentNullException(nameof(options)), FileResolverOptions fileResolverOptions => await this.ResolveAsync(fileResolverOptions).ConfigureAwait(false), StoreResolverOptions storeResolverOptions => await this.ResolveAsync(storeResolverOptions).ConfigureAwait(false), _ => throw new NotImplementedException($"Resolving certificates with options of type \"{options.GetType()}\" is not implemented.") });
public override string GetFullSource() { string package = ResolverOptions["package"]; if (ResolverOptions.TryGetValue("version", out string version)) { return($"{package} ({version})"); } return(package); }
public InheritancePublicFactsReplicator(IMainStorageContext context, RealStorage publicFactsStorage) : base(context.Logger) { _context = context; _publicFactsStorage = publicFactsStorage.LogicalStorage; _publicInheritanceStorage = publicFactsStorage.InheritanceStorage; _inheritanceResolver = context.DataResolversFactory.GetInheritanceResolver(); _resolverOptions = new ResolverOptions() { AddTopType = false }; }
public static ICertificate Resolve(this ResolverOptions options, ICertificateResolver certificateResolver) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (certificateResolver == null) { throw new ArgumentNullException(nameof(certificateResolver)); } return(certificateResolver.ResolveAsync(options).Result); }
public Resolver(string source, ResolutionType resolutionType, ILogger logger) { this.Source = source; this.ResolutionType = resolutionType; this.Logger = logger; if (resolutionType != ResolutionType.None) { this.ResolverOptions = BuildOptions(); } else { this.ResolverOptions = new ResolverOptions(); } }
protected override ResolverOptions BuildOptions() { ResolverOptions options = new ResolverOptions(); string[] parts = Source.Split('@'); options.Add("package", parts[0].ToLowerInvariant()); if (parts.Length > 1) { options.Add("version", parts[1].ToLowerInvariant()); } return(options); }
public override bool Exists() { string[] versions = GetAllPackageVersions(); if (versions == null) { return(false); } if (ResolverOptions.TryGetValue("version", out string version)) { return(Array.Exists(versions, v => v == version)); } ResolverOptions["version"] = versions.Last(); return(true); }
public void Run() { _logger.Info("Begin"); var globalStorage = _context.Storage.GlobalStorage; _logger.Info($"globalStorage == null = {globalStorage == null}"); var globalOperatorsStorage = globalStorage.OperatorsStorage; var op = new Operator(); op.KindOfOperator = KindOfOperator.LeftRightStream; op.IsSystemDefined = true; op.SystemHandler = new BinaryOperatorSystemHandler(this); _logger.Info($"op = {op}"); globalOperatorsStorage.Append(op); var operatorsResolver = _context.DataResolversFactory.GetOperatorsResolver(); var localCodeExecutionContext = new LocalCodeExecutionContext(); localCodeExecutionContext.Storage = globalStorage; var targetOp = operatorsResolver.GetOperator(KindOfOperator.LeftRightStream, localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); _logger.Info($"targetOp = {targetOp}"); _logger.Info("End"); }
private Value GetInheritanceRank(Value leftOperand, Value rightOperand, LocalCodeExecutionContext localCodeExecutionContext) { var subName = _strongIdentifierLinearResolver.Resolve(leftOperand, localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); var superName = _strongIdentifierLinearResolver.Resolve(rightOperand, localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); return(_inheritanceResolver.GetInheritanceRank(subName, superName, localCodeExecutionContext, ResolverOptions.GetDefaultOptions())); }
/// <inheritdoc/> public Value Call(Value leftOperand, Value rightOperand, Value annotation, LocalCodeExecutionContext localCodeExecutionContext) { #if DEBUG //Log($"leftOperand = {leftOperand}"); //Log($"rightOperand = {rightOperand}"); //Log($"annotation = {annotation}"); #endif Value valueFromSource = null; if (leftOperand.KindOfValue == KindOfValue.StrongIdentifierValue) { var strongIdentifier = leftOperand.AsStrongIdentifierValue; var kindOfName = strongIdentifier.KindOfName; switch (kindOfName) { case KindOfName.Concept: case KindOfName.Entity: valueFromSource = leftOperand; break; default: throw new ArgumentOutOfRangeException(nameof(kindOfName), kindOfName, null); } } else { valueFromSource = leftOperand; } #if DEBUG //Log($"valueFromSource = {valueFromSource}"); #endif if (rightOperand.KindOfValue == KindOfValue.StrongIdentifierValue) { var identifier = rightOperand.AsStrongIdentifierValue; #if DEBUG //Log($"identifier = {identifier}"); #endif if (identifier.KindOfName == KindOfName.Channel) { var channel = _channelsResolver.GetChannel(identifier, localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"channel = {channel}"); #endif return(channel.Handler.Write(valueFromSource)); } else { throw new Exception("Right operand should be a channel."); } } else { throw new Exception("Right operand should be a channel."); } }
public override Resolver Create(ResolverOptions options) { return(new ConfigurableResolver(_innerResolverFactory.Create(options), _balancerConfiguration)); }
private void ProcessUseNotInheritance() { var paramsList = TakePositionedParameters(4); #if DEBUG //Log($"paramsList = {paramsList.WriteListToString()}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif var inheritenceItem = new InheritanceItem(); DefaultSettingsOfCodeEntityHelper.SetUpInheritanceItem(inheritenceItem, _currentCodeFrame.LocalContext.Storage.DefaultSettingsOfCodeEntity); var subName = paramsList[0].AsStrongIdentifierValue; var superName = paramsList[1].AsStrongIdentifierValue; #if DEBUG //Log($"paramsList[2] = {paramsList[2]}"); #endif var rank = _logicalValueLinearResolver.Resolve(paramsList[2], _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions(), true).Inverse(); #if DEBUG //Log($"subName = {subName}"); //Log($"superName = {superName}"); //Log($"rank = {rank}"); #endif inheritenceItem.SubName = subName; inheritenceItem.SuperName = superName; inheritenceItem.Rank = rank; #if DEBUG //Log($"inheritenceItem = {inheritenceItem}"); #endif _globalStorage.InheritanceStorage.SetInheritance(inheritenceItem); _currentCodeFrame.CurrentPosition++; }
public override Resolver Create(ResolverOptions options) { return(new ChannelTestResolver(options)); }
private bool CommandLoop() { try { if (_currentCodeFrame == null) { #if DEBUG //Log("_currentCodeFrame == null return false;"); #endif return(false); } var currentPosition = _currentCodeFrame.CurrentPosition; #if DEBUG //Log($"currentPosition = {currentPosition}"); #endif var compiledFunctionBodyCommands = _currentCodeFrame.CompiledFunctionBody.Commands; #if DEBUG //Log($"compiledFunctionBodyCommands.Count = {compiledFunctionBodyCommands.Count}"); #endif if (currentPosition >= compiledFunctionBodyCommands.Count) { #if DEBUG //Log("currentPosition >= compiledFunctionBodyCommands.Count return true;"); #endif GoBackToPrevCodeFrame(); return(true); } var currentCommand = compiledFunctionBodyCommands[currentPosition]; #if DEBUG //Log($"currentCommand = {currentCommand}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif if (!CheckReturnedInfo()) { #if DEBUG //Log("!CheckReturnedInfo()"); #endif return(false); } switch (currentCommand.OperationCode) { case OperationCode.Nop: _currentCodeFrame.CurrentPosition++; break; case OperationCode.ClearStack: _currentCodeFrame.ValuesStack.Clear(); _currentCodeFrame.CurrentPosition++; break; case OperationCode.PushVal: _currentCodeFrame.ValuesStack.Push(currentCommand.Value); _currentCodeFrame.CurrentPosition++; break; case OperationCode.PushValFromVar: { var varName = currentCommand.Value.AsStrongIdentifierValue; #if DEBUG //Log($"varName = {varName}"); #endif var targetValue = _varsResolver.GetVarValue(varName, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"targetValue = {targetValue}"); #endif _currentCodeFrame.ValuesStack.Push(targetValue); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif _currentCodeFrame.CurrentPosition++; } break; case OperationCode.PushValToVar: { var varName = currentCommand.Value.AsStrongIdentifierValue; #if DEBUG //Log($"varName = {varName}"); #endif if (varName.KindOfName != KindOfName.Var) { throw new NotImplementedException(); } var currentValue = _currentCodeFrame.ValuesStack.Peek(); #if DEBUG //Log($"currentValue = {currentValue}"); #endif _currentVarStorage.SetValue(varName, currentValue); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif _currentCodeFrame.CurrentPosition++; } break; case OperationCode.CallBinOp: { var paramsList = TakePositionedParameters(3); #if DEBUG //Log($"paramsList = {paramsList.WriteListToString()}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif var kindOfOperator = currentCommand.KindOfOperator; if (kindOfOperator == KindOfOperator.IsNot) { kindOfOperator = KindOfOperator.Is; } #if DEBUG //Log($"kindOfOperator = {kindOfOperator}"); #endif var operatorInfo = _operatorsResolver.GetOperator(kindOfOperator, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"operatorInfo (1) = {operatorInfo}"); #endif CallOperator(operatorInfo, paramsList); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif if (currentCommand.KindOfOperator == KindOfOperator.IsNot) { var result = _currentCodeFrame.ValuesStack.Pop(); #if DEBUG //Log($"result = {result}"); #endif result = result.AsLogicalValue.Inverse(); #if DEBUG //Log($"result (2) = {result}"); #endif _currentCodeFrame.ValuesStack.Push(result); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif } _currentCodeFrame.CurrentPosition++; } break; case OperationCode.CallUnOp: { var paramsList = TakePositionedParameters(2); #if DEBUG //Log($"paramsList = {paramsList.WriteListToString()}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif var kindOfOperator = currentCommand.KindOfOperator; var operatorInfo = _operatorsResolver.GetOperator(kindOfOperator, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"operatorInfo (2)= {operatorInfo}"); #endif CallOperator(operatorInfo, paramsList); #if DEBUG //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif _currentCodeFrame.CurrentPosition++; } break; case OperationCode.Call: CallFunction(KindOfFunctionParameters.NoParameters, currentCommand.CountParams, true); break; case OperationCode.Call_P: CallFunction(KindOfFunctionParameters.PositionedParameters, currentCommand.CountParams, true); break; case OperationCode.Call_N: CallFunction(KindOfFunctionParameters.NamedParameters, currentCommand.CountParams, true); break; case OperationCode.AsyncCall_N: CallFunction(KindOfFunctionParameters.NamedParameters, currentCommand.CountParams, false); break; case OperationCode.UseInheritance: ProcessUseInheritance(); break; case OperationCode.UseNotInheritance: ProcessUseNotInheritance(); break; case OperationCode.AllocateAnonymousWaypoint: { if (currentCommand.CountParams == 0) { throw new NotImplementedException(); //break; } #if DEBUG //Log($"currentCommand.CountParams = {currentCommand.CountParams}"); #endif var paramsList = TakePositionedParameters(currentCommand.CountParams); #if DEBUG //Log($"paramsList = {paramsList.WriteListToString()}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif switch (currentCommand.CountParams) { case 2: { var firstParam = paramsList[0]; #if DEBUG //Log($"firstParam = {firstParam}"); #endif var resolvedFirstParam = _numberValueLinearResolver.Resolve(firstParam, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); var annotationValue = paramsList[1].AsAnnotationValue; var value = new WaypointValue((float)(double)resolvedFirstParam.GetSystemValue(), _context); _currentCodeFrame.ValuesStack.Push(value); _currentCodeFrame.CurrentPosition++; } break; case 3: { var firstParam = paramsList[0]; #if DEBUG //Log($"firstParam = {firstParam}"); #endif var resolvedFirstParam = _numberValueLinearResolver.Resolve(firstParam, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); var secondParam = paramsList[1]; #if DEBUG //Log($"secondParam = {secondParam}"); #endif var resolvedSecondParam = _numberValueLinearResolver.Resolve(secondParam, _currentCodeFrame.LocalContext, ResolverOptions.GetDefaultOptions()); var annotationValue = paramsList[2].AsAnnotationValue; var value = new WaypointValue((float)(double)resolvedFirstParam.GetSystemValue(), (float)(double)resolvedSecondParam.GetSystemValue(), _context); _currentCodeFrame.ValuesStack.Push(value); _currentCodeFrame.CurrentPosition++; } break; default: throw new ArgumentOutOfRangeException(nameof(currentCommand.CountParams), currentCommand.CountParams, null); } } break; case OperationCode.SetSEHGroup: { #if DEBUG //Log($"currentCommand = {currentCommand}"); #endif var targetSEHGroup = _currentCodeFrame.CompiledFunctionBody.SEH[currentCommand.TargetPosition]; #if DEBUG //Log($"targetSEHGroup = {targetSEHGroup}"); #endif _currentCodeFrame.CurrentSEHGroup = targetSEHGroup; _currentCodeFrame.SEHStack.Push(targetSEHGroup); _currentCodeFrame.CurrentPosition++; } break; case OperationCode.RemoveSEHGroup: { #if DEBUG //Log($"currentCommand = {currentCommand}"); #endif _currentCodeFrame.SEHStack.Pop(); if (_currentCodeFrame.SEHStack.Count == 0) { _currentCodeFrame.CurrentSEHGroup = null; } else { _currentCodeFrame.CurrentSEHGroup = _currentCodeFrame.SEHStack.Peek(); } _currentCodeFrame.CurrentPosition++; } break; case OperationCode.JumpTo: { #if DEBUG //Log($"currentCommand = {currentCommand}"); #endif _currentCodeFrame.CurrentPosition = currentCommand.TargetPosition; } break; case OperationCode.Error: { #if DEBUG //Log("Begin case OperationCode.Error"); #endif #if DEBUG //Log($"currentCommand = {currentCommand}"); //Log($"_currentCodeFrame = {_currentCodeFrame.ToDbgString()}"); #endif var currentValue = _currentCodeFrame.ValuesStack.Peek(); #if DEBUG //Log($"currentValue = {currentValue}"); #endif var ruleInstance = currentValue.AsRuleInstanceValue.RuleInstance; var errorValue = new ErrorValue(ruleInstance); errorValue.CheckDirty(); #if DEBUG //Log($"errorValue = {errorValue}"); #endif _currentError = errorValue; if (_currentCodeFrame.CurrentSEHGroup == null) { _currentCodeFrame.ProcessInfo.Status = ProcessStatus.Faulted; GoBackToPrevCodeFrame(); } else { #if DEBUG //Log("_currentSEHGroup != null"); #endif if (!CheckSEH()) { _currentCodeFrame.ProcessInfo.Status = ProcessStatus.Faulted; GoBackToPrevCodeFrame(); } } _globalLogicalStorage.Append(ruleInstance); #if DEBUG //Log("End case OperationCode.Error"); #endif } break; case OperationCode.Return: { #if DEBUG //Log("Begin case OperationCode.Return"); #endif _currentCodeFrame.ProcessInfo.Status = ProcessStatus.Completed; GoBackToPrevCodeFrame(); #if DEBUG //_instancesStorage.PrintProcessesList(); //Log("End case OperationCode.Return"); #endif } break; default: throw new ArgumentOutOfRangeException(nameof(currentCommand.OperationCode), currentCommand.OperationCode, null); } return(true); } catch (Exception e) { #if DEBUG Error(e); #endif throw; } }
public void Run() { _logger.Log("Begin"); var context = TstEngineContextHelper.CreateAndInitContext().EngineContext; var globalStorage = context.Storage.GlobalStorage; var filesList = FileHelper.GetParsedFilesInfo(context.AppFile, context.Id); #if DEBUG _logger.Log($"filesList.Count = {filesList.Count}"); _logger.Log($"filesList = {filesList.WriteListToString()}"); #endif var parsedFilesList = context.Parser.Parse(filesList, globalStorage.DefaultSettingsOfCodeEntity); #if DEBUG _logger.Log($"parsedFilesList.Count = {parsedFilesList.Count}"); _logger.Log($"parsedFilesList = {parsedFilesList.WriteListToString()}"); #endif var parsedCodeEntitiesList = LinearizeSubItems(parsedFilesList); #if DEBUG _logger.Log($"parsedCodeEntitiesList.Count = {parsedCodeEntitiesList.Count}"); _logger.Log($"parsedCodeEntitiesList = {parsedCodeEntitiesList.WriteListToString()}"); #endif var metadataStorage = globalStorage.MetadataStorage; foreach (var codeEntity in parsedCodeEntitiesList) { metadataStorage.Append(codeEntity); } var inlineTrigger = parsedCodeEntitiesList.FirstOrDefault(p => p.Kind == KindOfCodeEntity.InlineTrigger); _logger.Log($"inlineTrigger = {inlineTrigger}"); var triggersStorage = globalStorage.TriggersStorage; triggersStorage.Append(inlineTrigger.InlineTrigger); var mainEntity = metadataStorage.MainCodeEntity; #if DEBUG _logger.Log($"mainEntity = {mainEntity}"); #endif var triggersResolver = context.DataResolversFactory.GetTriggersResolver(); var localCodeExecutionContext = new LocalCodeExecutionContext(); localCodeExecutionContext.Storage = globalStorage; var targetTriggersList = triggersResolver.ResolveSystemEventsTriggersList(KindOfSystemEventOfInlineTrigger.Init, mainEntity.Name, localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); #if DEBUG _logger.Log($"targetTriggersList = {targetTriggersList.WriteListToString()}"); #endif _logger.Log("End"); }
public void Init() { _instanceState = InstanceState.Initializing; var targetSystemEventsTriggersList = _triggersResolver.ResolveSystemEventsTriggersList(KindOfSystemEventOfInlineTrigger.Init, Name, _localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"targetSystemEventsTriggersList = {targetSystemEventsTriggersList.WriteListToString()}"); #endif if (targetSystemEventsTriggersList.Any()) { targetSystemEventsTriggersList.Reverse(); var processInitialInfoList = new List <ProcessInitialInfo>(); foreach (var targetTrigger in targetSystemEventsTriggersList) { var localCodeExecutionContext = new LocalCodeExecutionContext(); var localStorageSettings = RealStorageSettingsHelper.Create(_context, _storage); localCodeExecutionContext.Storage = new LocalStorage(localStorageSettings); localCodeExecutionContext.Holder = Name; var processInitialInfo = new ProcessInitialInfo(); processInitialInfo.CompiledFunctionBody = targetTrigger.ResultItem.CompiledFunctionBody; processInitialInfo.LocalContext = localCodeExecutionContext; processInitialInfo.Metadata = targetTrigger.ResultItem.CodeEntity; processInitialInfoList.Add(processInitialInfo); } #if DEBUG //Log($"processInitialInfoList = {processInitialInfoList.WriteListToString()}"); #endif var taskValue = _context.CodeExecutor.ExecuteBatchAsync(processInitialInfoList); #if DEBUG //Log($"taskValue = {taskValue}"); #endif } var targetLogicConditionalTriggersList = _triggersResolver.ResolveLogicConditionalTriggersList(Name, _localCodeExecutionContext, ResolverOptions.GetDefaultOptions()); #if DEBUG //Log($"targetLogicConditionalTriggersList = {targetLogicConditionalTriggersList.WriteListToString()}"); #endif if (targetLogicConditionalTriggersList.Any()) { foreach (var targetTrigger in targetLogicConditionalTriggersList) { #if DEBUG //Log($"targetTrigger = {targetTrigger}"); #endif var triggerInstanceInfo = new LogicConditionalTriggerInstanceInfo(targetTrigger.ResultItem, this, _context, _storage); _logicConditionalTriggersList.Add(triggerInstanceInfo); } } _instanceState = InstanceState.Initialized; }
public ChannelTestResolver(ResolverOptions options) : base(options.LoggerFactory) { Options = options; }
public ChannelTestResolver(ResolverOptions options) { Options = options; }
public override Resolver Create(ResolverOptions options) { return(_createResolver(options)); }