2010年10月11日 星期一

.Net Framework 4.0 泛型中的共變數和反變數


Covariant(共變數)
IEnumerable<Derived> d = new List<Derived>();
IEnumerable<Base> b = d;

Contravariant(反變數)
Action<Base> b = (target) => { Console.WriteLine(target.GetType().Name); };
Action<Derived> d = b;
d(new Derived());

一般來說,Covariant 型別參數可以用來做為委派的傳回型別,而 Contravariant 型別參數可以用來做為參數型別。例如,Covariant 型別參數可以用來做為介面方法的傳回型別,而 Contravariant 型別參數可以用來做為介面方法的參數型別。

2010年10月7日 星期四

XAML 語法詳細資料

Microsoft XAML 語法詳細資料


包含下列章節。
  • XAML 語言規格
  • XAML 和 CLR
  • 物件項目語法
  • 物件項目的屬性
  • 屬性 (Attribute) 語法 (屬性 (Property))
  • 屬性項目語法
  • 集合語法
  • XAML 內容屬性
  • 內容屬性與集合語法合併
  • XAML 命名空間
  • 標記延伸
  • 附加屬性
  • 附加事件
  • XAML 根項目的結構分析
  • 選擇性和非建議的 XAML 使用方式

讀了上面這篇,WPF  已經會了七成了,重點是「中文的」
但是您要讀的懂才行呀!

2010年9月27日 星期一

PostgreSQL Schema 相關資訊取得方式

--列出所有資料表
SELECT * FROM information_schema.tables where table_schema='public'

--列出所有 Sequence
SELECT * FROM information_schema.sequences where sequence_schema='public'

--列出所有 Trigger
SELECT * FROM information_schema.routines where routine_schema='public' and data_type='trigger'

--列出角色可用資料表清單
select * from information_schema.role_table_grants where table_schema='public' and table_name in (SELECT table_name FROM information_schema.tables where table_schema='public')

--列出色角可用 Trigger
select * from information_schema.role_routine_grants where routine_schema='public' and routine_name in (SELECT routine_name FROM information_schema.routines where routine_schema='public' and data_type='trigger')

--列出可用角色清單
select * from information_schema.enabled_roles

--http://www.postgresql.org/docs/8.2/static/sql-grant.html
grant all on _data_history_sequence_seq to "postgres";

--http://www.postgresql.org/docs/8.2/static/sql-revoke.html
revoke all on _data_history_sequence_seq from "postgres";

2010年9月3日 星期五

在 PostgreSQL 如何透過 SQL 中斷其他 Connection?

首先要得知資料庫中有那些連線正在活動:
select * from pg_stat_activity


pg_stat_activity 是一個資料表,裡面包含了許多資訊,其中比較重要的是「procpid」欄位,如果要中斷別人的資料庫連線,需要這個欄位的資料當參數。


中斷資料庫連線:
select pg_terminate_backend(123);


pg_terminate_backend() 是一個函數,裡面要傳的參數就是「procpid」的資料,執行完成後,該條連線就會被中斷。


這些動作都需要權限才能執行。

2010年8月17日 星期二

如何讓 Windows 7 Bitlock 重新上鎖

簡單一條 Command:

manage-bde -lock P:

2010年8月4日 星期三

.Net Windows Form 拖拉放的用法

基本上是 DragEnter 事件要設定 Effect 屬性,與 DragDrop 事件要處理使用者放下來的資料就行了:

private void Form1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}

private void Form1_DragDrop(object sender, DragEventArgs e)
{
foreach(string each in e.Data.GetFormats())
Console.WriteLine(each);
}

2010年8月3日 星期二

Postgresql 的 information_schema 完整說明

http://www.postgresql.org/docs/current/static/information-schema.html