// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace Microsoft.Samples.WindowsAzureMmc.Model.Storage
{
    using System;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.Management.Automation;

    public class AzureBlobContainer : AzureObject
    {
        public AzureBlobContainer(PSObject powershellObject)
        {
            this.PSObject = powershellObject;
            this.Url = new Uri(powershellObject.Properties["Url"].Value.ToString());
            this.LastWriteTimeUtc = (DateTime)powershellObject.Properties["LastWriteTimeUtc"].Value;
            this.ObjectName = powershellObject.Properties["ObjectName"].Value.ToString();
            if (powershellObject.Properties["MetaData"] != null)
            {
                this.Metadata = powershellObject.Properties["MetaData"].Value as NameValueCollection;
            }

            this.Name = this.ObjectName;
        }

        [ReadOnly(true)]
        public DateTime LastWriteTimeUtc { get; set; }

        [ReadOnly(true)]
        public string ObjectName { get; set; }

        [ReadOnly(true)]
        public NameValueCollection Metadata { get; set; }

        [ReadOnly(true)]
        public bool IsPublic { get; set; }

        [ReadOnly(true)]
        public Uri Url { get; private set; }
    }
}