Example #1
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            var Result = Code.StartsWith(Operators, Skip, IdCharCheck: new IdCharCheck(true));

            if (Result.Index != -1)
            {
                var State  = Container.State;
                var ChildC = Code.TrimmedSubstring(State, Result.String.Length, Options.EnableMessages);
                if (!ChildC.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                var TOptions = Options;
                TOptions.Func = x => x.RealId is Type;

                var Child = Identifiers.Recognize(Container, ChildC, TOptions);
                if (Child == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var RChild = Child.RealId as Type;
                if (RChild == null || (RChild.TypeFlags & TypeFlags.CanBeReference) == 0)
                {
                    if (Options.EnableMessages)
                    {
                        State.Messages.Add(MessageId.UnknownId, Code);
                    }

                    return(SimpleRecResult.Failed);
                }

                ReferenceMode Mode;
                if (Result.Index == 0)
                {
                    Mode = ReferenceMode.Unsafe;
                }
                else if (Result.Index == 1)
                {
                    Mode = ReferenceMode.IdMustBeAssigned;
                }
                else if (Result.Index == 2)
                {
                    Mode = ReferenceMode.IdGetsAssigned;
                }
                else
                {
                    throw new ApplicationException();
                }

                Ret = new ReferenceType(Container, Child, Mode);
                if (Options.Func == null || Options.Func(Ret))
                {
                    return(SimpleRecResult.Succeeded);
                }
            }

            return(SimpleRecResult.Unknown);
        }
        public async Task SalvaJogosDeHojeH2H(IdContainer container, bool descending = false, IWebDriver driver = null)
        {
            if (driver != null)
            {
                _driver = driver;
            }
            Console.WriteLine($"Salvando Jogos De Hoje as {DateTime.Now}");

            ResultadosSiteHelper.CarregandoJogos = true;

            var ids = descending ? container.Ids.OrderByDescending(id => id.DataInicio.TimeOfDay) :
                      container.Ids.OrderBy(id => id.DataInicio.TimeOfDay);

            try
            {
                foreach (var i in ids)
                {
                    await CriarOuAtualizaInfosJogoH2H(i.Id, container.Id, true);
                }
            }
            catch (Exception e)
            {
                foreach (var i in ids)
                {
                    await CriarOuAtualizaInfosJogoH2H(i.Id, container.Id, true);
                }
            }

            ResultadosSiteHelper.CarregandoJogos = false;
        }
Example #3
0
        public static x86ConstLocation GetNullLocation(x86Architecture Arch, IdContainer Container)
        {
            var Value = new IntegerValue(0);
            var Type  = Container.GlobalContainer.CommonIds.VoidPtr;

            return(new x86ConstLocation(Arch, Value, Type, 0, Type.Size));
        }
Example #4
0
        public bool PreprocessContainer(IdContainer Container)
        {
            if (Container is Command)
            {
                var Command = Container as Command;
                if (Command.Type == CommandType.Try)
                {
                    if ((Command.Flags & CommandFlags.TryHasCatchVariable) != 0)
                    {
                        var Global         = Container.GlobalContainer;
                        var ExceptionClass = Identifiers.GetByFullNameFast <ClassType>(Global, "System.Exception");
                        if (ExceptionClass == null)
                        {
                            return(false);
                        }

                        var CatchScope = Command.CatchScope;
                        var CatchVar   = CatchScope.IdentifierList[0] as LocalVariable;
                        if (CatchVar == null || !CatchVar.TypeOfSelf.IsEquivalent(ExceptionClass))
                        {
                            throw new ApplicationException("Invalid catch variable");
                        }

                        CatchVar.Container = Command;
                        CatchScope.IdentifierList.RemoveAt(0);
                        Command.IdentifierList.Add(CatchVar);

                        var NCData = Command.Data.GetOrCreate <NCCommandData>();
                        NCData.CatchVariable = CatchVar;
                    }
                }
            }

            return(true);
        }
Example #5
0
        public Identifier TypeExtractor(IdContainer Container, ref CodeString Code)
        {
            if (TypeCodes == null)
            {
                return(null);
            }

            var OldCode = Code;
            var Global  = Container.GlobalContainer;
            var State   = Container.State;

            var EndStr = Code.EndStr(LetterCase.OnlyLower);

            Code = Code.Substring(0, Code.Length - EndStr.Length);

            if (EndStr.Length > 0)
            {
                for (var i = 0; i < TypeCodes.Length; i++)
                {
                    if (TypeCodes[i].String == EndStr)
                    {
                        return(TypeCodes[i].Identifier);
                    }
                }
            }

            Code = OldCode;
            return(null);
        }
Example #6
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            var State = Container.State;

            if (RecognizerHelper.Find(this, State, Code.String).Position != -1)
            {
                var DeclListFlags = VarDeclarationListFlags.EnableUnnamed;
                if (Options.EnableMessages)
                {
                    DeclListFlags |= VarDeclarationListFlags.EnableMessages;
                }
                var DeclList = VarDeclarationList.Create(Container, Code, null, DeclListFlags);
                if (DeclList == null)
                {
                    return(SimpleRecResult.Failed);
                }

                Ret = DeclList.ToTupleType(Container, Options.EnableMessages);
                if (Ret == null)
                {
                    return(SimpleRecResult.Failed);
                }

                if (Options.Func == null || Options.Func(Ret))
                {
                    return(SimpleRecResult.Succeeded);
                }
            }

            return(SimpleRecResult.Unknown);
        }
Example #7
0
 static void CopyIdentifiers(IdContainer Dst, IdContainer Src)
 {
     Dst.IdentifierList = Src.IdentifierList;
     for (var i = 0; i < Dst.IdentifierList.Count; i++)
     {
         Dst.IdentifierList[i].Container = Dst;
     }
 }
Example #8
0
        public bool ProcessContainer(IdContainer Container, bool NoExtract = false)
        {
            if (Container is Command)
            {
                var Old       = Container;
                var OldParent = Old.Parent;

                Container = ProcessCommand(Container as Command, NoExtract);
                if (Container == null)
                {
                    return(false);
                }

                if (Container != Old && OldParent.Children.Contains(Old))
                {
                    throw new ApplicationException();
                }
            }
            else if (Container is FunctionScope)
            {
                if (!ProcessFunctionScope(Container as FunctionScope))
                {
                    return(false);
                }
            }

            if (!NCArch.ProcessContainer(Container))
            {
                return(false);
            }

            if (Container is Command)
            {
                var Command = Container as Command;
                if (Command.Expressions != null)
                {
                    var Plugin = this.Plugin;
                    if (Plugin.CurrentlyUsing)
                    {
                        Plugin = CreatePlugin();
                    }

                    Plugin.Container = Command;
                    for (var i = 0; i < Command.Expressions.Count; i++)
                    {
                        var Expr = Command.Expressions[i].CallNewNode(Plugin);
                        if (Expr == null)
                        {
                            Plugin.Reset(); return(false);
                        }

                        Command.Expressions[i] = Expr;
                    }
                }
            }

            return(true);
        }
Example #9
0
 internal ReplicatedIdGenerator(FileSystemAbstraction fs, File file, IdType idType, System.Func <long> highId, ReplicatedIdRangeAcquirer acquirer, LogProvider logProvider, int grabSize, bool aggressiveReuse)
 {
     this._idType   = idType;
     this._highId   = highId();
     this._acquirer = acquirer;
     this._log      = logProvider.getLog(this.GetType());
     _idContainer   = new IdContainer(fs, file, grabSize, aggressiveReuse);
     _idContainer.init();
 }
Example #10
0
 public x86DataAllocator(IdContainer Container, bool AllocRegsLists = true)
     : base(Container.State.Arch as x86Architecture, AllocRegsLists)
 {
     this.Container     = Container;
     this.State         = Container.State;
     this.FuncScope     = Container.FunctionScope;
     this.x86CallConv   = Arch.GetCallingConvention(FuncScope.Type.CallConv);
     this.ContainerData = Container.Data.Get <x86IdContainerData>();
     this.FSData        = FuncScope.Data.Get <x86FuncScopeData>();
 }
Example #11
0
        static Command CreateJump(IdContainer Container, ExpressionNode To, CodeString Code)
        {
            var Then_Jump = new Command(Container, Code, CommandType.Unknown);

            Then_Jump.Extension   = new NCCommandExtension(Then_Jump, NCCommandType.Jump);
            Then_Jump.Expressions = new List <ExpressionNode>()
            {
                To
            };
            return(Then_Jump);
        }
        public async Task SalvaJogosDeAmanhaH2H(IdContainer container, bool descending = false, IWebDriver driver = null, TimeSpan?acimaDe = null)
        {
            if (driver != null)
            {
                _driver = driver;
            }
            Console.WriteLine($"Salvando Jogos De Amanhã as {DateTime.Now}");

            ResultadosSiteHelper.CarregandoJogos = true;

            var ids = descending ? container.Ids.OrderByDescending(id => id.DataInicio.TimeOfDay).ToList() :
                      container.Ids.OrderBy(id => id.DataInicio.TimeOfDay).ToList();

            if (acimaDe != null)
            {
                ids = ids.Where(i => i.DataInicio.TimeOfDay >= acimaDe.Value).ToList();
            }

            try
            {
                Task.Factory.StartNew(async() =>
                {
                    IWebDriver wd2           = SeleniumHelper.CreateDefaultWebDriver(true);
                    ResultadoSiteService rs2 = new ResultadoSiteService(wd2);

                    for (int i = 0; i < ids.Count; i++)
                    {
                        if (i % 2 == 0)
                        {
                            await rs2.CriarOuAtualizaInfosJogoH2H(ids[i].Id, container.Id, true);
                        }
                    }

                    wd2.Dispose();
                });

                for (int i = 0; i < ids.Count; i++)
                {
                    if (i % 2 != 0)
                    {
                        await CriarOuAtualizaInfosJogoH2H(ids[i].Id, container.Id, true);
                    }
                }
            }
            catch (Exception e)
            {
                _telegramService.EnviaMensagemParaOGrupo($"Erro: {e.Message}");
            }

            ResultadosSiteHelper.CarregandoJogos = false;
        }
Example #13
0
    /// <summary>
    ///     Get worklogs information for the supplied list of worklog IDs
    /// </summary>
    /// <param name="jiraClient">IWorkLogDomain to bind the extension method to</param>
    /// <param name="ids">IEnumerable with worklog ids</param>
    /// <param name="cancellationToken">CancellationToken</param>
    /// <returns>IList{WorkLog}</returns>
    public static async Task <IList <Worklog> > GetAsync(this IWorkLogDomain jiraClient, IEnumerable <long> ids, CancellationToken cancellationToken = default)
    {
        var worklogUri = jiraClient.JiraRestUri
                         .AppendSegments("worklog", "list")
                         .ExtendQuery("expand", "comment");

        jiraClient.Behaviour.MakeCurrent();
        var idContainer = new IdContainer
        {
            Ids = ids
        };
        var response = await worklogUri.PostAsync <HttpResponse <IList <Worklog>, Error> >(idContainer, cancellationToken).ConfigureAwait(false);

        return(response.HandleErrors());
    }
Example #14
0
        static Command CreateJump(IdContainer Container, string Label, CodeString Code)
        {
            var Plugin = Container.GetPlugin();

            if (!Plugin.Begin())
            {
                return(null);
            }

            var Node = Plugin.NewNode(new LabelExpressionNode(Code, Label));

            if (Node == null || Plugin.End(ref Node) == PluginResult.Failed)
            {
                return(null);
            }

            return(CreateJump(Container, Node, Code));
        }
Example #15
0
        bool ProcessRecursively(IdContainer Container)
        {
            if (!PreprocessContainer(Container))
            {
                return(false);
            }

            for (var i = 0; i < Container.Children.Count; i++)
            {
                var Ch = Container.Children[i];
                if (!ProcessRecursively(Ch))
                {
                    return(false);
                }
            }

            return(ProcessContainer(Container));
        }
Example #16
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var        State = Container.State;
            CodeString Inside, Cutted;

            var Result = RecognizerHelper.ExtractBracket(State, String, '(', ref Code, out Inside, out Cutted);

            if (Result == SimpleRecResult.Succeeded)
            {
                var Params = RecognizerHelper.GetParamList(State, Inside, 1);
                if (Params == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Node = Constants.CreateCIntNode(Container, Params[0]);
                if (Node == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Align = (int)Node.Integer;
                if (!DataStoring.VerifyAlign(Align))
                {
                    State.Messages.Add(MessageId.InvalidAlign, Cutted);
                    return(SimpleRecResult.Failed);
                }

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is AlignModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, Cutted);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new AlignModifier(Cutted, Align));
                return(SimpleRecResult.Succeeded);
            }

            return(Result);
        }
Example #17
0
            internal virtual void VisitAllIds(ClusterMember member, System.Action <long> idConsumer)
            {
                DatabaseLayout databaseLayout = DatabaseLayout.of(member.databaseDirectory());
                File           idFile         = databaseLayout.IdNodeStore();
                IdContainer    idContainer    = new IdContainer(Fs, idFile, 1024, true);

                idContainer.Init();
                Log.info(idFile.AbsolutePath + " has " + idContainer.FreeIdCount + " free ids");

                long id = idContainer.ReusableId;

                while (id != IdContainer.NO_RESULT)
                {
                    idConsumer(id);
                    id = idContainer.ReusableId;
                }

                idContainer.Close(0);
            }
Example #18
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var        State = Container.State;
            CodeString Inside, Cutted;

            var Result = RecognizerHelper.ExtractBracket(State, String, '(', ref Code, out Inside, out Cutted);

            if (Result == SimpleRecResult.Succeeded)
            {
                var Params = RecognizerHelper.GetParamList(State, Inside, 1);
                if (Params == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var Node = Constants.CreateCStrNode(Container, Params[0]);
                if (Node == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var AsmName = Node.String;
                if (string.IsNullOrEmpty(AsmName))
                {
                    State.Messages.Add(MessageId.DeficientExpr, Params[0]);
                    return(SimpleRecResult.Failed);
                }

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is AssemblyNameModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, Cutted);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new AssemblyNameModifier(Cutted, AsmName));
                return(SimpleRecResult.Succeeded);
            }

            return(Result);
        }
Example #19
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var Result = Code.StartsWith(Strings, null, new IdCharCheck(true));

            if (Result.Index != -1)
            {
                var State   = Container.State;
                var ModCode = Code.Substring(0, Result.String.Length);

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is CallingConventionModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, ModCode);
                        return(SimpleRecResult.Failed);
                    }
                }

                CallingConvention Conv;
                if (Result.Index == 0)
                {
                    Conv = CallingConvention.StdCall;
                }
                else if (Result.Index == 1)
                {
                    Conv = CallingConvention.CDecl;
                }
                else if (Result.Index == 2)
                {
                    Conv = CallingConvention.ZinniaCall;
                }
                else
                {
                    throw new NotImplementedException();
                }

                Out.Add(new CallingConventionModifier(ModCode, Conv));
                Code = Code.Substring(Result.String.Length).Trim();
                return(SimpleRecResult.Succeeded);
            }

            return(SimpleRecResult.Unknown);
        }
Example #20
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            var State  = Container.State;
            var Result = RecognizerHelper.Find(this, State, Code.String);

            if (Result.Position != -1)
            {
                var Left  = Code.TrimmedSubstring(State, 0, Result.Position, Options.EnableMessages);
                var Right = Code.TrimmedSubstring(State, Result.Position + 1, Options.EnableMessages);
                if (!Left.IsValid || !Right.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                Ret = Identifiers.GetMember(Container, Left, Right, Options);
                return(Ret == null ? SimpleRecResult.Failed : SimpleRecResult.Succeeded);
            }

            return(SimpleRecResult.Unknown);
        }
Example #21
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            if (Code.IsValidIdentifierName)
            {
                var List = Container.GetIdentifier(Code.ToString(), Options.Mode, Options.Func);
                Ret = Identifiers.SelectIdentifier(Container.State, List, Code, Options);
                if (Ret == null)
                {
                    return(SimpleRecResult.Failed);
                }

                if (!Identifiers.VerifyAccess(Container, Ret, Code, Options.EnableMessages))
                {
                    return(SimpleRecResult.Failed);
                }

                return(SimpleRecResult.Succeeded);
            }

            return(SimpleRecResult.Unknown);
        }
Example #22
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            if (!Check(Container.State, Code))
            {
                return(SimpleRecResult.Failed);
            }

            var NewCode = Code.TrimBrackets(Container.State);

            if (!NewCode.IsValid)
            {
                return(SimpleRecResult.Failed);
            }
            if (NewCode.Length == Code.Length)
            {
                return(SimpleRecResult.Unknown);
            }

            Ret = Identifiers.Recognize(Container, NewCode, Options);
            return(Ret == null ? SimpleRecResult.Failed : SimpleRecResult.Succeeded);
        }
Example #23
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            if (Code.Length > 0 && Code[Code.Length - 1] == '*')
            {
                var State  = Container.State;
                var ChildC = Code.TrimmedSubstring(State, 0, Code.Length - 1, Options.EnableMessages);
                if (!ChildC.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                var TOptions = Options;
                TOptions.Func = x => x.RealId is Type;

                var Child = Identifiers.Recognize(Container, ChildC, TOptions);
                if (Child == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var RChild = Child.RealId as Type;
                if (RChild == null || (RChild.TypeFlags & TypeFlags.CanBePointer) == 0)
                {
                    if (Options.EnableMessages)
                    {
                        State.Messages.Add(MessageId.UnknownId, Code);
                    }

                    return(SimpleRecResult.Failed);
                }

                Ret = new PointerType(Container, Child);
                if (Options.Func == null || Options.Func(Ret))
                {
                    return(SimpleRecResult.Succeeded);
                }
            }

            return(SimpleRecResult.Unknown);
        }
        public async void AnalisaJogosH2H(IdContainer container)
        {
            //var jogot = _jogoRepository.TrazerJogoPorIdBet("KU067KaT");
            //_analiseService.AnalisaOverH2H(jogot);return;

            var ids   = container.Ids.OrderBy(i => i.DataInicio.TimeOfDay).ToList();
            var jogos = _jogoRepository.TrazJogosPorIds(container.Ids.Select(i => i.Id).ToArray()).OrderBy(j => j.DataInicio.TimeOfDay).ToList();

            //foreach (var jo in jogos)
            //{

            //    jo.Time1.QtdJogosH2H05 = jo.Time1.H2HInfos.Count(j => j.TotalGols == 1);
            //    jo.Time1.QtdJogosH2H15 = jo.Time1.H2HInfos.Count(j => j.TotalGols == 2);
            //    jo.Time1.QtdJogosH2H25 = jo.Time1.H2HInfos.Count(j => j.TotalGols >= 3);
            //    jo.Time2.QtdJogosH2H05 = jo.Time2.H2HInfos.Count(j => j.TotalGols == 1);
            //    jo.Time2.QtdJogosH2H15 = jo.Time2.H2HInfos.Count(j => j.TotalGols == 2);
            //    jo.Time2.QtdJogosH2H25 = jo.Time2.H2HInfos.Count(j => j.TotalGols >= 3);
            //    jo.Time1.QtdJogosUnderH2H25 = jo.Time1.H2HInfos.Count(j => j.TotalGols <= 2);
            //    jo.Time1.QtdJogosUnderH2H35 = jo.Time1.H2HInfos.Count(j => j.TotalGols <= 3);
            //    jo.Time1.QtdJogosH2HOver15 = jo.Time1.H2HInfos.Count(j => j.TotalGols >= 2);
            //    jo.Time1.QtdJogosH2HOver25 = jo.Time1.H2HInfos.Count(j => j.TotalGols >= 3);
            //    jo.Time2.QtdJogosUnderH2H25 = jo.Time2.H2HInfos.Count(j => j.TotalGols <= 2);
            //    jo.Time2.QtdJogosUnderH2H35 = jo.Time2.H2HInfos.Count(j => j.TotalGols <= 3);
            //    jo.Time2.QtdJogosH2HOver15 = jo.Time2.H2HInfos.Count(j => j.TotalGols >= 2);
            //    jo.Time2.QtdJogosH2HOver25 = jo.Time2.H2HInfos.Count(j => j.TotalGols >= 3);

            //    _jogoRepository.Salvar(jo);
            //}

            for (int i = 0; i < jogos.Count; i++)
            {
                var j = jogos[i];
                _analiseService.AnalisaOverH2H(j);
                await Task.Delay(200);

                _analiseService.AnalisaUnderH2H(j);
                await Task.Delay(200);
            }
        }
        public void AtualizaJogosComErros(IdContainer container = null, bool amanha = false)
        {
            container = container == null?amanha?_idContainerRepository.TrazerIdContainerAmanha() :
                            _idContainerRepository.TrazerIdContainerHoje() :
                                container;

            JogoRepository jr = new JogoRepository();
            var            idsJogosComErro = container.IdsComErro.Select(i => i.Id).Distinct().ToList();
            var            jogos           = jr.TrazJogosPorIds(idsJogosComErro.ToArray());

            foreach (var i in idsJogosComErro)
            {
                var id         = container.IdsComErro.FirstOrDefault(j => j.Id == i);
                var jogoPronto = _jogoRepository.JogoProntoParaAnalise(i);
                if (jogoPronto)
                {
                    container.IdsComErro.Remove(id);
                }
            }

            _idContainerRepository.Salvar(container);
        }
Example #26
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            if (Code.StartsWith(String, new IdCharCheck(true)))
            {
                var State   = Container.State;
                var ModCode = Code.Substring(0, String.Length);

                for (var i = 0; i < Out.Count; i++)
                {
                    if (Out[i] is NoBaseModifier)
                    {
                        State.Messages.Add(MessageId.NotExpected, ModCode);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new NoBaseModifier(ModCode));
                Code = Code.Substring(String.Length).Trim();
                return(SimpleRecResult.Succeeded);
            }

            return(SimpleRecResult.Unknown);
        }
Example #27
0
        public SimpleRecResult Recognize(IdContainer Container, ref CodeString Code, List <Modifier> Out)
        {
            var Result = Code.StartsWith(Strings, null, new IdCharCheck(true));

            if (Result.Index != -1)
            {
                var State   = Container.State;
                var ModCode = Code.Substring(0, Result.String.Length);

                ParameterFlags Flags;
                if (Result.Index == 0)
                {
                    Flags = ParameterFlags.ParamArray;
                }
                else
                {
                    throw new NotImplementedException();
                }

                for (var i = 0; i < Out.Count; i++)
                {
                    var FlagMod = Out[i] as ParamFlagModifier;
                    if (FlagMod != null && (FlagMod.Flags & Flags) != 0)
                    {
                        State.Messages.Add(MessageId.NotExpected, ModCode);
                        return(SimpleRecResult.Failed);
                    }
                }

                Out.Add(new ParamFlagModifier(ModCode, Flags));
                Code = Code.Substring(Result.String.Length).Trim();
                return(SimpleRecResult.Succeeded);
            }

            return(SimpleRecResult.Unknown);
        }
Example #28
0
 public EntityManager(WorldConfiguration config)
 {
     _worldId      = config.Id;
     _entityIds    = new IdContainer(config.MaxEntities);
     _relationship = MemoryUtils.AllocateBlock <Relationship>(config.MaxEntities, true);
 }
Example #29
0
        public SimpleRecResult Recognize(IdContainer Container, CodeString Code, GetIdOptions Options, ref Identifier Ret)
        {
            var Position = Code.Length - 1;

            if (Position >= 0 && Code[Position] == ']')
            {
                var State = Container.State;
                var ZPos  = Code.GetBracketPos(State, true, Options.EnableMessages);
                if (ZPos == -1)
                {
                    return(SimpleRecResult.Failed);
                }

                var Left = Code.TrimmedSubstring(State, 0, ZPos, Options.EnableMessages);
                if (!Left.IsValid)
                {
                    return(SimpleRecResult.Failed);
                }

                var TOptions = Options;
                TOptions.Func = x => x.RealId is Type;

                var TypeOfVals = Identifiers.Recognize(Container, Left, TOptions);
                if (TypeOfVals == null)
                {
                    return(SimpleRecResult.Failed);
                }

                var RTypeOfVals = TypeOfVals.RealId as Type;
                if (RTypeOfVals == null || (RTypeOfVals.TypeFlags & TypeFlags.CanBeArrayType) == 0)
                {
                    if (Options.EnableMessages)
                    {
                        State.Messages.Add(MessageId.UnknownId, Code);
                    }

                    return(SimpleRecResult.Failed);
                }

                var StrParams = Code.Substring(ZPos + 1, Position - ZPos - 1).Trim();
                if (StrParams.IsEqual("?"))
                {
                    Ret = new NonrefArrayType(Container, TypeOfVals, null);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
                else if (StrParams.IsEqual("*"))
                {
                    if ((RTypeOfVals.TypeFlags & TypeFlags.CanBePointer) == 0)
                    {
                        if (Options.EnableMessages)
                        {
                            State.Messages.Add(MessageId.UnknownId, Code);
                        }

                        return(SimpleRecResult.Failed);
                    }

                    Ret = new PointerAndLength(Container, TypeOfVals);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }

                var SplParams = RecognizerHelper.SplitToParameters(State, StrParams,
                                                                   ',', Options.EnableMessages, true);

                if (SplParams == null)
                {
                    return(SimpleRecResult.Failed);
                }

                if (SplParams.Length == 0 || SplParams[0].Length == 0)
                {
                    for (var i = 0; i < SplParams.Length; i++)
                    {
                        if (SplParams[i].Length > 0)
                        {
                            State.Messages.Add(MessageId.NotExpected, SplParams[i]);
                            return(SimpleRecResult.Failed);
                        }
                    }

                    var IndexCount = SplParams.Length == 0 ? 1 : SplParams.Length;
                    Ret = new RefArrayType(Container, TypeOfVals, IndexCount);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
                else
                {
                    var Plugin = Container.GetPlugin();
                    Plugin.GetPlugin <EvaluatorPlugin>().MustBeConst = true;

                    var Lengths = new int[SplParams.Length];
                    for (var i = 0; i < SplParams.Length; i++)
                    {
                        var Node    = Expressions.CreateExpression(SplParams[i], Plugin);
                        var ConstCh = Node as ConstExpressionNode;
                        if (ConstCh == null)
                        {
                            return(SimpleRecResult.Failed);
                        }

                        if (!(ConstCh.Type is NonFloatType))
                        {
                            if (Options.EnableMessages)
                            {
                                State.Messages.Add(MessageId.MustBeInteger, StrParams);
                            }

                            return(SimpleRecResult.Failed);
                        }

                        if (!VerifyArrayLength(State, ConstCh, StrParams, Options.EnableMessages))
                        {
                            return(SimpleRecResult.Failed);
                        }

                        Lengths[i] = (int)ConstCh.Integer;
                    }

                    Ret = new NonrefArrayType(Container, TypeOfVals, Lengths);
                    if (Options.Func == null || Options.Func(Ret))
                    {
                        return(SimpleRecResult.Succeeded);
                    }
                }
            }

            return(SimpleRecResult.Unknown);
        }
        public async Task <IdContainer> SalvaJogosIds(bool amanha = false)
        {
            NavegarParaSite(_configuration.Sites.Resultado.Principal);

            if (amanha)
            {
                _driver.FindElement(By.ClassName("tomorrow")).Click();
            }

            await Task.Delay(5000);

            try
            {
                ExpandiTodasTabelas();
            }
            catch { }

            List <IdJogo> idJogos = new List <IdJogo> {
            };

            var trsJogos     = _driver.FindElements(By.ClassName("stage-scheduled")).ToList();
            var trsJogosLive = _driver.FindElements(By.ClassName("stage-live")).ToList();

            if (trsJogosLive.Any())
            {
                trsJogosLive.ForEach(j => trsJogos.Add(j));
            }

            var idContainer = _idContainerRepository.TrazerIdContainerHoje();

            if (amanha)
            {
                idContainer = new IdContainer(idJogos, DateTime.Now.Date.AddDays(1));
            }
            else
            {
                if (idContainer != null)
                {
                    idContainer.Ids = idJogos;
                }
                else
                {
                    idContainer = new IdContainer(idJogos, DateTime.Now.Date);
                }
            }

            _idContainerRepository.Salvar(idContainer);

            foreach (var tr in trsJogos)
            {
                string id        = tr.GetAttribute("id").Substring(4);
                string classInfo = tr.GetAttribute("class");

                if (!Srf(classInfo) && !JogoCanceladoAdiadoOuEncerrado(classInfo))
                {
                    DateTime dataInicio = DateTime.Parse(tr.FindElement(By.ClassName("cell_ad")).Text);
                    if (amanha)
                    {
                        dataInicio = dataInicio.AddDays(1);
                    }
                    IdJogo idJogo = new IdJogo(id, dataInicio);
                    idContainer.Ids.Add(idJogo);
                }
            }

            _idContainerRepository.Salvar(idContainer);
            await VerificaJogosNãoCarregados(amanha);

            idContainer = amanha ? _idContainerRepository.TrazerIdContainerAmanha() : _idContainerRepository.TrazerIdContainerHoje();
            return(idContainer);
        }