Esempio n. 1
0
        public static bool fixMatchingConfig(FixType type, int index, object config, ref List <Model.MatchingConfig> matchingConfig)
        {
            bool rct = false;

            try
            {
                switch (type)
                {
                case FixType.ROIParameter:
                    matchingConfig[index].ROIParameter[0] = new ViewWindow.Model.RoiData(0, (ViewWindow.Model.ROI)config);
                    rct = true;
                    break;

                case FixType.CreatModelParameter:
                    matchingConfig[index].CreatModelParameter[0] = (CreatModelParameter)config;
                    rct = true;
                    break;

                case FixType.FindModelParameter:
                    matchingConfig[index].FindModelParameter[0] = (FindModelParameter)config;
                    rct = true;
                    break;

                default:
                    rct = false;
                    break;
                }
            }
            catch (Exception)
            {
                rct = false;
            }

            return(rct);
        }
        private async static Task<Document> ChangePropertySetAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken, FixType fixType)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
            var diagnosticSpan = diagnostic.Location.SourceSpan;
            var propertyStatement = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First();
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken);

            var getAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "get") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
            var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];

            var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
                .WithAdditionalAnnotations(Formatter.Annotation);

            var modifiers = setAcessor.Modifiers.Add(privateprotectedModifier);
            setAcessor = setAcessor.WithModifiers(modifiers);

            var newProperty = SyntaxFactory.PropertyDeclaration(propertyStatement.Type, propertyStatement.Identifier)
                .WithModifiers(propertyStatement.Modifiers)
                .WithAccessorList(SyntaxFactory.AccessorList(SyntaxFactory.List<AccessorDeclarationSyntax>(new AccessorDeclarationSyntax[] { getAcessor, setAcessor })))
                .WithLeadingTrivia(propertyStatement.GetLeadingTrivia()).WithTrailingTrivia(propertyStatement.GetTrailingTrivia())
                .WithAdditionalAnnotations(Formatter.Annotation);
            var newRoot = root.ReplaceNode(propertyStatement, newProperty);
            var newDocument = document.WithSyntaxRoot(newRoot);
            return newDocument;
        }
        private static IfStatementSyntax CreateIfStatement(string paramName, FixType fixType)
        {
            var identifier = IdentifierName(paramName);

            var nullSyntax     = LiteralExpression(SyntaxKind.NullLiteralExpression);
            var condition      = BinaryExpression(SyntaxKind.EqualsExpression, identifier, nullSyntax);
            var throwStatement = ThrowStatement(BuildExceptionExpression(identifier));

            switch (fixType)
            {
            case FixType.SimpleIfPlusCoalesce:
            case FixType.SimpleIf:
            {
                var ifStatement = IfStatement(condition, throwStatement);
                return(ifStatement);
            }

            case FixType.IfWithBlockPlusCoalesce:
            case FixType.IfWithBlock:
            {
                var blockSyntax = Block(throwStatement);
                var ifStatement = IfStatement(condition, blockSyntax);
                return(ifStatement);
            }

            default: throw new NotImplementedException($"Unknown fix type {fixType}");
            }
        }
        private static SyntaxList <StatementSyntax> GetNewBodyStatements(
            ConstructorDeclarationSyntax constructor,
            IList <string> paramNames,
            FixType fixType)
        {
            switch (fixType)
            {
            case FixType.IfWithBlockPlusCoalesce:
            case FixType.SimpleIfPlusCoalesce:
            {
                // Coalesce fixes where possible
                var assignmentStatements     = paramNames.Select(x => CreateFixerForAssignment(constructor, x));
                var declarationFixStatements =
                    paramNames.Select(x => CreateFixerForDeclaration(constructor, x)).ToList();

                var paramFixStatements = declarationFixStatements.Union(assignmentStatements).ToArray();
                var updatedStatements  = constructor.Body.Statements;
                foreach (var(oldStatement, newStatement, _) in paramFixStatements.Where(
                             x => x.oldStatement != null))
                {
                    var oldStatementIndex = constructor.Body.Statements.IndexOf(oldStatement);
                    updatedStatements = updatedStatements
                                        .RemoveAt(oldStatementIndex)
                                        .Insert(oldStatementIndex, newStatement);
                }

                // if fixes where coalesce not applicable
                var processedParams = paramFixStatements
                                      .Where(x => x.newStatement != null)
                                      .Select(x => x.paramName)
                                      .ToArray();
                var notProcessedParameters = paramNames.Except(processedParams);
                var paramFixIfStatements   = notProcessedParameters.Select(x => CreateIfStatement(x, fixType))
                                             .Where(x => x != null)
                                             .ToList();

                return(updatedStatements.InsertRange(0, paramFixIfStatements));
            }

            case FixType.ContractRequires:
            {
                var paramFixStatements = paramNames.Select(CreateContractRequires)
                                         .Where(x => x != null)
                                         .ToList();
                return(constructor.Body.Statements.InsertRange(0, paramFixStatements));
            }

            case FixType.SimpleIf:
            case FixType.IfWithBlock:
            {
                var paramFixStatements = paramNames.Select(x => CreateIfStatement(x, fixType))
                                         .Where(x => x != null)
                                         .ToList();
                return(constructor.Body.Statements.InsertRange(0, paramFixStatements));
            }

            default: throw new NotImplementedException($"Unknown fix type {fixType}");
            }
        }
Esempio n. 5
0
 internal void Handle(GsaLine nmeaMessage)
 {
     Gsa          = nmeaMessage;
     HDop         = nmeaMessage.Hdop;
     VDop         = nmeaMessage.Vdop;
     PDop         = nmeaMessage.Pdop;
     SatelliteIds = nmeaMessage.SatelliteIDs;
     GsaMode      = nmeaMessage.Mode;
     FixType      = nmeaMessage.Fix;
 }
Esempio n. 6
0
        public GpvtgReceivedEventArgs(string[] values)
        {
            if (String.Compare(values[0], "GPVTG", true) != 0 || values.Length != 10)
            {
                throw new ArgumentException("Invalid GPVTG sentence.", "values");
            }

            this.Identifier = values[0];

            if (!String.IsNullOrEmpty(values[1]))
            {
                this.TrueBearing = Single.Parse(values[1]);
            }

            if (!String.IsNullOrEmpty(values[3]))
            {
                this.MagneticBearing = Single.Parse(values[3]);
            }

            if (!String.IsNullOrEmpty(values[5]))
            {
                this.KnotsSpeed = Single.Parse(values[5]);
            }

            if (!String.IsNullOrEmpty(values[7]))
            {
                this.KphSpeed = Single.Parse(values[7]);
            }

            if (!String.IsNullOrEmpty(values[9]))
            {
                switch (values[9])
                {
                case "A":
                    this.Mode = FixType.Autonomous;
                    break;

                case "D":
                    this.Mode = FixType.Differential;
                    break;

                case "E":
                    this.Mode = FixType.Estimated;
                    break;

                case "S":
                    this.Mode = FixType.Simulator;
                    break;

                default:
                    this.Mode = FixType.Invalid;
                    break;
                }
            }
        }
Esempio n. 7
0
        public void Decode(Tokenizer tok)
        {
            string param = tok.GetString();

            m_autoSelection     = (param == "A");
            m_fixType           = (FixType)tok.GetInt();
            m_nSatellites       = tok.GetInt();
            m_precisionDilution = tok.GetDouble();
            m_hDop = tok.GetDouble();
            m_vDop = tok.GetDouble();
        }
Esempio n. 8
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            FixType svr    = (FixType)value;
            string  svrstr = svr.ToString().ToLower();

            switch (svr)
            {
            case FixType.RegexSubstitute:
                svrstr = "regex-substitute";
                break;
            }
            writer.WriteValue(svrstr);
        }
        private static string GetRequiredUsingName(FixType fixType)
        {
            switch (fixType)
            {
            case FixType.ContractRequires: return("System.Diagnostics.Contracts");

            case FixType.IfWithBlockPlusCoalesce:
            case FixType.IfWithBlock:
            case FixType.SimpleIf:
            case FixType.SimpleIfPlusCoalesce: return("System");

            default: throw new NotImplementedException($"Unknown fix type {fixType}");
            }
        }
Esempio n. 10
0
        private PlaylistFixerForm(LanguageManager languageManager, MainForm parent, FixType type)
        {
            InitializeComponent();

            uiBottom.SplitWidth();
            uiScanFilenames.Checked = Properties.Settings.Default.ScanFilenames;
            uiScanCues.Checked      = Properties.Settings.Default.ScanCues;
            uiScanTags.Checked      = Properties.Settings.Default.ScanTags;

            _lm = languageManager;
            _lm.AddAllControls(this);

            _parent = parent;

            CurrentType = type;
        }
Esempio n. 11
0
 private void FixVehicle(FixType type)
 {
     if ((int)type == 0)
     {
         if (player.LastVehicle.Exists())
         {
             player.LastVehicle.Repair();
         }
     }
     if ((int)type == 1)
     {
         if (player.LastVehicle.Exists())
         {
             player.LastVehicle.EngineHealth = 1000;
         }
     }
 }
        /// <summary>
        /// Froms the type of the fix.
        /// </summary>
        /// <param name="fix">The fix.</param>
        /// <returns>A string representation of a Fix Type</returns>
        public static string FromFixType(FixType fix)
        {
            switch (fix)
            {
            case FixType.Fix:
                return("3d");

            case FixType.Diff:
            case FixType.RTKfixed:
            case FixType.RTKfloating:
            case FixType.WAAS:
            case FixType.PostProcess:
                return("dgps");

            default:
                return("none");
            }
        }
        private async static Task<Document> ChangePropertySetAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken, FixType fixType)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
            var diagnosticSpan = diagnostic.Location.SourceSpan;
            var propertyStatement = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First();
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken);

            var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
            var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
                    .WithTrailingTrivia(setAcessor.GetTrailingTrivia())
                    .WithLeadingTrivia(setAcessor.GetLeadingTrivia());

            var newSet = SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration, setAcessor.AttributeLists, SyntaxTokenList.Create(privateprotectedModifier), setAcessor.Body);
            if(setAcessor.Body == null) newSet = newSet.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken));
            var newProperty = propertyStatement.ReplaceNode(setAcessor, newSet);

            var newRoot = root.ReplaceNode(propertyStatement, newProperty);
            var newDocument = document.WithSyntaxRoot(newRoot);
            return newDocument;
        }
Esempio n. 14
0
        public static FixType parseFixType(string fixtype_string)
        {
            FixType result = FixType.no_fix;

            if (!String.IsNullOrEmpty(fixtype_string))
            {
                if (fixtype_string == "1")
                {
                    result = FixType.no_fix;
                }
                else if (fixtype_string == "2")
                {
                    result = FixType._2D_fix;
                }
                else if (fixtype_string == "3")
                {
                    result = FixType._3D_fix;
                }
            }
            return(result);
        }
        public void CompileMessageTO_CompileMessageTOUnitTest_ToErrorInfo_CorrectErrorInfoReturned()
        {
            //init
            var message    = new CompileMessageTO();
            var expectedID = Guid.NewGuid();

            message.UniqueID  = expectedID;
            message.ErrorType = ErrorType.Critical;
            const FixType expectedFixType = FixType.ReloadMapping;

            message.MessageType    = CompileMessageType.MappingChange;
            message.MessagePayload = "Test Fix Data";

            //exe
            var actual = message.ToErrorInfo();

            //aserts
            Assert.AreEqual(expectedID, actual.InstanceID, "ToErrorInfo created an error info object with an incorrect InstanceID");
            Assert.AreEqual(ErrorType.Critical, actual.ErrorType, "ToErrorInfo created an error info object with an incorrect ErrorType");
            Assert.AreEqual(expectedFixType, actual.FixType, "ToErrorInfo created an error info object with an incorrect FixType");
            Assert.AreEqual(CompileMessageType.MappingChange.GetDescription(), actual.Message, "ToErrorInfo created an error info object with an incorrect Message");
            Assert.AreEqual("Test Fix Data", actual.FixData, "ToErrorInfo created an error info object with incorrect FixData");
        }
Esempio n. 16
0
        void OnGUI()
        {
            //GUILayout.Label("Base Settings", EditorStyles.boldLabel);
            m_Clip = EditorGUILayout.ObjectField("Clip", m_Clip, typeof(AnimationClip), false) as AnimationClip;
            m_Root = EditorGUILayout.ObjectField("Root", m_Root, typeof(GameObject), true) as GameObject;

            m_FixType = (FixType)EditorGUILayout.EnumPopup("Fix Type", m_FixType);

            switch (m_FixType)
            {
            case FixType.ManualList:
                ShowManualListPanel();
                break;

            case FixType.ManualReplace:
                ShowManualReplacePanel();
                break;
            }

            if (GUILayout.Button("fix"))
            {
                switch (m_FixType)
                {
                case FixType.Auto:
                    DoAutoFix();
                    break;

                case FixType.ManualList:
                    DoManualListFix();
                    break;

                case FixType.ManualReplace:
                    DoManualReplaceFix();
                    break;
                }
            }
        }
        public void CompileMessageTO_Clone_ShouldCloneAllProperties()
        {
            //------------Setup for test--------------------------
            var                      message        = new CompileMessageTO();
            var                      uniqueID       = Guid.NewGuid();
            var                      workspaceID    = Guid.NewGuid();
            const string             serviceName    = "Some Service Name";
            var                      messageID      = Guid.NewGuid();
            var                      serviceID      = Guid.NewGuid();
            const ErrorType          errorType      = ErrorType.Critical;
            const FixType            fixType        = FixType.ReloadMapping;
            const CompileMessageType messageType    = CompileMessageType.MappingChange;
            const string             messagePayload = "Test Fix Data";

            message.UniqueID       = uniqueID;
            message.WorkspaceID    = workspaceID;
            message.ServiceID      = serviceID;
            message.MessageID      = messageID;
            message.ErrorType      = errorType;
            message.ServiceName    = serviceName;
            message.MessageType    = messageType;
            message.MessagePayload = messagePayload;
            //------------Execute Test---------------------------
            var clonedTO = message.Clone();

            //------------Assert Results-------------------------
            Assert.AreEqual(workspaceID, clonedTO.WorkspaceID);
            Assert.AreEqual(messageID, clonedTO.MessageID);
            Assert.AreEqual(serviceID, clonedTO.ServiceID);
            Assert.AreEqual(uniqueID, clonedTO.UniqueID);
            Assert.AreEqual(serviceName, clonedTO.ServiceName);
            Assert.AreEqual(errorType, clonedTO.ErrorType);
            Assert.AreEqual(fixType, clonedTO.ToFixType());
            Assert.AreEqual(messageType, clonedTO.MessageType);
            Assert.AreEqual(messagePayload, clonedTO.MessagePayload);
        }
Esempio n. 18
0
        public GprmcReceivedEventArgs(string[] values)
        {
            if (String.Compare(values[0], "GPRMC", true) != 0 || values.Length != 13)
            {
                throw new ArgumentException("Invalid GPRMC sentence.", "values");
            }

            this.Identifier = values[0];

            if (!String.IsNullOrEmpty(values[1]) && !String.IsNullOrEmpty(values[9]))
            {
                this.DateTime = DateTime.ParseExact(values[9], "ddMMyy", CultureInfo.InvariantCulture).Add(TimeSpan.ParseExact(values[1], @"hhmmss\.fff", CultureInfo.InvariantCulture));
            }

            if (!String.IsNullOrEmpty(values[2]))
            {
                this.Status = values[2];
            }

            if (!String.IsNullOrEmpty(values[3]))
            {
                this.Latitude = Single.Parse(values[3].Substring(0, 2)) + (Single.Parse(values[3].Substring(2, values[3].Length - 2)) / 60.0f);

                if (values[4] == "S")
                {
                    this.Latitude = -this.Latitude;
                }
            }

            if (!String.IsNullOrEmpty(values[5]))
            {
                this.Longitude = Single.Parse(values[5].Substring(0, 3)) + (Single.Parse(values[5].Substring(3, values[5].Length - 3)) / 60.0f);

                if (values[6] == "W")
                {
                    this.Longitude = -this.Longitude;
                }
            }

            if (!String.IsNullOrEmpty(values[7]))
            {
                this.KnotsSpeed = Single.Parse(values[7]);
            }

            if (!String.IsNullOrEmpty(values[8]))
            {
                this.TrueBearing = Single.Parse(values[8]);
            }

            if (!String.IsNullOrEmpty(values[10]))
            {
                this.MagneticVariation = Single.Parse(values[10]);

                if (values[11] == "W")
                {
                    this.MagneticVariation = -this.MagneticVariation;
                }
            }

            if (!String.IsNullOrEmpty(values[12]))
            {
                switch (values[12])
                {
                case "A":
                    this.Mode = FixType.Autonomous;
                    break;

                case "D":
                    this.Mode = FixType.Differential;
                    break;

                case "E":
                    this.Mode = FixType.Estimated;
                    break;

                case "S":
                    this.Mode = FixType.Simulator;
                    break;

                default:
                    this.Mode = FixType.Invalid;
                    break;
                }
            }
        }
Esempio n. 19
0
        public override void DoTheJob()
        {
            string  output       = jobParam.AutoOutputFolder;
            FixType fix          = jobParam.FixType;
            bool    needFix      = jobParam.AutoFixType;
            string  templateName = jobParam.DataTemplateFilePath;
            string  macType      = jobParam.MacType;

            bool success = true;

            int templateIndex = -1;

            MSExcel.Worksheet ws1 = null;

            WordUtility _wu = new WordUtility(filePath, out success);

            if (!success)
            {
                LogHelper.AddException("Word文档打开失败", true);
                return;
            }

            string tempZhsh   = _wu.GetText(_wu.WordDocument, 3);         //L2:证书编号
            string tempName   = _wu.GetText(_wu.WordDocument, 7);         //B4:送校单位
            string tempQiju   = _wu.GetText(_wu.WordDocument, 11);        //B5:仪器名称
            string tempSerial = _wu.GetText(_wu.WordDocument, 15).Trim(); //F5:仪器型号

            _wu.TryClose();

            if (tempSerial != "" && tempSerial != macType)
            {
                LogHelper.AddDataError("证书中包含的仪器型号与指定的仪器型号不符" + Environment.NewLine + "证书仪器型号: " + tempSerial + Environment.NewLine + "指定仪器型号: " + macType, true);
            }

            string str         = tempZhsh.Substring(8);
            string strSavename = PathExt.PathCombine(output, tempName + "_" + macType + "_" + str + ".xlsx");

            if (File.Exists(strSavename))
            {
                if (FormOperator.MessageBox_Show_YesNo(@"文件已存在,是否覆盖?" + Environment.NewLine + strSavename, "提示"))
                {
                    File.Delete(strSavename);
                }
                else
                {
                    success = false;
                    return;
                }
            }
            File.Copy(templateName, strSavename);

            ExcelUtility _sr = new ExcelUtility(strSavename, out success);

            if (!success)
            {
                if (_sr != null && _sr.ExcelWorkbook != null)
                {
                    _sr.ExcelWorkbook.Saved = true;
                    _sr.TryClose();
                }
                LogHelper.AddException(@"Excel文档无法打开", true);
                LogHelper.AddProblemFilesAndReset(filePath);
                return;
            }
            _sr.ExcelApp.DisplayAlerts          = false;
            _sr.ExcelApp.AlertBeforeOverwriting = false;

            try
            {
                foreach (MSExcel.Worksheet item in _sr.ExcelWorkbook.Sheets)
                {
                    if (item.Name == @"标准模板")
                    {
                        templateIndex = item.Index;
                    }
                    else if (item.Name.Contains(@"标准模板"))
                    {
                        LogHelper.AddException(@"发现多余的标准模板", true);
                    }
                }
                LogHelper.State.Push("找到标准模板:" + templateIndex.ToString());
                if (templateIndex > -1)
                {
                    ws1 = (MSExcel.Worksheet)_sr.ExcelWorkbook.Sheets[templateIndex];
                    ws1.Copy(ws1, Type.Missing);
                    ws1 = (MSExcel.Worksheet)_sr.ExcelWorkbook.Sheets[templateIndex];
                    if (!ws1.Name.Contains(@"标准模板"))
                    {
                        LogHelper.AddException(@"标准模板复制出错", true);
                        success = false;
                        return;
                    }
                    else
                    {
                        ws1.Name = str;
                    }
                    LogHelper.State.Push("复制标准模板完成");
                }
                else
                {
                    LogHelper.AddException(@"找不到模板excel中的标准模板页", true);
                }

                _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(4, 2), tempName);
                _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(5, 6), macType);
                _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(5, 2), tempQiju);
                _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(2, 12), str);

                LogHelper.State.Push("写入4个信息");

                _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(8, 13), EnumExt.GetDescriptionFromEnumValue <FixType>(fix));

                LogHelper.State.Push("写入修正信息");

                if (!needFix)
                {
                    //电离室->半导体
                    MSExcel.Range rr = _sr.GetRange(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition("L8"));
                    rr.FormulaLocal = "";
                    rr.Formula      = "";
                    rr.FormulaArray = "";

                    LogHelper.State.Push("不修正时清空公式");

                    _sr.WriteValue(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(8, 12), "1.000000", "@");

                    LogHelper.State.Push("写入1");
                }

                LogHelper.State.Push("准备写入记录者图片");

                //写入记录者
                _sr.WriteImage(_sr.ExcelWorkbook, ws1.Index, new ExcelPosition(29, 7), PathExt.PathCombine(ProgramConfiguration.ProgramFolder, person.Path), 45, 28);
                LogHelper.State.Push("写完记录者图片");
                _sr.ExcelWorkbook.Save();
                LogHelper.State.Push("保存完毕");
            }
            catch (Exception ex)
            {
                Log.LogHelper.AddException("生成证书时遇到异常:" + ex.Message, true);
                Log.LogHelper.AddLog("执行位置:" + LogHelper.State.Peek(), true);
            }
            finally
            {
                //关闭Excel
                if (_sr.ExcelWorkbook != null)
                {
                    _sr.ExcelWorkbook.Saved = true;
                    _sr.TryClose();
                }
                //有重大失误的情况下报错,没有失误就删除源word文件
                if (LogHelper.HasException)
                {
                    LogHelper.AddProblemFilesAndReset(filePath);
                }
                else
                {
                    File.Delete(filePath);
                }
            }
        }
Esempio n. 20
0
        void UpdateData(object sender, System.EventArgs args)
        {
            try
            {
                if (gps.Opened)
                {
                    string str = "";
                    if (device != null)
                    {
                        str = "Name: '" + device.FriendlyName + "' Svc: '" + device.ServiceState + "', Dvc: '" + device.DeviceState + "'\r\n";
                    }
                    else
                    {
                        str = "Name: '' Svc:''\r\n";
                    }

                    if (position != null)
                    {
                        //if all valid
                        if ((((((this.position.LatitudeValid && this.position.LongitudeValid) && this.position.SatellitesInSolutionValid) && this.position.SatellitesInViewValid) && this.position.SatelliteCountValid) && this.position.TimeValid) && (this.position.SatelliteCount > 2))
                        {
                            m_FixValid = true;
                            if (m_XMLLogging)
                            {
                                this.position2XMLFile(this.position);
                            }
                        }
                        else
                        {
                            m_FixValid = false;
                        }

                        //Latitude
                        if (position.LatitudeValid)
                        {
                            str += "Lat: " + position.Latitude.ToString("00.000") + " ";
                            //str += "Lat (D,M,S): " + position.LatitudeInDegreesMinutesSeconds + "\r\n";
                        }
                        else
                        {
                            str += "Lat: --.--- ";
                        }

                        //Longitude
                        if (position.LongitudeValid)
                        {
                            str += "Lon: " + position.Longitude.ToString("00.000") + "\r\n";
                            //str += "Lon (D,M,S): " + position.LongitudeInDegreesMinutesSeconds + "\r\n";
                        }
                        else
                        {
                            str += "Lon: --.---\r\n";
                        }

                        //sat in view and in solution
                        if (position.SatellitesInSolutionValid &&
                            position.SatellitesInViewValid &&
                            position.SatelliteCountValid)
                        {
                            str += "Sat. Count: " + position.GetSatellitesInSolution().Length + "/" +
                                   position.GetSatellitesInView().Length + " (" +
                                   position.SatelliteCount + ")\r\n";
                        }
                        //list sats in solution
                        if (position.SatellitesInSolutionValid)
                        {
                            satSol = position.GetSatellitesInSolution();
                        }
                        //list sats in view and there signal
                        if (position.SatellitesInViewValid)
                        {
                            /* Satellite[] */
                            sats = position.GetSatellitesInView();
                            str += "SV:";
                            foreach (Satellite sat in sats)
                            {
                                str += sat.Id.ToString("00") + " ";
                            }
                            str += "\r\nSN:";
                            foreach (Satellite sat in sats)
                            {
                                str += sat.SignalStrength.ToString("00") + " ";
                            }
                            str += "\r\n";
                            panel1.Invalidate();
                        }
                        else
                        {
                            //panel1.Invalidate();
                        }
                        //time
                        if (position.TimeValid)
                        {
                            str += "Time: " + position.Time.ToString() + "\r\n";
                            if (m_FixValid)
                            {
                                SetTimeToGPS(position.Time);
                            }
                        }

                        //fixtype
                        FixType fx = position.eFixType;
                        switch (fx)
                        {
                        case FixType.Unknown: str += "FixType: Unknown\r\n";
                            break;

                        case FixType.XyD: str += "FixType: 2D\r\n";
                            break;

                        case FixType.XyzD: str += "FixType: 3D\r\n";
                            break;
                        }
                        //fix quality
                        FixQuality fq = position.eFixQuality;
                        switch (fq)
                        {
                        case FixQuality.Unknown: str += "FixQuality: Unknown\r\n";
                            break;

                        case FixQuality.Gps: str += "FixQuality: GPS\r\n";
                            break;

                        case FixQuality.DGps: str += "FixQuality: DGPS\r\n";
                            break;
                        }
                    }
                    panel1.Invalidate();

                    status.Text = str;
                }
            }
            catch (NullReferenceException)
            {
            }
        }
        private async Task <Document> ChangePropertySetAsync(Document document, PropertyDeclarationSyntax propertyStatement, CancellationToken cancellationToken, FixType fixType)
        {
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken);

            var getAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "get") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
            var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];

            var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
                                           .WithAdditionalAnnotations(Formatter.Annotation);

            var modifiers = setAcessor.Modifiers.Add(privateprotectedModifier);

            setAcessor = setAcessor.WithModifiers(modifiers);

            var newProperty = SyntaxFactory.PropertyDeclaration(propertyStatement.Type, propertyStatement.Identifier)
                              .WithModifiers(propertyStatement.Modifiers)
                              .WithAccessorList(SyntaxFactory.AccessorList(SyntaxFactory.List <AccessorDeclarationSyntax>(new AccessorDeclarationSyntax[] { getAcessor, setAcessor })))
                              .WithLeadingTrivia(propertyStatement.GetLeadingTrivia()).WithTrailingTrivia(propertyStatement.GetTrailingTrivia())
                              .WithAdditionalAnnotations(Formatter.Annotation);
            var root = await document.GetSyntaxRootAsync();

            var newRoot     = root.ReplaceNode(propertyStatement, newProperty);
            var newDocument = document.WithSyntaxRoot(newRoot);

            return(newDocument);
        }
Esempio n. 22
0
 public TokenPrinter(FixType fixType = DefaultFixType)
 {
     _fixType = fixType;
 }
Esempio n. 23
0
        private async static Task <Document> ChangePropertySetAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken, FixType fixType)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var diagnosticSpan    = diagnostic.Location.SourceSpan;
            var propertyStatement = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType <PropertyDeclarationSyntax>().First();
            var semanticModel     = await document.GetSemanticModelAsync(cancellationToken);

            var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
            var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
                                           .WithTrailingTrivia(setAcessor.GetTrailingTrivia())
                                           .WithLeadingTrivia(setAcessor.GetLeadingTrivia());

            var newSet = SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration, setAcessor.AttributeLists, SyntaxTokenList.Create(privateprotectedModifier), setAcessor.Body);

            if (setAcessor.Body == null)
            {
                newSet = newSet.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken));
            }
            var newProperty = propertyStatement.ReplaceNode(setAcessor, newSet);

            var newRoot     = root.ReplaceNode(propertyStatement, newProperty);
            var newDocument = document.WithSyntaxRoot(newRoot);

            return(newDocument);
        }
Esempio n. 24
0
        private async static Task <Document> ChangePropertySetAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken, FixType fixType)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var diagnosticSpan    = diagnostic.Location.SourceSpan;
            var propertyStatement = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType <PropertyDeclarationSyntax>().First();
            var semanticModel     = await document.GetSemanticModelAsync(cancellationToken);

            var getAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "get") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
            var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];

            var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
                                           .WithAdditionalAnnotations(Formatter.Annotation);

            var modifiers = setAcessor.Modifiers.Add(privateprotectedModifier);

            setAcessor = setAcessor.WithModifiers(modifiers);

            var newProperty = SyntaxFactory.PropertyDeclaration(propertyStatement.Type, propertyStatement.Identifier)
                              .WithModifiers(propertyStatement.Modifiers)
                              .WithAccessorList(SyntaxFactory.AccessorList(SyntaxFactory.List <AccessorDeclarationSyntax>(new AccessorDeclarationSyntax[] { getAcessor, setAcessor })))
                              .WithLeadingTrivia(propertyStatement.GetLeadingTrivia()).WithTrailingTrivia(propertyStatement.GetTrailingTrivia())
                              .WithAdditionalAnnotations(Formatter.Annotation);
            var newRoot     = root.ReplaceNode(propertyStatement, newProperty);
            var newDocument = document.WithSyntaxRoot(newRoot);

            return(newDocument);
        }
Esempio n. 25
0
		protected Function(string name, int argumentCount, FixType fixType = FixType.PostFix)
		{
			FixType = fixType;
			Name = name;
			ArgumentCount = argumentCount;
		}
        private async Task <Solution> AddNullCheck(Document document, ConstructorDeclarationSyntax constructor, IList <string> paramNames, FixType fixType, CancellationToken cancellationToken)
        {
            var newBodyStatements = GetNewBodyStatements(constructor, paramNames, fixType);

            if (!newBodyStatements.Any())
            {
                return(document.Project.Solution);
            }

            var newBody = constructor.Body.WithStatements(newBodyStatements);

            var documentEditor = await DocumentEditor.CreateAsync(document, cancellationToken);

            documentEditor.ReplaceNode(constructor.Body, newBody);
            var newDocument = documentEditor.GetChangedDocument();

            return(await AddMissingUsingsIfNeeded(documentEditor, newDocument, GetRequiredUsingName(fixType), cancellationToken));
        }