Default Property Attribute Default Event Attribute Toolbox Bitmap
アトリビュート • クラスに設定するアトリビュート – Default. Property. Attribute • 既定のプロパティを指定 – Default. Event. Attribute • 既定のイベントを指定 – Toolbox. Bitmap. Attribute • ツールボックスのアイコンのビットマップを指定 [ Default. Property("My. Property") Default. Event("My. Event") Toolbox. Bitmap(typeof(My. Control), "My. Control. Bitmap") ] わんくま同盟 東京勉強会 #37
アトリビュート • Webコントロールのクラスに必要なアトリビ ュート – Asp. Net. Hosting. Permission • 保護された ASP. NET クラスにアクセスする – Toolbox. Data. Attribute • ツールボックスからドラッグされるとき コントロールに生 成される既定のタグ [ Asp. Net. Hosting. Permission(Security. Action. Demand, Level = Asp. Net. Hosting. Permission. Level. Minimal), Asp. Net. Hosting. Permission(Security. Action. Inheritance. Demand, Level = Asp. Net. Hosting. Permission. Level. Minimal), Toolbox. Data("<{0}: Web. User. Control 1 runat="server"> </{0}: Web. User. Control 1>") ] わんくま同盟 東京勉強会 #37
型コンバータ public override bool Can. Convert. From(IType. Descriptor. Context context, Type source. Type) { if (source. Type == typeof(string)) return true; return base. Can. Convert. From(context, source. Type); } public override object Convert. From(IType. Descriptor. Context context, System. Globalization. Culture. Info culture, object value) { if (value. Get. Type() == typeof(string)) { Complex newval = new Complex(0, 0); string[] input = ((string)value). Split(new Char[] { ', ' }); if (input. Get. Length(0) == 2) { newval. r = double. Parse(input[0]); newval. i = double. Parse(input[1]); } return newval; } return base. Convert. From(context, culture, value); } わんくま同盟 東京勉強会 #37
型コンバータ public override bool Can. Convert. To(IType. Descriptor. Context context, Type destination. Type) { if (destination. Type == typeof(string)) return true; if (destination. Type == typeof(Instance. Descriptor)) return true; return base. Can. Convert. To(context, destination. Type); } Instance. Descriptorをサポートする わんくま同盟 東京勉強会 #37
型コンバータ public override object Convert. To(IType. Descriptor. Context context, System. Globalization. Culture. Info culture, object value, Type dest. Type) { if (dest. Type == typeof(string) && value is Complex) { Complex ic = (Complex)value; return ic. r. To. String() + ", " + ic. i. To. String(); } if (dest. Type == typeof(Instance. Descriptor) && value is Complex) { Complex ic = (Complex)value; System. Reflection. Constructor. Info ctor = typeof(Complex). Get. Constructor( new Type[] { typeof(double), typeof(double) }); if (ctor != null) { return new Instance. Descriptor(ctor, new object[] { ic. r, ic. i }); } } return base. Convert. To(context, culture, value, dest. Type); } わんくま同盟 東京勉強会 #37
型コンバータ public override bool Get. Standard. Values. Supported (IType. Descriptor. Context context) { return true; } public override Type. Converter. Standard. Values. Collection Get. Standard. Values(IType. Descriptor. Context context) { string[] values = { "日本", "カナダ" }; Standard. Values. Collection svc = new Standard. Values. Collection(values); return svc; } 配列を作って変換する わんくま同盟 東京勉強会 #37
- Slides: 20