Zhuangkh

A .Net Developer

All Posts in 2020


「读书笔记:Concurrency in .Net」Compose&Closure

函数组合 <table class="table"> <thead> <tr> <th>流水线</th> <th>函数组合</th> </tr> </thead> <tbody> <tr> <td>每个函数输出是下一个函数输入</td> <td>返回多个函数组合而成的新函数</td> </tr> <tr> <td>立即求值</td> <td>延迟求值</td> </tr> </tbody> </table> Example: 咖啡豆 -> 磨豆 -> [咖啡粒] -> 冲咖啡 -> [咖啡] 使用链的方式调用 FuncBeans,Ground grind = beans = new Ground(beans); FuncGround,Coffee brew = ground = new Coffee(ground); Coffee coffee = brew(grind(beans)); …

FP BookNotes Closure

「读书笔记:Concurrency in .Net」Functional Programming

函数式编程Functional Programming FP是一种将计算是为对表达式求值的编程范式 FP优点 可组合性和模块化 表达性 可靠性和测试 易于并发 延迟求值 生产力 正确性 可维护性 FP原则 高阶函数(HOF)作为头等值 不可变性 纯函数 声明式编程风格 HOF FP中函数作为头等值,意味着函数可以由变量命名、分配给变量,可以出现在任何构造可以出现的地方。 HOF使编程专注于结果,而不是步骤。 HOF优点 组合和模块化 实现函数式组合的方式 组合 柯里化 部分应用函数 代码可重用性 创建高度动态和适应性强的系统 HOF与lambda 一种重构代码,减少代码冗余的方式,一个优雅的解决方案。 简洁的内联编码 限制类级别变量的暴露 代码流易读性高 Example: stream在使用后被Disposed,一种不可重复使用的模式。 string text; using(var …

Book Notes FP

WPF : Validation

Validation Rule 简单示例 class ViewModel { public int Number { get; set; } } TextBox TextBox.Text Binding Path=Number UpdateSourceTrigger=PropertyChanged Delay=200 /Binding /TextBox.Text /TextBox 示例中由于绑定的属性Number是int型(int在绑定到界面上时会自动添加int⇋string的converter),所以当我们输入非数字时,converter抛出的转换异常会被捕获到,此时Textbox上会出现红色边框。 异常被捕获 描述错误的实际消息存储在 System.Windows.Controls.ValidationError 对象的 …

.Net WPF Validation

Reading Revit File Without Revit

Starting the main Revit program needs to be accompanied by loading multiple components, which usually takes a long time. This is especially annoying after the file automatically calls the wrong version of Revit! So is there any way to read the Revit program without opening Revit? It should be clear that it will be very difficult not to read or modify member information in Revit (there may be …

Revit Ole Storage COM Structured Storage

Merge Multiple .Net Assemblies Into One

When we use a lot of external dependencies, the generated folder may contain a lot of Dlls that are not conducive to distribution. Before Here are two ways to pack multiple assemblies into one. Costura.Fody Costura is an add-in for Fody. Fody is an extensible tool for weaving .net assemblies. It enables the manipulating the IL of an assembly as part of a build. Costura is easy to use. Install …

.Net IL Merge Fody

「读书笔记:云计算概念、技术与架构」云计算基础

云起源与影响 云起源与影响 云特性与云模型 云特性与云模型 云使能技术——网络和Internet架构 网络和Internet架构 云使能技术——数据中心技术 数据中心技术 云使能技术——虚拟化技术 虚拟化技术 云使能技术——Web、多租户、服务技术 Web、多租户、服务技术 云使能技术——云安全 云安全

Book Notes Cloud

Improve Sound Quality By Equalizing Headphone Frequency Responses

Frequency response, which describes the response of the headphones to audio at different frequencies. The closer the waveform to the original audio, the higher the degree of reduction of the headphones , and to a certain extent it represents the quality of the headphones. DT770 Pro It's a very complex process from playing to being heard, for example: Raw Audio-Mixer-DSP Algorithm-DAC-Preamp …

Headphone Audio Equalizer APO

WPF基础Ⅱ: 依赖属性

依赖属性 与.Net属性对比: 更高效 支持附加功能 更改通知 属性值继承 创建依赖属性 /// summary /// 只能为依赖对象添加依赖属性 /// /summary public class DependencyClass : DependencyObject { /// summary /// 定义依赖属性 /// 约定俗成命名规则:属性名+Property /// /summary public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(//注册依赖属性 Number, //属性名 typeof(int), //属性类型 …

.Net WPF

WPF基础Ⅰ: XAML文件

基础 XAML单位 一个设备无关单位被定义为1/96英寸 标准Windows dpi为96 dpi 设备无关单位 * 系统dpi = 实际像素数 (eg: 1/96英寸 * 96dpi =1像素) XAML命名空间 使用特殊特性 xmlns 声明命名空间 命名空间可使用XML名称空间或者**.Net名称空间** # XML名称空间 使用URI xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml # .Net名称空间 使用类的完整名称 xmlns:Prefix=clr-namespace:Namespace;assembly=AssemblyName XAML属性 简单属性 可直接设置属性值 Grid …

.Net WPF

家庭网络环境改造Ⅰ:硬件与虚拟化环境

随着家里需要用网络的设备日益增多,硬路由的性能瓶颈逐渐浮现.加上外部网络环境的糟糕(DNS胁持,HTTP胁持),每个设备单独配置网络环境又很麻烦. 于是乎在基友的安利下决定选择软路由来作为解决方案. Hardware Configuration Router - 机箱:BRZHiFi CUBE-6 - 主板:ASRock A320M-ITX - CPU:AMD 2200G - 内存:G.SKill Trident Z 16G DDR4 - 电源:SeaSonic SFX 450W - 网卡:Intel I350-T4v2 - 硬盘:LiteON T9 256G+HGST 1T 选择CUBE-6而不是一般的A4机箱的原因是想同时作为NAS设备使用,需要安装3.5寸硬盘的空间.单纯软路由的话还是选择小巧的A4机箱就好. 而网卡的选择上可根据个人需要进行选择(比如廉价的OCP万兆网卡方案),我这 …

Network Router

Delete Enterprise Applications In Azure Active Directory

Problem When we want to delete an Azure AD,one of the steps is to delete all enterprise applications in that directory. AAD Remove Check But some applicatons like Azure DevOps can not delete directly (Option not available). DevOps Delete Options Solution With PowerShell Create a new user in Azure AD with a role of Global administrator. Create new user Start PowerShell and install Azure AD module. …

Azure AzureAD

Generate a True Metafile in .NET

A few days ago when I was building the MS-OLEDS file for AutoCAD, I needed to create a Metafile as part of it. However, I encountered some small problems when using the built-in API. The Problem with Built-in API In System.Drawing.Imaging has a Metafile Class that allows us do a sequence of graphics operations on it.Here is my code and the test file in the HEX editor. public static void …

.Net Metafile

Generate Transient Element In Revit

今天瞎折腾的时候,突然在Revit Document里看到一组相当有趣并有着详细注释的API: Document..::..MakeTransientElements The method establishes a context within which transient elements will be created and then invokes the given maker object to create the elements. For more information refer to the IsTransient method. Element..::..IsTransient Transient elements are usually created for short term use. This type of element can be …

Revit Dynamo

.Net MD5算法与系统FIPS兼容性

使用dotNet框架自带的Md5加密MD5CryptoServiceProvider时,在部分电脑上会出现InvalidOperationException. System.InvalidOperationException: 此实现不是 Windows 平台 FIPS 验证的加密算法的一部分。 在 System.Security.Cryptography.MD5CryptoServiceProvider..ctor() 出现的原因是系统启用了FIPS兼容算法,而FIPS标准并不支持MD5,所以当框架中的MD5算法调用系统的加密模块时就会爆异常. FIPS 140-2 defines security standards that the United States and Canadian governments use to validate security levels …

.Net MD5

Convert Between IFC ID and Revit ID

The IFC specification was devised a methodology to compress the standard GUIDs to conserve space, you can find detailed instructions at buildingSMART IFC GUID.But there is no direct way to get the standard GUID or IFC-GUID in Revit. Sample ID GUID (Length:36) :c71cffa8-2bb5-4842-bd34-f25c022e8f00 Revit UniqueID (Length:45) : c71cffa8-2bb5-4842-bd34-f25c022997b1-000718b1 Revit ElementID (Length: …

IFC Revit