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


C# ResXResourceReader.OfType方法代码示例

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


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

示例1: GetProperty

        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
        {
            string retVal = "";
            switch (propertyName.ToLower())
            {
                case "all":
                    int moduleId = _moduleContext.ModuleId;
                    int portalId = _moduleContext.PortalId;
                    int tabId = _moduleContext.TabId;
                    ModuleInfo module = new ModuleController().GetModule(moduleId, tabId);

                    dynamic properties = new ExpandoObject();
                    System.IO.FileInfo fi = new System.IO.FileInfo(HttpContext.Current.Server.MapPath("~/" + _moduleContext.Configuration.ModuleControl.ControlSrc.Replace(".html", "") + ".resx"));
                    string physResourceFile = fi.DirectoryName + "/App_LocalResources/" + fi.Name;
                    string relResourceFile = "/DesktopModules/" + module.DesktopModule.FolderName + "/App_LocalResources/" + fi.Name;
                    if (File.Exists(physResourceFile))
                    {
                        using (var rsxr = new ResXResourceReader(physResourceFile))
                        {
                            var res = rsxr.OfType<DictionaryEntry>()
                                .ToDictionary(
                                    entry => entry.Key.ToString().Replace(".", "_"),
                                    entry => Localization.GetString(entry.Key.ToString(), relResourceFile));

                            properties.Resources = res;
                        }
                    }
                    else
                    {
                        properties.Resources = physResourceFile + " not found";
                    }
                    properties.Settings = _moduleContext.Settings;
                    properties.Editable = _moduleContext.EditMode && _moduleContext.IsEditable;
                    properties.Admin = accessingUser.IsInRole(PortalSettings.Current.AdministratorRoleName);
                    properties.ModuleId = moduleId;
                    properties.PortalId = portalId;
                    properties.UserId = accessingUser.UserID;
                    properties.HomeDirectory = PortalSettings.Current.HomeDirectory.Substring(1);
                    properties.RawUrl = HttpContext.Current.Request.RawUrl;

                    List<string> languages = new List<string>();
                    LocaleController lc = new LocaleController();
                    Dictionary<string, Locale> loc = lc.GetLocales(_moduleContext.PortalId);
                    foreach (KeyValuePair<string, Locale> item in loc)
                    {
                        string cultureCode = item.Value.Culture.Name;
                        languages.Add(cultureCode);
                    }
                    properties.Languages = languages;
                    properties.CurrentLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.Name;

                    retVal = JsonConvert.SerializeObject(properties);
                    break;
                case "view":
                    retVal = (string)_moduleContext.Settings["View"];
                    if (String.IsNullOrEmpty(retVal))
                        retVal = "View.html";
                    break;
                case "list":
                    retVal = (string)_moduleContext.Settings["List"];
                    if (String.IsNullOrEmpty(retVal))
                        retVal = "List.html";
                    break;
            }
            return retVal;

        }
开发者ID:weggetor,项目名称:BBImageStory,代码行数:67,代码来源:BusinessController.cs


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