本文整理汇总了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;
}