本文整理汇总了C#中Args.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# Args.ContainsKey方法的具体用法?C# Args.ContainsKey怎么用?C# Args.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args.ContainsKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resource
/// <summary>
/// Initializes a new instance of the <see cref="Resource"/> class,
/// adding optional arguments for namespace and other endpoint
/// arguments.
/// </summary>
/// <param name="service">The service.</param>
/// <param name="path">The path of this resource.</param>
/// <param name="args">The variable arguments.</param>
public Resource(Service service, string path, Args args)
{
this.Service = service;
/* Pull out namespace items (app, owner, sharing) from the args, and
* then use to create the full path.
*/
Args clonedArgs = new Args(args);
Args splunkNamespace = new Args();
if (args.ContainsKey("app"))
{
splunkNamespace.Set("app", args["app"].ToString());
clonedArgs.Remove("app");
}
if (args.ContainsKey("owner"))
{
splunkNamespace.Set("owner", args["owner"].ToString());
clonedArgs.Remove("owner");
}
if (args.ContainsKey("sharing"))
{
splunkNamespace.Set(
"sharing", args["sharing"].ToString());
clonedArgs.Remove("sharing");
}
if (!clonedArgs.ContainsKey("count"))
{
clonedArgs.Set("count", "-1");
}
this.RefreshArgs = clonedArgs;
this.Path = service.Fullpath(
path, splunkNamespace.Count == 0 ? null : splunkNamespace);
this.MaybeValid = false;
}
示例2: Fullpath
/// <summary>
/// Ensures that the given path is fully qualified, prepending a path
/// prefix if necessary.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="splunkNamespace">The Splunk namespace.</param>
/// <returns>A fully qualified URL.</returns>
/// <remarks>
/// The path prefix is constructed using the current owner and app
/// context when available.
/// </remarks>
public string Fullpath(string path, Args splunkNamespace)
{
// If already fully qualified (i.e. root begins with /), then return
// the already qualified path.
if (path.StartsWith("/"))
{
return path;
}
// If no namespace at all and no service instance of app and no
// sharing, return base service endpoint + path.
if (splunkNamespace == null && this.App == null)
{
return "/services/" + path;
}
// Base namespace values.
string localApp = this.App;
string localOwner = this.Owner;
string localSharing = string.Empty;
// Override with invocation namespace if set.
if (splunkNamespace != null)
{
if (splunkNamespace.ContainsKey("app"))
{
localApp = (string)splunkNamespace["app"];
}
if (splunkNamespace.ContainsKey("owner"))
{
localOwner = (string)splunkNamespace["owner"];
}
if (splunkNamespace.ContainsKey("sharing"))
{
localSharing = (string)splunkNamespace["sharing"];
}
}
// Sharing, if set calls for special mapping, override here.
// "user" --> {user}/{app}
// "app" --> nobody/{app}
// "global" --> nobody/{app}
// "system" --> nobody/system
if (localSharing.Equals("app") || localSharing.Equals("global"))
{
localOwner = "nobody";
}
else if (localSharing.Equals("system"))
{
localApp = "system";
localOwner = "nobody";
}
return string.Format(
"/servicesNS/{0}/{1}/{2}",
localOwner == null ? "-" : localOwner,
localApp == null ? "-" : localApp,
path);
}