Inheritance: IPackageMetadata, IDataErrorInfo, INotifyPropertyChanged
        internal bool SaveMetadataAfterEditSource(string editedFilePath)
        {
            if (!File.Exists(editedFilePath))
            {
                return(true);
            }

            using (Stream metadataFileStream = File.OpenRead(editedFilePath))
            {
                try
                {
                    using (var str = ManifestUtility.ReadManifest(metadataFileStream))
                    {
                        Manifest manifest    = Manifest.ReadFrom(str, true);
                        var      newMetadata = new EditablePackageMetadata(manifest.Metadata, _uiServices);
                        PackageMetadata = newMetadata;

                        return(true);
                    }
                }
                catch (Exception exception)
                {
                    bool confirmExit = UIServices.ConfirmCloseEditor(
                        "There is an error in the metadata source.",
                        exception.GetBaseException().Message +
                        Environment.NewLine +
                        Environment.NewLine +
                        "Do you want to cancel your changes and return?");

                    return(confirmExit);
                }
            }
        }
Exemplo n.º 2
0
        internal PackageViewModel(
            IPackage package,
            string source,
            IMruManager mruManager,
            IUIServices uiServices,
            IPackageEditorService editorService,
            ISettingsManager settingsManager,
            CredentialPublishProvider credentialPublishProvider,
            IList <Lazy <IPackageContentViewer, IPackageContentViewerMetadata> > contentViewerMetadata,
            IList <Lazy <IPackageRule> > packageRules)
        {
            _settingsManager           = settingsManager ?? throw new ArgumentNullException(nameof(settingsManager));
            _editorService             = editorService ?? throw new ArgumentNullException(nameof(editorService));
            _uiServices                = uiServices ?? throw new ArgumentNullException(nameof(uiServices));
            _mruManager                = mruManager ?? throw new ArgumentNullException(nameof(mruManager));
            _credentialPublishProvider = credentialPublishProvider ?? throw new ArgumentNullException(nameof(credentialPublishProvider));
            _package = package ?? throw new ArgumentNullException(nameof(package));
            _contentViewerMetadata = contentViewerMetadata;
            _packageRules          = packageRules;

            _packageMetadata = new EditablePackageMetadata(_package, _uiServices);

            PackageSource = source;

            _isSigned = _packageMetadata.IsSigned;

            _packageRoot = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);
        }
Exemplo n.º 3
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        internal PackageViewModel(
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
            IPackage package,
            string path,
            string source,
            IMruManager mruManager,
            IUIServices uiServices,
            IPackageEditorService editorService,
            ISettingsManager settingsManager,
            CredentialPublishProvider credentialPublishProvider,
            IList <Lazy <IPackageContentViewer, IPackageContentViewerMetadata> > contentViewerMetadata,
            IList <Lazy <IPackageRule> > packageRules)
        {
            SettingsManager            = settingsManager ?? throw new ArgumentNullException(nameof(settingsManager));
            _editorService             = editorService ?? throw new ArgumentNullException(nameof(editorService));
            UIServices                 = uiServices ?? throw new ArgumentNullException(nameof(uiServices));
            _mruManager                = mruManager ?? throw new ArgumentNullException(nameof(mruManager));
            _credentialPublishProvider = credentialPublishProvider ?? throw new ArgumentNullException(nameof(credentialPublishProvider));
            _package = package ?? throw new ArgumentNullException(nameof(package));
            ContentViewerMetadata = contentViewerMetadata;
            _packageRules         = packageRules;

            _packageMetadata = new EditablePackageMetadata(_package, UIServices);

            PackagePath   = path;
            PackageSource = source;

            _isSigned = _packageMetadata.IsSigned;

            RootFolder = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);
        }
Exemplo n.º 4
0
        internal PackageViewModel(
            IPackage package,
            string source,
            IMruManager mruManager,
            IUIServices uiServices,
            IPackageEditorService editorService,
            ISettingsManager settingsManager)
        {
            if (package == null) {
                throw new ArgumentNullException("package");
            }
            if (mruManager == null) {
                throw new ArgumentNullException("mruManager");
            }
            if (uiServices == null) {
                throw new ArgumentNullException("uiServices");
            }
            if (editorService == null) {
                throw new ArgumentNullException("editorService");
            }
            if (settingsManager == null) {
                throw new ArgumentNullException("settingsManager");
            }

            _settingsManager = settingsManager;
            _editorService = editorService;
            _uiServices = uiServices;
            _mruManager = mruManager;
            _package = package;
            _packageMetadata = new EditablePackageMetadata(_package);
            PackageSource = source;

            _packageRoot = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);
        }
        internal PackageViewModel(
            IPackage package,
            string source,
            IMruManager mruManager,
            IUIServices uiServices,
            IPackageEditorService editorService,
            ISettingsManager settingsManager,
            IList <Lazy <IPackageContentViewer, IPackageContentViewerMetadata> > contentViewerMetadata,
            IList <Lazy <IPackageRule> > packageRules)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            if (mruManager == null)
            {
                throw new ArgumentNullException("mruManager");
            }
            if (uiServices == null)
            {
                throw new ArgumentNullException("uiServices");
            }
            if (editorService == null)
            {
                throw new ArgumentNullException("editorService");
            }
            if (settingsManager == null)
            {
                throw new ArgumentNullException("settingsManager");
            }

            _settingsManager       = settingsManager;
            _editorService         = editorService;
            _uiServices            = uiServices;
            _mruManager            = mruManager;
            _package               = package;
            _contentViewerMetadata = contentViewerMetadata;
            _packageRules          = packageRules;

            _packageMetadata = new EditablePackageMetadata(_package);

            PackageSource = source;

            _packageRoot = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);

            // HACK: this is after the package.GetFiles() since that reads the signature
            _packageMetadata.PublisherCertificate = _package.PublisherCertificate;
        }
        internal PackageViewModel(
            IPackage package,
            string source,
            IMruManager mruManager,
            IUIServices uiServices,
            IPackageEditorService editorService,
            ISettingsManager settingsManager,
            IList <Lazy <IPackageContentViewer, IPackageContentViewerMetadata> > contentViewerMetadata,
            IList <Lazy <IPackageRule> > packageRules)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            if (mruManager == null)
            {
                throw new ArgumentNullException("mruManager");
            }
            if (uiServices == null)
            {
                throw new ArgumentNullException("uiServices");
            }
            if (editorService == null)
            {
                throw new ArgumentNullException("editorService");
            }
            if (settingsManager == null)
            {
                throw new ArgumentNullException("settingsManager");
            }

            _settingsManager       = settingsManager;
            _editorService         = editorService;
            _uiServices            = uiServices;
            _mruManager            = mruManager;
            _package               = package;
            _contentViewerMetadata = contentViewerMetadata;
            _packageRules          = packageRules;

            _packageMetadata = new EditablePackageMetadata(_package, _uiServices);

            PackageSource = source;
            _isSigned     = package.IsSigned;

            _packageRoot = PathToTreeConverter.Convert(_package.GetFiles().ToList(), this);
        }
        internal bool SaveMetadataAfterEditSource(string editedFilePath)
        {
            if (!File.Exists(editedFilePath))
            {
                return true;
            }

            using (Stream metadataFileStream = File.OpenRead(editedFilePath))
            {
                try
                {
                    Manifest manifest = Manifest.ReadFrom(metadataFileStream);
                    var newMetadata = new EditablePackageMetadata(manifest.Metadata);
                    PackageMetadata = newMetadata;

                    return true;
                }
                catch (Exception exception)
                {
                    bool confirmExit = UIServices.ConfirmCloseEditor(
                        "There is an error in the metadata source.",
                        exception.GetBaseException().Message +
                        Environment.NewLine +
                        Environment.NewLine +
                        "Do you want to cancel your changes and return?");

                    return confirmExit;
                }
            }
        }