/// <summary>
        /// Initializes a new instance of AzureSMProfile and loads its content from specified path.
        /// Any errors generated in the process are stored in ProfileLoadErrors collection.
        /// </summary>
        /// <param name="path">Location of profile file on disk.</param>
        public AzureSMProfile(string path) : this()
        {
            ProfilePath       = path;
            ProfileLoadErrors = new List <string>();

            if (!AzureSession.Instance.DataStore.DirectoryExists(AzureSession.Instance.ProfileDirectory))
            {
                AzureSession.Instance.DataStore.CreateDirectory(AzureSession.Instance.ProfileDirectory);
            }

            if (AzureSession.Instance.DataStore.FileExists(ProfilePath))
            {
                string contents = AzureSession.Instance.DataStore.ReadFileAsText(ProfilePath);

                IProfileSerializer serializer;

                if (CloudException.IsXml(contents))
                {
                    serializer = new XmlProfileSerializer();
                    if (!serializer.Deserialize(contents, this))
                    {
                        ProfileLoadErrors.AddRange(serializer.DeserializeErrors);
                    }
                }
                else if (CloudException.IsJson(contents))
                {
                    bool converted = false;
                    // first try legacy conversion
                    try
                    {
                        var legacyProfile = JsonConvert.DeserializeObject <LegacyAzureSMProfile>(contents);
                        converted = legacyProfile.TryConvert(this);
                    }
                    catch
                    {
                    }

                    if (!converted)
                    {
                        serializer = new JsonProfileSerializer();
                        if (!serializer.Deserialize(contents, this))
                        {
                            ProfileLoadErrors.AddRange(serializer.DeserializeErrors);
                        }
                    }
                }
            }
        }
        public override string ToString()
        {
            JsonProfileSerializer jsonSerializer = new JsonProfileSerializer();

            return(jsonSerializer.Serialize(this));
        }