本文整理汇总了C#中Resources.GetRunningResources方法的典型用法代码示例。如果您正苦于以下问题:C# Resources.GetRunningResources方法的具体用法?C# Resources.GetRunningResources怎么用?C# Resources.GetRunningResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resources
的用法示例。
在下文中一共展示了Resources.GetRunningResources方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public static Func<IHttpHeaders, IHttpContext, Task<JObject>> Get(Configuration config, Resources.ResourceManager resourceMgr)
{
return (headers, context) =>
{
var result = new JObject();
var resources = new JArray();
var resourceSource = resourceMgr.GetRunningResources();
string resourceFilter;
if (headers.TryGetByName("resources", out resourceFilter))
{
var resourceNames = resourceFilter.Split(';');
resourceSource = resourceSource.Where(r => resourceNames.Contains(r.Name));
}
else
{
// add the imports, if any
if (config.Imports != null)
{
var imports = new JArray();
config.Imports.ForEach(a => imports.Add(a.ConfigURL));
result["imports"] = imports;
}
}
// generate configuration with our filter function
resourceSource.GenerateConfiguration(resources, (resource, rObject) =>
{
// get download configuration for this resource
var configEntry = resourceMgr.Configuration.GetDownloadConfiguration(resource.Name);
if (configEntry != null)
{
if (!string.IsNullOrWhiteSpace(configEntry.BaseURL))
{
rObject["fileServer"] = configEntry.BaseURL;
}
}
});
result["resources"] = resources;
result["fileServer"] = "http://%s/files/";
result["loadScreen"] = "nui://keks/index.html";
var source = new TaskCompletionSource<JObject>();
source.SetResult(result);
return source.Task;
};
}