Ejemplo n.º 1
0
        public string ReplacePathVariables(string Pattern, PackageProject Project, PackageVersion Version)
        {
            ComponentProjectTarget sampleTarget = Project.Components.First().Targets.First();

            var replacements = new Dictionary<string, string>
                               {
                                   { "{version-major}", Version.Major.ToString(CultureInfo.InvariantCulture) },
                                   { "{version-minor}", Version.Minor.ToString(CultureInfo.InvariantCulture) },
                                   { "{version-label}", Version.Label },
                                   { "{release-date}", Version.ReleaseDate.ToString("yyyy.MM.dd") },
                                   { "{version}", CombineVersion(Version) },
                                   { "{cell}", _indexHelper.GetCellName(sampleTarget.Cell) },
                                   { "{module}", _indexHelper.GetModuleName(sampleTarget.Cell, sampleTarget.Module) },
                                   { "{modification}", _indexHelper.GetModificationName(sampleTarget.Cell, sampleTarget.Modification) },
                               };

            var sb = new StringBuilder(Pattern);
            foreach (var replacement in replacements)
            {
                string value = replacement.Value == null
                                   ? string.Empty
                                   : Path.GetInvalidFileNameChars()
                                         .Aggregate(replacement.Value, (current, invalidChar) => current.Replace(invalidChar, ' '));

                sb.Replace(replacement.Key, value);
            }
            return sb.ToString();
        }
Ejemplo n.º 2
0
 public void SavePackage(PackageProject Model, PackageVersion Version, [NotNull] string FileName, string RootDirectory)
 {
     string directoryName = Path.GetDirectoryName(FileName);
     if (directoryName != null)
         Directory.CreateDirectory(directoryName);
     _enpacker.Enpack(Model, Version, RootDirectory).Save(FileName);
 }
 public ProjectViewModel GetInstance(PackageProject Project, string ProjectFileName, string RootDirectory, ILoadProjectService LoadProjectService)
 {
     List<TargetViewModel> targets = Project.Components.SelectMany(c =>
                                                                   c.Targets.Select(t => new TargetViewModel(_indexHelper.GetCellName(t.Cell),
                                                                                                             _indexHelper.GetModuleName(t.Cell, t.Module))))
                                            .Distinct(TargetViewModel.Comparer)
                                            .ToList();
     string name = Path.GetFileName(ProjectFileName);
     return new ProjectViewModel(Project, name, ProjectFileName, RootDirectory, targets, LoadProjectService, _eventAggregator);
 }
Ejemplo n.º 4
0
 public void SavePackage(PackageProject PackageProject, PackageVersion PackageVersion,
                         string ProjectRoot)
 {
     string defaultFileName = _variablesProcessor.ReplacePathVariables(_launchParameters.OutputFileName ?? "{cell} ver. {version}.sfp",
                                                                   PackageProject, PackageVersion);
     SaveFileRequest.Raise(new SaveFileInteractionContext(new SaveFileRequestArguments(_savingTool.FileExtension,
                                                                                       new FileRequestArguments.FileTypeDescription(
                                                                                           _savingTool.FileExtension, "Файл пакета прошивок"))
                                                          {
                                                              DefaultFileName = defaultFileName
                                                          }),
                           c => SavePackage(c.FileName, PackageProject, PackageVersion, ProjectRoot));
 }
Ejemplo n.º 5
0
 public ProjectViewModel(PackageProject Project, string Name, string FilePath,
                         string ProjectRoot, ICollection<TargetViewModel> Targets, ILoadProjectService LoadProjectService, IEventAggregator EventAggregator)
 {
     _loadProjectService = LoadProjectService;
     _eventAggregator = EventAggregator;
     this.Name = Name;
     _project = Project;
     this.FilePath = FilePath;
     this.Targets = Targets;
     this.ProjectRoot = ProjectRoot;
     LoadProjectCommand = new DelegateCommand(LoadProject);
     OpenFileRequest = new InteractionRequest<OpenFileInteractionContext>();
 }
Ejemplo n.º 6
0
 public FirmwarePackage Enpack(PackageProject Project, PackageVersion Version, string RootDirectory)
 {
     return new FirmwarePackage
            {
                Components = Project.Components
                                    .Select(componentProject =>
                                            new FirmwareComponent(
                                                componentProject.Targets.Select(
                                                    t => new ComponentTarget(t.Cell, t.Modification, t.Channel, t.Module)).ToList(),
                                                componentProject.FileMaps
                                                                .SelectMany(fm => fm.EnumerateFiles(RootDirectory))
                                                                .Select(f => new FirmwareFile(f.Name, f.Content))
                                                                .ToList())
                                            {
                                                BootloaderRequirement =
                                                    new BootloaderRequirement(componentProject.BootloaderRequirement.BootloaderId,
                                                                              new VersionRequirements(
                                                                                  componentProject.BootloaderRequirement.CompatibleVersion,
                                                                                  componentProject.BootloaderRequirement.Version))
                                            })
                                    .ToList(),
                Information = new PackageInformation(new Version(Version.Major, Version.Minor), Version.Label, Version.ReleaseDate)
            };
 }
Ejemplo n.º 7
0
 private void SavePackage(string FileName, PackageProject PackageProject, PackageVersion PackageVersion, string ProjectRoot)
 {
     if (FileName == null) return;
     _savingTool.SavePackage(PackageProject, PackageVersion, FileName, ProjectRoot);
 }