Exemplo n.º 1
0
        /// <summary>
        /// 群消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns>0不拦截 1拦截消息</returns>
        public override int GroupMsgProcess(GroupMsg msg, long CurrentQQ)
        {
            Console.WriteLine($"GroupMsgProcess {CurrentQQ}\n" + JsonConvert.SerializeObject(msg));
            if (msg.FromGroupId != 516141713)
            {
                return(0);
            }
            if (msg.MsgType == MsgType.PicMsg)
            {
                var picContent = msg.GetPic();
                Apis.SendGroupMsg(msg.FromGroupId,
                                  picContent.Content + CodeUtils.At(msg.FromUserId) +
                                  CodeUtils.Pic_Http(picContent.FriendPic.FirstOrDefault().Url));
            }
            else if (msg.MsgType == MsgType.VoiceMsg)
            {
                var voiceContent = msg.GetVoice();
                Apis.SendGroupMsg(msg.FromGroupId, voiceContent.Content + CodeUtils.Voice_Http(voiceContent.Url));
            }
            else
            {
                Apis.SendGroupMsg(msg.FromGroupId, msg.Content + CodeUtils.At(msg.FromUserId));
            }

            Apis.RevokeMsg(new RevokeMsgReq
            {
                GroupID = msg.FromGroupId, MsgRandom = msg.MsgRandom, MsgSeq = msg.MsgRandom
            });
            return(0);
        }
Exemplo n.º 2
0
        public static CodeFileComparer GetTwoFiles()
        {
            var baseRepositoryPath = RepoPath;

            var sourceRepoOpts = configureTemporaryRepository(baseRepositoryPath, "source");
            var targetRepoOpts = configureTemporaryRepository(baseRepositoryPath, "target");


            using (var repo = new Repository(RepoPath))
                using (var sourceRepo = new Repository(repo.Info.Path, sourceRepoOpts))
                    using (var targetRepo = new Repository(repo.Info.Path, targetRepoOpts))
                    {
                        var masterBranches = repo.Branches.Where(c => c.FriendlyName.Contains("master")).ToList();
                        var masterBranch   = masterBranches.FirstOrDefault();
                        var latestCommit   = masterBranch.Commits.Skip(0).First();
                        var previousCommit = masterBranch.Commits.Skip(1).First();

                        var treeChanges   = repo.Diff.Compare <TreeChanges>(previousCommit.Tree, latestCommit.Tree);
                        var modifiedItems = treeChanges.Modified;
                        foreach (var modifiedItem in modifiedItems)
                        {
                            if (IsCodeFile(modifiedItem.Path))
                            {
                                var sourceFileContents = getFileBySha(sourceRepo, modifiedItem.Path, previousCommit.Sha);
                                var targetFileContents = getFileBySha(targetRepo, modifiedItem.Path, latestCommit.Sha);
                                var sourceCodeFile     = CodeUtils.CreateCodeFileFromContents(sourceFileContents, "source", modifiedItem.Path);
                                var targetCodeFile     = CodeUtils.CreateCodeFileFromContents(targetFileContents, "target", modifiedItem.Path);
                                return(new CodeFileComparer(sourceCodeFile, targetCodeFile, null));
                            }
                        }
                        return(null);
                    }
        }
Exemplo n.º 3
0
        void Verify_encoding_is_part_of_Code_name()
        {
            var codeNames = ToEnumConverter.GetCodeNames();

            for (int i = 0; i < IcedConstants.NumberOfCodeValues; i++)
            {
                var codeName = codeNames[i];
                if (CodeUtils.IsIgnored(codeName))
                {
                    continue;
                }
                var code   = (Code)i;
                var prefix = code.ToOpCode().Encoding switch {
                    EncodingKind.Legacy => string.Empty,
                    EncodingKind.VEX => "VEX_",
                    EncodingKind.EVEX => "EVEX_",
                    EncodingKind.XOP => "XOP_",
                    EncodingKind.D3NOW => "D3NOW_",
                    _ => throw new InvalidOperationException(),
                };
                if (prefix != string.Empty)
                {
                    Assert.StartsWith(prefix, codeName, StringComparison.Ordinal);
                }
            }
        }
Exemplo n.º 4
0
        public static IEnumerable <CodeFileComparer> ReadRepository()
        {
            using (var repo = new Repository(RepoPath))
            {
                var masterBranches = repo.Branches.Where(c => c.FriendlyName.Contains("master")).ToList();
                var latestCommit   = masterBranches.FirstOrDefault().Commits.Skip(0).First();
                var previousCommit = masterBranches.FirstOrDefault().Commits.Skip(1).First();


                var treeChanges   = repo.Diff.Compare <TreeChanges>(previousCommit.Tree, latestCommit.Tree);
                var modifiedItems = treeChanges.Modified;
                foreach (var modifiedItem in modifiedItems)
                {
                    if (IsCodeFile(modifiedItem.Path))
                    {
                        var patchChanges = repo.Diff.Compare <Patch>(previousCommit.Tree, latestCommit.Tree, new List <string>()
                        {
                            modifiedItem.Path
                        });
                        var changeBlocks         = getChangeBlocks(patchChanges);
                        var previousFileContents = getFileBySha(repo, modifiedItem.Path, previousCommit.Sha);
                        var newFileContents      = getFileBySha(repo, modifiedItem.Path, latestCommit.Sha);
                        var previousCodeFile     = CodeUtils.CreateCodeFileFromContents(previousFileContents, "source", modifiedItem.Path);
                        var newCodeFile          = CodeUtils.CreateCodeFileFromContents(newFileContents, "target", modifiedItem.Path);
                        yield return(new CodeFileComparer(previousCodeFile, newCodeFile, null));
                    }
                }
            }
        }
 public ClassDefinition(string typeDeclarations, string typeContents, string extensions, string attributes, IStaticCodeElement owner) : base(typeDeclarations, typeContents, owner)
 {
     CodeUtils.GetElementDefinitions(typeContents, this);
     Members = Elements.OfType <MemberDefinition>().ToList();
     this.GetAttributes(attributes);
     this.GetExtensions(extensions);
 }
Exemplo n.º 6
0
        public HeadConfig(String version, String devCode, String pduType, String seq, String routeFlag, String dstAddr)
        {
            //获取版本号
            String hiVer  = version.Substring(0, 1);
            String lowVer = version.Substring(1, 1);

            this.version = (byte)((CodeUtils.String2Byte(hiVer)) * 16 + CodeUtils.String2Byte(lowVer));

            //获取设备id
            for (int i = 0; i < 6; i++)
            {
                this.devCode[i] = CodeUtils.String2Byte(devCode.Substring(2 * i, 2));
            }

            //获取pduType:与埃德尔有区别
            this.pduType = getRespPduType(pduType);

            //路由Flag信息
            this.routeFlag = CodeUtils.String2Byte(routeFlag);

            //目标节点地址信息
            for (int i = 0; i < 2; i++)
            {
                this.dstAddr[i] = CodeUtils.String2Byte(dstAddr.Substring(2 * i, 2));
            }

            //获取seq序列ID
            this.seq = CodeUtils.String2Byte(seq);
        }
Exemplo n.º 7
0
        public static HashSet <Code> Read(string name)
        {
            var filename   = PathUtils.GetTestTextFilename(name, "Decoder");
            int lineNumber = 0;
            var hash       = new HashSet <Code>();

            foreach (var line in File.ReadLines(filename))
            {
                lineNumber++;
                if (line.Length == 0 || line[0] == '#')
                {
                    continue;
                }
                var value = line.Trim();
                if (CodeUtils.IsIgnored(value))
                {
                    continue;
                }
                if (!ToEnumConverter.TryCode(value, out var code))
                {
                    throw new InvalidOperationException($"Error parsing Code file '{filename}', line {lineNumber}: Invalid value: {value}");
                }
                hash.Add(code);
            }
            return(hash);
        }
Exemplo n.º 8
0
    public IEnumerator GetSingleCase(GameObject loadingGo, string countryName, System.Action <bool, CaseDetails> aCallback)
    {
        string          path            = "https://api.covid19tracking.narrativa.com/api/" + CodeUtils.GetCurrentDate() + "/country/" + countryName;
        UnityWebRequest cardInfoRequest = UnityWebRequest.Get(path);
        var             operation       = cardInfoRequest.SendWebRequest();

        loadingGo.SetActive(true);
        yield return(CodeUtils.ProgressBar(operation));

        if (cardInfoRequest.isNetworkError || cardInfoRequest.isHttpError)
        {
            aCallback(true, new CaseDetails());
            Debug.Log(cardInfoRequest.error);
            yield break;
        }
        loadingGo.SetActive(false);
        JSONNode    cardInfo       = JSON.Parse(cardInfoRequest.downloadHandler.text);
        int         deadTotal      = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_deaths"];
        int         covidTotal     = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_confirmed"];
        int         covidToday     = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_new_confirmed"];
        int         deadToday      = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_new_deaths"];
        int         recoveredToday = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_new_recovered"];
        int         recoveredTotal = cardInfo["dates"][CodeUtils.GetCurrentDate()]["countries"][CodeUtils.UppercaseFirst(countryName)]["today_recovered"];
        CaseDetails caseDetail     = new CaseDetails(covidToday, deadToday, recoveredTotal, recoveredToday, covidTotal, deadTotal, countryName);

        aCallback(false, caseDetail);
    }
Exemplo n.º 9
0
        private void RefreshModules()
        {
            using (var ctrlSA = new SAController())
            {
                lstModule.BeginUpdate();
                lstModule.Items.Clear();

                ctrlSA.ListModuleInfo(out m_Modules);
                var groupModules = (from module in m_Modules
                                    group module by module.ModuleID into groupModule
                                    select groupModule);
                foreach (var modtype in CodeUtils.GetCodes("DEFMOD", "MODTYPE"))
                {
                    if (modtype.CodeValueName.Contains(txtFilter.Text.ToUpper()) || (txtFilter.Text == "?TYPE"))
                    {
                        lstModule.Items.Add(new ImageListBoxItem(modtype, Language.ModuleTypeImageIndex));
                    }
                }

                foreach (var groupModule in groupModules)
                {
                    if (groupModule.First().ModuleName.Contains(txtFilter.Text.ToUpper()))
                    {
                        lstModule.Items.Add(new ImageListBoxItem(groupModule.First(), Language.ModuleImageIndex));
                    }
                }

                lstModule.EndUpdate();
            }
        }
Exemplo n.º 10
0
        public Item EnsureItemWithUnit(string itemDescription)
        {
            itemDescription = itemDescription ?? "";

            var parts = itemDescription.Split(',');

            string name = parts[0].Trim();
            string unit = parts.Count() > 1 ? parts[1] : null;

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new Exception($"Incorrect item description provided: {itemDescription}");
            }

            var entity = _rep.GetByText(name);

            if (entity == null)
            {
                entity = new ItemEntity
                {
                    Text = name,
                    Unit = CodeUtils.CreateCode(unit),
                    Code = CodeUtils.CreateCode(name)
                };
                _rep.Add(entity);
            }

            return(ItemMapper.MapToModel(entity));
        }
Exemplo n.º 11
0
        void Make_sure_all_Code_values_are_tested_exactly_once()
        {
            var tested = new bool[IcedConstants.CodeEnumCount];

            foreach (var info in OpCodeInfoTestCases.OpCodeInfoTests)
            {
                Assert.False(tested[(int)info.Code]);
                tested[(int)info.Code] = true;
            }
            var sb        = new StringBuilder();
            var codeNames = ToEnumConverter.GetCodeNames();

            for (int i = 0; i < tested.Length; i++)
            {
                if (!tested[i] && !CodeUtils.IsIgnored(codeNames[i]))
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(',');
                    }
                    sb.Append(codeNames[i]);
                }
            }
            Assert.Equal(string.Empty, sb.ToString());
        }
Exemplo n.º 12
0
        protected override StringRequestInfo ProcessMatchedRequest(byte[] readBuffer, int offset, int length)
        {
            //TODO LIST: decode the readBuffer

            byte[] src = CodeUtils.adDecode(readBuffer.CloneRange(offset, length - 2));

            String data = BitConverter.ToString(src, 0, src.Length).Replace("-", "");

            //TODO: construct the receving adler data
            //String data = Encoding.ASCII.GetString(src, 0, src.Length);
            //preamble(1B) version(1B) leng(2B) deviceId(4B) Pdutype(1B) seq(1B) oid-list/tag-list(N) crc(2B)
            String preamble = data.Substring(0, 2);
            String version  = data.Substring(2, 2);
            String leng     = data.Substring(4, 4);
            String deviceId = data.Substring(8, 8);
            String pduType  = data.Substring(16, 2);
            String seq      = data.Substring(18, 2);
            String settings = data.Substring(20, data.Length - 4 - 12 * 2); //减去结尾回车换行符号,减去总的字节数
            String crcs     = data.Substring(data.Length - 8, 4);

            String result = "Adler:" + preamble + "," + version + "," +
                            leng + "," + deviceId + "," + pduType + "," +
                            seq + "," + settings + "," + crcs;

            BasicRequestInfoParser m_Parser = new BasicRequestInfoParser(":", ",");

            return(m_Parser.ParseRequestInfo(result));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 私聊消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns>0不拦截 1拦截消息</returns>
        public override int FriendMsgProcess(FriendMsg msg, long CurrentQQ)
        {
            Console.WriteLine($"FriendMsgProcess {CurrentQQ}\n" + JsonConvert.SerializeObject(msg));
            switch (msg.MsgType)
            {
            case MsgType.PicMsg:
            {
                var picContent = msg.GetPic();
                Apis.SendFriendMsg(msg.FromUin,
                                   picContent.Content + CodeUtils.Pic_Http(picContent.FriendPic.FirstOrDefault().Url));
                break;
            }

            case MsgType.VoiceMsg:
            {
                var voiceContent = msg.GetVoice();
                Apis.SendFriendMsg(msg.FromUin, voiceContent.Content + CodeUtils.Voice_Http(voiceContent.Url));
                break;
            }

            default:
                Apis.SendFriendMsg(msg.FromUin, msg.Content);
                break;
            }

            return(0);
        }
Exemplo n.º 14
0
        static (string hexBytes, Code code, DecoderOptions options, InstructionInfoTestCase testCase) ParseLine(string line, int bitness, Dictionary <string, Register> toRegister)
        {
            Static.Assert(MiscInstrInfoTestConstants.InstrInfoElemsPerLine == 5 ? 0 : -1);
            var elems = line.Split(commaSeparator, MiscInstrInfoTestConstants.InstrInfoElemsPerLine);

            if (elems.Length != MiscInstrInfoTestConstants.InstrInfoElemsPerLine)
            {
                throw new Exception($"Expected {MiscInstrInfoTestConstants.InstrInfoElemsPerLine - 1} commas");
            }

            var testCase = new InstructionInfoTestCase();

            testCase.IP = bitness switch {
                16 => DecoderConstants.DEFAULT_IP16,
                32 => DecoderConstants.DEFAULT_IP32,
                64 => DecoderConstants.DEFAULT_IP64,
                _ => throw new InvalidOperationException(),
            };

            var hexBytes = ToHexBytes(elems[0].Trim());
            var codeStr  = elems[1].Trim();

            if (CodeUtils.IsIgnored(codeStr))
            {
                return(default);
Exemplo n.º 15
0
        static SymbolOptionsTestCase?ParseLine(string line)
        {
            var elems = line.Split(commaSeparator);

            if (elems.Length != 5)
            {
                throw new Exception($"Invalid number of commas: {elems.Length - 1}");
            }

            var hexBytes = elems[0].Trim();

            if (CodeUtils.IsIgnored(elems[1].Trim()))
            {
                return(null);
            }
            var bitness         = NumberConverter.ToInt32(elems[2].Trim());
            var formattedString = elems[3].Trim().Replace('|', ',');
            var flags           = SymbolTestFlags.None;

            foreach (var value in elems[4].Split(spaceSeparator, StringSplitOptions.RemoveEmptyEntries))
            {
                if (!Dicts.ToSymbolTestFlags.TryGetValue(value, out var f))
                {
                    throw new InvalidOperationException($"Invalid flags value: {value}");
                }
                flags |= f;
            }
            return(new SymbolOptionsTestCase(hexBytes, bitness, formattedString, flags));
        }
Exemplo n.º 16
0
    private static IEnumerable <TSource> DoOrderByFx <TSource>(IEnumerable <TSource> source, string keySelectorExpression, Type keyType)
    {
        if (source == null)
        {
            throw new ArgumentNullException("source");
        }

        if (string.IsNullOrEmpty(keySelectorExpression))
        {
            throw new ArgumentException("Argument can't be null nor empty.", "keySelectorExpression");
        }

        if (keyType == null)
        {
            throw new ArgumentNullException("keyType");
        }

        keySelectorExpression = CodeUtils.PreprocessCode(keySelectorExpression);

        Session   session         = RoslynUtils.CreateSession();
        Type      keySelectorType = ReflectionUtils.CreateFuncType2(typeof(TSource), keyType);
        Exception exception;

        object keySelector =
            TryExecute(keySelectorExpression, session, keySelectorType, out exception);

        if (keySelector != null && keySelectorType.IsInstanceOfType(keySelector))
        {
            return(InvokeOrderBy(keyType, source, keySelector));
        }

        throw new ArgumentException(string.Format("Couldn't parse key selector expression ('{0}') as Func<TSource, TKey>. TSource: '{1}'. TKey: '{2}'.", keySelectorExpression, typeof(TSource), keyType), "keySelectorExpression");
    }
Exemplo n.º 17
0
    public static List <object> SelectFx <TSource>(this IEnumerable <TSource> source, string selectorExpression)
    {
        if (source == null)
        {
            throw new ArgumentNullException("source");
        }

        if (string.IsNullOrEmpty(selectorExpression))
        {
            throw new ArgumentException("Argument can't be null nor empty.", "selectorExpression");
        }

        selectorExpression = CodeUtils.PreprocessCode(selectorExpression);

        Session session = RoslynUtils.CreateSession();

        Exception exception;

        Func <TSource, object> selector =
            TryExecute <Func <TSource, object> >(selectorExpression, session, out exception);

        if (selector != null)
        {
            return(source.Select(selector).ToList());
        }

        throw new ArgumentException(string.Format("Couldn't parse selector expression ('{0}') as Func<T, object>. TSource: '{1}'.", selectorExpression, typeof(TSource)), "selectorExpression", exception);
    }
Exemplo n.º 18
0
        /**
         * 发送雨量计校时信息
         **/
        private bool sendYLConfig(DeviceDTO dto, Dictionary <String, String> settings)
        {
            var       server      = bootstrap.GetServerByName(YL_SERVER);
            YLServer  casicServer = server as YLServer;
            YLSession session     = casicServer.GetSessionByID(dto.SessionId) as YLSession;

            byte[] set = ApplicationContext.getInstance().getUpdateTime();
            //更新session中devID的编号
            String devName = settings["yw_deviceId"];

            session.DeviceID = devName;

            byte[] devCodes = new byte[2];
            devCodes[0] = byte.Parse(devName.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
            devCodes[1] = byte.Parse(devName.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);

            set[2] = devCodes[0];
            set[3] = devCodes[1];
            byte[] sendCode = CodeUtils.yl_addCrc(set);
            //TODO LIST:获取会话信息,发送数据
            //session.Send(set, 0, set.Length);
            session.Send(sendCode, 0, sendCode.Length);
            session.Logger.Info("雨量计配置信息下发成功:" + BitConverter.ToString(sendCode));
            return(true);
        }
Exemplo n.º 19
0
        public void testCRC()
        {
            string data = "0101020404028485A1";
            string crc  = CodeUtils.CRC16_Standard(data, 0, data.Length);

            Console.Write(crc);
        }
Exemplo n.º 20
0
        static OptionsInstructionInfo?ReadTestCase(string line, int lineNo)
        {
            var parts = line.Split(seps);

            if (parts.Length != 4)
            {
                throw new InvalidOperationException($"Invalid number of commas ({parts.Length - 1} commas)");
            }

            int bitness  = NumberConverter.ToInt32(parts[0].Trim());
            var hexBytes = parts[1].Trim();

            HexUtils.ToByteArray(hexBytes);
            var codeStr = parts[2].Trim();

            if (CodeUtils.IsIgnored(codeStr))
            {
                return(null);
            }
            var code = ToCode(codeStr);

            var properties = new List <(OptionsProps property, object value)>();

            foreach (var part in parts[3].Split(optsseps, StringSplitOptions.RemoveEmptyEntries))
            {
                properties.Add(OptionsParser.ParseOption(part));
            }

            return(new OptionsInstructionInfo(bitness, hexBytes, code, properties));
        }
Exemplo n.º 21
0
        /// <inheritdoc/>
        public override string[] GetExpressions()
        {
            List <string> expressions = new List <string>();

            expressions.AddRange(base.GetExpressions());

            if (!String.IsNullOrEmpty(DataColumn))
            {
                expressions.Add(DataColumn);
            }
            if (!String.IsNullOrEmpty(Expression))
            {
                expressions.Add(Expression);
            }
            else
            {
                if (AllowExpressions && !String.IsNullOrEmpty(Brackets))
                {
                    string[] brackets = Brackets.Split(new char[] { ',' });
                    // collect expressions found in the text
                    expressions.AddRange(CodeUtils.GetExpressions(Text, brackets[0], brackets[1]));
                }
            }
            return(expressions.ToArray());
        }
Exemplo n.º 22
0
        /// <summary>
        /// Détermine le nom du type T-SQL avec la précision.
        /// </summary>
        /// <param name="property">Propriété de classe.</param>
        /// <returns>Nom du type T-SQL.</returns>
        public static string DeterminerSqlDataType(this ModelProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            IPersistenceData persistenceData =
                property.IsDatabaseOnly ?
                property.DataMember :                              // Propriété non applicative : les données de persistence sont portées par le champ directement.
                (IPersistenceData)property.DataDescription.Domain; // Propriété applicative : les données de persistences sont portées par le domaine.

            string persistentType = CodeUtils.PowerDesignerPersistentDataTypeToSqlDatType(persistenceData.PersistentDataType);

            bool hasLength    = persistenceData.PersistentLength.HasValue;
            bool hasPrecision = persistenceData.PersistentPrecision.HasValue;

            if (hasLength)
            {
                persistentType += "(" + persistenceData.PersistentLength;
                if (hasPrecision)
                {
                    persistentType += "," + persistenceData.PersistentPrecision;
                }

                persistentType += ")";
            }
            else if (property.DataDescription.IsPrimaryKey && property.DataDescription.Domain.Code == "DO_ID")
            {
                persistentType += " identity";
            }

            return(persistentType);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Format 'while' statement
        /// </summary>
        /// <param name="codeLine">line to format</param>
        /// <returns>formated line (without statement string)</returns>
        public virtual string formatWhile(string codeLine)
        {
            Match match = this.whileStatementRegex.Match(codeLine);

            codeLine = match.Value;
            codeLine = CodeUtils.replaceFirst(codeLine, this.whileStatement, "");
            return(codeLine);
        }
 private void getAttributeParametersFromContent(string attributeContent)
 {
     foreach (var parameter in attributeContent.Split(','))
     {
         var fullParameterContent = CodeUtils.ExpandAllSymbols(parameter);
         Parameters.Add(fullParameterContent);
     }
 }
Exemplo n.º 25
0
        static VirtualAddressTestCase?ParseLine(string line)
        {
            var elems = line.Split(commaSeparator);

            if (elems.Length != 7)
            {
                throw new Exception($"Invalid number of commas: {elems.Length - 1}");
            }

            var bitness = NumberConverter.ToInt32(elems[0].Trim());

            if (CodeUtils.IsIgnored(elems[1].Trim()))
            {
                return(null);
            }
            var hexBytes      = elems[2].Trim();
            var operand       = NumberConverter.ToInt32(elems[3].Trim());
            var elementIndex  = NumberConverter.ToInt32(elems[4].Trim());
            var expectedValue = NumberConverter.ToUInt64(elems[5].Trim());

            var registerValues = new List <(Register register, int elementIndex, int elementSize, ulong value)>();

            foreach (var tmp in elems[6].Split(spaceSeparator, StringSplitOptions.RemoveEmptyEntries))
            {
                var kv = tmp.Split(equalSeparator);
                if (kv.Length != 2)
                {
                    throw new Exception($"Expected key=value: {tmp}");
                }
                var key      = kv[0];
                var valueStr = kv[1];

                Register register;
                int      expectedElementIndex;
                int      expectedElementSize;
                if (key.IndexOf(';') >= 0)
                {
                    var parts = key.Split(semicolonSeparator);
                    if (parts.Length != 3)
                    {
                        throw new Exception($"Invalid number of semicolons: {parts.Length - 1}");
                    }
                    register             = ToEnumConverter.GetRegister(parts[0]);
                    expectedElementIndex = NumberConverter.ToInt32(parts[1]);
                    expectedElementSize  = NumberConverter.ToInt32(parts[2]);
                }
                else
                {
                    register             = ToEnumConverter.GetRegister(key);
                    expectedElementIndex = 0;
                    expectedElementSize  = 0;
                }
                ulong value = NumberConverter.ToUInt64(valueStr);
                registerValues.Add((register, expectedElementIndex, expectedElementSize, value));
            }

            return(new VirtualAddressTestCase(bitness, hexBytes, operand, elementIndex, expectedValue, registerValues.ToArray()));
        }
Exemplo n.º 26
0
        /// <inheritdoc/>
        public override void GetData()
        {
            base.GetData();
            if (!String.IsNullOrEmpty(DataColumn))
            {
                object value = Report.GetColumnValue(DataColumn);
                Text = value == null ? "" : value.ToString();
            }
            else if (!String.IsNullOrEmpty(Expression))
            {
                object value = Report.Calc(Expression);
                Text = value == null ? "" : value.ToString();
            }
            else
            {
                // process expressions
                if (AllowExpressions && !String.IsNullOrEmpty(this.brackets))
                {
                    string[]     bracket_arr = this.brackets.Split(new char[] { ',' });
                    FindTextArgs args        = new FindTextArgs();
                    args.Text         = new FastString(Text);
                    args.OpenBracket  = bracket_arr[0];
                    args.CloseBracket = bracket_arr[1];
                    int expressionIndex = 0;
                    while (args.StartIndex < args.Text.Length)
                    {
                        string expression = CodeUtils.GetExpression(args, false);
                        if (expression == "")
                        {
                            break;
                        }

                        string value = Report.Calc(expression).ToString();
                        args.Text        = args.Text.Remove(args.StartIndex, args.EndIndex - args.StartIndex);
                        args.Text        = args.Text.Insert(args.StartIndex, value);
                        args.StartIndex += value.Length;
                        expressionIndex++;
                    }
                    Text = args.Text.ToString();
                }
            }

            if (Visible)
            {
                Visible = !String.IsNullOrEmpty(Text) || !HideIfNoData;
            }
            if (Visible)
            {
                try
                {
                    origRect = this.Bounds;
                    UpdateAutoSize();
                }
                catch
                {
                }
            }
        }
        public void AnalyseAllCodeProjectFilesForSolution_Test()
        {
            var allFilePaths = CodeUtils.GetAllCodeProjectFilesForSolution(@"..\..\..\ModelManager.sln");

            foreach (var path in allFilePaths)
            {
                var codeProjectFile = new CodeProjectFile(path, true);
            }
        }
        public void ReadAllCodeFilesForProject_Test()
        {
            var allFilePaths = CodeUtils.GetAllCodeFilesForProject(@"..\..\..\ModelManager\ModelManager.csproj");

            foreach (var path in allFilePaths)
            {
                Assert.IsNotNull(CodeUtils.ReadCodeFile(path));
            }
        }
        public void ReadAllCodeFilesForSolution_Test()
        {
            var allFilePaths = CodeUtils.GetAllCodeFilesForSolution(@"..\..\..\ModelManager.sln");

            foreach (var path in allFilePaths)
            {
                Assert.IsNotNull(CodeUtils.ReadCodeFile(path));
            }
        }
Exemplo n.º 30
0
        public void GetAllCodeFiles()
        {
            var folderPath = Path.GetDirectoryName(FilePath);

            foreach (var element in ItemGroups["Compile"])
            {
                IncludedCodeFiles.Add(CodeUtils.ReadCodeFile(Path.Combine(folderPath, element)));
            }
        }