Esempio n. 1
0
        public TagDTO Get(string title)
        {
            Tag tag;

            using (var context = new AcknowledgementsTrackerContext())
            {
                context.Database.Log = message => Debug.WriteLine(message);
                tag = context.Tags
                      .Where(t => t.Title == title)
                      .FirstOrDefault();
            }

            return(assembler.Assemble(tag));
        }
        public bool Build(IProject project)
        {
            AssemblerOutput output;

            using (IAssembler assembler = _assemblerFactory.CreateAssembler())
            {
                AssemblerHelper.SetupAssembler(assembler, _inputFile, _outputFile, project.ProjectDirectory,
                                               project.IncludeDirs);

                string outputString;
                switch (_stepType)
                {
                case BuildStepType.All:
                    outputString =
                        assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.SymbolTable | AssemblyFlags.List);
                    output = new AssemblerOutput(outputString,
                                                 !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ProjectOutput = _outputFile;
                    project.BuildSystem.ListOutput    = _outputFile.ChangeExtension("lst");
                    project.BuildSystem.LabelOutput   = _outputFile.ChangeExtension("lab");
                    break;

                case BuildStepType.Assemble:
                    outputString = assembler.Assemble(AssemblyFlags.Normal);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ProjectOutput = _outputFile;
                    break;

                case BuildStepType.Listing:
                    outputString = assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.List);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ListOutput = _outputFile.ChangeExtension("lst");
                    break;

                case BuildStepType.SymbolTable:
                    outputString = assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.SymbolTable);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.LabelOutput = _outputFile.ChangeExtension("lab");
                    break;

                default:
                    throw new InvalidOperationException("Unknown step type");
                }
            }
            _outputText = output.OutputText;
            return(output.Succeeded);
        }
Esempio n. 3
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Returns a new instance of a concrete subtype of <typeparamref name="TObject"/>, described by the matching configuration object
        /// of a concrete subtype of <typeparamref name="TConfiguration"/> in <paramref name="objectConfiguration"/>.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A new instance of the appropriate subtype of <typeparamref name="Tobject"/>.</returns>
        public virtual TObject Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            IAssembler <TObject, TConfiguration> assembler = GetAssembler(objectConfiguration);
            TObject createdObject = assembler.Assemble(context, objectConfiguration, configurationSource, reflectionCache);

            return(createdObject);
        }
        public void Configure_From_Type()
        {
            Configuration cfg = new Configuration();

            cfg.AddType(typeof(AttributedUserDTO));

            IAssembler <AttributedUserDTO, User> asm = cfg.GetAssembler <AttributedUserDTO, User>();
            AttributedUserDTO dto = asm.AssembleFrom(m_user);

            Assert.AreEqual(dto.Id, m_user.Id);
            Assert.AreEqual(dto.Age, m_user.Age);
            Assert.AreEqual(dto.UserName, m_user.UserName.ToUpper());
            Assert.AreEqual(dto.ProjectCount, m_user.Projects.Count);
            Assert.AreEqual(dto.FullName, m_user.FirstName + " " + m_user.LastName);
            Assert.AreEqual(dto.Gender, Gender.Male);
            Assert.AreEqual(dto.GenderCode, "M");


            AttributedUserDTO dto2 = new AttributedUserDTO();

            asm.Assemble(ref dto2, ref m_user);

            Assert.AreEqual(dto2.Id, m_user.Id);
            Assert.AreEqual(dto2.Age, m_user.Age);
            Assert.AreEqual(dto2.UserName, m_user.UserName.ToUpper());
            Assert.AreEqual(dto2.ProjectCount, m_user.Projects.Count);
        }
Esempio n. 5
0
        public Program AssembleExecutable(string fileName, byte[] image, IAssembler asm, IPlatform platform, Address addrLoad)
        {
            var program = asm.Assemble(addrLoad, new StreamReader(new MemoryStream(image), Encoding.UTF8));

            program.Name     = Path.GetFileName(fileName);
            program.Platform = platform;
            foreach (var sym in asm.ImageSymbols)
            {
                program.ImageSymbols[sym.Address !] = sym;
Esempio n. 6
0
        public Program AssembleExecutable(ImageLocation asmFileLocation, byte[] image, IAssembler asm, IPlatform platform, Address addrLoad)
        {
            var program = asm.Assemble(addrLoad, new StreamReader(new MemoryStream(image), Encoding.UTF8));

            program.Name     = asmFileLocation.GetFilename();
            program.Location = asmFileLocation;
            program.Platform = platform;
            foreach (var sym in asm.ImageSymbols)
            {
                program.ImageSymbols[sym.Address !] = sym;
Esempio n. 7
0
        public AcknowledgementDTO Get(int id)
        {
            using (var context = new AcknowledgementsTrackerContext())
            {
                context.Database.Log = message => Debug.WriteLine(message);
                var acknowledgement = context.Acknowledgements.Find(id);

                return(acknowledgementsAssembler.Assemble(acknowledgement));
            }
        }
Esempio n. 8
0
 protected void DoRewriteFile(string relativePath)
 {
     using (var stm = new StreamReader(FileUnitTester.MapTestPath(relativePath)))
     {
         var lr = asm.Assemble(baseAddress, stm);
         program.SegmentMap = lr.SegmentMap;
         program.ImageMap   = lr.ImageMap;
         program.Platform   = lr.Platform ?? new MsdosPlatform(sc, lr.Architecture);
     }
     DoRewriteCore();
 }
Esempio n. 9
0
        public async Task <IResult <SubtaskModel> > GetTask(Guid taskId)
        {
            if (taskId == Guid.Empty)
            {
                _logger.LogWarning("Sub-task ID cannot be empty");
                return(Result.BadRequest <SubtaskModel>($"Sub-task ID cannot be empty"));
            }

            var job = await _dbContext.Tasks
                      .AsNoTracking()
                      .SingleOrDefaultAsync(x => x.TaskId == taskId);

            return(job == null
                ? Result.NotFound <SubtaskModel>($"Sub-task not found with ID {taskId}")
                : Result.Ok(_taskAssembler.Assemble(job)));
        }
Esempio n. 10
0
        public async Task <IResult <JobModel> > GetJob(Guid jobId)
        {
            if (jobId == Guid.Empty)
            {
                _logger.LogWarning("Job ID cannot be empty");
                return(Result.BadRequest <JobModel>($"Job ID cannot be empty"));
            }

            var job = await _dbContext.Jobs
                      .AsNoTracking()
                      .SingleOrDefaultAsync(x => x.JobId == jobId);

            // TODO: Add the SubtaskSummaryModel to the query and JobModel

            return(job == null
                ? Result.NotFound <JobModel>($"Job not found with ID {jobId}")
                : Result.Ok(_jobAssembler.Assemble(job)));
        }
        public AssemblerOutput AssembleFile(FilePath inputFile, FilePath outputFile, FilePath originalDir,
                                            IEnumerable <FilePath> includeDirs, AssemblyFlags flags = AssemblyFlags.Normal)
        {
            IAssembler assembler = _assemblerFactory.CreateAssembler();

            AssemblerHelper.SetupAssembler(assembler, inputFile, outputFile, originalDir, includeDirs);
            string rawOutput = assembler.Assemble(flags);

            // lets write it to the output window so the user knows whats happening
            string outputText = string.Format(OutputFormatting, Path.GetFileName(inputFile), inputFile, rawOutput);

            bool errors = outputText.Contains("error");

            OnAssemblerFileFinished(this, new AssemblyFinishFileEventArgs(inputFile, outputFile, outputText, !errors));

            // tell if the assembly was successful
            return(new AssemblerOutput(outputText, !errors));
        }
Esempio n. 12
0
        public Program AssembleExecutable(string fileName, byte[] image, IAssembler asm, IPlatform platform, Address addrLoad)
        {
            var program = asm.Assemble(addrLoad, new StreamReader(new MemoryStream(image), Encoding.UTF8));

            program.Name     = Path.GetFileName(fileName);
            program.Platform = platform;
            foreach (var sym in asm.ImageSymbols)
            {
                program.ImageSymbols[sym.Address] = sym;
            }
            foreach (var ep in asm.EntryPoints)
            {
                program.EntryPoints[ep.Address] = ep;
            }
            program.EntryPoints[asm.StartAddress] =
                ImageSymbol.Procedure(program.Architecture, asm.StartAddress);
            CopyImportReferences(asm.ImportReferences, program);
            return(program);
        }
        private void ParseLine()
        {
            string output = _assembler.Assemble(_currentLine, AssemblyFlags.Normal);

            _currentLine = string.Empty;

            Match match = Regex.Match(output, "Pass one... \r\nPass two... \r\n(?<value>.*\r\n)*Done\r\nAssembly time: .* seconds\r\n",
                                      RegexOptions.Compiled | RegexOptions.Singleline);

            if (match.Success)
            {
                string filteredOutput = match.Groups["value"].Value;
                DisplayOutput(filteredOutput);
                DisplayLineStart();
            }
            else
            {
                DisplayOutput("Error in input");
                DisplayLineStart();
            }
        }
Esempio n. 14
0
        public CodeCountInfo CountCode(string lines)
        {
            int size;
            int min;
            int max;

            string outputLines = null;

            using (IAssembler assembler = _assemblerFactory.CreateAssembler())
            {
                if (!string.IsNullOrEmpty(lines))
                {
                    outputLines = assembler.Assemble(lines, AssemblyFlags.CodeCounter | AssemblyFlags.Commandline);
                }
            }

            if (string.IsNullOrEmpty(outputLines))
            {
                return(new CodeCountInfo(0, 0, 0));
            }

            Match match = Regex.Match(outputLines, @"Size: (?<size>\d+)\s*Min. execution time: (?<min>\d+)\s*Max. execution time: (?<max>\d+)");

            if (!int.TryParse(match.Groups["size"].Value, out size))
            {
                size = 0;
            }

            if (!int.TryParse(match.Groups["min"].Value, out min))
            {
                min = 0;
            }

            if (!int.TryParse(match.Groups["max"].Value, out max))
            {
                max = 0;
            }
            return(new CodeCountInfo(size, min, max));
        }
Esempio n. 15
0
        //[Test]
        public void ComparePerformance()
        {
            User user = Helpers.CreateComplexUser();

            // add more tasks
            user.Projects[0].Tasks.Add(new Task(5));
            user.Projects[0].Tasks.Add(new Task(4));
            user.Projects[0].Tasks.Add(new Task(2));
            user.Projects[0].Tasks.Add(new Task(6));
            user.Projects[0].Tasks.Add(new Task(4));
            user.Projects[0].Tasks.Add(new Task(2));

            user.Projects[1].Tasks.Add(new Task(3));
            user.Projects[1].Tasks.Add(new Task(4));
            user.Projects[1].Tasks.Add(new Task(5));
            user.Projects[1].Tasks.Add(new Task(1));
            user.Projects[1].Tasks.Add(new Task(4));

            user.Projects[0].Tasks.Add(new Task(5));
            user.Projects[0].Tasks.Add(new Task(4));
            user.Projects[0].Tasks.Add(new Task(2));
            user.Projects[0].Tasks.Add(new Task(6));
            user.Projects[0].Tasks.Add(new Task(4));
            user.Projects[0].Tasks.Add(new Task(2));

            user.Projects[1].Tasks.Add(new Task(3));
            user.Projects[1].Tasks.Add(new Task(4));
            user.Projects[1].Tasks.Add(new Task(5));
            user.Projects[1].Tasks.Add(new Task(1));
            user.Projects[1].Tasks.Add(new Task(4));


            UserDTO dto = new UserDTO();

            Configuration cfg;

            cfg = new Configuration();
            cfg.AddType(typeof(UserDTO));
            cfg.AddType(typeof(ProjectDTO));          // todo: should this be automatically detected
            cfg.AddType(typeof(DocumentDTO));         // todo: should this be automatically detected
            cfg.AddType(typeof(TaskDTO));             // todo: should this be automatically detected

            cfg.BuildAssemblers();
            IAssembler <UserDTO, User> assembler = cfg.GetAssembler <UserDTO, User>();

            assembler.Assemble(ref dto, ref user);             // run it once

            long time = Environment.TickCount;

            for (int i = 0; i < ITER_COUNT; i++)
            {
                assembler.Assemble(ref dto, ref user);
            }
            long time1 = Environment.TickCount - time;

            Console.Out.WriteLine("Generated assembler timing = {0}", time1);

            Assemble(dto, user);             // run it once
            time = Environment.TickCount;
            for (int i = 0; i < ITER_COUNT; i++)
            {
                Assemble(dto, user);
            }
            long time2 = Environment.TickCount - time;

            Console.Out.WriteLine("Manual assembler timing = {0}", time2);
            Console.Out.WriteLine("Ratio = {0}", time1 / (double)time2);
        }
Esempio n. 16
0
 public static T AssembleItem <T>(this IAssembler <T> assembler, MappedData data) where T : class
 {
     return(assembler.Assemble(data).FirstOrDefault());
 }
 public TTgt Map(TSrc source)
 {
     return(_assembler.Assemble(source, _mappingAction));
 }