当前位置:网站首页>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
score
Need 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
options
Set 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 .
边栏推荐
- 使用ssh连接被拒
- Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
- SSH connection denied
- New generation garbage collector ZGC
- BUUCTF---Reverse---easyre
- Implementation of packaging video into MP4 format and storing it in TF Card
- [DSP] [Part 2] understand c6678 and create project
- I've seen many tutorials, but I still can't write a program well. How can I break it?
- Maximum likelihood estimation and cross entropy loss
- Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
猜你喜欢
Utilisation de l'écran OLED
Application layer of tcp/ip protocol cluster
小孩子學什麼編程?
5. Wireless in vivo nano network: top ten "feasible?" problem
Tencent Android development interview, basic knowledge of Android Development
[DSP] [Part 1] start DSP learning
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
Comment faire une radio personnalisée
小孩子学什么编程?
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle
随机推荐
Error analysis ~csdn rebound shell error
BeagleBoneBlack 上手记
Appx code signing Guide
JS implementation force deduction 71 question simplified path
Qinglong panel white screen one key repair
使用.Net驱动Jetson Nano的OLED显示屏
“罚点球”小游戏
Node.js: express + MySQL实现注册登录,身份认证
[cloud native and 5g] micro services support 5g core network
JVM_ Common [interview questions]
【计网】第三章 数据链路层(3)信道划分介质访问控制
知识图谱之实体对齐二
棋盘左上角到右下角方案数(2)
Enumeration gets values based on parameters
逻辑是个好东西
使用.Net分析.Net达人挑战赛参与情况
Leetcode question 448 Find all missing numbers in the array
Node. Js: express + MySQL realizes registration, login and identity authentication
电子游戏的核心原理
【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和