public void Run()
 {
     car.Name = inputService.ReadCar();
     while (true)
     {
         car.Command = ChooseOperation(renderCarCommands, outPutService, inputService);
         renderCarCommands.Execute(car);
         outPutService.Clear();
     }
 }
 public void Run()
 {
     car.Name = inputService.ReadCar(outputService);
     while (true)
     {
         car.Command = inputParse.CommandParser(inputService.ReadCommand(outputService));
         renderCarCommands.Execute(car, this.outputService);
         outputService.Clear();
     }
 }
Example #3
0
        public void WriteBuildInfo(string name, Version version)
        {
            if (options.Set(BuildOptions.ErrorList))
            {
                err.Clear();
            }

            if (options.Set(BuildOptions.Output))
            {
                output.Clear();
                output.WriteLine(OutputFormat.Header, "Build started. File: {0}", doc.Title);
                output.WriteLine(OutputFormat.Important, "Using {0} version {1}.", name, version);
            }
        }
Example #4
0
        //
        public static void PreProcessPendingObjects(KnowledgeBase KB, IOutputService output, List <KBObject> objs)
        {
            FileIniDataParser fileIniData = new FileIniDataParser();

            output.Clear();
            output.SelectOutput("KBDoctor");
            output.StartSection("KBDoctor", "Review_Objects", "Review Objects");


            InitializeIniFile(KB);

            IniData parsedData  = fileIniData.ReadFile(KB.UserDirectory + "\\KBDoctor.ini");
            string  SectionName = "ReviewObject";

            List <KBObject> atts = new List <KBObject>();

            foreach (KBObject obj in objs)
            {
                List <KBObject> objlist = new List <KBObject>();
                objlist.Add(obj);
                if (Utility.isRunable(obj) && !Utility.IsGeneratedByPattern(obj))
                {
                    //Check objects with parameteres without inout
                    if (parsedData[SectionName]["ParamINOUT"].ToLower() == "true")
                    {
                        Objects.ParmWOInOut(objlist, output);
                    }

                    //Clean variables not used
                    if (parsedData[SectionName]["CleanUnusedVariables"].ToLower() == "true")
                    {
                        CleanKB.CleanKBObjectVariables(obj, output);
                    }

                    //Check commit on exit
                    if (parsedData[SectionName]["CheckCommitOnExit"].ToLower() == "true")
                    {
                        Objects.CommitOnExit(objlist, output);
                    }

                    //Is in module
                    if (parsedData[SectionName]["CheckModule"].ToLower() == "true")
                    {
                        Objects.isInModule(objlist, output);
                    }

                    //With variables not based on attributes
                    if (parsedData[SectionName]["VariablesBasedAttOrDomain"].ToLower() == "true")
                    {
                        Objects.ObjectsWithVarNotBasedOnAtt(objlist, output);
                    }

                    //Code commented
                    if (parsedData[SectionName]["CodeCommented"].ToLower() == "true")
                    {
                        Objects.CodeCommented(objlist, output);
                    }

                    //Check complexity metrics
                    //maxNestLevel  6 - ComplexityLevel  30 - MaxCodeBlock  500 - parametersCount  6
                    int maxNestLevel = 7;
                    Int32.TryParse(parsedData[SectionName]["MaxNestLevel"], out maxNestLevel);

                    int complexityLevel = 30;
                    complexityLevel = Int32.Parse(parsedData[SectionName]["MaxComplexity"]);

                    int maxCodeBlock = 500;
                    maxCodeBlock = Int32.Parse(parsedData[SectionName]["MaxBlockSize"]);

                    int maxParametersCount = 6;
                    maxParametersCount = Int32.Parse(parsedData[SectionName]["MaxParameterCount"]);

                    Objects.CheckComplexityMetrics(objlist, output, maxNestLevel, complexityLevel, maxCodeBlock, maxParametersCount);



                    /*
                     * Tiene todas las referencias?
                     * Tiene calls que pueden ser UDP
                     * Mas de un parametro de salida
                     * Constantes en el código
                     * Nombre "poco claro" / Descripcion "poco clara"
                     * Si es modulo, revisar que no tenga objetos publicos no llamados
                     * Si es modulo, revisar que no tenga objetos privados llamados desde fuera
                     * Si es modulo, Valor de la propiedad ObjectVisibility <> Private
                     */
                }
                if (obj is Artech.Genexus.Common.Objects.Attribute && parsedData[SectionName]["AttributeBasedOnDomain"].ToLower() == "true")
                {
                    atts.Add(obj);
                    //Attribute Has Domain
                    Objects.AttributeHasDomain(objlist, output);
                }
                if (obj is SDT && parsedData[SectionName]["SDTBasedAttOrDomain"].ToLower() == "true")
                {
                    //SDTItems Has Domain
                    Objects.SDTBasedOnAttDomain(objlist, output);
                }
            }
            if (atts.Count > 0 && parsedData[SectionName]["AttributeWithoutTable"].ToLower() == "true")
            {
                // Attributes without table
                Objects.AttributeWithoutTable(atts, output);
            }

            output.EndSection("KBDoctor", "Review_Objects", true);
        }
        private async void Build()
        {
            // Abort if a build is already in progress.
            if (_isBusy)
            {
                return;
            }

            var document = _documentService.ActiveDocument as TextDocument;

            if (document == null || document.DocumentType.Name != ShaderDocumentFactory.FxFile)
            {
                return;
            }

            Logger.Debug("Building effect {0}.", document.GetName());

            // Document must be saved to file system before we can build it.
            bool isSaved = !document.IsUntitled && !document.IsModified;

            if (!isSaved)
            {
                isSaved = _documentService.Save(document);
            }

            // Abort if the save operation was canceled.
            if (!isSaved || document.Uri == null)
            {
                Logger.Debug("Document was not saved. Build canceled by user.");
                return;
            }

            // Delete old Error window items.
            _outputService.Clear();
            RemoveErrors(document);

            // Push a new message to the status bar.
            var status = new StatusViewModel
            {
                Message      = "Building effect...",
                ShowProgress = true,
                Progress     = double.NaN,
            };

            _statusService.Show(status);

            // Disable buttons to avoid re-entrance.
            _isBusy = true;
            UpdateCommands();

            int successes  = 0;
            int failures   = 0;
            int exceptions = 0;

            var goToLocationCommand = new DelegateCommand <Error>(GoToLocation);

            if (IsFxcEffectProcessorEnabled)
            {
                try
                {
                    Logger.Info("Building effect using FXC.");
                    _outputService.WriteLine($"----- Build started: {document.GetName()}, Compiler: FXC -----");

                    var result = await BuildFxcAsync(Editor.Services, document, goToLocationCommand);

                    if (result.Item1)
                    {
                        successes++;
                    }
                    else
                    {
                        failures++;
                    }

                    AddErrors(document, result.Item2, result.Item1);
                }
                catch (Exception exception)
                {
                    exceptions++;
                    Logger.Warn(exception, "Build using FXC failed.");
                    _outputService.WriteLine(Invariant($"Exception: {exception.Message}"));
                    _outputService.Show();
                }
            }

            if (IsMonoGameEffectProcessorEnabled)
            {
                try
                {
                    Logger.Info("Building effect using MonoGame.");
                    _outputService.WriteLine($"----- Build started: {document.GetName()}, Compiler: MonoGame -----");

                    var result = await BuildMonoGameAsync(Editor.Services, Editor.ApplicationName, document, goToLocationCommand);

                    if (result.Item1)
                    {
                        successes++;
                    }
                    else
                    {
                        failures++;
                    }

                    AddErrors(document, result.Item2, result.Item1);
                }
                catch (Exception exception)
                {
                    exceptions++;

                    Logger.Warn(exception, "Build using MonoGame failed.");
                    _outputService.WriteLine(Invariant($"Exception: {exception.Message}"));
                    _outputService.Show();
                }
            }

            if (IsXnaEffectProcessorEnabled)
            {
                try
                {
                    Logger.Info("Building effect using XNA.");
                    _outputService.WriteLine($"----- Build started: {document.GetName()}, Compiler: XNA -----");

                    var result = await BuildXnaAsync(Editor.Services, document, goToLocationCommand);

                    if (result.Item1)
                    {
                        successes++;
                    }
                    else
                    {
                        failures++;
                    }

                    AddErrors(document, result.Item2, result.Item1);
                }
                catch (Exception exception)
                {
                    exceptions++;
                    Logger.Warn(exception, "Build using XNA failed.");
                    _outputService.WriteLine(Invariant($"Exception: {exception.Message}"));
                    _outputService.Show();
                }
            }

            _outputService.WriteLine($"========== Build completed: {successes} succeeded, {failures + exceptions} failed ==========");

            if (failures + exceptions == 0)
            {
                status.Progress    = 100;
                status.IsCompleted = true;
            }
            else
            {
                status.Message      = "Build failed.";
                status.ShowProgress = false;
                _outputService.Show();

                if (failures > 0)
                {
                    _errorService?.Show();
                }
            }

            // Enable buttons.
            _isBusy = false;
            UpdateCommands();

            status.CloseAfterDefaultDurationAsync().Forget();
        }