Exemplo n.º 1
0
        public string ProcessCommand(string FileName, string Command)
        {
            FileDetails fileDetails = new FileDetails(FileName);

            if (Array.Exists(Constants.objArrVersion, element => element.Equals(Command)))
            {
                Console.WriteLine("File Version: {0}", fileDetails.Version());
            }
            else if (Array.Exists(Constants.objArrSize, element => element.Equals(Command)))
            {
                Console.WriteLine("File Size: {0}", fileDetails.Size());
            }
            else
            {
                Console.WriteLine("Invalid command parameter.");
            }

            return(String.Empty);
        }
Exemplo n.º 2
0
        public string ProcessCommand(string FileName, string Command)
        {
            FileDetails fileDetails = new FileDetails(FileName);

            string[] arrVersion = new string[] { "-v", "--v", "/v", "--version" };
            string[] arrSize    = new string[] { "-s", "--s", "/s", "--size" };

            if (Array.Exists(arrVersion, element => element.Equals(Command)))
            {
                Console.WriteLine("File Version: {0}", fileDetails.Version());
            }
            else if (Array.Exists(arrSize, element => element.Equals(Command)))
            {
                Console.WriteLine("File Size: {0}", fileDetails.Size());
            }
            else
            {
                Console.WriteLine("Invalid command parameter.");
            }

            return(String.Empty);
        }
Exemplo n.º 3
0
        public FileInfo GetFileDetails(string[] args)
        {
            string[]          versionSpecs = new string[] { "-v", "--v", "/v", "-version" };
            string[]          sizeSpecs    = new string[] { "-s", "--s", "/s", "-size" };
            FileSpecification myFileSpec   = new FileSpecification();

            for (int i = 0; i < args.Count(); i++)
            {
                switch (i)
                {
                case 0:
                    foreach (string verSpec in versionSpecs)
                    {
                        if (args[0].Contains(verSpec))
                        {
                            myFileSpec.IsVersionRequired = true;
                            break;
                        }
                    }
                    break;

                case 1:
                    foreach (string sizeSpec in sizeSpecs)
                    {
                        if (args[1].Contains(sizeSpec))
                        {
                            myFileSpec.IsSizeRequired = true;
                            break;
                        }
                    }
                    break;
                }
            }

            FileDetails fileDetails = new FileDetails(myFileSpec);

            return(fileDetails.GetFileInfo());
        }