コンパイラを準備する。
自分は、visual studio 2010 profissionalを準備
クラスライブラリを作る
c#で.Net Framework 3.5を指定してClassLibrary1を作る。
サンプルコード
Flickrが動かないので、美人のURLを取得するコードを書いた。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SmallBasic.Library;
using System.Net;
using System.Text.RegularExpressions;
namespace ClassLibrary1
{
/// <summary>
/// オリジナル エクステンション
/// </summary>
[SmallBasicType]
public static class Class1
{
/// <summary>
/// 美人 サムネイル
/// </summary>
/// <param>なし</param>
/// <returns>10個のURL</returns>
/// <example>Class1.Bijin()</example>
public static Primitive Bijin()
{
var result = new Primitive();
WebClient wc = new WebClient();
string html = wc.DownloadString("http://bjin.me/api/?type=rand&count=10&format=json");
string anchor = "thumb\":\"(?<url>.*?)\",\"pubDate";
Regex re = new Regex(anchor, RegexOptions.IgnoreCase | RegexOptions.Singleline);
var i = 0;
for (Match m = re.Match(html); m.Success; m = m.NextMatch())
{
string url = m.Groups["url"].Value;
string ul = url.Replace("\\/", "/");
result[i] = ul;
i++;
}
return result;
}
}
}
参照設定で "C:\Program Files\Microsoft\Small Basic\SmallBasicLibrary.dll" を加える。
XMLドキュメントコメントに記述しておくとインテリセンスに表示される。
プロジェクトのプロパティにて [ビルド] - [XML ドキュメント ファイル(X):] のチェックしてビルドする。
デプロイ
ビルドして、できたアセンブリ(.dll)とXMLドキュメント(.xml)を、
"C:\Program Files\Microsoft\Small Basic\lib" にコピー 。
lib フォルダは自分で作る。
テスト
b = Class1.Bijin()
For i =0 To 9
myimage = ImageList.LoadImage(b[i])
height = ImageList.GetHeightOfImage(myimage)
width = ImageList.GetWidthOfImage(myimage)
GraphicsWindow.Clear()
GraphicsWindow.Height = height
GraphicsWindow.Width = width
GraphicsWindow.DrawImage(myimage, 0, 0)
Program.Delay(9000)
EndFor
GraphicsWindow.Hide()