public static DeployitManifest Load(XDocument xmlData)
        {
            var root = xmlData.Root;

            if (root == null)
            {
                throw new ArgumentException("Manifest has no root node");
            }
            if (root.Name != "udm.DeploymentPackage")
            {
                throw new ArgumentException("invalid root xml node");
            }

            var result = new DeployitManifest
            {
                ApplicationName = root.Attribute("application").ValueOrEmptyIfNull(),
                Version         = root.Attribute("version").ValueOrEmptyIfNull()
            };

            var deployables = root.Element("deployables");

            if (deployables == null)
            {
                return(result);
            }

            foreach (var deployable in deployables.Elements())
            {
                result.Entries.Add(Entry.Load(deployable));
            }

            return(result);
        }
 public ManifestItemViewModel(ManifestEditorViewModel editor, DeployitManifest manifest)
     : base(null)
 {
     if (manifest == null)
         throw new ArgumentNullException("manifest", "manifest is null.");
     if (editor == null)
         throw new ArgumentNullException("editor", "editor is null.");
     _manifest = manifest;
     TreeItemLabel = manifest.ApplicationName;
     _manifest.ApplicationNameChanged += (_, __) => OnApplicationNameChanged();
     _manifest.VersionChanged += (_, __) => OnApplicationVersionChanged();
     _editor = editor;
     IsExpanded = true;
     ItemEditor = new ManifestEditorInfoViewModel(manifest);
     BuildMenuItems();
 }
		public static void Build(DeployitManifest manifest, string packageRootPath,string packagePath)
		{
			using (var z = new ZipFile(System.Text.Encoding.UTF8))
			{
			    var stream = new MemoryStream();
				var writer = new StreamWriter(stream, DeployitManifest.Encoding);
				manifest.Save(writer);
				writer.Flush();
				stream.Seek(0L, SeekOrigin.Begin);
				z.AddEntry(@"deployit-manifest.xml", stream);

				foreach (var entry in manifest.Entries)
				{
				    if (string.IsNullOrEmpty(entry.Path)) {continue;}

                    var formattedPath = FormatPath(entry.Path);
				    var path = Path.Combine(packageRootPath, formattedPath);

                    if (EntryExists(z, formattedPath)) { continue; }

				    if (Directory.Exists(path))
				    {
                        z.AddDirectory(path, formattedPath);
				    }
				    else if (File.Exists(path))
				    {
				        z.AddFile(path, Path.GetDirectoryName(formattedPath));
				    }
				    else
				    {
				        throw new InvalidOperationException(string.Format("Cannot find data in '{0}' for entry '{1}'", path,entry.Name));
                    }
				}
				z.SortEntriesBeforeSaving = false;
				z.ParallelDeflateThreshold = -1;
				z.Save(packagePath);
			}
		}
 private void DoNewManifest()
 {
     var manifest = new DeployitManifest("My application", "1.0");
     SetManifest(manifest);
     _openedManifestFileName = null;
     RaisePropertyChanged(() => Title);
 }
 private void SetManifest(DeployitManifest manifest)
 {
     Manifest = new ManifestEditorViewModel(manifest, _server);
     Manifest.PropertyChanged += ManifestOnPropertyChanged;
 }
        /// <summary>
        /// Initializes a new instance of the ManifestEditorViewModel class.
        /// </summary>
        /// <param name="manifest"></param>
        /// <param name="server"></param>
        public ManifestEditorViewModel(DeployitManifest manifest, IDeployitServer server)
        {
            Manifest = manifest;
            Manifest.ApplicationNameChanged += (_, __) => RaisePropertyChanged(() => ManifestAppName);
            Manifest.VersionChanged += (_, __) => RaisePropertyChanged(() => ManifestVersion);
            Server = server;
            var descriptorsList = server.MetadataService.GetDescriptors();
            AllDescriptors = descriptorsList.ToDictionary(_ => _.Type);
            Descriptors = descriptorsList
                .Where(_ => _.Interfaces.Contains("udm.Deployable") && !_.IsVirtual)
                .ToDictionary(_ => _.Type);

            AvailableDescriptors = (
                from d in Descriptors.Values
                where !d.IsVirtual
                orderby d.Type
                select d
                ).ToList();

            TreeRoots = new List<ManifestItemViewModel> {new ManifestItemViewModel(this, manifest)};
        }
 /// <summary>
 /// Initializes a new instance of the ManifestEditorViewModel class.
 /// </summary>
 /// <param name="manifest"></param>
 public ManifestEditorInfoViewModel(DeployitManifest manifest)
 {
     _manifest = manifest;
     _manifest.ApplicationNameChanged += (_, __) => RaisePropertyChanged(() => ApplicationName);
     _manifest.VersionChanged += (_, __) => RaisePropertyChanged(() => Version);
 }
        public static DeployitManifest Load(XDocument xmlData)
        {
            var root = xmlData.Root;
            if (root == null)
            {
                throw new ArgumentException("Manifest has no root node");
            }
            if (root.Name != "udm.DeploymentPackage")
            {
                throw new ArgumentException("invalid root xml node");
            }

			var result = new DeployitManifest
			    {
			        ApplicationName = root.Attribute("application").ValueOrEmptyIfNull(),
			        Version = root.Attribute("version").ValueOrEmptyIfNull()
			    };

		    var deployables = root.Element("deployables");
		    if (deployables == null) {return result;}

		    foreach (var deployable in deployables.Elements())
		    {
		        result.Entries.Add(Entry.Load(deployable));
		    }

		    return result;
		}