public static AppcastViewModel Deserialize(TextReader reader, DirectoryInfo baseFolder)
		{
			var root = XElement.Load(reader);

			var result = new AppcastViewModel
							{
								//ApplicationName = root.Element(ChannelNode).Element(TitleNode).Value,
								Description = root.Element(ChannelNode).Element(DescriptionNode).Value,
								Language = root.Element(ChannelNode).Element(LanguageNode).Value,
								AppcastLink = root.Element(ChannelNode).Element(LinkNode).Value,
							};
			result.AppcastItems =
				new ObservableCollection<AppcastItemViewModel>(
					(from appcastItem in root.Element(ChannelNode).Elements(ItemNode)
					 select AppcastItemViewModel.Deserialize(result, appcastItem, baseFolder)));
			var val = Utility.GetXElementValue(root.Element(ChannelNode), AppcastNameNode);
			if (!string.IsNullOrEmpty(val))
			{
				result.AppcastName = val;
			}
			val = Utility.GetXElementValue(root.Element(ChannelNode), ApplicationNameNode);
			if (!string.IsNullOrEmpty(val))
			{
				result.ApplicationName = val;
			}
			val = Utility.GetXElementValue(root.Element(ChannelNode), LastUpdatedNode);
			if (!string.IsNullOrEmpty(val))
			{
				result.LastUpdated = DateTime.Parse(val);
			}
			val = Utility.GetXElementValue(root.Element(ChannelNode), AppcastBaseAddressNode);
			if (!string.IsNullOrEmpty(val))
			{
				result.AppcastBaseAddress = val;
			}
			return result;
		}
		private void CopyFrom(AppcastViewModel obj)
		{
			OutputPath = obj.OutputPath;
			ApplicationName = obj.ApplicationName;
			AppcastName = obj.AppcastName;
			Description = obj.Description;
			AppcastLink = obj.AppcastLink;
			LastUpdated = obj.LastUpdated;
			//AppTitle = obj.AppTitle;
			AppcastBaseAddress = obj.AppcastBaseAddress;
			Language = obj.Language;
			AppcastItems = new ObservableCollection<AppcastItemViewModel>();
			foreach (var appcastItem in obj.AppcastItems)
			{
				appcastItem.PropertyChanged += PropertyChangeTracking;
				AppcastItems.Add(appcastItem);
			}
			AcceptChanges();
		}
Beispiel #3
0
		static int Main(string[] args)
		{
			Constants.SetApplicationName("Appcast");
#if TESTING
			var testargs = new List<string>
			               	{
			               		"-i",
			               		@"C:\code\tubeCentric.root\amazon tools.root\Amazon SES\TenCentMail.Setup\bin\Release\en-us\TenCentMail.msi",
			               		
								"-o",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\appcast2.xml",
			               		
								"-r",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\releasenotes.0.2.txt",
			               		
								"-k",
			               		@"C:\Users\curtis\Documents\CarverLab\TenCentMail\NetSparkle_DSA.priv",
			               	};
			args = testargs.ToArray();
#endif

			var config = new Config(args);

			if (args.Length == 0)
			{
				config.ShowHelp();
				return 1;
			}
			try
			{
				config.Parse();
			}
			catch (Exception exception)
			{
				System.Console.WriteLine(exception);
				return 200;
			}

			config.Logo(System.Console.Error);

			var bootstrapper = new SimpleBootstrapper();
			bootstrapper.Run();
			var appcast = new AppcastViewModel();

			string did;
			if (config.OutputPath.Exists && !config.Overwrite)
			{
				appcast.Load(config.OutputPath.FullName);
				did = "Updated";
			}
			else
			{
				appcast.AppcastBaseAddress = config.AppcastBaseAddress;
				appcast.AppcastName = config.AppcastName;
				appcast.ApplicationName = config.ApplicationName;
				appcast.Description = config.Description;
				appcast.Language = config.Language;
				appcast.OutputPath = config.OutputPath;
				var link = new Uri(config.AppcastBaseAddress);
				appcast.AppcastLink = string.Format("{0}/{1}/{2}", link.AbsolutePath, appcast.ApplicationName, appcast.AppcastName);
				did = "Created";
			}

			string releaseNotesPath = null;
			if (config.ReleaseNotesPath != null)
			{
				releaseNotesPath = config.ReleaseNotesPath.FullName;
			}
			if (string.IsNullOrEmpty(appcast.AppcastName) && !string.IsNullOrEmpty(config.AppcastName))
			{
				appcast.AppcastName = config.AppcastName;
			}
			if (string.IsNullOrEmpty(appcast.ApplicationName) && !string.IsNullOrEmpty(config.ApplicationName))
			{
				appcast.ApplicationName = config.ApplicationName;
			}
			if (string.IsNullOrEmpty(appcast.AppcastBaseAddress) && !string.IsNullOrEmpty(config.AppcastBaseAddress))
			{
				appcast.AppcastBaseAddress = config.AppcastBaseAddress;
			}
			var item = new AppcastItemViewModel(appcast, config.InputPath.FullName, releaseNotesPath, config.PrivateKeyPath.FullName);
			appcast.AppcastItems.Add(item);

			appcast.Save(appcast.OutputPath.FullName);
			//Environment.SetEnvironmentVariable("AppcastAppVersion", item.Version.ToString(3), EnvironmentVariableTarget.Machine);
			File.WriteAllText("appcastappversion.txt", item.Version.ToString(3));

			System.Console.WriteLine(@"{0} {1}", did, appcast.OutputPath);
			return 0;
		}