コード例 #1
0
        /// <summary>
        /// Create a permissions string to provide
        /// <see cref="BlobSasBuilder.Permissions"/>.
        /// </summary>
        /// <returns>A permissions string.</returns>
        internal static string ToPermissionsString(this SnapshotSasPermissions permissions)
        {
            var sb = new StringBuilder();

            if ((permissions & SnapshotSasPermissions.Read) == SnapshotSasPermissions.Read)
            {
                sb.Append(Constants.Sas.Permissions.Read);
            }
            if ((permissions & SnapshotSasPermissions.Write) == SnapshotSasPermissions.Write)
            {
                sb.Append(Constants.Sas.Permissions.Write);
            }
            if ((permissions & SnapshotSasPermissions.Delete) == SnapshotSasPermissions.Delete)
            {
                sb.Append(Constants.Sas.Permissions.Delete);
            }
            if ((permissions & SnapshotSasPermissions.PermanentDelete) == SnapshotSasPermissions.PermanentDelete)
            {
                sb.Append(Constants.Sas.Permissions.PermanentDelete);
            }
            if ((permissions & SnapshotSasPermissions.SetImmutabilityPolicy) == SnapshotSasPermissions.SetImmutabilityPolicy)
            {
                sb.Append(Constants.Sas.Permissions.SetImmutabilityPolicy);
            }
            return(sb.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Ensure the <see cref="BlobSasBuilder"/>'s properties are in a
        /// consistent state.
        /// </summary>
        private void EnsureState()
        {
            // Container
            if (String.IsNullOrEmpty(this.BlobName))
            {
                // Make sure the permission characters are in the correct order
                this.Permissions = ContainerSasPermissions.Parse(this.Permissions).ToString();
                this.Resource    = Constants.Sas.Resource.Container;
            }

            // Blob or Snapshot
            else
            {
                // Blob
                if (String.IsNullOrEmpty(this.Snapshot))
                {
                    // Make sure the permission characters are in the correct order
                    this.Permissions = BlobSasPermissions.Parse(this.Permissions).ToString();
                    this.Resource    = Constants.Sas.Resource.Blob;
                }
                // Snapshot
                else
                {
                    // Make sure the permission characters are in the correct order
                    this.Permissions = SnapshotSasPermissions.Parse(this.Permissions).ToString();
                    this.Resource    = Constants.Sas.Resource.BlobSnapshot;
                }
            }
            if (String.IsNullOrEmpty(this.Version))
            {
                this.Version = SasQueryParameters.SasVersion;
            }
        }