Exemplo n.º 1
0
        private static bool EnsureOptions(Options options)
        {
            if (!EnsureDataType(options))
                return false;

            if (options.Source == null)
            {
                var pathMap = new Dictionary<DataType, string>
                {
                    { DataType.Data, @"Data" },
                    { DataType.Skin, @"UI" }
                };
                options.Source = Path.Combine(ConfigurationManager.AppSettings["ContentRoot"], pathMap[options.DataType]);
                logger.Info("Source not specified. Using default '{0}'", options.Source);
            }

            options.Source = Environment.ExpandEnvironmentVariables(options.Source);
            if (!Directory.Exists(options.Source) && !File.Exists(options.Source))
            {
                logger.Error("Invalid source specified '{0}'", options.Source);
                return false;
            }

            if (Directory.Exists(options.Source))
                options.Source = options.Source.EnsureEndsWith(Path.DirectorySeparatorChar);

            logger.Debug("Options: {0}", options.Dump());
            return true;
        }