C#知识点
zxcvb036
这个作者很懒,什么都没留下…
展开
-
宁芝蓝牙X87 说明书
说明书原创 2022-05-24 19:16:59 · 4691 阅读 · 0 评论 -
NewtonJson 自定义的JsonConverter用于自定义文本解析函数
先看一下Json的格式。要解析其中的时间戳字段,自带的Converter无法进行,只能自己创建所需的转换函数 { "id": 1384552022690369570, "machineId": 101, "msgCode": 80002, "startTime": 1618937902137, "endTime": 1618937915316, "createStartTime": 16189379005原创 2021-09-09 08:39:16 · 1687 阅读 · 0 评论 -
如何使用Visual Studio 自带的 单元测试框架
参考链接https://docs.microsoft.com/zh-cn/visualstudio/test/getting-started-with-unit-testing?view=vs-2019&tabs=mstest1 在 Visual Studio 中,打开要测试的项目。2 在“解决方案资源管理器”中,选择解决方案节点。 然后,在顶部菜单栏中,选择“文件” > “添加” > “新项目” 。3 在新项目对话框中,找到要使用的测试框架的单元测试项目模板(如 MSTest)原创 2021-07-01 16:06:51 · 859 阅读 · 1 评论 -
c# 模板方法 设计模式
一定要保证 有一个稳定的操作的骨架,对子类虚函数带来变化using System;namespace RefactoringGuru.DesignPatterns.TemplateMethod.Conceptual{ // The Abstract Class defines a template method that contains a skeleton of // some algorithm, composed of calls to (usually) abstra原创 2021-05-08 20:16:26 · 101 阅读 · 0 评论 -
Rabbtmq 主题模式
RabbitMq Topics模式讲解交换机的Fanout模式发送很多冗余的消息,Direct模式可以对消息进行精确的筛选,但因为匹配要求严格,不能给系统太多的自由。* (star) can substitute for exactly one word.# (hash) can substitute for zero or more words.生产者代码using System;using System.Linq;using RabbitMQ.Client;using System.T原创 2021-04-02 09:47:33 · 71 阅读 · 0 评论 -
RabbitMq Routing模式讲解
RabbitMq 路由模式 讲解前面讲到的 将交换机设置成fanout,进行消息广播的模式,对消息没有任何的控制,是一种简单无脑的模式,没法对消息进行过滤和控制步骤1 声明交换机时设置 交换机类型为directchannel.ExchangeDeclare(exchange: “direct_logs”, type: “direct”);2 发布消息到交换机时设置 routingKeyvar body = Encoding.UTF8.GetBytes(message);channel.Bas原创 2021-04-02 09:30:30 · 131 阅读 · 1 评论 -
2021-04-02
/* RabbitMq 发布者/订阅者模式一.1 producer 负责发布消息2 queue 负责存储转发消息3 consumer 负责订阅和消费消息二.1.生产者 不直接发送的消息给一个queue,甚至更多的时候 生产者 甚至不知道消息将被传递给队列生产者直接将消息发送给exchange.2.exchange交换机,一端接收消息 一端将消息push给队列交换机的工作模式1 direct2 topic3 headers4 fanout*/// 生产者的 代码using S原创 2021-04-02 09:16:41 · 55 阅读 · 0 评论 -
RabbitMQ Work Queue模式讲解
RabbitMQ Work Queue模式讲解一.W/Q 模式的结构有一个负责发送任务,多个执行单元接受任务后进行处理。该模式中,没个消费者接受的任务量是均衡的。不会根据具体任务的处理时间进行更精确的分配发布者代码var message = GetMessage(args);var body = Encoding.UTF8.GetBytes(message);var properties = channel.CreateBasicProperties();properties.Persisten原创 2021-04-02 08:38:30 · 191 阅读 · 1 评论 -
C# 反射获得字段 和 修改字段的方法
usingSystem;usingSystem.Reflection; namespaceattributeTest{ [System.AttributeUsage(System.AttributeTargets.Class|System.AttributeTargets.Struct)]publicclassAuthorAttribute:System.Attribute{publicstringname{get;...原创 2021-03-12 12:40:30 · 675 阅读 · 0 评论 -
刘铁锰 WPF MVVM学习笔记
MVVM 定义 Model---数据 View ---界面 ViewModel ---数据和界面的交互 Service----定义数据操作文档结构讲解1 数据准备1.1 基础数据定义 class Dish { public string Name { get; set; } public string Categroy { get; set; } public string Evaluate { get; set;原创 2021-01-21 11:10:50 · 496 阅读 · 0 评论 -
数据库 存储过程
@[TOC]数据库存储过程什么是存储过程 存储 过程就是数据库中编写并保存的函数存储过程的概念 存储过程是为完成特定的功能而编写的一组Sql程序,经编译后存储在数据库中。 存储过程可以接受输入参数 返回表格 结果存储过程的优点1.存储过程的运行速度比较快,大概是sql语句的2-10倍2. 存储过程可以接受参数,输出参数,返回单个 或多个结果,以及报错信息3. 使用存储过程可以完成所有数据库操作,可以校验操作权限 保证数据安全4. 存储过程在服务器端运行,减少了客户机的压力5.原创 2021-01-21 09:17:43 · 2097 阅读 · 0 评论 -
C# Json
Json Api的参考https://www.newtonsoft.com/jsonusing System;using System.Xml;using System.Xml.Serialization;using System.IO;using Newtonsoft.Json;using Newtonsoft.Json.Converters;public class Test{ public static void Main() { Product p原创 2020-12-02 22:50:36 · 139 阅读 · 0 评论 -
C# xmlserializer
using System;using System.Xml;using System.Xml.Serialization;using System.IO;/* The XmlRootAttribute allows you to set an alternate name (PurchaseOrder) of the XML element, the element namespace; by default, the XmlSerializer uses the class nam.原创 2020-12-02 22:22:11 · 811 阅读 · 0 评论 -
C# Dapper 简化数据库操作
参考 :https://www.jianshu.com/p/c4ca2989d26a仍有很多其他复杂操作,Dapper真好使CREATE TABLE [dbo].[Books] ( [BookId] INT NOT NULL, [Publisher] NVARCHAR (30) NULL, [Title] NVARCHAR (50) NOT NULL, CONSTRAINT [PK_Books] PRIMARY KEY CLUSTERED ([BookId]原创 2020-11-28 22:41:35 · 269 阅读 · 0 评论 -
mysql 数据重复则进行修改,无数据则添加数据的操作方法
使用Replace 代替Insert1.设置Table的普通索引alter table table_name add index index_name (column_list) ;2.唯一索引alter table table_name add unique (column_list) ;3.主键索引alter table table_name add primary key (column_list) ;使用 ReplaceREPLACE INTO users (id,name,age)原创 2020-11-26 10:30:09 · 302 阅读 · 0 评论 -
Sql Server 索引
索引的优点·创建唯一索引可以保证每一行数据的唯一性·可以加快数据的检索速度·加速表和表之间的连接,可以实现数据的参照完整性·对数据进行分组或排序时,可以减少查询中分组和排序的时间·通过索引,可以在查询过程中使用优化隐藏器提高系统的性能索引的缺点·创建 索引和维护索引需要耗费时间,这种时间随着数据量的增加而增加·索引需要占用物理空间,除了数据表占用数据空间外,每个索引还要占用一定的物理空间·对表中数据进行增加 删除 修改时,索引也要维护,降低了数据的维护速度分类聚集索引 非聚集索引 全原创 2020-11-24 09:44:30 · 72 阅读 · 0 评论 -
Sql Server 触发器
存储过程 是定义好的工具包,用于实现某一特定的功能触发器是具有智能的工具包,当外界调条件改变时,符合触发器条件时,就自动运行,完成指定的任务事件处理机制作用:·1 对数据库间的数据完整性做强制性约束·2 对数据库中的表进行级联操作,可以自动触发操作的类型·3 跟踪变化,对违法的操作进行回滚或撤销 保证数据库安全·4 可以设定 错误返回的信息,增加程序的可维护性·5 触发器可以调用更多的存储过程分类:1 数据操作语言触发器依附于特定的表或者视图进行操作,当数据服务器有数据操作事件时,触发原创 2020-11-23 20:35:12 · 63 阅读 · 0 评论 -
Sql Server 存储过储
存储过程是 在数据库中存储一段用于查询或其他操作的代码,用于在使用过程中直接调用此过程,防止在使用时语句编写错误定义:CREATE PROCEDURE xxxProcASSELECT * FROM dbo.Grade; 使用:EXEC xxxProc;定义CREATE PROCEDURE QueryById @id intASSELECT * FROM xx WHERE Id = @id;使用EXEC QueryById 23;使用VS 在数据库的 “可编程性” 下查看已原创 2020-11-23 20:07:24 · 223 阅读 · 0 评论 -
C# Entity Framework 依赖注入
using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.ComponentModel.DataAnnotations.Schema;using System.Text;namespace ConsoleApp6{ [Table("Books")] public class Book { public int原创 2020-11-21 23:32:52 · 443 阅读 · 0 评论 -
C# entity framework 数据库操作方法
新建数据库CREATE TABLE [dbo].[Books]( [BookId] INT NOT NULL PRIMARY KEY IDENTITY, [Title] NVARCHAR(50) NOT NULL, [Publisher] NVARCHAR(50) NULL)定义类 [Table("Books")] public class Book { public int BookId { get; set; }原创 2020-11-21 17:35:25 · 425 阅读 · 0 评论 -
WPF Blend 自定义控件
#1.使用Blend 设计控件<UserControl x:Class="WpfApp25.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.open...原创 2020-11-04 08:15:46 · 945 阅读 · 0 评论 -
WPF Blend 制作按钮效果
<Grid Background="#FF815151"> <Ellipse Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="100" Margin="175.263,227.368,0,0" VerticalAlignment="Top" Width="100"> <Ellipse.Effect> <DropShadowEff...原创 2020-11-03 20:03:09 · 520 阅读 · 0 评论 -
WPF Blend 绿色聊天UI, 带侧边栏
1.先看效果2.参考视频链接https://www.bilibili.com/video/BV1954y1e7hP?from=search&seid=4089968730070473333<Window x:Class="WpfApp23.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micros原创 2020-11-03 19:06:27 · 374 阅读 · 0 评论 -
C# MVVM 模型 以及用户管理实例
1.先看效果2.Blend 界面设计,参考https://blog.csdn.net/zxcvb036/article/details/1094687233.文件的结构4.Model class User : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(strin原创 2020-11-03 16:14:57 · 618 阅读 · 0 评论 -
使用Blend 设计 Wpf页面,反向storyboard添加
参考B站视频<Window x:Class="LoginForm.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"原创 2020-11-03 14:27:21 · 348 阅读 · 0 评论 -
WPF中的命令的使用
原创 2020-09-28 15:11:17 · 161 阅读 · 0 评论 -
C# WPF TreeView 等级显示条目
<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xm原创 2020-09-27 13:48:19 · 345 阅读 · 0 评论 -
C# 序列化容器 Xml Json
//序列化 [XmlRoot("SimpleClass")] public class SimpleSerilzedClass { [XmlElement("我的名")] public string Name { get; set; } [XmlElement("我的ID")] public int ID { get; set; } public SimpleSerilzedClass(stri..原创 2020-09-25 16:54:27 · 128 阅读 · 0 评论 -
C# 反射加载dll
原创 2020-09-25 15:39:22 · 140 阅读 · 0 评论 -
C#匿名函数
C#中委托的演变C#1 中,通过使用在代码中其他位置定义的方法显式初始化委托来创建委托的实例C#2中,引入了匿名方法的概念,作为一种编写可在委托调用中执行的未命名内联句块的方式C#3 中,引入了lambda 表达式,这种表达式和匿名方法类似,但更具表达力 更简单。匿名方法 和lambda表达式 合起来被称为匿名函数 class Program { delegate void TestDelegate(string s); static void M(s原创 2020-09-25 14:05:02 · 376 阅读 · 0 评论 -
C# 的适配器模式
背景:将两个无关的类,通过适配器 统一相关操作。//C# 里 A<–Aadapter,直接调用 a 将使用 A类的方法进行输出// 将 A的方法定义乘virtual 将Aadapter 中方法override ,则可以直接使用子类分方法了。//重写和覆盖的区别using System;namespace ConsoleApp24{ class A { public void printSomething() {原创 2020-09-24 17:34:00 · 102 阅读 · 0 评论 -
C# 委托 多播模式
using System;namespace ConsoleApp1{ public delegate void OneDelegateHandler(); class A { public OneDelegateHandler AEvent; public void onTrigger() { if (AEvent != null) { A.原创 2020-07-22 22:36:19 · 106 阅读 · 0 评论 -
C# 信号量semaphore使用
using System;using System.Threading;namespace SemaphoreSample{ class Program { private static Semaphore _pool; private static int _padding; static void Main(string[] args) { // 初始值 设为 0 /原创 2020-07-21 17:54:08 · 274 阅读 · 0 评论 -
WPF 单例启动模式
1.使用系统互斥量进行判断 bool mutexCreated; var mutex = new System.Threading.Mutex(false, "SingleAPP", out mutexCreated); if (!mutexCreated) { return; }2.新建启动文件2.删掉App.xmal...原创 2020-07-21 16:50:53 · 250 阅读 · 0 评论 -
C# Monitor 锁定对象和 计时重入 的例子
using System;using System.Collections.Generic;using System.Diagnostics.Eventing.Reader;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.原创 2020-07-21 15:27:25 · 182 阅读 · 0 评论 -
C# BackgroundWork 搭配 ManualResetEventSlim进行线程等待
using System;using System.Collections.Generic;using System.ComponentModel;using System.IO.Ports;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using Sy原创 2020-07-21 10:09:50 · 204 阅读 · 0 评论 -
C# async 和await的错误观念
错误1.用async 关键字修饰的方法一旦调用,就会自动在一个工作者线程上执行。— 方法在 调用者线程上执行,并不是在工作者线程执行。仅仅使用async关键字,改变不了代码在哪里执行,只有方法的实现代码决定是否启动任何异步工作错误2.await关键字造成当前线程阻塞,直到被等待的任务完成。要阻塞当前线程直到任务完成,应该调用wait()方法。await关键字对他后面的表达式进行求值,该表达式一般是Task或Task,为最终任务添加延续,然后立即将控制返回调用者。异步工作完成后的某个时间,从awai原创 2020-07-20 12:59:58 · 243 阅读 · 0 评论 -
C# task wait的用法
using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Linq.Expressions;using System.Net;using System.Text;using System.Threading;using System.Threading.Tasks;namespace ConsoleApp21.原创 2020-07-20 12:46:53 · 3358 阅读 · 0 评论 -
C# 多线程编程的重要知识点【2】 --任务的取消
using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace ConsoleApp21{ class Program { static void Main(string[] args).原创 2020-07-20 10:47:41 · 176 阅读 · 0 评论 -
C# 多线程编写的主要知识点[1]
1.Thread ThreadStart threadStart = Dowork1; Thread thread = new Thread(threadStart); thread.Start(); //do something in main thread.Join();// wait thread run to end private static void原创 2020-07-19 23:16:33 · 103 阅读 · 0 评论