当前位置:网站首页>use. Net analysis Net talent challenge participation
use. Net analysis Net talent challenge participation
2022-07-06 20:31:00 【Sang Yu Xiao Wu】
background
C# Is my 2012 Contacted in college courses in ,.NET Framework I've been using it so far . from 2014 year .NET Open source ,2019 Released in .NET Core 3 When , The company happens to have Nvidia Jetson platform Linux Development tasks of embedded devices ,.NET It just applies to Windows, Linux, and macOS Cross platform solutions for . It's easy for me to get started , It began a new process of understanding it , According to Microsoft's official .NET The document has also done several hands-on projects .
21 At the end of the year, I helped university teachers develop a garden credit evaluation system , This task can be said to be quite urgent , All the front and rear ends are completed by one person , There are only three or four days off on New Year's Day , Although the task is arduous , It's a challenge , Just then I finished learning .NET Of 《 Create your own first Web application 》, Let the challenge be more intense —— use .NET. In fact, it's not to challenge yourself , A better way to learn a language is to follow the project while learning and writing , It's twelve o'clock in the middle of the night , Fortunately, the delivery was completed on time .
At that time, the middleware for authentication and authorization written by myself also put Jwt The authentication is realized once . ok , This is the consequence of not having a teacher . Then when I finish my project, I'm free , Just in the circle of friends, I saw what Mr. Yang Zhongke sent .NET Recording and broadcasting sharing . really , What a timely rain .
Then I received the invitation from Mr. Yang's circle of friends , I really don't covet that there is something in the prize that Mr. Yang hasn't sent yet .NET New book .
So I took part in 《.NET 20 Annual learning challenge | seek .NET Technical expert 》 , And completed the challenge of three modules . Through these three challenges, we are systematically right .NET Have a preliminary understanding of the ability of . Find out .NET Can do more interesting things , adopt Xamarin Preliminary understanding of Technology , I played with the Xiaomi watch that fell gray at the table because of the epidemic , Recently, it is being studied with Xamarin How technology simulates through Bluetooth HID Equipment control computer , Be a flying rat between your wrists .
Back to the challenge , The challenge is 5 month 21 End of the day , I just want to ask the organizer about Mr. Yang's book , ah , No , It's a prize , You see, I have a chance ?
Ample food and clothing by working with our own hands. , It's over to grab and analyze the ranking list by yourself .
Knowledge needed
Based on the code I have completed , I've sorted out , Complete this small project ( Everything is a project ) The required knowledge points .
First, we need to get the data of the leaderboard , You may need to use reptile Technology , Capture and analyze web pages , Then when analyzing the web page request , I found that the official ranking data is through API Acquired , And no authentication is required , This is too convenient . We can pull the ranking data at one time by slightly changing the parameters .
https://docs.microsoft.com/api/challenges/17c618cc-3c82-4a29-b2c6-d78b1de10b98/leaderboard?%24top=100&%24skip=0
F12 Open web debugging , Get the corresponding challenge ranking page as above API Address , The parameter top Change it to 100,skip Change it to 0 that will do .
In this way, other technologies or knowledge points we need are as follows :
- adopt HttpClient Use REST service
- Asynchronous programming async await Basic use
- Use System.Text.Json analysis Json data
- LINQ Basic approach
Of course, there are other unnecessary , Such as anonymous objects .
Realize the idea
Prepare the data
First, create an anonymous object based on the ranking data of the three challenges
// API There is a course name in the , Write it directly in order to recognize
var apiInfo = new[]{
(
title:"C# Study ",
url:"https://docs.microsoft.com/api/challenges/17c618cc-3c82-4a29-b2c6-d78b1de10b98/leaderboard?%24top=100&%24skip=0"
),
(
title:"ASP.NET Core Development ",
url:"https://docs.microsoft.com/api/challenges/b64cc891-e999-4652-909b-d545698a2e60/leaderboard?%24top=100&%24skip=0"
),
(
title:".NET Mobile application ",
url:"https://docs.microsoft.com/api/challenges/38ec3c07-3ce6-4fb8-b423-b79166202364/leaderboard?%24top=100&%24skip=0"
)
};
Design objects that store data
Create a class that stores the challenger's learning information , It contains the name of the Challenger userName , Number of challenges completed learnNum And the challenges accomplished learnName , And a method to add a new challenge class addClass
public class StudyInfo {
public StudyInfo(string userName, int learnNum, List<string> learnName)
{
this.userName = userName;
this.learnNum = learnNum;
this.learnName = learnName;
}
public string userName {
get;private set; }
public int learnNum {
get; private set; }
public List<string> learnName{
get; private set; }
public void addClass(string className) {
this.learnNum++;
this.learnName.Add(className);
}
}
Leaderboard data acquisition
Use HttpClient Get the data of challenge leaderboard
var client = new HttpClient();
foreach (var item in apiInfo)
{
string jsoninfo = await client.GetStringAsync(item.url);
// analysis
}
Data analysis and output
Conduct json Data analysis , Through the specific returned content, we can easily find the meaning represented by the field .
totalScoreUnits Indicates the number of sections of this challenge , Only by completing so many sections of learning can we complete the challenge , Use var user = new List<StudyInfo>(); To store user challenge information , Create or update data according to the analysis results . Finally, the results are arranged in reverse order and output to the file .
stay System.Text.Json We need to pay attention to several points in the use of :
- Acquired json The value of , We need to force data conversion , Save the user's learning course
scoreNeed to use float type - Traverse json Array time , You need to put it first JsonNode Object to carry out
AsArray()Handle ,JsonNode It is not supported foreach Of - The final output json Serialization , Need to carry out
optionsSet up , In this way, Chinese characters will not be encoded
var options = new JsonSerializerOptions {
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) };
JsonNode jsonNode = JsonNode.Parse(jsoninfo)!;
// Total number of courses
int classnum = (int)jsonNode["totalScoreUnits"]!;
foreach (var uinfo in jsonNode["results"]!.AsArray())
{
// Users who have finished learning
if ((float)uinfo["score"]! == classnum)
{
// See if there is any information about this user
var temp = user.FirstOrDefault(e => e.userName == (string)uinfo["userDisplayName"]!);
if (temp is null)
{
// Initially create this user
user.Add(new StudyInfo((string)uinfo["userDisplayName"]!, 1, new List<string>() {
item.title }));
}
else
{
// Yes , Update learning data
temp.addClass(item.title);
}
}
}
// Reverse order and turn to json The characters are stored in the file
var jsonRes = JsonSerializer.Serialize(user.OrderByDescending(x => x.learnNum), options);
File.WriteAllText("output.json", jsonRes);
Make a simple analysis
It's mostly used here Linq operation , If the Linq Don't understand , You can take a look at Mr. Yang's related courses .
// A brief analysis of
Console.WriteLine($" complete 《C# Study 》{
user.Where(x=>x.learnName.IndexOf("C# Study ")>-1).Count()} people ");
Console.WriteLine($" complete 《ASP.NET Core Development 》{
user.Where(x => x.learnName.IndexOf("ASP.NET Core Development ") > -1).Count()} people ");
Console.WriteLine($" complete 《.NET Mobile application 》{
user.Where(x => x.learnName.IndexOf(".NET Mobile application ") > -1).Count()} people ");
Console.WriteLine($" Only complete 1 Challenge {
user.Where(x => x.learnNum == 1).Count()} people ");
Console.WriteLine($" Only complete 2 Challenge {
user.Where(x => x.learnNum ==2).Count()} people ");
Console.WriteLine($" To complete 3 Challenge {
user.Where(x => x.learnNum == 3).Count()} people \n Namely ");
foreach (var item in user.Where(x => x.learnNum == 3)) {
Console.WriteLine(item.userName);
}
Last
The detailed code implementation I put in .Net Analysis of talent challenge participation github , Students who are interested in it can choose .
.NET Is a free cross platform open source Developer Platform , hope .NET Can develop better and better . If you want to know more about .NET , It is highly recommended to go to B Stand and pay attention to Mr. Yang Zhongke To learn his related video courses . You can also focus on “dotNet Cross platform ” Official account to learn more .NET technology ;.NET Learning and community activities Can pay attention to :MSReactor .

边栏推荐
- Deep learning classification network -- zfnet
- Case ① | host security construction: best practice of 3 levels and 11 capabilities
- BeagleBoneBlack 上手记
- 【计网】第三章 数据链路层(3)信道划分介质访问控制
- Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
- Pytest (3) - Test naming rules
- 2022 refrigeration and air conditioning equipment installation and repair examination contents and new version of refrigeration and air conditioning equipment installation and repair examination quest
- Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
- Leetcode question 448 Find all missing numbers in the array
- String length limit?
猜你喜欢

Anaconda安装后Jupyter launch 没反应&网页打开运行没执行
![[DIY]自己设计微软MakeCode街机,官方开源软硬件](/img/a3/999c1d38491870c46f380c824ee8e7.png)
[DIY]自己设计微软MakeCode街机,官方开源软硬件
![[DSP] [Part 1] start DSP learning](/img/81/051059958dfb050cb04b8116d3d2a8.png)
[DSP] [Part 1] start DSP learning

Pytest (3) - Test naming rules

Continuous test (CT) practical experience sharing

(work record) March 11, 2020 to March 15, 2021

Quel genre de programmation les enfants apprennent - ils?

Le lancement du jupyter ne répond pas après l'installation d'Anaconda

How does kubernetes support stateful applications through statefulset? (07)

Digital triangle model acwing 1018 Minimum toll
随机推荐
Why do novices often fail to answer questions in the programming community, and even get ridiculed?
Qinglong panel white screen one key repair
What programming do children learn?
枚举根据参数获取值
OLED屏幕的使用
[network planning] Chapter 3 data link layer (4) LAN, Ethernet, WLAN, VLAN
Tencent T3 teaches you hand in hand. It's really delicious
Groovy基础语法整理
Catch ball game 1
[cloud native and 5g] micro services support 5g core network
Wechat applet common collection
Leetcode question 283 Move zero
[network planning] Chapter 3 data link layer (3) channel division medium access control
Leetcode question 448 Find all missing numbers in the array
永磁同步电机转子位置估算专题 —— 基波模型类位置估算概要
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
Discussion on beegfs high availability mode
Number of schemes from the upper left corner to the lower right corner of the chessboard (2)
OLED屏幕的使用
Anaconda安装后Jupyter launch 没反应&网页打开运行没执行