本文整理汇总了C#中Author.setname方法的典型用法代码示例。如果您正苦于以下问题:C# Author.setname方法的具体用法?C# Author.setname怎么用?C# Author.setname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author.setname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MSParseProfile
public SearchType MSParseProfile(Uri URL, String compareName, ResultType resType)
{
Author author = new Author();
String type = "Author";
if (resType == ResultType.AUTHOR)
{
type = "Author";
}
else if (resType == ResultType.JOURNAL)
{
type = "Journal";
}
WebClient wc = new WebClient();
wc.Proxy = WebProxy.GetDefaultProxy();
var data = wc.DownloadString(URL);
//Console.WriteLine(data);
JObject obj = JObject.Parse(data);
int resultCount = 0;
/* while (resultCount < obj["d"]["Author"]["Result"].Count())
{
String firstName = (String)obj["d"]["Author"]["Result"][resultCount]["FirstName"];
String lastName = (String)obj["d"]["Author"]["Result"][resultCount]["LastName"];
String middleName = (String)obj["d"]["Author"]["Result"][resultCount]["MiddleName"];
if (compareName.Contains(firstName) || compareName.Contains(lastName) || compareName.Contains(middleName))
{
String authorname = (String)obj["d"]["Author"]["Result"][resultCount]["FirstName"] + " " + (String)obj["d"]["Author"]["Result"][resultCount]["MiddleName"] + " " + (String)obj["d"]["Author"]["Result"][resultCount]["LastName"];
Console.WriteLine(authorname);
author.setname(authorname);
String hindex = (String)obj["d"]["Author"]["Result"][resultCount]["HIndex"];
author.sethIndex(Convert.ToInt32(hindex));
String iindex = (String)obj["d"]["Author"]["Result"][resultCount]["GIndex"];
author.setiIndex(Convert.ToInt32(iindex));
String count = (String)obj["d"]["Author"]["Result"][resultCount]["CitationCount"];
author.setnumPapers(Convert.ToInt32(count));
}
resultCount++;
}*/
int num = 5;
if (obj["d"][type]["Result"].Count() < num)
{
num = obj["d"][type]["Result"].Count();
}
if (obj["d"][type]["Result"].Count() > 0)
{
String authorname = "";
int fl = 0;
for (int i = 0; i < num; i++)
{
authorname = (String)obj["d"][type]["Result"][i]["FirstName"] + " " + (String)obj["d"][type]["Result"][i]["MiddleName"] + " " + (String)obj["d"][type]["Result"][i]["LastName"];
Console.WriteLine(authorname+"----====----"+compareName);
String[] comp;
char [] ch={' '};
comp = compareName.ToLower().Split(ch);
foreach (String s in comp)
{
if (authorname.ToLower().Contains(s))
{
Console.WriteLine(authorname + "----====----" + compareName);
resultCount = i;
fl=1;
break;
}
}
if (fl == 1)
{
break;
}
}
authorname = (String)obj["d"][type]["Result"][resultCount]["FirstName"] + " " + (String)obj["d"][type]["Result"][resultCount]["MiddleName"] + " " + (String)obj["d"][type]["Result"][resultCount]["LastName"];
Console.WriteLine(authorname);
author.setname(authorname);
String hindex = (String)obj["d"][type]["Result"][resultCount]["HIndex"];
author.sethIndex(Convert.ToInt32(hindex));
String iindex = (String)obj["d"][type]["Result"][resultCount]["GIndex"];
author.setiIndex(Convert.ToInt32(iindex));
String count = (String)obj["d"][type]["Result"][resultCount]["CitationCount"];
//.........这里部分代码省略.........
示例2: GSParseProfile
public void GSParseProfile(Uri URL)
{
String strResponse = this.GSTryConnect(URL);
HtmlDocument document = new HtmlDocument();
document.Load(new StringReader(strResponse));
String authorName = "";
String residence = "";
String interest = "";
String hindex = "";
String iindex = "";
String totalcitations = "";
this.resultList.resultType = this.query.resultType;
this.resultList.loadType();
SearchType type;
Author author = new Author();
author.setresArea("");
author.setstatsGraphUrl(new Uri("http://google.com"));
author.setinstitute("");
HtmlNode profileNode = document.DocumentNode.SelectSingleNode("//div[@class='g-section g-tpl-250-alt']//div[@class='g-unit']");
if (profileNode != null)
{
//Console.WriteLine("hey");
// Console.WriteLine(profileNode.InnerText);
// Author author = new Author();
HtmlNode userInfoNode = profileNode.SelectSingleNode("//div[@class='cit-user-info']//div[@class='g-unit']");
HtmlNode userNameNode = userInfoNode.SelectSingleNode("//span[@id='cit-name-read']");
authorName = userNameNode.InnerText;
author.setname(authorName);
HtmlNode userResidenceNode = userInfoNode.SelectSingleNode("//span[@id='cit-affiliation-read']");
residence = userResidenceNode.InnerText;
author.setinstitute(residence);
HtmlNode userInterestNode = userInfoNode.SelectSingleNode("//span[@id='cit-int-read']");
interest = userInterestNode.InnerText;
author.setresArea(interest);
Console.WriteLine("Author " + authorName + residence + interest);
HtmlNode dataNode = profileNode.SelectSingleNode("div[@class='cit-lbb']//table//tr//table[@id='stats']");
if (dataNode != null)
{
int i = 0;
foreach (HtmlNode hindexNode in dataNode.SelectNodes("tr//td[@class='cit-borderleft cit-data']"))
{
if (i == 0)
{
totalcitations = hindexNode.InnerText;
author.setnumPapers(Convert.ToInt32(totalcitations));
}
else if (i == 2)
{
hindex = hindexNode.InnerText;
author.sethIndex(Convert.ToInt32(hindex));
}
else if (i == 4)
{
iindex = hindexNode.InnerText;
author.setiIndex(Convert.ToInt32(iindex));
}
i++;
}
HtmlNode imageNode = profileNode.SelectSingleNode("div[@class='cit-lbb']//table//td[@valign='top']//img[@src]");
String url = imageNode.Attributes["src"].Value;
Console.WriteLine(hindex + "hey " + iindex + "hi" + totalcitations + " " + url);
url = System.Net.WebUtility.HtmlDecode(url);
var strUrl = new Uri(url);
author.setstatsGraphUrl(strUrl);
type = author;
this.resultList.type = type;
}
}
else
{
//.........这里部分代码省略.........