本文整理汇总了C#中IWebAgent类的典型用法代码示例。如果您正苦于以下问题:C# IWebAgent类的具体用法?C# IWebAgent怎么用?C# IWebAgent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWebAgent类属于命名空间,在下文中一共展示了IWebAgent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RedditUser
public RedditUser(Reddit reddit, JToken json, IWebAgent webAgent)
: base(json)
{
Reddit = reddit;
WebAgent = webAgent;
JsonConvert.PopulateObject(json["data"].ToString(), this, reddit.JsonSerializerSettings);
}
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:7,代码来源:RedditUser.cs
示例2: Post
public Post(Reddit reddit, JToken post, IWebAgent webAgent)
: base(reddit, webAgent, post)
{
Reddit = reddit;
WebAgent = webAgent;
JsonConvert.PopulateObject(post["data"].ToString(), this, reddit.JsonSerializerSettings);
}
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:7,代码来源:Post.cs
示例3: VotableThing
public VotableThing(Reddit reddit, IWebAgent webAgent, JToken json)
: base(reddit, json)
{
Reddit = reddit;
WebAgent = webAgent;
JsonConvert.PopulateObject(json["data"].ToString(), this, Reddit.JsonSerializerSettings);
}
开发者ID:AndreCAndersen,项目名称:RedditSharp,代码行数:7,代码来源:VotableThing.cs
示例4: Comment
public Comment(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
: base(reddit, webAgent, json)
{
var data = json["data"];
JsonConvert.PopulateObject(data.ToString(), this, reddit.JsonSerializerSettings);
Reddit = reddit;
WebAgent = webAgent;
// Parse sub comments
// TODO: Consider deserializing this properly
var subComments = new List<Comment>();
if (data["replies"] != null && data["replies"].Any())
{
foreach (var comment in data["replies"]["data"]["children"])
subComments.Add(new Comment(reddit, comment, webAgent, sender));
}
Comments = subComments.ToArray();
this.Parent = sender;
// Handle Reddit's API being horrible
if (data["context"] != null)
{
var context = data["context"].Value<string>();
LinkId = context.Split('/')[4];
}
}
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:27,代码来源:Comment.cs
示例5: InitAsync
public async new Task<AuthenticatedUser> InitAsync(Reddit reddit, JToken json, IWebAgent webAgent)
{
CommonInit(reddit, json, webAgent);
await Task.Factory.StartNew(() => JsonConvert.PopulateObject(json["name"] == null ? json["data"].ToString() : json.ToString(), this,
reddit.JsonSerializerSettings));
return this;
}
开发者ID:j1xwnbsr,项目名称:HFYBotReborn,代码行数:7,代码来源:AuthenticatedUser.cs
示例6: Init
public new AuthenticatedUser Init(Reddit reddit, JToken json, IWebAgent webAgent)
{
CommonInit(reddit, json, webAgent);
JsonConvert.PopulateObject(json["name"] == null ? json["data"].ToString() : json.ToString(), this,
reddit.JsonSerializerSettings);
return this;
}
开发者ID:j1xwnbsr,项目名称:HFYBotReborn,代码行数:7,代码来源:AuthenticatedUser.cs
示例7: AuthProvider
/// <summary>
/// Allows use of reddit's OAuth interface, using an app set up at https://ssl.reddit.com/prefs/apps/.
/// </summary>
/// <param name="clientId">Granted by reddit as part of app.</param>
/// <param name="clientSecret">Granted by reddit as part of app.</param>
/// <param name="redirectUri">Selected as part of app. Reddit will send users back here.</param>
/// <param name="agent">Implementation of IWebAgent to use to make requests.</param>
public AuthProvider(string clientId, string clientSecret, string redirectUri, IWebAgent agent)
{
_clientId = clientId;
_clientSecret = clientSecret;
_redirectUri = redirectUri;
_webAgent = agent;
}
开发者ID:j1xwnbsr,项目名称:HFYBotReborn,代码行数:14,代码来源:AuthProvider.cs
示例8: InitAsync
public async Task<RedditUser> InitAsync(Reddit reddit, JToken json, IWebAgent webAgent)
{
CommonInit(reddit, json, webAgent);
await JsonConvert.PopulateObjectAsync(json["name"] == null ? json["data"].ToString() : json.ToString(), this,
reddit.JsonSerializerSettings);
return this;
}
开发者ID:haroldma,项目名称:RedditSharp,代码行数:7,代码来源:RedditUser.cs
示例9: Init
public Comment Init(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
{
var data = CommonInit(reddit, json, webAgent, sender);
ParseComments(reddit, json, webAgent, sender);
JsonConvert.PopulateObject(data.ToString(), this, reddit.JsonSerializerSettings);
return this;
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:7,代码来源:Comment.cs
示例10: InitAsync
public async Task<Comment> InitAsync(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
{
var data = CommonInit(reddit, json, webAgent, sender);
await ParseCommentsAsync(reddit, json, webAgent, sender);
await Task.Factory.StartNew(() => JsonConvert.PopulateObject(data.ToString(), this, reddit.JsonSerializerSettings));
return this;
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:7,代码来源:Comment.cs
示例11: WikiPageSettings
protected internal WikiPageSettings(Reddit reddit, JToken json, IWebAgent webAgent)
{
var editors = json["editors"].ToArray();
Editors = editors.Select(x =>
{
return new RedditUser(reddit, x, webAgent);
});
JsonConvert.PopulateObject(json.ToString(), this, reddit.JsonSerializerSettings);
}
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:9,代码来源:WikiPageSettings.cs
示例12: SubredditImage
public SubredditImage(Reddit reddit, SubredditStyle subredditStyle,
string cssLink, string name, IWebAgent webAgent)
{
Reddit = reddit;
WebAgent = webAgent;
SubredditStyle = subredditStyle;
Name = name;
CssLink = cssLink;
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:9,代码来源:SubredditImage.cs
示例13: SubredditStyle
public SubredditStyle(Reddit reddit, Subreddit subreddit, JToken json, IWebAgent webAgent) : this(reddit, subreddit, webAgent)
{
Images = new List<SubredditImage>();
var data = json["data"];
CSS = HttpUtility.HtmlDecode(data["stylesheet"].Value<string>());
foreach (var image in data["images"])
{
Images.Add(new SubredditImage(
Reddit, this, image["link"].Value<string>(),
image["name"].Value<string>(), image["url"].Value<string>(), WebAgent));
}
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:12,代码来源:SubredditStyle.cs
示例14: ParseCommentsAsync
private async Task ParseCommentsAsync(Reddit reddit, JToken data, IWebAgent webAgent, Thing sender)
{
// Parse sub comments
// TODO: Consider deserializing this properly
var subComments = new List<Comment>();
if (data["replies"] != null && data["replies"].Any())
{
foreach (var comment in data["replies"]["data"]["children"])
subComments.Add(await new Comment().InitAsync(reddit, comment, webAgent, sender));
}
Comments = subComments.ToArray();
}
开发者ID:haroldma,项目名称:RedditSharp,代码行数:12,代码来源:Comment.cs
示例15: ParseCommentsAsync
private async Task ParseCommentsAsync(Reddit reddit, JToken data, IWebAgent webAgent, Thing sender)
{
// Parse sub comments
var replies = data["data"]["replies"];
var subComments = new List<Comment>();
if (replies != null && replies.Count() > 0)
{
foreach (var comment in replies["data"]["children"])
subComments.Add(await new Comment().InitAsync(reddit, comment, webAgent, sender));
}
Comments = subComments.ToArray();
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:12,代码来源:Comment.cs
示例16: Subreddit
protected internal Subreddit(Reddit reddit, JToken json, IWebAgent webAgent)
: base(json)
{
Reddit = reddit;
WebAgent = webAgent;
JsonConvert.PopulateObject(json["data"].ToString(), this, reddit.JsonSerializerSettings);
Name = Url;
if (Name.StartsWith("/r/"))
Name = Name.Substring(3);
if (Name.StartsWith("r/"))
Name = Name.Substring(2);
Name = Name.TrimEnd('/');
}
开发者ID:JosephDomenici,项目名称:Reddit-Readability-Bot,代码行数:13,代码来源:Subreddit.cs
示例17: RedditAuth
public RedditAuth(IWebAgent agent)
{
_uname = ConfigurationManager.AppSettings["BotUsername"];
_pass = ConfigurationManager.AppSettings["BotPassword"];
_clientId = ConfigurationManager.AppSettings["ClientID"];
_clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
_redirectUri = ConfigurationManager.AppSettings["RedirectURI"];
if ( string.IsNullOrEmpty( _uname ) ) throw new Exception( "Missing 'BotUsername' in config" );
if ( string.IsNullOrEmpty( _pass ) ) throw new Exception( "Missing 'BotPassword' in config" );
if ( string.IsNullOrEmpty( _clientId ) ) throw new Exception( "Missing 'ClientID' in config" );
if ( string.IsNullOrEmpty( _clientSecret ) ) throw new Exception( "Missing 'ClientSecret' in config" );
if ( string.IsNullOrEmpty( _redirectUri ) ) throw new Exception( "Missing 'RedirectURI' in config" );
_webAgent = agent;
_timerState = new TimerState();
}
开发者ID:CrustyJew,项目名称:DirtBag,代码行数:15,代码来源:RedditAuth.cs
示例18: CommonInit
private JToken CommonInit(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
{
base.Init(reddit, webAgent, json);
var data = json["data"];
Reddit = reddit;
WebAgent = webAgent;
this.Parent = sender;
// Handle Reddit's API being horrible
if (data["context"] != null)
{
var context = data["context"].Value<string>();
LinkId = context.Split('/')[4];
}
return data;
}
开发者ID:anavaino,项目名称:RedditSharp,代码行数:17,代码来源:Comment.cs
示例19: Parse
public static Thing Parse(Reddit reddit, JToken json, IWebAgent webAgent)
{
var kind = json["kind"].ValueOrDefault<string>();
switch (kind)
{
case "t1":
return new Comment(reddit, json, webAgent, null);
case "t2":
return new RedditUser(reddit, json, webAgent);
case "t3":
return new Post(reddit, json, webAgent);
case "t4":
return new PrivateMessage(reddit, json, webAgent);
case "t5":
return new Subreddit(reddit, json, webAgent);
default:
return null;
}
}
开发者ID:JosephDomenici,项目名称:Reddit-Readability-Bot,代码行数:19,代码来源:Thing.cs
示例20: PrivateMessage
public PrivateMessage(Reddit reddit, JToken json, IWebAgent webAgent)
: base(json)
{
Reddit = reddit;
WebAgent = webAgent;
JsonConvert.PopulateObject(json["data"].ToString(), this, reddit.JsonSerializerSettings);
var data = json["data"];
if (data["replies"] != null && data["replies"].Any())
{
if (data["replies"]["data"] != null)
{
if (data["replies"]["data"]["children"] != null)
{
var replies = new List<PrivateMessage>();
foreach (var reply in data["replies"]["data"]["children"])
replies.Add(new PrivateMessage(reddit, reply, webAgent));
Replies = replies.ToArray();
}
}
}
}
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:21,代码来源:PrivateMessage.cs
注:本文中的IWebAgent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论