protected void InternalDelete(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App app = instance as App;

            if (app == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OrgExtensionTable.SetOrgExtension(this.domain, 1, app.AppId, null);
        }
        protected void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            App owaExtension = instance as App;

            if (owaExtension == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            OWAExtensionDataProvider.RunAction(delegate
            {
                switch (owaExtension.ObjectState)
                {
                case ObjectState.New:
                    if (!owaExtension.IsDownloadOnly)
                    {
                        OrgExtensionTable.SetOrgExtension(this.domain, 0, null, owaExtension.GetExtensionDataForInstall(this.adRecipientSession));
                        return;
                    }
                    break;

                case ObjectState.Unchanged:
                    break;

                case ObjectState.Changed:
                    {
                        OrgApp orgApp = instance as OrgApp;
                        if (orgApp == null)
                        {
                            throw new NotSupportedException("Save: " + instance.GetType().FullName);
                        }
                        OrgExtensionTable.ConfigureOrgExtension(this.domain, orgApp.AppId, orgApp.Enabled, orgApp.DefaultStateForUser == DefaultStateForUser.AlwaysEnabled, orgApp.DefaultStateForUser == DefaultStateForUser.Enabled, orgApp.ProvidedTo, OrgApp.ConvertPresentationFormatToWireUserList(this.adRecipientSession, orgApp.UserList));
                        break;
                    }

                default:
                    return;
                }
            });
        }