Skip to content

Instantly share code, notes, and snippets.

View mfakane's full-sized avatar

mfakane mfakane

View GitHub Profile
@mfakane
mfakane / StationTemplate.cs
Created April 19, 2016 11:15
Metasequoia.Sharp の Station プラグインのはりぼて
using System;
using System.ComponentModel;
using System.Linq;
using Metasequoia;
using Metasequoia.Sharp;
namespace YourNameSpace
{
[DisplayName("StationSample\tCopyright (C) 2016, your name")] // プラグイン一覧に表示する情報
[StationPlugin(0xAB86CB1E, 0x0E94E0BC, "Station サンプル")] // 作者 ID, プラグイン ID, 項目名
@mfakane
mfakane / XInput.cs
Last active April 4, 2016 10:07
C# で XInput おためし、おきらく (取得はともかく振動はテストしてないです)
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
namespace Linearstar.Lavis.Interop
{
public class XInput
{
const string XInputLibrary = "XINPUT9_1_0";
@mfakane
mfakane / ObservableCollectionWrapper.cs
Last active September 29, 2015 17:41
M→VM 用コレクションラッパ
// usage:
//
// Model のコレクションの変化を自動的に反映する ViewModel コレクションを作成
// ObservableCollectionWrapper.Create(modelCollection, (Model m) => new ViewModel(m))
//
// 任意の ViewModel 側コレクションを Model コレクションに同期させる
// ViewModel コレクションへの操作を Model 側に反映させることもできる (Caliburn.Micro での Conductor の Items に使用するなど)
// ObservableCollectionWrapper.Create(modelCollection, viewModelCollection, (Model m) => new ViewModel(m), vm => vm.Model)
using System;
using System.Collections;
@mfakane
mfakane / AutoNavi.ahk
Last active December 25, 2015 07:09
MouseGestureL.ahk 向け自動ナビ表示スクリプト
; MouseGestureL.ahk 向け自動ナビ表示スクリプト
; ジェスチャ受付開始から 500ms 経過するかジェスチャ入力するとアドバンスドナビが有効になって、
; ジェスチャ入力から変化がなく 500ms 経過するとリアルナビが有効になる
; MG_User.ahk のユーザー定義サブルーチンのところに追加する
AN_Main()
{
global
static AN_Counter := 0
@mfakane
mfakane / Sudo.cs
Created November 3, 2012 11:51
UAC lift
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
namespace Sudo
{
class Program
{
static void Main(string[] args)
@mfakane
mfakane / MmdDrop.cs
Created October 21, 2012 06:15
自動ファイルドロップ
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
@mfakane
mfakane / megalopolisapi.txt
Created August 23, 2012 05:05
Megalopolis API
see https://github.com/mfakane/Megalopolis/wiki/API
@mfakane
mfakane / megalithapi.txt
Created August 22, 2012 14:57
Megalith API
Megalith API
読み込みに関すること
文字コードは Shift_JIS
各種 txt や dat ファイルはローカルにキャッシュを持ち HTTP の If-Modified-Since を利用することを推奨。
/settings.ini
設定である。
PHP コードではあるが用いられている構文は多くないので、各自適当にパース。
@mfakane
mfakane / SelenaClient.cs
Created July 14, 2012 05:28
Royal/RoyalFlare/Selena/SelenaClient.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Collections.Specialized;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
namespace Royal.Selena
1. C# を組み込みスクリプトにできるのか
場合による。
基本的にホストが .NET 上で動くものであればそれほど難しくはないが、ネイティブから呼び出すにはいくらか変則的な手法を用いる必要がある。これについては後述。
C# の実行時コンパイルにより動的にコードを実行する手法はよく見られ、.NET のライブラリにそのための機能は存在する。
コンパイルして生成された dll (.NET アセンブリ, Assembly) を動的に読み込み呼び出すことで既存のコンテキストでコードを実行できる。
また、最近では Microsoft の "Roslyn" や、Mono の Mono.CSharp.dll などコンパイラをサービスとして公開することでスクリプト的な使用方法をより簡単にする動きがある。
ただし、C# はスクリプト言語ではない。