本文整理汇总了C#中Config.get方法的典型用法代码示例。如果您正苦于以下问题:C# Config.get方法的具体用法?C# Config.get怎么用?C# Config.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateOutput
public string GenerateOutput(HttpContext context, Config c)
{
StringBuilder sb = new StringBuilder();
//Figure out CustomErrorsMode
System.Configuration.Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
CustomErrorsSection section = (configuration != null) ? section = (CustomErrorsSection)configuration.GetSection("system.web/customErrors") : null;
CustomErrorsMode mode = (section != null) ? section.Mode : CustomErrorsMode.RemoteOnly;
//What is diagnostics enableFor set to?
DiagnosticMode dmode = c.get<DiagnosticMode>("diagnostics.enableFor", DiagnosticMode.None);
//Is it set all all?
bool diagDefined = (c.get("diagnostics.enableFor",null) != null);
//Is it available from localhost.
bool availLocally = (!diagDefined && mode == CustomErrorsMode.RemoteOnly) || (dmode == DiagnosticMode.Localhost);
sb.AppendLine("The Resizer diagnostics page is " + (availLocally ? "only available from localhost." : "disabled."));
sb.AppendLine();
if (diagDefined) sb.AppendLine("This is because <diagnostics enableFor=\"" + dmode.ToString() + "\" />.");
else sb.AppendLine("This is because <customErrors mode=\"" + mode.ToString() + "\" />.");
sb.AppendLine();
sb.AppendLine("To override for localhost access, add <diagnostics enableFor=\"localhost\" /> in the <resizer> section of Web.config.");
sb.AppendLine();
sb.AppendLine("To ovveride for remote access, add <diagnostics enableFor=\"allhosts\" /> in the <resizer> section of Web.config.");
sb.AppendLine();
return sb.ToString();
}
示例2: Install
public IPlugin Install(Configuration.Config c)
{
this.c = c;
c.Plugins.add_plugin(this);
c.Pipeline.PostAuthorizeRequestStart += Pipeline_PostAuthorizeRequestStart;
c.Pipeline.RewriteDefaults += Pipeline_RewriteDefaults;
redirectThrough = c.get("cloudfront.redirectthrough", null);
redirectPermanent = c.get("cloudfront.permanentRedirect", false);
return this;
}
示例3: SizeLimits
public SizeLimits(Config c)
: base("SizeLimits")
{
//<sizelimits imageWidth="" imageHeight="" totalWidth="" totalHeight="" totalBehavior="ignorelimits|throwexception" />
int imgWidth = c.get("sizelimits.imageWidth", imageSize.Width);
int imgHeight = c.get("sizelimits.imageHeight", imageSize.Height);
imageSize = new Size(imgWidth, imgHeight);
int totalWidth = Math.Max(1, c.get("sizelimits.totalWidth", totalSize.Width));
int totalHeight = Math.Max(1, c.get("sizelimits.totalHeight", totalSize.Height));
if (totalWidth < 1 || totalHeight < 1)
AcceptIssue(new Issue("sizelimits.totalWidth and sizelimits.totalHeight must both be greater than 0. Reverting to defaults.", IssueSeverity.ConfigurationError));
else
totalSize = new Size(totalWidth, totalHeight);
totalBehavior = c.get<TotalSizeBehavior>("sizelimits.totalbehavior", TotalSizeBehavior.ThrowException);
}
示例4: GenerateOutput
//.........这里部分代码省略.........
string edition = null;
//Pick the largest edition
foreach (string s in new string[] { "R3Elite", "R3Creative", "R3Performance" })
{
if (new List<string>(editionsUsed.Values).Contains(s))
{
edition = s;
break;
}
}
Dictionary<string, string> friendlyNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
friendlyNames.Add("R3Elite", "Elite Edition or Support Contract");
friendlyNames.Add("R3Creative", "Creative Edition");
friendlyNames.Add("R3Performance", "Performance Edition");
if (edition == null)
sb.AppendLine("\nYou are not using any paid plugins.");
else {
sb.Append("\nYou are using plugins from the " + friendlyNames[edition] + ": ");
foreach (string s in editionsUsed.Keys) sb.Append(s + " (" + friendlyNames[editionsUsed[s]] + "), ");
sb.Remove(sb.Length - 2, 2);
sb.AppendLine();
}
sb.AppendLine("\nRegistered plugins:\n");
foreach (IPlugin p in c.Plugins.AllPlugins)
sb.AppendLine(p.ToString());
sb.AppendLine("\nConfiguration:\n");
//Let plugins redact sensitive information from the configuration before we display it
Node n = c.getConfigXml();
foreach (IRedactDiagnostics d in c.Plugins.GetAll<IRedactDiagnostics>())
n = d.RedactFrom(n);
string config = n.ToString();
string pwd = c.get("remoteReader.signingKey", String.Empty);
if (!string.IsNullOrEmpty(pwd)) config.Replace(pwd,"*********");
sb.AppendLine(config);
sb.AppendLine("\nAccepted querystring keys:\n");
foreach (string s in c.Pipeline.SupportedQuerystringKeys) {
sb.Append(s + ", ");
}
sb.AppendLine();
sb.AppendLine("\nAccepted file extensions:\n");
foreach (string s in c.Pipeline.AcceptedImageExtensions) {
sb.Append(s + ", ");
}
sb.AppendLine();
//Echo server assembly, iis version, OS version, and CLR version.
sb.AppendLine("\nEnvironment information:\n");
string iis = context != null ? context.Request.ServerVariables["SERVER_SOFTWARE"] : "NOT ASP.NET";
if (!string.IsNullOrEmpty(iis)) iis += " on ";
sb.AppendLine("Running " + iis +
System.Environment.OSVersion.ToString() + " and CLR " +
System.Environment.Version.ToString());
sb.AppendLine("Trust level: " + GetCurrentTrustLevel().ToString());
try{
string wow64 = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432");
string arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
示例5: LoadSettings
/// <summary>
/// Uses the defaults from the resizing.diskcache section in the specified configuration.
/// Throws an invalid operation exception if the DiskCache is already started.
/// </summary>
public void LoadSettings(Config c)
{
Subfolders = c.get("diskcache.subfolders", Subfolders);
Enabled = c.get("diskcache.enabled", Enabled);
AutoClean = c.get("diskcache.autoClean", AutoClean);
VirtualCacheDir = c.get("diskcache.dir", VirtualCacheDir);
HashModifiedDate = c.get("diskcache.hashModifiedDate", HashModifiedDate);
CacheAccessTimeout = c.get("diskcache.cacheAccessTimeout", CacheAccessTimeout);
AsyncBufferSize = c.get("diskcache.asyncBufferSize", AsyncBufferSize);
AsyncWrites = c.get("diskcache.asyncWrites", AsyncWrites);
CleanupStrategy.LoadFrom(c.getNode("cleanupStrategy"));
}
示例6: Install
/// <summary>
/// Loads the settings from 'c', starts the cache, and registers the plugin.
/// Will throw an invalidoperationexception if already started.
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
public IPlugin Install(Config c)
{
if (c.get("diskcache.logging", false)) {
if (c.Plugins.LogManager != null)
log = c.Plugins.LogManager.GetLogger("ImageResizer.Plugins.DiskCache");
else
c.Plugins.LoggingAvailable += delegate(ILogManager mgr) {
if (log != null) log = c.Plugins.LogManager.GetLogger("ImageResizer.Plugins.DiskCache");
};
}
LoadSettings(c);
Start();
c.Pipeline.AuthorizeImage += Pipeline_AuthorizeImage;
c.Plugins.add_plugin(this);
return this;
}
示例7: Install
public IPlugin Install(Configuration.Config c)
{
this.c = c;
c.Plugins.add_plugin(this);
c.Pipeline.PostAuthorizeRequestStart += Pipeline_PostAuthorizeRequestStart;
c.Pipeline.RewriteDefaults += Pipeline_RewriteDefaults;
c.Pipeline.PostRewrite += Pipeline_PostRewrite;
AllowedRedirects = c.get("remoteReader.allowedRedirects",AllowedRedirects);
return this;
}
示例8: test007_readUserConfig
public void test007_readUserConfig()
{
MockSystemReader mockSystemReader = new MockSystemReader();
SystemReader.setInstance(mockSystemReader);
string hostname = mockSystemReader.getHostname();
Config userGitConfig = mockSystemReader.userGitConfig;
Config localConfig = new Config(userGitConfig);
mockSystemReader.values.Clear();
string authorName;
string authorEmail;
// no values defined nowhere
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);
// the system user name is defined
mockSystemReader.values.put(Constants.OS_USER_NAME_KEY, "os user name");
localConfig.uncache(UserConfig.KEY);
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
Assert.AreEqual("os user name", authorName);
if (hostname != null && hostname.Length != 0)
{
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("os user [email protected]" + hostname, authorEmail);
}
// the git environment variables are defined
mockSystemReader.values.put(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
mockSystemReader.values.put(Constants.GIT_AUTHOR_EMAIL_KEY, "[email protected]");
localConfig.uncache(UserConfig.KEY);
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("git author name", authorName);
Assert.AreEqual("[email protected]", authorEmail);
// the values are defined in the global configuration
userGitConfig.setString("user", null, "name", "global username");
userGitConfig.setString("user", null, "email", "[email protected]");
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("global username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
// the values are defined in the local configuration
localConfig.setString("user", null, "name", "local username");
localConfig.setString("user", null, "email", "[email protected]");
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("local username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
authorName = localConfig.get(UserConfig.KEY).getCommitterName();
authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail();
Assert.AreEqual("local username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
}
示例9: NotifyUse
/// <summary>
/// Notifies the licensing service that the given feature is active in the given app configuration,
/// so that it may take appropriate verification steps asynchronously, or schedule the request for watermarking upon failure.
/// </summary>
/// <param name="config"></param>
/// <param name="feature"></param>
/// <param name="featureDisplayName"></param>
internal static void NotifyUse(Config config, Guid feature)
{
//We only deal with ASP.NET requests. Outside of an HTTP request, no licensing is enforced
if (HttpContext.Current == null) return;
//Map local requests if configured
string domain = HttpContext.Current.Request.Url.DnsSafeHost;
if (HttpContext.Current.Request.IsLocal) {
domain = config.get("licenses.local.use", null);
//We can't continue if we don't have a domain to work with
if (domain == null) return;
}
//Locate master license service
ILicenseService s = config.Plugins.GetOrInstall<ILicenseService>(CreateVerifier());
//Verify the ILicenseService instance hasn't been replaced or tampered with since startup
lock(lockTracker){
long seed = feature.ToString().GetHashCode();
long auth = seed;
if (tracker == null) tracker = new Dictionary<Config, Dictionary<Guid, long>>();
Dictionary<Guid, long> ct;
if (!tracker.TryGetValue(config, out ct)) {
ct = new Dictionary<Guid, long>();
tracker.Add(config, ct);
} else if (!ct.TryGetValue(feature, out auth)) auth = seed;
long response = s.VerifyAuthenticity(feature);
if (response != auth) throw new ImageProcessingException("Licensing service responded incorrectly; tampering suspected.");
tracker[config][feature] = auth + 1;
}
//Inform the license service that the specified feature is in use for the given domain and configuration
s.NotifyUse(domain, feature);
}