示例#1
0
        public static AbstractDriveInfo CreateInstance(string type, object value, string name)
        {
            switch (type.ToLowerInvariant())
            {
            case "azurefile":
                var d = new AzureFileServiceDriveInfo(value as string, name);
                return(d);

            case "azureblob":
                var b = new AzureBlobServiceDriveInfo(value as string, name);
                return(b);

            case "azuretable":
                var t = new AzureTableServiceDriveInfo(value as string, name);
                return(t);

            case "azurequeue":
                var q = new AzureQueueServiceDriveInfo(value as string, name);
                return(q);

            case "local":
                var l = new LocalDriveInfo(value as string, name);
                return(l);

            default:
                return(null);
            }
        }
示例#2
0
        internal void CopyTo(string path, AzureTableServiceDriveInfo target, string copyPath, bool deleteOriginal = false)
        {
            var parts = PathResolver.SplitPath(path);

            if (parts.Count == 0)
            {
                this.RootProvider.WriteWarning("Not supported to copy multiple tables.");
                return;
            }

            var targetRef = AzureTablePathResolver.ResolvePath(target.Client, copyPath);

            if (targetRef.PathType == PathType.AzureTableRoot)
            {
                this.RootProvider.WriteWarning("Must specify the target table.");
                return;
            }

            var items = this.ListItems(path);

            foreach (ITableEntity i in items)
            {
                var o = TableOperation.InsertOrReplace(i);
                targetRef.Table.Execute(o);
                this.RootProvider.WriteWarning(string.Format("Entity {0} # {1} is inserted", i.PartitionKey, i.RowKey));
            }

            if (deleteOriginal)
            {
                var sourceRef = AzureTablePathResolver.ResolvePath(this.Client, path);
                foreach (ITableEntity i in items)
                {
                    var o = TableOperation.Delete(i);
                    sourceRef.Table.Execute(o);
                    this.RootProvider.WriteWarning(string.Format("Source Entity {0} # {1} is deleted", i.PartitionKey, i.RowKey));
                }
            }
        }