Example #1
0
        static void CheckArgs(ArgsParsed arg)
        {
            arg.ErrorMessage = string.Empty;

            if (arg.action == Action.Upload)
            {
                if (string.IsNullOrEmpty(arg.FileName) &&
                    string.IsNullOrEmpty(arg.StorageAccountName) &&
                    string.IsNullOrEmpty(arg.StorageAccountKey) &&
                    string.IsNullOrEmpty(arg.BlobName) &&
                    string.IsNullOrEmpty(arg.ContainerName))
                {
                    arg.ErrorMessage = string.Empty;
                }
                else
                {
                    arg.ErrorMessage = "Missing argument for uplaod scenario";
                }
            }
            else if (arg.action == Action.Download)
            {
                if (string.IsNullOrEmpty(arg.FileName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountKey) &&
                    string.IsNullOrEmpty(arg.SourceBlobName) &&
                    string.IsNullOrEmpty(arg.SourceContainerName))
                {
                    arg.ErrorMessage = string.Empty;
                }
                else
                {
                    arg.ErrorMessage = "Missing argument for downlaod scenario";
                }
            }
            else if (arg.action == Action.Copy)
            {
                if (string.IsNullOrEmpty(arg.SourceStorageAccountName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountKey) &&
                    string.IsNullOrEmpty(arg.SourceBlobName) &&
                    string.IsNullOrEmpty(arg.SourceContainerName) &&
                    string.IsNullOrEmpty(arg.StorageAccountName) &&
                    string.IsNullOrEmpty(arg.StorageAccountKey) &&
                    string.IsNullOrEmpty(arg.BlobName) &&
                    string.IsNullOrEmpty(arg.ContainerName))
                {
                    arg.ErrorMessage = string.Empty;
                }
                else
                {
                    arg.ErrorMessage = "Missing argument for copy scenario";
                }
            }
            else
            {
                arg.ErrorMessage = "Unexpected action";
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            ArgsParsed arg = ParseArgs(args);

            if (string.IsNullOrEmpty(arg.ErrorMessage))
            {
                if (arg.action == Action.Upload)
                {
                    UploadFileWithNuggetDLL(arg.FileName, arg.ContentType, arg.StorageAccountName, arg.StorageAccountKey, arg.ContainerName, arg.BlobName);
                }
                else
                {
                    DumpSyntax("Not implemented");
                }
            }
            else
            {
                DumpSyntax(arg.ErrorMessage);
            }
        }
Example #3
0
        static ArgsParsed ParseArgs(string[] args)
        {
            ArgsParsed result = new ArgsParsed();

            result.ErrorMessage = string.Empty;
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-action":
                    if (++i < args.Length)
                    {
                        if (args[i] == "upload")
                        {
                            result.action = Action.Upload;
                        }
                        else if (args[i] == "download")
                        {
                            result.action = Action.Download;
                        }
                        else if (args[i] == "copy")
                        {
                            result.action = Action.Copy;
                        }
                        else
                        {
                            result.action = Action.None;
                        }
                    }
                    break;

                case "-filename":
                    if (++i < args.Length)
                    {
                        result.FileName = args[i];
                    }
                    break;

                case "-contenttype":
                    if (++i < args.Length)
                    {
                        result.ContentType = args[i];
                    }
                    break;

                case "-storageaccountname":
                    if (++i < args.Length)
                    {
                        result.StorageAccountName = args[i];
                    }
                    break;

                case "-storageaccountkey":
                    if (++i < args.Length)
                    {
                        result.StorageAccountKey = args[i];
                    }
                    break;

                case "-containername":
                    if (++i < args.Length)
                    {
                        result.ContainerName = args[i];
                    }
                    break;

                case "-blobname":
                    if (++i < args.Length)
                    {
                        result.BlobName = args[i];
                    }
                    break;

                case "-sourcestorageaccountname":
                    if (++i < args.Length)
                    {
                        result.SourceStorageAccountName = args[i];
                    }
                    break;

                case "-sourcestorageaccountkey":
                    if (++i < args.Length)
                    {
                        result.SourceStorageAccountKey = args[i];
                    }
                    break;

                case "-sourcecontainername":
                    if (++i < args.Length)
                    {
                        result.SourceContainerName = args[i];
                    }
                    break;

                case "-sourceblobname":
                    if (++i < args.Length)
                    {
                        result.SourceBlobName = args[i];
                    }
                    break;
                }
            }
            CheckArgs(result);
            return(result);
        }
Example #4
0
        static ArgsParsed ParseArgs(string[] args)
        {
            ArgsParsed result = new ArgsParsed();
            result.ErrorMessage = string.Empty;
            for(int i = 0; i <args.Length; i++ )
            {
                switch (args[i])
                {
                    case "-action":
                        if (++i < args.Length)
                        {
                            if (args[i] == "upload")
                                result.action = Action.Upload;
                            else if (args[i] == "download")
                                result.action = Action.Download;
                            else if (args[i] == "copy")
                                result.action = Action.Copy;
                            else
                                result.action = Action.None;
                        }
                        break;
                    case "-filename":
                        if (++i < args.Length)
                        {
                            result.FileName = args[i];
                        }
                        break;
                    case "-contenttype":
                        if (++i < args.Length)
                        {
                            result.ContentType = args[i];
                        }
                        break;
                    case "-storageaccountname":
                        if (++i < args.Length)
                        {
                            result.StorageAccountName = args[i];
                        }
                        break;
                    case "-storageaccountkey":
                        if (++i < args.Length)
                        {
                            result.StorageAccountKey = args[i];
                        }
                        break;
                    case "-containername":
                        if (++i < args.Length)
                        {
                            result.ContainerName = args[i];
                        }
                        break;
                    case "-blobname":
                        if (++i < args.Length)
                        {
                            result.BlobName = args[i];
                        }
                        break;
                    case "-sourcestorageaccountname":
                        if (++i < args.Length)
                        {
                            result.SourceStorageAccountName = args[i];
                        }
                        break;
                    case "-sourcestorageaccountkey":
                        if (++i < args.Length)
                        {
                            result.SourceStorageAccountKey = args[i];
                        }
                        break;
                    case "-sourcecontainername":
                        if (++i < args.Length)
                        {
                            result.SourceContainerName = args[i];
                        }
                        break;
                    case "-sourceblobname":
                        if (++i < args.Length)
                        {
                            result.SourceBlobName = args[i];
                        }
                        break;
                }

            }
            CheckArgs(result);
            return result;
        }
Example #5
0
        static void CheckArgs(ArgsParsed arg)
        {
            arg.ErrorMessage = string.Empty;

            if (arg.action == Action.Upload)
            {
                if(string.IsNullOrEmpty(arg.FileName) &&
                    string.IsNullOrEmpty(arg.StorageAccountName) &&
                    string.IsNullOrEmpty(arg.StorageAccountKey) &&
                    string.IsNullOrEmpty(arg.BlobName) &&
                    string.IsNullOrEmpty(arg.ContainerName))
                    arg.ErrorMessage = string.Empty;
                else
                    arg.ErrorMessage = "Missing argument for uplaod scenario";

            }
            else if (arg.action == Action.Download)
            {
                if (string.IsNullOrEmpty(arg.FileName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountKey) &&
                    string.IsNullOrEmpty(arg.SourceBlobName) &&
                    string.IsNullOrEmpty(arg.SourceContainerName))
                    arg.ErrorMessage = string.Empty;
                else
                    arg.ErrorMessage = "Missing argument for downlaod scenario";
            }
            else if (arg.action == Action.Copy)
            {
                if (string.IsNullOrEmpty(arg.SourceStorageAccountName) &&
                    string.IsNullOrEmpty(arg.SourceStorageAccountKey) &&
                    string.IsNullOrEmpty(arg.SourceBlobName) &&
                    string.IsNullOrEmpty(arg.SourceContainerName)&&
                    string.IsNullOrEmpty(arg.StorageAccountName) &&
                    string.IsNullOrEmpty(arg.StorageAccountKey) &&
                    string.IsNullOrEmpty(arg.BlobName) &&
                    string.IsNullOrEmpty(arg.ContainerName))
                    arg.ErrorMessage = string.Empty;
                else
                    arg.ErrorMessage = "Missing argument for copy scenario";

            }
            else
                arg.ErrorMessage = "Unexpected action";

        }