示例#1
0
        public byte[] Encode()
        {
            ASCIIEncoding       aSCIIEncoding       = new ASCIIEncoding();
            UnicodeEncoding     unicodeEncoding     = new UnicodeEncoding();
            NameValueCollection nameValueCollection = new NameValueCollection();

            nameValueCollection[SASIdentifier.IdName] = Convert.ToBase64String(unicodeEncoding.GetBytes(this.Id));
            if (this.AccessPolicy.SignedStart.HasValue)
            {
                string   signedStartName = SASAccessPolicy.SignedStartName;
                DateTime?signedStart     = this.AccessPolicy.SignedStart;
                nameValueCollection[signedStartName] = SASUtilities.EncodeTime(signedStart.Value);
            }
            if (this.AccessPolicy.SignedExpiry.HasValue)
            {
                string   signedExpiryName = SASAccessPolicy.SignedExpiryName;
                DateTime?signedExpiry     = this.AccessPolicy.SignedExpiry;
                nameValueCollection[signedExpiryName] = SASUtilities.EncodeTime(signedExpiry.Value);
            }
            if (this.AccessPolicy.SignedPermission.HasValue)
            {
                string        signedPermissionName = SASAccessPolicy.SignedPermissionName;
                SASPermission?signedPermission     = this.AccessPolicy.SignedPermission;
                nameValueCollection[signedPermissionName] = SASUtilities.EncodeSASPermission(signedPermission.Value);
            }
            return(MetadataEncoding.Encode(nameValueCollection));
        }
示例#2
0
        public void EncodeToServiceMetadata(out byte[] serviceMetadata)
        {
            NameValueCollection nameValueCollection;

            this.ToNameValues(out nameValueCollection);
            serviceMetadata = MetadataEncoding.Encode(nameValueCollection);
        }
示例#3
0
        public void Decode(string sasIdentifier)
        {
            ASCIIEncoding   aSCIIEncoding   = new ASCIIEncoding();
            UnicodeEncoding unicodeEncoding = new UnicodeEncoding();

            SASUtilities.ValidateACIIEncoding(sasIdentifier);
            NameValueCollection nameValueCollection = new NameValueCollection();

            MetadataEncoding.Decode(aSCIIEncoding.GetBytes(sasIdentifier), nameValueCollection);
            string item  = nameValueCollection[SASIdentifier.IdName];
            string str   = nameValueCollection[SASAccessPolicy.SignedStartName];
            string item1 = nameValueCollection[SASAccessPolicy.SignedExpiryName];
            string str1  = nameValueCollection[SASAccessPolicy.SignedPermissionName];

            if (!string.IsNullOrEmpty(item))
            {
                this.Id = unicodeEncoding.GetString(Convert.FromBase64String(item));
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.AccessPolicy.SignedStart = new DateTime?(SASUtilities.ParseTime(str));
            }
            if (!string.IsNullOrEmpty(item1))
            {
                this.AccessPolicy.SignedExpiry = new DateTime?(SASUtilities.ParseTime(item1));
            }
            if (!string.IsNullOrEmpty(str1))
            {
                this.AccessPolicy.SignedPermission = new SASPermission?(SASUtilities.ParseSASPermission(str1));
            }
        }
示例#4
0
        public static BlobServiceMetaData GetInstance(NameValueCollection metadata)
        {
            BlobServiceMetaData blobServiceMetaDatum = new BlobServiceMetaData();

            if (metadata != null || metadata.Count < 1)
            {
                blobServiceMetaDatum.metadataNameValuePairs = metadata;
                blobServiceMetaDatum.metadata = MetadataEncoding.Encode(blobServiceMetaDatum.metadataNameValuePairs);
                blobServiceMetaDatum.PopulateCopyProperties();
            }
            return(blobServiceMetaDatum);
        }
示例#5
0
        public static BlobServiceMetaData GetInstance(byte[] metadata)
        {
            BlobServiceMetaData blobServiceMetaDatum = new BlobServiceMetaData();

            if (metadata != null)
            {
                blobServiceMetaDatum.metadata = metadata;
                MetadataEncoding.Decode(metadata, blobServiceMetaDatum.metadataNameValuePairs);
                blobServiceMetaDatum.PopulateCopyProperties();
            }
            return(blobServiceMetaDatum);
        }
示例#6
0
        public byte[] GetMetadata()
        {
            string str;

            this.metadataNameValuePairs[RealServiceManager.CopyIdTag]                = this.CopyId;
            this.metadataNameValuePairs[RealServiceManager.CopySourceTag]            = this.CopySource;
            this.metadataNameValuePairs[RealServiceManager.CopyStatusTag]            = this.CopyStatus;
            this.metadataNameValuePairs[RealServiceManager.CopyStatusDescriptionTag] = this.CopyStatusDescription;
            this.metadataNameValuePairs[RealServiceManager.CopyProgressOffsetTag]    = this.CopyProgressOffset;
            this.metadataNameValuePairs[RealServiceManager.CopyProgressTotalTag]     = this.CopyProgressTotal;
            NameValueCollection nameValueCollection = this.metadataNameValuePairs;
            string copyCompletionTimeTag            = RealServiceManager.CopyCompletionTimeTag;

            if (this.CopyCompletionTime.HasValue)
            {
                str = this.CopyCompletionTime.Value.ToString();
            }
            else
            {
                str = null;
            }
            nameValueCollection[copyCompletionTimeTag] = str;
            string[] allKeys = this.metadataNameValuePairs.AllKeys;
            for (int i = 0; i < (int)allKeys.Length; i++)
            {
                string str1 = allKeys[i];
                if (this.metadataNameValuePairs[str1] == null)
                {
                    this.metadataNameValuePairs.Remove(str1);
                }
            }
            if (this.metadataNameValuePairs.Count <= 0)
            {
                this.metadata = null;
            }
            else
            {
                this.metadata = MetadataEncoding.Encode(this.metadataNameValuePairs);
            }
            return(this.metadata);
        }
示例#7
0
 protected BaseAclSettings(byte[] serviceMetadata)
 {
     if (serviceMetadata != null)
     {
         NameValueCollection nameValueCollection = new NameValueCollection();
         MetadataEncoding.Decode(serviceMetadata, nameValueCollection);
         string str  = nameValueCollection.Get("PublicAccess");
         string str1 = nameValueCollection.Get("PublicAccess1");
         string str2 = nameValueCollection.Get("SASIdentifiers");
         if (str != null)
         {
             this.publicAccessLevel = str;
         }
         else if (str1 != null)
         {
             this.publicAccessLevel = str1;
         }
         if (!string.IsNullOrEmpty(str2))
         {
             this.sasIdentifiers = SASUtilities.DecodeSASIdentifiers(str2);
         }
     }
 }
示例#8
0
        protected override void EncodeEntry(Uri requestUrl, ListBlobsOperationContext lboc, IListBlobResultsBlobProperties blobProps, XmlWriter xmlWriter)
        {
            string str;
            string httpString;
            string eTag;

            if (!blobProps.IsActualBlob)
            {
                xmlWriter.WriteStartElement("BlobPrefix");
                this.WriteElementString(xmlWriter, "Name", blobProps.BlobName);
            }
            else
            {
                xmlWriter.WriteStartElement("Blob");
                this.WriteElementString(xmlWriter, "Name", blobProps.BlobName);
                if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue)
                {
                    this.WriteElementString(xmlWriter, "Snapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(blobProps.Snapshot));
                }
                if (lboc.ListingAcrossContainers)
                {
                    NephosAssertionException.Assert(!string.IsNullOrEmpty(blobProps.ContainerName), string.Concat("XStore didn't return us valid ContainerName for this blob ", blobProps.BlobName, " when we are listing blobs across the account"));
                    this.WriteElementString(xmlWriter, "ContainerName", blobProps.ContainerName);
                }
                if (lboc.IsIncludingUrlInResponse)
                {
                    string empty = string.Empty;
                    if (lboc.ListingAcrossContainers)
                    {
                        empty = string.Concat("/", blobProps.ContainerName);
                    }
                    string str1 = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), empty);
                    string str2 = HttpRequestAccessorCommon.TrimRootContainerNameFromEnd(str1, true);
                    string str3 = string.Concat(str2, "/", blobProps.BlobName);
                    if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue)
                    {
                        str3 = string.Concat(str3, HttpUtilities.GetSnapshotQueryParameterStringForUrl(blobProps.Snapshot));
                    }
                    this.WriteElementString(xmlWriter, "Url", str3);
                }
                if (lboc.IsUsingPropertiesElement)
                {
                    xmlWriter.WriteStartElement("Properties");
                }
                string str4  = (lboc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified");
                string str5  = (lboc.IsUsingPropertiesElement ? "Content-Length" : "Size");
                string str6  = (lboc.IsUsingPropertiesElement ? "Content-Type" : "ContentType");
                string str7  = (lboc.IsUsingPropertiesElement ? "Content-Encoding" : "ContentEncoding");
                string str8  = (lboc.IsUsingPropertiesElement ? "Content-Language" : "ContentLanguage");
                string str9  = (lboc.IsUsingPropertiesElement ? "Cache-Control" : "CacheControl");
                string str10 = (lboc.IsUsingPropertiesElement ? "Content-MD5" : "ContentMD5");
                bool   value = blobProps.LastModifiedTime.Value > DateTimeConstants.MinimumBlobLastModificationTime;
                if (value)
                {
                    XmlWriter xmlWriter1 = xmlWriter;
                    string    str11      = str4;
                    if (blobProps.LastModifiedTime.HasValue)
                    {
                        httpString = HttpUtilities.ConvertDateTimeToHttpString(blobProps.LastModifiedTime.Value);
                    }
                    else
                    {
                        httpString = null;
                    }
                    this.WriteElementString(xmlWriter1, str11, httpString);
                    XmlWriter xmlWriter2 = xmlWriter;
                    if (blobProps.LastModifiedTime.HasValue)
                    {
                        DateTime?lastModifiedTime = blobProps.LastModifiedTime;
                        eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes);
                    }
                    else
                    {
                        eTag = null;
                    }
                    this.WriteElementString(xmlWriter2, "Etag", eTag);
                }
                XmlWriter xmlWriter3 = xmlWriter;
                string    str12      = str5;
                if (blobProps.ContentLength.HasValue)
                {
                    str = blobProps.ContentLength.Value.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    str = null;
                }
                this.WriteElementString(xmlWriter3, str12, str);
                if (value)
                {
                    this.WriteElementString(xmlWriter, str6, blobProps.ContentType);
                    this.WriteElementString(xmlWriter, str7, blobProps.ContentEncoding);
                    this.WriteElementString(xmlWriter, str8, blobProps.ContentLanguage);
                    if (lboc.IsIncludingCrc64InResponse)
                    {
                        this.WriteElementString(xmlWriter, "Content-CRC64", blobProps.ContentCrc64);
                    }
                    if (lboc.IsUsingPropertiesElement)
                    {
                        this.WriteElementString(xmlWriter, str10, blobProps.ContentMD5);
                    }
                    if (lboc.IsIncludingCacheControlInResponse)
                    {
                        this.WriteElementString(xmlWriter, str9, blobProps.CacheControl);
                    }
                    if (lboc.IsIncludingContentDispositionInResponse)
                    {
                        this.WriteElementString(xmlWriter, "Content-Disposition", blobProps.ContentDisposition);
                    }
                }
                if (lboc.IsIncludingBlobTypeInResponse)
                {
                    if (blobProps.SequenceNumber.HasValue)
                    {
                        long num = blobProps.SequenceNumber.Value;
                        this.WriteElementString(xmlWriter, "x-ms-blob-sequence-number", num.ToString());
                    }
                    this.WriteElementString(xmlWriter, "BlobType", blobProps.BlobType);
                }
                if (lboc.IsIncludingLeaseStatusInResponse && blobProps.Snapshot == DateTime.MaxValue)
                {
                    this.WriteElementString(xmlWriter, "LeaseStatus", blobProps.LeaseStatus);
                    if (lboc.IsIncludingLeaseStateAndDurationInResponse)
                    {
                        if (!string.IsNullOrEmpty(blobProps.LeaseState))
                        {
                            this.WriteElementString(xmlWriter, "LeaseState", blobProps.LeaseState);
                        }
                        if (!string.IsNullOrEmpty(blobProps.LeaseDuration))
                        {
                            this.WriteElementString(xmlWriter, "LeaseDuration", blobProps.LeaseDuration);
                        }
                    }
                }
                if (lboc.IsIncludingCopyPropertiesInResponse)
                {
                    if (!string.IsNullOrEmpty(blobProps.CopyId))
                    {
                        this.WriteElementString(xmlWriter, "CopyId", blobProps.CopyId);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopySource))
                    {
                        this.WriteElementString(xmlWriter, "CopySource", (this.obfuscateSourceUri ? HttpUtilities.ObfuscateSourceUri(blobProps.CopySource) : blobProps.CopySource));
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyStatus))
                    {
                        this.WriteElementString(xmlWriter, "CopyStatus", blobProps.CopyStatus);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyStatusDescription))
                    {
                        this.WriteElementString(xmlWriter, "CopyStatusDescription", blobProps.CopyStatusDescription);
                    }
                    if (!string.IsNullOrEmpty(blobProps.CopyProgress))
                    {
                        this.WriteElementString(xmlWriter, "CopyProgress", blobProps.CopyProgress);
                    }
                    if (blobProps.CopyCompletionTime.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && !blobProps.CopyStatus.Equals("pending", StringComparison.OrdinalIgnoreCase))
                    {
                        DateTime?copyCompletionTime = blobProps.CopyCompletionTime;
                        this.WriteElementString(xmlWriter, "CopyCompletionTime", HttpUtilities.ConvertDateTimeToHttpString(copyCompletionTime.Value));
                    }
                }
                if (lboc.IsIncludingIncrementalCopy && blobProps.IsIncrementalCopy)
                {
                    this.WriteElementString(xmlWriter, "IncrementalCopy", "true");
                    if (blobProps.LastCopySnapshot.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && blobProps.CopyStatus.Equals("success", StringComparison.OrdinalIgnoreCase))
                    {
                        if (blobProps.LastCopySnapshot.Value <= DateTimeConstants.MinimumIncrementalCopySnapshotTime)
                        {
                            AlertsManager.AlertOrLogException("LastCopySnapshot set to Minimum value, while a valid timestamp was expected.", null, null);
                        }
                        DateTime?lastCopySnapshot = blobProps.LastCopySnapshot;
                        this.WriteElementString(xmlWriter, "CopyDestinationSnapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(lastCopySnapshot.Value));
                    }
                }
                if (lboc.IsIncludingEncryption)
                {
                    this.WriteElementString(xmlWriter, "ServerEncrypted", (!blobProps.IsBlobEncrypted.HasValue || !blobProps.IsBlobEncrypted.Value ? "false" : "true"));
                }
                if (lboc.IsUsingPropertiesElement)
                {
                    xmlWriter.WriteEndElement();
                }
                if (value && lboc.IsFetchingMetadata)
                {
                    MetadataEncoding.WriteMetadataToXml(xmlWriter, blobProps.Metadata, true, lboc.RequestVersion);
                }
            }
            xmlWriter.WriteEndElement();
        }
示例#9
0
        public ListContainersResultContainerProperties(IBaseBlobContainer container)
        {
            long num;

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            this.containerName = container.ContainerName;
            NephosAssertionException.Assert(container.LastModificationTime.HasValue);
            this.lastModifiedTime = container.LastModificationTime;
            if (container.ApplicationMetadata != null)
            {
                this.applicationMetadata = new NameValueCollection();
                try
                {
                    MetadataEncoding.Decode(container.ApplicationMetadata, this.applicationMetadata);
                }
                catch (MetadataFormatException metadataFormatException1)
                {
                    MetadataFormatException metadataFormatException = metadataFormatException1;
                    CultureInfo             invariantCulture        = CultureInfo.InvariantCulture;
                    object[] objArray = new object[] { this.containerName };
                    throw new NephosStorageDataCorruptionException(string.Format(invariantCulture, "Error decoding application metadata for container {0}", objArray), metadataFormatException);
                }
            }
            if (container.LeaseInfo != null)
            {
                if (container.LeaseInfo.Type == LeaseType.ReadWrite && container.LeaseInfo.Duration.HasValue)
                {
                    TimeSpan?duration = container.LeaseInfo.Duration;
                    TimeSpan zero     = TimeSpan.Zero;
                    if ((duration.HasValue ? duration.GetValueOrDefault() <= zero : true))
                    {
                        goto Label1;
                    }
                    this.leaseStatus = "locked";
                    goto Label0;
                }
Label1:
                this.leaseStatus = "unlocked";
Label0:
                if (container.LeaseInfo.State.HasValue)
                {
                    this.leaseState = LeaseStateStrings.LeaseStates[(int)container.LeaseInfo.State.Value];
                    if (container.LeaseInfo.State.Equals(Microsoft.Cis.Services.Nephos.Common.Storage.LeaseState.Leased))
                    {
                        TimeSpan?nullable = container.LeaseInfo.Duration;
                        TimeSpan timeSpan = TimeSpan.FromSeconds(4294967295);
                        if ((!nullable.HasValue ? true : nullable.GetValueOrDefault() != timeSpan))
                        {
                            this.leaseDuration = "fixed";
                        }
                        else
                        {
                            this.leaseDuration = "infinite";
                        }
                    }
                }
            }
            if (container.ServiceMetadata != null)
            {
                NameValueCollection nameValueCollection = new NameValueCollection();
                try
                {
                    MetadataEncoding.Decode(container.ServiceMetadata, nameValueCollection);
                }
                catch (MetadataFormatException metadataFormatException3)
                {
                    MetadataFormatException metadataFormatException2 = metadataFormatException3;
                    CultureInfo             cultureInfo = CultureInfo.InvariantCulture;
                    object[] objArray1 = new object[] { this.containerName };
                    throw new NephosStorageDataCorruptionException(string.Format(cultureInfo, "Error decoding service metadata for container {0}", objArray1), metadataFormatException2);
                }
                this.containerQuotaInGB = (long)RealServiceManager.MaxShareQuotaInGBPriorToLargeFileShareFeature;
                string str = nameValueCollection.Get(RealServiceManager.XSmbContainerQuotaMetadataName);
                if (str != null)
                {
                    if (!long.TryParse(str, out num) || num < (long)RealServiceManager.MinShareQuotaInGB || num > this.containerQuotaInGB)
                    {
                        TimeSpan?nullable1 = null;
                        AlertsManager.AlertOrLogException(string.Format("Invalid XsmbContainerQuota retrieved from servicemetadata for account {0}: {1}", this.accountNameForLogging, str), "InvalidXSMBContainerQuota", nullable1);
                    }
                    else
                    {
                        this.containerQuotaInGB = num;
                    }
                }
                string str1 = nameValueCollection.Get("PublicAccess");
                string str2 = nameValueCollection.Get("PublicAccess1");
                if (str1 != null)
                {
                    this.publicAccessLevel = str1;
                    return;
                }
                if (str2 != null)
                {
                    this.publicAccessLevel = str2;
                }
            }
        }
示例#10
0
        public ListBlobResultsBlobProperties(IBlobObject blobObject, string separator)
        {
            if (blobObject == null)
            {
                throw new ArgumentNullException("blobObject");
            }
            this.blobName      = blobObject.Name;
            this.containerName = blobObject.ContainerName;
            if (separator == null || blobObject.Type != Microsoft.Cis.Services.Nephos.Common.Storage.BlobType.None)
            {
                this.isActualBlob = true;
                this.contentType  = blobObject.ContentType;
                NephosAssertionException.Assert(blobObject.LastModificationTime.HasValue);
                NephosAssertionException.Assert(blobObject.ContentLength.HasValue);
                this.lastModifiedTime = blobObject.LastModificationTime;
                this.size             = blobObject.ContentLength;
                NameValueCollection nameValueCollection = null;
                if (blobObject.ServiceMetadata != null)
                {
                    nameValueCollection = new NameValueCollection();
                    try
                    {
                        MetadataEncoding.Decode(blobObject.ServiceMetadata, nameValueCollection);
                    }
                    catch (MetadataFormatException metadataFormatException1)
                    {
                        MetadataFormatException metadataFormatException = metadataFormatException1;
                        CultureInfo             invariantCulture        = CultureInfo.InvariantCulture;
                        object[] objArray = new object[] { this.blobName };
                        throw new NephosStorageDataCorruptionException(string.Format(invariantCulture, "Error decoding service metadata for blob {0}", objArray), metadataFormatException);
                    }
                    this.contentEncoding    = nameValueCollection[RealServiceManager.ContentEncodingTag];
                    this.contentLanguage    = nameValueCollection[RealServiceManager.ContentLanguageTag];
                    this.cacheControl       = nameValueCollection[RealServiceManager.CacheControlTag];
                    this.contentCrc64       = nameValueCollection[RealServiceManager.ContentCrc64Tag];
                    this.contentMD5         = nameValueCollection[RealServiceManager.ContentMD5Tag];
                    this.contentDisposition = nameValueCollection[RealServiceManager.ContentDispositionTag];
                    if (this.contentMD5 != null && this.contentMD5.Equals(RealServiceManager.EmptyContentMD5Value, StringComparison.OrdinalIgnoreCase))
                    {
                        this.contentMD5 = null;
                    }
                    this.copyId                = nameValueCollection[RealServiceManager.CopyIdTag];
                    this.copySource            = nameValueCollection[RealServiceManager.CopySourceTag];
                    this.copyStatus            = nameValueCollection[RealServiceManager.CopyStatusTag];
                    this.copyStatusDescription = nameValueCollection[RealServiceManager.CopyStatusDescriptionTag];
                    if (!string.IsNullOrEmpty(nameValueCollection[RealServiceManager.CopyProgressOffsetTag]) && !string.IsNullOrEmpty(nameValueCollection[RealServiceManager.CopyProgressTotalTag]))
                    {
                        this.copyProgress = string.Format("{0}/{1}", nameValueCollection[RealServiceManager.CopyProgressOffsetTag], nameValueCollection[RealServiceManager.CopyProgressTotalTag]);
                    }
                    this.copyCompletionTime = RealServiceManager.ParseDateTimeFromString(nameValueCollection[RealServiceManager.CopyCompletionTimeTag]);
                }
                if (blobObject.ApplicationMetadata != null)
                {
                    this.metadata = new NameValueCollection();
                    try
                    {
                        MetadataEncoding.Decode(blobObject.ApplicationMetadata, this.metadata);
                    }
                    catch (MetadataFormatException metadataFormatException3)
                    {
                        MetadataFormatException metadataFormatException2 = metadataFormatException3;
                        CultureInfo             cultureInfo = CultureInfo.InvariantCulture;
                        object[] objArray1 = new object[] { this.blobName };
                        throw new NephosStorageDataCorruptionException(string.Format(cultureInfo, "Error decoding application metadata for blob {0}", objArray1), metadataFormatException2);
                    }
                }
                this.blobType = BlobTypeStrings.GetString(blobObject.Type);
                if (blobObject.LeaseInfo != null)
                {
                    if (blobObject.LeaseInfo.Type == LeaseType.ReadWrite && blobObject.LeaseInfo.Duration.HasValue)
                    {
                        TimeSpan?duration = blobObject.LeaseInfo.Duration;
                        TimeSpan zero     = TimeSpan.Zero;
                        if ((duration.HasValue ? duration.GetValueOrDefault() <= zero : true))
                        {
                            goto Label1;
                        }
                        this.leaseStatus = "locked";
                        goto Label0;
                    }
Label1:
                    this.leaseStatus = "unlocked";
Label0:
                    if (blobObject.LeaseInfo.State.HasValue)
                    {
                        this.leaseState = LeaseStateStrings.LeaseStates[(int)blobObject.LeaseInfo.State.Value];
                        if (blobObject.LeaseInfo.State.Equals(Microsoft.Cis.Services.Nephos.Common.Storage.LeaseState.Leased))
                        {
                            TimeSpan?nullable = blobObject.LeaseInfo.Duration;
                            TimeSpan timeSpan = TimeSpan.FromSeconds(4294967295);
                            if ((!nullable.HasValue ? true : nullable.GetValueOrDefault() != timeSpan))
                            {
                                this.leaseDuration = "fixed";
                            }
                            else
                            {
                                this.leaseDuration = "infinite";
                            }
                        }
                    }
                }
                this.snapshot = blobObject.Snapshot;
                if (blobObject.Type != Microsoft.Cis.Services.Nephos.Common.Storage.BlobType.IndexBlob)
                {
                    this.sequenceNumber = null;
                }
                else
                {
                    NephosAssertionException.Assert(blobObject.SequenceNumber.HasValue, "SequenceNumber must be present for PageBlob's.");
                    this.sequenceNumber = blobObject.SequenceNumber;
                }
                this.isBlobEncrypted   = blobObject.IsBlobEncrypted;
                this.isIncrementalCopy = blobObject.IsIncrementalCopy;
                if (this.isIncrementalCopy && nameValueCollection != null)
                {
                    this.lastCopySnapshot = RealServiceManager.ParseDateTimeFromString(nameValueCollection[RealServiceManager.LastCopySnapshotTag]);
                }
            }
        }
示例#11
0
 public static void ValidateServiceProperties(NameValueCollection serviceMetadataCollection, string contentType)
 {
     StorageStampHelpers.ValidateServiceProperties(MetadataEncoding.Encode(serviceMetadataCollection), contentType);
 }
示例#12
0
 public static void ValidateApplicationMetadata(NameValueCollection metadata)
 {
     StorageStampHelpers.ValidateApplicationMetadata(MetadataEncoding.GetMetadataLengthWithAsciiEncoding(metadata));
 }
示例#13
0
        protected override void EncodeEntry(Uri requestUrl, ListContainersOperationContext loc, IListContainersResultContainerProperties collProps, XmlWriter xmlWriter)
        {
            string httpString;
            string eTag;

            xmlWriter.WriteStartElement(this.XmlContainerElementName);
            xmlWriter.WriteElementString("Name", collProps.ContainerName);
            if (loc.IsIncludingUrlInResponse)
            {
                string str = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), "/", collProps.ContainerName);
                xmlWriter.WriteElementString("Url", str);
            }
            if (loc.IsUsingPropertiesElement)
            {
                xmlWriter.WriteStartElement("Properties");
            }
            string    str1       = (loc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified");
            XmlWriter xmlWriter1 = xmlWriter;
            string    str2       = str1;

            if (collProps.LastModifiedTime.HasValue)
            {
                httpString = HttpUtilities.ConvertDateTimeToHttpString(collProps.LastModifiedTime.Value);
            }
            else
            {
                httpString = null;
            }
            xmlWriter1.WriteElementString(str2, httpString);
            XmlWriter xmlWriter2 = xmlWriter;

            if (collProps.LastModifiedTime.HasValue)
            {
                DateTime?lastModifiedTime = collProps.LastModifiedTime;
                eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes);
            }
            else
            {
                eTag = null;
            }
            xmlWriter2.WriteElementString("Etag", eTag);
            if (loc.IsIncludingLeaseStateAndDurationInResponse)
            {
                if (!string.IsNullOrEmpty(collProps.LeaseStatus))
                {
                    xmlWriter.WriteElementString("LeaseStatus", collProps.LeaseStatus);
                }
                if (!string.IsNullOrEmpty(collProps.LeaseState))
                {
                    xmlWriter.WriteElementString("LeaseState", collProps.LeaseState);
                }
                if (!string.IsNullOrEmpty(collProps.LeaseDuration))
                {
                    xmlWriter.WriteElementString("LeaseDuration", collProps.LeaseDuration);
                }
            }
            if (loc.IsIncludingShareQuotaInResponse)
            {
                long containerQuotaInGB = collProps.ContainerQuotaInGB;
                xmlWriter.WriteElementString("Quota", containerQuotaInGB.ToString(CultureInfo.InvariantCulture));
            }
            if (loc.IsIncludingPublicAccessInResponse && !string.IsNullOrEmpty(collProps.PublicAccessLevel))
            {
                if (Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, "container") || Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, bool.TrueString))
                {
                    xmlWriter.WriteElementString("PublicAccess", "container");
                }
                else if (Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, "blob"))
                {
                    xmlWriter.WriteElementString("PublicAccess", "blob");
                }
            }
            if (loc.IsUsingPropertiesElement)
            {
                xmlWriter.WriteEndElement();
            }
            if (loc.IsFetchingMetadata)
            {
                MetadataEncoding.WriteMetadataToXml(xmlWriter, collProps.Metadata, true, loc.RequestVersion);
            }
            xmlWriter.WriteEndElement();
        }