Exemplo n.º 1
0
		static void Main(string[] args)
		{
			LogManager.LogFactory = new ConsoleLogFactory();
			var log = LogManager.GetLogger(typeof(Program));

			var useConsoleHost = args.Length > 0 ? args[0].Equals("-console-host") : false;
			var useJson = !useConsoleHost && args.Length > 0 ? args[0].Equals("-json") : false;

			var viewRemotePath = args.Length > 1 ? args[1] : "/Server";

			log.InfoFormat("Usage: [-json|-console-host|-xml] /remote/path\n");

			log.InfoFormat("Viewing {0} GetDirectoryInfo on '{1}' using '{2}'\n", 
				useConsoleHost ? "ConsoleService" : "WebService", viewRemotePath, useJson ? "JSON" : "XML");

			using (var serviceClient = GetServiceClient(useConsoleHost, useJson))
			{
				var request = new GetDirectoryInfo { ForPath = viewRemotePath };
				var response = serviceClient.Send<GetDirectoryInfoResponse>(request);

				foreach (var dir in response.Directories)
				{
					log.InfoFormat("/{0} \t   ({1})", dir.Name.PadRight(45, ' '), dir.FileCount.ToString());
				}

				foreach (var file in response.Files)
				{
					log.InfoFormat(" + {0} \t{1} bytes", file.Name.PadRight(45, ' '), file.FileSizeBytes.ToString().PadLeft(6,' '));
				}
			}

		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var directoryNames = (this.CurrentPath ?? string.Empty).Split('/');
            var path = directoryNames.Length > 0
                ? directoryNames[directoryNames.Length - 1].Trim() : null;

            Title = !string.IsNullOrEmpty(path) ? path : "/";

            var request = new GetDirectoryInfo { ForPath = this.CurrentPath };
            var response = AppConfig.ServiceClient.Send<GetDirectoryInfoResponse> (request);

            this.Items = new List<object>();
            response.Directories.ForEach(x => this.Items.Add(x));
            response.Files.ForEach(x => this.Items.Add(x));

            TableView.Delegate = new TableDelegate (this);
            TableView.DataSource = new DataSource (this);
        }