public SPOSiteContext(CmdletContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.Context = context;
 }
        internal static SPOSiteContext InstantiateSPOSiteContext(Uri url, PSCredential credentials, PSHost host, bool isNetworkCredentials)
        {
            if (!IsValidServerVersion(url))
            {
                throw new InvalidOperationException("Could not connect to SharePoint Online: unsupported version of service.");
            }
            CmdletContext context = new CmdletContext(url.AbsoluteUri, host);
            if (isNetworkCredentials)
            {
                context.AuthenticationMode = ClientAuthenticationMode.Default;
                context.Credentials = credentials.GetNetworkCredential();
            }
            else
            {
                context.Credentials = new SharePointOnlineCredentials(credentials.UserName, credentials.Password);
            }

            if (context.HasPendingRequest)
                context.ExecuteQuery();
            return new SPOSiteContext(context);
        }