public ValueTask <IService> CreateService(IFactoryContext factoryContext, Uri?baseUri, InvokeData invokeData, IServiceCommunication serviceCommunication, CancellationToken token) { switch (_creators[invokeData.Type]) { case IServiceCatalog.Creator creator: var service = creator(); service.Start(baseUri, invokeData, serviceCommunication); return(new ValueTask <IService>(service)); case IServiceCatalog.ServiceCreator creator: return(new ValueTask <IService>(creator(baseUri, invokeData, serviceCommunication))); case IServiceCatalog.ServiceCreatorAsync creator: return(creator(factoryContext, baseUri, invokeData, serviceCommunication, token)); default: return(Infra.Unexpected <ValueTask <IService> >(_creators[invokeData.Type]?.GetType())); } }
public ParamNode(DocumentIdNode documentIdNode, IParam param) { Infra.NotNull(param.Name); documentIdNode.SaveToSlot(out _documentIdSlot); _param = param; }
public bool TryGetValue(TKey key, [NotNullWhen(true)] out TValue?value) { if (_localDictionary.TryGetValue(key, out var localEntry) && localEntry.TryGetValue(out value)) { return(true); } if (_globalDictionary.TryGetValue(key, out var globalEntry) && globalEntry.TryGetValue(out value) && globalEntry.AddReference()) { if (localEntry is not null) { var valueTask = localEntry.RemoveReference(); Infra.Assert(valueTask.IsCompleted); valueTask.GetAwaiter().GetResult(); } _localDictionary[key] = globalEntry; return(true); } value = default; return(false); }
public static string HelmTemplate(Infra cfg) { var valueFiles = new List <string>(); foreach (string file in cfg.ValuesFiles) { string path = String.Format("-f {0}/{1}", srcDir, file); valueFiles.Add(path); } string valueFilePath = String.Join(" ", valueFiles.ToArray()); var values = new List <string>(); foreach (string value in cfg.Values) { values.Add(value); } string valuesList = String.Join(" ", values.ToArray()); string tplName = GetTemplateName(cfg); string arg = string.Format(helmTplArg, tplName, cfg.Alias, cfg.ChartId, valueFilePath, valuesList, cfg.Version); if (!String.IsNullOrEmpty(cfg.Namespace)) { arg = String.Format("{0} --namespace {1}", arg, cfg.Namespace); } string output = Utils.Exec(helmCmd, arg); return(output); }
public ActionResult Insert(Infra.Models.CreditCard c) { var _account = (Account)Session["Account"]; if (_account != null) { if (ModelState.IsValid) { try { c.AccountId = _account.Id; if (SendRequest(c).ToString() == "OK") { _repository.Add(c); } else { return RedirectToAction("Insert", c); } } catch (Exception) { return RedirectToAction("Insert", c); } TempData["AlertMessage"] = "Cartão validado e cadastrado com sucesso!"; return RedirectToAction("Index"); } return View(c); } else { return View("Index", "Access"); } }
public static void HelmAdd(Infra cfg) { string arg = string.Format(helmAddArg, cfg.Alias, cfg.ChartUrl); var prms = new List <string>(); foreach (CmdParam param in cfg.ChartParams) { if (param.NoValue) { prms.Add(String.Format("--{0}", param.Name)); } else { prms.Add(String.Format("--{0}={1}", param.Name, param.Value)); } } if (prms.Count > 0) { var extraArgs = String.Join(" ", prms.ToArray()); arg = string.Format("{0} {1}", arg, extraArgs); } Utils.Exec(helmCmd, arg); }
public ElseIfNode(DocumentIdNode documentIdNode, IElseIf elseIf) { Infra.NotNull(elseIf.Condition); documentIdNode.SaveToSlot(out _documentIdSlot); _elseIf = elseIf; }
public void BuildInfra(Infra infra, HexTile curr, int team) { infra.curr = curr; infra.team = team; //infra.gameObject.SetActive(false); Instantiate(infra); }
public Retorno <Extrato> GerarExtrato(Conta conta, BaseDeDados baseDeDados, Tela tela, int intervaloExtrato) { try { #region Regras de negócio #region RN1 - Apenas intervalo maior ou igual a zero if (intervaloExtrato < 0) { return(Infra.RetornarFalha <Extrato>(new MensagemFalha(TipoFalha.IntervaloExtratoMenorQueZero))); } #endregion #region RN2 - Apenas histórico no intervalo selecionado List <Transacao> historicoTransacoes = new List <Transacao>(baseDeDados.getHistoricoTransacoes(conta)); if (intervaloExtrato > 0) { historicoTransacoes.RemoveAll(x => x.DataTransacao < DateTime.Now.AddDays(-intervaloExtrato)); } #endregion double valorDisponivel = baseDeDados.RetornaSaldoDisponivel(conta); #endregion Extrato extrato = new Extrato(valorDisponivel, historicoTransacoes); return(Infra.RetornarSucesso <Extrato>(extrato, new OperacaoRealizadaMensagem("Consulta de Extrato"))); } catch (Exception e) { return(Infra.RetornarFalha <Extrato>(new Mensagem(e))); } }
protected IEnumerator Trace() { for (int i = 0; i < curr.nears.Count; i++) { Infra temp = curr.nears[i].infra; if (temp && temp.team != team) { target = temp; StartCoroutine("Work"); yield break; } } if (!target || !finder.CheckTarget()) { finder.Reset(); HexTile tile = finder.Search(); if (!tile) { StartCoroutine("Idle"); yield break; } else { target = tile.infra; } } StartCoroutine("Move"); }
public override IList <string> Transform(IList <string> items, Infra cfg) { var lines = UtilsTransformer.MultiLinesToArray(items); ProcessLines(lines, cfg); return(lines); }
public override IList <string> Transform(IList <string> items, Infra cfg) { var lines = UtilsTransformer.MultiLinesToArray(items); UtilsTransformer.WriteFileContent(GetContext(), String.Format("{0}.yaml", cfg.Alias), lines, cfg.ToDir); return(lines); }
public object Evaluate(XPathCompiledExpression compiledExpression) { Infra.NotNull(ExecutionContext); compiledExpression.SetResolver(this); return(new DataModelXPathNavigator(ExecutionContext.DataModel).Evaluate(compiledExpression.XPathExpression) !); }
public virtual void Convert() { List <Character> toConvert = Infra.GetPeasantsInRange(this.transform.position, ConvertRadius); for (int i = 0; i < toConvert.Count; i++) { toConvert[i].Alliance = this.Alliance; } }
private static string GetTemplateName(Infra cfg) { if (!string.IsNullOrEmpty(cfg.Template)) { return(cfg.Template); } return(cfg.ChartId); }
public InitialNode(DocumentIdNode documentIdNode, IInitial initial) : base(documentIdNode, children: null) { Infra.NotNull(initial.Transition); _initial = initial; Transition = initial.Transition.As <TransitionNode>(); Transition.SetSource(this); }
public ValueTask <IDataModelHandler> CreateHandler(IFactoryContext factoryContext, string dataModelType, IErrorProcessor?errorProcessor, CancellationToken token) { Infra.Assert(CanHandle(dataModelType)); return(new ValueTask <IDataModelHandler>(new EcmaScriptDataModelHandler(errorProcessor))); }
public CustomActionDispatcher(IErrorProcessor?errorProcessor, ICustomAction customAction, IFactoryContext factoryContext) { _errorProcessor = errorProcessor; _customAction = customAction; _factoryContext = factoryContext; Infra.NotNull(customAction.XmlNamespace); Infra.NotNull(customAction.XmlName); Infra.NotNull(customAction.Xml); }
public DefaultAssignEvaluator(IAssign assign) { _assign = assign ?? throw new ArgumentNullException(nameof(assign)); Infra.NotNull(assign.Location); LocationEvaluator = assign.Location.As <ILocationEvaluator>(); ExpressionEvaluator = assign.Expression?.As <IObjectEvaluator>(); InlineContentEvaluator = assign.InlineContent?.As <IObjectEvaluator>(); }
public override void Convert() { List <Character> toConvert = Infra.GetPeasantsInRange(this.transform.position, ConvertRadius); for (int i = 0; i < toConvert.Count; i++) { toConvert[i].SetAlliance(Alliance); } Invoke("Convert", 3f); }
public HistoryNode(DocumentIdNode documentIdNode, IHistory history) : base(documentIdNode, children: null) { Infra.NotNull(history.Transition); _history = history; Id = history.Id ?? new IdentifierNode(Identifier.New()); Transition = history.Transition.As <TransitionNode>(); Transition.SetSource(this); }
public StateMachineNode(DocumentIdNode documentIdNode, IStateMachine stateMachine) : base(documentIdNode, GetChildNodes(stateMachine.Initial, stateMachine.States)) { _stateMachine = stateMachine; Infra.NotNull(stateMachine.Initial); Initial = stateMachine.Initial.As <InitialNode>(); ScriptEvaluator = _stateMachine.Script?.As <ScriptNode>(); DataModel = _stateMachine.DataModel?.As <DataModelNode>(); }
public DefaultRaiseEvaluator(IRaise raise) { if (raise is null) { throw new ArgumentNullException(nameof(raise)); } Infra.NotNull(raise.OutgoingEvent); _raise = raise; }
public DefaultInlineContentEvaluator(IInlineContent inlineContent) { if (inlineContent is null) { throw new ArgumentNullException(nameof(inlineContent)); } Infra.NotNull(inlineContent.Value); _inlineContent = inlineContent; }
public ValueTask Execute(IExecutionContext executionContext, CancellationToken token) { if (executionContext is null) { throw new ArgumentNullException(nameof(executionContext)); } Infra.NotNull(_executor); return(_executor.Execute(executionContext, token)); }
public DataNode(DocumentIdNode documentIdNode, IData data) { Infra.NotNull(data.Id); documentIdNode.SaveToSlot(out _documentIdSlot); _data = data; ResourceEvaluator = data.Source?.As <IResourceEvaluator>(); ExpressionEvaluator = data.Expression?.As <IObjectEvaluator>(); InlineContentEvaluator = data.InlineContent?.As <IObjectEvaluator>(); }
public DefaultContentBodyEvaluator(IContentBody contentBody) { if (contentBody is null) { throw new ArgumentNullException(nameof(contentBody)); } Infra.NotNull(contentBody.Value); _contentBody = contentBody; }
private void _discoverExtraRules() { var ruleUIs = Infra.FindComponentsInChildWithTag <RuleUI>(ChoosePanel, "RuleUI"); for (int i = 0; i < ruleUIs.Count; i++) { var rule = RuleManager.ChooseRandomExtraRule(); ruleUIs[i].GetComponent <RuleUI>().SetRule(rule); } ChoosePanel.SetActive(true); // Show actual panel }
public ICEFInfraWrapper?GetInfra() { if ((Target?.IsAlive).GetValueOrDefault()) { if (Infra?.GetWrappedObject() != null) { return(Infra); } } return(null); }
public DefaultForEachEvaluator(IForEach forEach) { _forEach = forEach ?? throw new ArgumentNullException(nameof(forEach)); Infra.NotNull(forEach.Array); Infra.NotNull(forEach.Item); ArrayEvaluator = forEach.Array.As <IArrayEvaluator>(); ItemEvaluator = forEach.Item.As <ILocationEvaluator>(); IndexEvaluator = forEach.Index?.As <ILocationEvaluator>(); ActionEvaluatorList = forEach.Action.AsArrayOf <IExecutableEntity, IExecEvaluator>(); }
protected virtual IEnumerator Work() { while (target.alive) { yield return(new WaitForSeconds(0.3f)); target.Hit(ATT); } target = null; StartCoroutine("Idle"); }
private void ProcessNewMessage(Infra.Queue.AzureMessage azureMessage) { if (azureMessage.MessageType == (int)Infra.Queue.AzureMessageType.NEW_TRANSACTION) { ProcessTransaction(azureMessage); } if (azureMessage.MessageType == (int)Infra.Queue.AzureMessageType.NEW_TRANSACTION_INSTANT_BUY) { ProcessQuickTransaction(azureMessage); } }
public string SendRequest(Infra.Models.CreditCard c) { try { var transaction = new CreditCardTransaction() { AmountInCents = 100, CreditCard = new GatewayApiClient.DataContracts.CreditCard() { CreditCardNumber = c.Number, CreditCardBrand = CreditCardBrandEnum.Visa, ExpMonth = c.Expiry.Date.Month, ExpYear = c.Expiry.Date.Year, SecurityCode = c.Cvc, HolderName = c.Name } }; Guid merchantKey = Guid.Parse("2feddd0e-174d-4a1e-889b-e7f6785ccf11"); string statusCode = String.Empty; string errorCode = String.Empty; string descriptionError = String.Empty; var serviceClient = new GatewayServiceClient(merchantKey); var httpResponse = serviceClient.Sale.Create(transaction); if (httpResponse.HttpStatusCode.ToString() != "Created") { errorCode = httpResponse.Response.ErrorReport.ErrorItemCollection[0].ErrorCode.ToString(); descriptionError = httpResponse.Response.ErrorReport.ErrorItemCollection[0].Description.ToString(); switch (errorCode) { case "400": TempData["AlertMessage"] = "Algum campo não foi enviado ou foi enviado de maneira incorreta. " + descriptionError; break; case "404": TempData["AlertMessage"] = "Recurso não encontrado. " + descriptionError; break; case "500": TempData["AlertMessage"] = "Erro nos servidores da MundiPagg, tente novamente mais tarde. " + descriptionError; break; case "504": TempData["AlertMessage"] = "Tempo comunicação excedida entre a MundiPagg e a adquirente. " + descriptionError; break; default: break; } return TempData["AlertMessage"].ToString(); } else { var httpResponse2 = serviceClient.Sale.QueryOrder(httpResponse.Response.OrderResult.OrderKey); statusCode = httpResponse2.HttpStatusCode.ToString(); return statusCode; } } catch (Exception e) { TempData["AlertMessage"] = "Ocorreu um erro ao cadastrar o Cartão de Crédito. Por favor, tente novamente"; throw new Exception("Erro: " + e.Message); } }