当前位置: 首页>>代码示例>>C#>>正文


C# Sites.GetUserConfigurationProperties方法代码示例

本文整理汇总了C#中Sites.GetUserConfigurationProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Sites.GetUserConfigurationProperties方法的具体用法?C# Sites.GetUserConfigurationProperties怎么用?C# Sites.GetUserConfigurationProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sites的用法示例。


在下文中一共展示了Sites.GetUserConfigurationProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowDialog

        public static Sites.SiteUtilBase ShowDialog(Sites.SiteUtilBase selectedSite)
        {
            List<OnlineVideos.Reflection.FieldPropertyDescriptorByRef> actualProps = selectedSite.GetUserConfigurationProperties();

            // limit to what the UI can show
            actualProps = actualProps.Where(prop => (prop.IsEnum || prop.Namespace == "System")).ToList();

            if (actualProps.Count > 0)
            {
                bool changes = false;
                int selectIndex = 0;
                do
                {
                    int windowId = GUIDialogSiteUserSettings.GUIDIALOGMENU_ONLINEVIDEO; // try our special dialog first
                    GUIDialogMenu dlgSiteOptions = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId) as GUIDialogSiteUserSettings;
                    if (dlgSiteOptions == null || !((GUIDialogSiteUserSettings)dlgSiteOptions).IsAvailable) // if not available use the default one
                    {
                        windowId = (int)GUIWindow.Window.WINDOW_DIALOG_MENU; 
                        dlgSiteOptions = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId);
                    }
                    if (dlgSiteOptions == null) return selectedSite;
                    dlgSiteOptions.Reset();
                    dlgSiteOptions.SetHeading(string.Format("{0}: {1}", selectedSite.Settings.Name, GUILocalizeStrings.Get(5)));
                    foreach (var ovsUserCfg in actualProps)
                    {
                        /*object valueO = ovsUserCfg.GetValue(selectedSite);
                        string value = valueO != null ? valueO.ToString() : string.Empty;*/
						string value = selectedSite.GetConfigValueAsString(ovsUserCfg);
                        if (ovsUserCfg.IsPassword)
                        {
                            value = new string('*', value.Length);
                        }
                        string desc = ovsUserCfg.Description;
                        dlgSiteOptions.Add(new GUIListItem(ovsUserCfg.DisplayName, value, "", false, null) 
                        {
                            // don't set Label3 if we are not using our custom dialog
                            Label3 = windowId == GUIDialogSiteUserSettings.GUIDIALOGMENU_ONLINEVIDEO && !string.IsNullOrEmpty(desc) ? desc : string.Empty 
                        });
                    }
                    dlgSiteOptions.SelectedLabel = selectIndex;
                    dlgSiteOptions.DoModal(GUIWindowManager.ActiveWindow);
                    selectIndex = dlgSiteOptions.SelectedLabel;
                    if (dlgSiteOptions.SelectedId == -1) break;
                    else
                    {
						OnlineVideos.Reflection.FieldPropertyDescriptorByRef prop = actualProps.First(a => a.DisplayName == dlgSiteOptions.SelectedLabelText);
                        if (prop.IsBool)
                        {
                            GUIDialogMenu dlgTrueFalse = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId);
                            dlgTrueFalse.Reset();
                            dlgTrueFalse.SetHeading(string.Format("{0}: {1}", selectedSite.Settings.Name, prop.DisplayName));
                            dlgTrueFalse.Add(true.ToString());
                            dlgTrueFalse.Add(false.ToString());
                            string value = selectedSite.GetConfigValueAsString(prop);
							if (value == false.ToString()) dlgTrueFalse.SelectedLabel = 1;
                            dlgTrueFalse.DoModal(GUIWindowManager.ActiveWindow);
                            if (dlgTrueFalse.SelectedId != -1)
                            {
								if (value != dlgTrueFalse.SelectedLabelText)
                                {
									selectedSite.SetConfigValueFromString(prop, dlgTrueFalse.SelectedLabelText);
                                    changes = true;
                                }
                            }
                        }
                        else if (prop.IsEnum)
                        {
                            GUIDialogMenu dlgEnum = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId);
                            dlgEnum.Reset();
                            dlgEnum.SetHeading(string.Format("{0}: {1}", selectedSite.Settings.Name, prop.DisplayName));
							string value = selectedSite.GetConfigValueAsString(prop);
                            int i = 0;
                            foreach (string e in prop.GetEnumValues())
                            {
                                dlgEnum.Add(e);
                                if (e == value) dlgEnum.SelectedLabel = i;
                                i++;
                            }
                            dlgEnum.DoModal(GUIWindowManager.ActiveWindow);
                            if (dlgEnum.SelectedId != -1)
                            {
                                if (value != dlgEnum.SelectedLabelText)
                                {
									selectedSite.SetConfigValueFromString(prop, dlgEnum.SelectedLabelText);
                                    changes = true;
                                }
                            }
                        }
                        else
                        {
							string value = selectedSite.GetConfigValueAsString(prop);
                            string newValue = (string)value.Clone();
                            if (GUIOnlineVideos.GetUserInputString(ref newValue, prop.IsPassword))
                            {
                                if (value != newValue)
                                {
                                    try
                                    {
										selectedSite.SetConfigValueFromString(prop, newValue);
                                        changes = true;
//.........这里部分代码省略.........
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:101,代码来源:SiteUserSettingsDialog.cs


注:本文中的Sites.GetUserConfigurationProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。