This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record MyInfo | |
{ | |
public string foo { get; set; } | |
public string bar { get; set; } | |
public decimal abc { get; set; } | |
} | |
var info = new MyInfo { | |
foo = "FOO 123.456", | |
bar = "我是中文字", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// HTML原生的 validation | |
/// ref→[Constraint validation interfaces](https://developer.mozilla.org/en-US/docs/Web/API/Constraint_validation#element.setcustomvalidity(message)) | |
/// ref→[HTMLObjectElement.validationMessage](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage) | |
/// ref→[HTMLObjectElement.validity](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity) | |
/// ref→[validityState.badInput](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/badInput) | |
/// | |
<!DOCTYPE html> | |
<html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// C# switch pattern 語法整理 | |
/// ref→[The evolution of Pattern Matching in C# (from version 6 to 10)](https://www.youtube.com/watch?v=MzNHMJCyU40&ab_channel=NickChapsas) | |
/// ref→[Pattern matching overview](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/pattern-matching) | |
/// ref→[Patterns (C# reference)](https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/operators/patterns) | |
/// | |
using System; | |
using System.Collections.Generic; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scrollToOffset(element, offset /* int */) | |
{ | |
//ref→https://newbedev.com/javascript-scrollintoview-smooth-scroll-and-offset | |
const bodyRect = document.body.getBoundingClientRect().top; | |
const elementRect = element.getBoundingClientRect().top; | |
const elementPosition = elementRect - bodyRect; | |
const offsetPosition = elementPosition - offset; | |
window.scrollTo({ | |
top: offsetPosition, | |
behavior: "smooth" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 取得 jquery 版本 | |
jQuery().jquery | |
/// 或 | |
$.fn.jquery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Linq.Expressions; | |
/// <summary> | |
/// global type handling helper | |
/// </summary> | |
public static class GT<TModel> | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dapper; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
/// 專門載入基本資料。如:下拉選單 Select 或 AutoComplete 的項目清單。 | |
/// C#9.0 | |
namespace YourProject.DB.BasicData |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.ComponentModel.DataAnnotations; | |
public static class DBHelperClassExtensions | |
{ | |
public static string DisplayNameOf(Type ty, string propertyName) | |
{ | |
var field = ty.GetProperty(propertyName); | |
var attr = field.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// BenchmarkDotNet v0.13.0 | |
/// ref→[Getting started](https://benchmarkdotnet.org/articles/guides/getting-started.html) | |
/// | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task HandleQuery() => CatchHandling(async () => | |
{ | |
var qryArgs = new TodoQryAgs | |
{ | |
Msg = f_testFail ? "測試邏輯失敗" : "今天天氣真好", | |
Amt = 999 | |
}; | |
dataList = await bizApi.QryDataListAsync(qryArgs); | |
}); |