C# 序列化原码分析

C# Field,Property,Attribute的区别 这几个词如果只看字面意思很有可能会混淆,我自己也是一直分不太清楚,因为翻译的问题,之前都是一知半解,今天专门查了查资料,整理了一下。 Attribute & Property 1. There's a lot of difference between a C# property and attribute. A property lets you get/set data in you 阅读详情

mcs\class\referencesource\mscorlib\system\runtime\serialization\formatterservices.cs


private static MemberInfo[] GetSerializableMembers(RuntimeType type) {
            // get the list of all fields
            FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            int countProper = 0;
            for (int i = 0;  i < fields.Length; i++) {
                if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
                    continue;
                countProper++;
            }
            if (countProper != fields.Length) {
                FieldInfo[] properFields = new FieldInfo[countProper];
                countProper = 0;
                for (int i = 0;  i < fields.Length; i++) {
                    if ((fields[i].Attributes & FieldAttributes.NotSerialized) == FieldAttributes.NotSerialized)
                        continue;
                    properFields[countProper] = fields[i];
                    countProper++;
                }
                return properFields;
            }
            else
                return fields;
        }

C# JSON 序列化源码 C# JSON 序列化源码 //源码来源: CodeBetter.Json //修改说明: 修正几个错误,加入字典的反序列化 //技术联系: yandefu@163.com 如果使用中有问题,或者有修改升级有空通知一下 立即下载

相关推荐

C#序列化学习的源码

一个简单的序列化的源码,介绍基本的序列化。

c# Attribute与自定义

using System; using System.Reflection; public class Demo { // Make three fields: // The first field is private. private string m_field = "String A"; // The second field is public. ...

linuxheik的专栏 899

C#对象序列化 源代码

C#对象序列化 源代码

C#高级--反射详解

C#高级–反射详解 一、什么是反射/反编译 1、C#编译运行过程 高级语言->编译->dll/exe文件->CLR/JIT->机器码 2、原理解析 metadata:元数据数据清单,记录了dll中包含了哪些东西,是一个描述。 IL:中间语言,编译把高级语言编译后得到的C#中最真实的语言状态,面向对象语言。 反射:来自于System.Reflection,是一个帮助类库,可以读取dll/exe中metadata,使用metadata创建对象。 Emit:一种反射技术,可以动态创建dl

李宥的博客 3万+

C#序列化与反序列化类-源代码

C#序列化与反序列化类-源代码,支持将类和任何C#对象序列化到文件

对象序列化_跨语言(C# )wox开源项目源码

对象序列化_跨语言(C# )wox开源项目源码 wox开源项目源码

C# 字段(Field)、属性(Property)、特性(Attribute)

世界文章。。。 先看一个类: class A { private int a; //这就叫字段a public void set_a(int a) { this.a = a; } public int get_a() { return a; } }上面的类如果要给 a 赋值和取值,就要调用 set_

Rand Tsui 3787

TCGA之GDC-client工具下载安装与使用

文章主要是对GDC-client工具下载TCGA数据库数据整个过程的一个记录 1.下载GDC-client工具 GDC-client工具网址:GDC Data Transfer Tool | NCI Genomic Data Commons (cancer.gov) 我这里下的是上图中红圈中的版本, 2.解压安装 从网上了解的是不能解压到带中文的路径里,解压后是一个.exe文件,为了能直接在cmd命令行下使用,将其加入系统环境: 点击新建之后,输入将文件解压到的路径,然后...

better_strong的博客 1万+

c#之反射_FieldInfo_GetField_

using System;using System.Reflection;//要检查的类public class Demo{ // Make three fields: // The first field is p...

772

图像去噪实战:Noise2Noise与Noise2Void在医学影像中的应用(附代码)

本文深入探讨了Noise2Noise与Noise2Void在医学影像去噪中的革命性应用,通过自监督学习技术有效解决临床数据配对难题。文章提供详细的代码实现和临床部署方案,展示如何提升低剂量CT、MRI等影像的诊断质量,特别适用于辐射敏感场景和急诊快速处理。

weixin_29092579的博客 241

分享通达信破解交易接口的使用!

那其实通达信破解交易接口的使用方法比较复杂,这里以MA均线指标为例子,只要理解了这些操作步骤,就可以很容易地使用其他指标包括自己编写的指标来进行交易。委托结果(包含委托编号), 需要分配 1024*1024 字节的空间。委托结果数组, 每项结果需要分配 1024*1024 字节的空间。0: 买入, 1: 卖出, 2: 融资买入, 3: 融券卖出,4: (市价委托)上海五档即成剩撤, 深圳五档即成剩撤。4: 买券还券, 5: 卖券还款, 6: 现券还券。0: 上海限价委托, 深圳限价委托。

1841085904的博客 2358

DrawTools绘图程序代码分析

在网上下载了一些使用GDI+绘图的原码来学习,一开始先找了个代码少的、逻辑比较简单的项目——DrawTools。该项目用于展示如何使用C#的GDI+来绘制简单的图形。代码从https://github.com/tolbkni/DrawTools中下载的,我看的是其中的Winform版本的实现代码,该程序代码量有两千行左右,主要实现的功能有:绘制线条绘制矩形绘制椭圆绘制自由曲线各种绘图对象的移动操作

gc_2299的博客 4786

173、LLC谐振变换器的PCB设计实战(布线)

LLC谐振变换器PCB设计实战要点 LLC谐振变换器的PCB设计核心在于控制寄生参数,避免高频振铃和EMI问题。功率回路需确保电流路径最短且紧耦合,谐振电容焊盘需加宽以减少发热。驱动走线应独立于功率回路,避免干扰,并合理控制宽度和长度。变压器绕组结构影响共模噪声,建议原边在外层并加屏蔽铜箔。地平面设计需根据功率等级选择整块或分割,大功率下功率地与信号地应单点连接。谐振电流采样推荐四端开尔文电阻以减少电感干扰。散热需优化铜皮和过孔布局,功率器件优先放置顶层。布局应先确定谐振腔,再排布控制电路。经验上需实测寄生

Jack010169的博客 46

c#中字段(field)和属性(property)的区别

class myclass {   private int  _age;//私有的字段   public int age //属性   {     get  { return this. _age;}     set  {this.age=value; }   } } 对一个私有的字段提供这样的属性有什么意义呢?为什么不直接把age改成公有的?   分析: 1、属性可以只读

susan19890313的专栏 1万+

【Matlab】飞行器气动弹性仿真与分析

气动弹性是飞行器设计领域的核心交叉学科,融合了空气动力学、结构动力学和控制理论,主要研究飞行器结构在气动力作用下的弹性变形、振动响应及相互耦合规律,直接影响飞行器的飞行稳定性、操纵性和结构安全性。随着飞行器向高速度、高机动性、轻量化方向发展,气动弹性问题愈发突出,如颤振、发散、嗡鸣等现象,严重时会导致飞行器结构破坏甚至飞行事故,因此气动弹性仿真与分析已成为飞行器设计、验证和优化的关键环节。当前,飞行器气动弹性仿真面临诸多技术挑战:气动力与结构变形的强耦合特性难以精准描述,易出现仿真误差;

unber的博客 233

【银河麒麟V10】【桌面】【服务器】系统启动问题

1、如果之前运行好好的,重启后系统报错,一般80%是因为fstab的问题,回想下之前有没有添加过外接存储,修改过/etc/fstab,如果是的话一般是因为存储异常(比如网络存储无法连接,本地存储路径变化)导致系统开机自检失败,导致无法正常启动; 处理方式:进入单用户(单用户进入的几种方式上面有专门文章介绍),修改/etc/fstab,将新增的内容暂时注释掉,然后重启系统,能正常进入系统后再分析失败原因。 ...

桂安俊@KylinOS 3万+

C#练习题答案: 在运行时创建一个简单的类【难度:5级】--景越C#经典编程题库,1000道C#基础练习题等你来挑战

在运行时创建一个简单的类【难度:5级】: 答案1: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; public static class Kata { public static bool D...

景越c#经典编程题库(csharp programming training) 219

13、基于RBF的自适应鲁棒控制与反步控制方法及实现

本文介绍了基于RBF神经网络的自适应鲁棒控制与反步控制方法,详细阐述了控制系统的程序结构、核心算法及实现流程。通过Simulink搭建仿真系统,利用RBF网络逼近系统中的不确定非线性函数,并结合Lyapunov稳定性理论设计控制律,实现了对倒立摆等复杂非线性系统的高精度跟踪控制。文章还提供了完整的MATLAB/Simulink代码示例和仿真结果分析,验证了该方法的有效性与鲁棒性,为实际工程应用提供了可行的技术路径。

ol789012的博客 87

原码、补码、反码的转换

1.原码 (1)一个正数,他的原码就是它对应的二进制数字。 (2)一个负数,按照绝对值大小转换成的二进制数,然后最高位补1,就是负数的原码。 2.反码 (1)正数的反码与原码相同(这是规定)。 (2)负数的反码是对该数的原码除符号位外各位取反(1变为0,0变为1) (3)符号位:符号位就是在二进制中用来表示一个数字的正或者负﹐是最高位(最左边的一位),1表示负数,0表示正数。 3.补码 (1)正数的补码与原码相同(规定)。 (2)负数的补码为对该数的原码除符号位外各位取反(就是负数本身的反码),然后在最后

w1911026171的博客 1万+

【第2章>第10节】深度学习DenseNet模型分析与matlab仿真

本文介绍了基于DenseNet深度学习模型的图像分类MATLAB实现方法。主要内容包括:1. DenseNet模型原理,详细解析了初始卷积层、密集块、过渡层等核心结构;2. 在MATLAB环境下完成DenseNet工具箱安装和测试样本准备;3. 实现图像预处理(统一缩放为224×224)、模型训练和测试的完整流程;4. 提供了混淆矩阵和准确率等测试结果分析。文章附带完整的MATLAB程序代码和操作视频教程,适合深度学习初学者快速掌握DenseNet模型的图像分类应用。通过实际测试,验证了该方案的有效性。

FPGA/MATLAB学习教程/源码/项目合作开发 330

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

真实值转换为原码

任务   本关任务是实现ZhenToYuan(z)函数,其功能是将给定的真实值z转换成 8 位原码,说明如下:   1)参数z是长度不超过 8 的字符串,表示的是−1111111到+1111111之间的一个二进制整数;   2)z对应的真实值的符号可能是+或-,也可能没有,如没有,表示是正数,如'-1001'、'+101'、'101'都是z可能的取值;   3)函数的返回值是字符串类型,表示真实值z对应的 8 位原码;   4)为方便理解,本关使用的函数名和变量名大多采用拼音形式,如ZhenToYuan(

m0_69217114的博客 3043

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

原码,补码,反码的转化

原码,补码,反码的转化

qq_44482624的博客 3万+

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

C#格式化器如何序列化类型实例

为了简化格式化器的操作,FCL在System.Runtime.Serialization命名空间提供了一个为了简化格式化器的操作,FCL在System.Runtime.Serialization命名空间提供了一个FormatterServices类型。该类型只包含静态方法,而且该类型不能实例化。 以下步骤描述了格式化器如何自动序列化类型应用了SerializableAttribute 特性的对象: 格式化器调用FormatterServices的GetSerializableMembers方法: p

Lenny的博客 317

C#中的序列化与反序列化的源代码(三种方法)

第一种序列化的方法:BinaryFormatter(二进制的形式) using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlC

1079

C#反序列化到类的源码演示

如下内容是关于C#反序列化到类的演示的内容,应该是对小伙伴有所用途。using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Threading.Ta...

weixin_33978044的博客 254
上一篇: c# Attribute与自定义
下一篇: GetCustomAttributes
linuxheik
博客等级 码龄15年 865粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值