Пример #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.cmdUpdate.Click += this.cmdUpdate_Click;
            this.cmdCancel.Click += this.cmdCancel_Click;

            this._providerId = Convert.ToInt32(this.Request.Params["ProviderId"]);

            var provider = ExtensionUrlProviderController.GetModuleProviders(this.ModuleContext.PortalId)
                           .SingleOrDefault(p => p.ProviderConfig.ExtensionUrlProviderId == this._providerId);

            if (provider != null)
            {
                var settingsControlSrc = provider.ProviderConfig.SettingsControlSrc;

                var settingsControl = this.Page.LoadControl(settingsControlSrc);

                this.providerSettingsPlaceHolder.Controls.Add(settingsControl);

                // ReSharper disable SuspiciousTypeConversion.Global
                this._providerSettingsControl = settingsControl as IExtensionUrlProviderSettingsControl;

                // ReSharper restore SuspiciousTypeConversion.Global
                if (this._providerSettingsControl != null)
                {
                    this._providerSettingsControl.Provider = provider.ProviderConfig;
                }
            }
        }
Пример #2
0
        public void GetModuleProviders_ExcludeSingleProviderWithTypeThatDoesNotExist()
        {
            var getExtensionUrlProvidersDataSet = GetDataSetForExtensionUrlProvidersCall();
            var providersTable = getExtensionUrlProvidersDataSet.Tables[0];

            AddProviderRow(providersTable, providerType: "This.Is.Not.A.Real.Type");
            SetupGetModuleProvidersCall(getExtensionUrlProvidersDataSet.CreateDataReader());

            var providers = ExtensionUrlProviderController.GetModuleProviders(Constants.PORTAL_ValidPortalId);

            Assert.IsNotNull(providers, "Providers list should be empty, not null");
            Assert.IsEmpty(providers, "Providers list should be empty, since there is only an invalid entry");
        }
Пример #3
0
        public void GetModuleProviders_OnlyExcludeProviderWithTypeThatDoesNotExistButIncludeOther()
        {
            var getExtensionUrlProvidersDataSet = GetDataSetForExtensionUrlProvidersCall();
            var providersTable = getExtensionUrlProvidersDataSet.Tables[0];

            AddProviderRow(providersTable, providerName: "Broken Provider", providerType: "This.Is.Not.A.Real.Type");
            AddProviderRow(providersTable, providerName: "Working Provider", providerType: typeof(FakeExtensionUrlProvider).AssemblyQualifiedName);
            SetupGetModuleProvidersCall(getExtensionUrlProvidersDataSet.CreateDataReader());

            var providers = ExtensionUrlProviderController.GetModuleProviders(Constants.PORTAL_ValidPortalId);

            Assert.IsNotNull(providers, "Providers list should be empty, not null");
            Assert.AreEqual(1, providers.Count, "Providers list should have the one valid entry, but not the invalid entry");
            Assert.AreEqual("Working Provider", providers[0].ProviderConfig.ProviderName, "Providers list should have the valid entry");
        }
Пример #4
0
        private static void SerializeExtensionUrlProviders(XmlWriter writer, int portalId)
        {
            var providers = ExtensionUrlProviderController.GetModuleProviders(portalId);

            if (!providers.Any())
            {
                return;
            }

            writer.WriteStartElement("extensionUrlProviders");

            foreach (var provider in providers)
            {
                writer.WriteStartElement("extensionUrlProvider");
                writer.WriteElementString("name", provider.ProviderConfig.ProviderName);
                writer.WriteElementString("active", provider.ProviderConfig.IsActive.ToString());
                var settings = provider.ProviderConfig.Settings;
                if (settings.Any())
                {
                    writer.WriteStartElement("settings");
                    foreach (var setting in settings)
                    {
                        writer.WriteStartElement("setting");
                        writer.WriteAttributeString("name", setting.Key);
                        writer.WriteAttributeString("value", setting.Value);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                }

                ////if (provider.ProviderConfig.TabIds.Any())
                ////{
                ////    writer.WriteStartElement("tabIds");
                ////    foreach (var tabId in provider.ProviderConfig.TabIds)
                ////    {
                ////        // TODO: translate to tab path?
                ////        writer.WriteElementString("tabId", tabId.ToString(CultureInfo.InvariantCulture));
                ////    }
                ////    writer.WriteEndElement();
                ////}

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }