本文整理汇总了C#中Args.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Args.Set方法的具体用法?C# Args.Set怎么用?C# Args.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Search
/// <summary>
/// Creates a simplified synchronous search using search arguments.
/// </summary>
/// <param name="query">The search string.</param>
/// <param name="inputArgs">The variable arguments.</param>
/// <param name="outputArgs">The output arguments.</param>
/// <returns>The stream handle of the search.</returns>
/// <remarks>
/// Use this method for simple searches.
/// </remarks>
public Stream Search(string query, Args inputArgs, Args outputArgs)
{
inputArgs = Args.Create(inputArgs);
inputArgs.Set("search", query);
// always block until results are ready.
inputArgs.Set("exec_mode", "blocking");
Job job = this.GetJobs().Create(query, inputArgs);
return job.Results(outputArgs);
}
示例3: Login
/// <summary>
/// Authenticates the <see cref="Service"/> instance with a username
/// and password.
/// </summary>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
/// <returns>The <see cref="Service"/>.</returns>
public Service Login(string username, string password)
{
this.Username = username;
this.Password = password;
Args args = new Args();
args.Set("username", username);
args.Set("password", password);
ResponseMessage response = Post("/services/auth/login", args);
StreamReader streamReader = new StreamReader(response.Content);
XmlDocument doc = new XmlDocument();
doc.LoadXml(streamReader.ReadToEnd());
string sessionKey = doc
.SelectSingleNode("/response/sessionKey")
.InnerText;
this.Token = "Splunk " + sessionKey;
this.Version = this.GetInfo().Version;
if (!this.Version.Contains("."))
{
// internal build
this.Version = "6.0";
}
if (this.VersionCompare("4.3") >= 0)
{
this.PasswordEndPoint = "storage/passwords";
}
return this;
}