Esempio n. 1
0
        public static int Main(string[] args)
        {
            Serializer.Setup();

            // Determine what operation to perform.
            INapackOperation operation = NapackOperationFinder.FindOperation(args);

            if (operation == null)
            {
                NapackOperationFinder.WriteGeneralUsageToConsole();
                return(ERROR);
            }

            try
            {
                operation.PerformOperation();
            }
            catch (Exception ex)
            {
                NapackClient.Log(ex.Message);
                return(ERROR);
            }

            return(SUCCESS);
        }
Esempio n. 2
0
        public static INapackOperation FindOperation(string[] args)
        {
            foreach (Type operationType in NapackOperationFinder.KnownOperations)
            {
                CommandLineParser parser = new CommandLineParser(operationType);
                try
                {
                    INapackOperation operation = parser.Parse(args) as INapackOperation;
                    if (operation.IsValidOperation())
                    {
                        // This check is performed because there's the potential for two operations to have identical arguments, but be different.
                        return(operation);
                    }
                }
                catch { }
            }

            return(null);
        }