Skip to content

Instantly share code, notes, and snippets.

@mk3008
mk3008 / Module1.vb
Last active August 29, 2015 14:06
Attribute.Inheritedと、MemberInfo.GetCustomAttributes の関係
Module Module1
Sub Main()
Dim log As Action(Of Func(Of Boolean)) =
Sub(f)
Dim cnt As Integer = 100000
Dim sw As New Stopwatch
sw.Start()
For i As Integer = 1 To 100000
f.Invoke()
@mk3008
mk3008 / Build_XmlLteral.vb
Last active August 29, 2015 14:05
XMLリテラルを使用した複数行文字列の代入
Imports System.Text
Module Module1
Sub Main()
Build_String()
Build_StringBuilder()
Build_ResourceFile()
Build_XmlLiteral()
End Sub
@mk3008
mk3008 / Json.vb
Last active August 29, 2015 14:05
BacklogNetサンプル
Imports System.Net
Imports System.IO
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
''' <summary>
''' Json
''' </summary>
''' <remarks>
''' 参考サイト
'1:パラメータ指定なし
Dim dic As New Dictionary(Of String, Object)
Dim cmd As IDbComand = DynamicSqlParser.CreateDbCommand(cn, My.Resources.IfSql_prefix, "@", dic)
'2:一部指定
Dim dic As New Dictionary(Of String, Object)
dic.Add("name", "A%")
Dim cmd As IDbCommand = DynamicSqlParser.CreateDbCommand(cn, My.Resources.IfSql_prefix, "@", dic)
'3:一部指定
Dim dic As New Dictionary(Of String, Object)
dic.Add("age", {20, 21, 22, 30, 31, 32, 40, 41, 42})
Dim cmd As IDbCommand = DynamicSqlParser.CreateDbCommand(cn, My.Resources.InSql, "@", dic)
Dim dic As New Dictionary(Of String, Object)
dic.Add("minage", 20)
dic.Add("maxage", 29)
Dim cmd As IDbCommand = DynamicSqlParser.CreateDbCommand(cn, My.Resources.EqualSql, "@", dic)
@mk3008
mk3008 / DynamicSqlParser.vb
Last active August 29, 2015 14:05
動的SQLパーサーとSQL文のサンプル(StringBuilderの拡張メソッドソースコードは https://gist.github.com/mk3008/03b423c6942599465510 にあります)
Imports System.Text.RegularExpressions
Imports System.Text
''' <summary>
''' 動的SQLパーサー
''' </summary>
''' <remarks></remarks>
Public Class DynamicSqlParser
''' <summary>
''' DBコマンドを作成します
@mk3008
mk3008 / IDbCommandExtension.vb
Last active March 11, 2018 17:39
区切り文字を追加するStringBuilder拡張メソッドとその例
Imports System.Runtime.CompilerServices
Imports System.Text
Public Module IDbCommandExtension
''' <summary>
''' DBコマンドの情報を返します
''' </summary>
''' <param name="source"></param>
''' <returns></returns>
''' <remarks></remarks>
@mk3008
mk3008 / Magick.vb
Created August 10, 2014 08:24
Magick.NET Export PDF Thumbnail Sample
Imports ImageMagick
Imports System.Drawing
''' <summary>
''' Magick.NETラッパー
''' </summary>
''' <remarks></remarks>
Public Class Magick
''' <summary>
@mk3008
mk3008 / ActionExtension.vb
Last active August 29, 2015 14:04
アクションにロギング機能を差し込む(NLog)
Imports System.Runtime.CompilerServices
Public Module ActionExtension
Private Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
<Extension()>
Public Sub InvokeWithLog(source As Action)
Try
Logger.Info("Start")