2010年11月27日土曜日

星空写真

写真の話です。

この時期になると、茅ヶ崎でも新月の夜には星がよく見えます。
なので、家の前で写真を撮ってみました。
これは EF24-85mmの24mm F3.5 ISO1000 16秒 で撮ってます。
Photoshopでリサイズとアンシャープだけかけてます。

こっちは EF50mm F1.8 ISO400 10秒 で撮ってます。

条件が違うんで直接の比較にはならないですけど、やっぱ短焦点ですね。
星の色とか鮮明さが違います。
でも50mmだと画角が狭い感じです。

なんで、24mm F1.8を注文してみました。
また新月の夜で晴れた日があれば挑戦してみようかな。

最後に、色々補正した結果の写真です。
4枚の写真を合成してるんですが、成功はしてない感じです。

2010年4月18日日曜日

[C#] SharpSVNを使ってSubversionを操作してみる

SharpSVNはSubvertionの.Net用クライアントライブラリ。 それを使って、ローカルのファイルを更新する処理のメモです。 ざっくりコードを乗せてみます。
  1. using (SvnClient client = new SvnClient())  
  2. {  
  3.   
  4.     //サーバー上のリポジトリ位置の設定  
  5.     SvnUriTarget repos = new SvnUriTarget(new Uri("file:///C:/svn_repository/SvnTest/"));  
  6.     //クライアントのファイル位置を設定  
  7.     SvnPathTarget local = new SvnPathTarget(@"C:\source\subvertionTest");  
  8.   
  9.     //両方の情報を取得  
  10.     SvnInfoEventArgs serverInfo;  
  11.     SvnInfoEventArgs clientInfo;  
  12.     client.GetInfo(repos, out serverInfo);  
  13.     client.GetInfo(local, out clientInfo);  
  14.   
  15.     //リビジョンを比較  
  16.     if (serverInfo.Revision != clientInfo.Revision)  
  17.     {  
  18.         SvnUpdateResult ret;  
  19.         //クライアントのファイルを最新に更新  
  20.         client.Update(@"C:\source\subvertionTest"out ret);  
  21.     }  
  22.   
  23.     //ファイルの一覧取得用引数の指定  
  24.     SvnListArgs args = new SvnListArgs();  
  25.     //リビジョンを指定  
  26.     args.Revision = 2;  
  27.     //処理結果格納変数を定義  
  28.     System.Collections.ObjectModel.Collection<svnlisteventargs> list;  
  29.     //一覧の取得を実行  
  30.     client.GetList(repos, out list);  
  31.   
  32.     //処理結果の表示  
  33.     foreach (var i in list)  
  34.     {  
  35.         switch (i.Entry.NodeKind)  
  36.         {  
  37.             case SvnNodeKind.Directory:  
  38.                 Console.WriteLine("Directory:{0}",i.EntryUri.LocalPath);  
  39.                 break;  
  40.             case SvnNodeKind.File:  
  41.                 Console.WriteLine("File:{0}",i.EntryUri.LocalPath);  
  42.                 break;  
  43.         }  
  44.     }  
  45. }  
  46. </svnlisteventargs>  

2010年3月30日火曜日

[WCF](暫定)WCFでSoapとRestを共通で

はじめてのWCFです。

ホントはRestとNamedPipeをやりたかったけど、IIS7.0がいるって事らしいのであきらめました。
なんで、SoapとRestの共通化(?)する方法。

まず、適当なWcfサービスを作って、「System.ServiceMode.Web」を参照設定する。
InterfaceにUsing System.ServiceMode.Web; なんて書いてGetMessageなんてメソッドを作る。
この時、Attributeに「WebGet」をつける。

  1. [WebGet(UriTemplate = "GetMessage/{key}/")]  
  2. [OperationContract]  
  3. string GetMessage(string key);  
実処理も適当に実装。
  1. public string GetMessage(string key)  
  2. {  
  3.     return "IService1.GetMessage + " + key;  
  4. }  
以上で、Wcfサービスのコーディングは完了。 後はWeb.Configの設定。 system.serviceModelの中を色々と変更。 まず、behaviorsを書く。
  1. <behaviors>  
  2.   <servicebehaviors>  
  3.     <behavior name="WcfService1.Service1Behavior">  
  4.       <servicemetadata httpgetenabled="true">  
  5.     </servicemetadata></behavior>  
  6.   </servicebehaviors>  
  7.   <endpointbehaviors>  
  8.     <behavior name="WcfService1.Service1Behavior">  
  9.     </behavior>  
  10.     <behavior name="WcfService1.Service1RestBehavior">  
  11.       <webhttp>  
  12.     </webhttp></behavior>  
  13.   </endpointbehaviors>  
  14. </behaviors>  
次にservices.serviceにendPointを書く。
  1. <services>  
  2.   <service behaviorconfiguration="WcfService1.Service1Behavior" name="WcfService1.Service1">  
  3.     <endpoint address="Soap" behaviorconfiguration="WcfService1.Service1Behavior" binding="basicHttpBinding" name="SoapEP" contract="WcfService1.IService1">  
  4.     <endpoint address="Rest" behaviorconfiguration="WcfService1.Service1RestBehavior" binding="webHttpBinding" name="RestEP" contract="WcfService1.IService1">  
  5.     <endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange">  
  6.   </endpoint></endpoint></endpoint></service>  
  7. </services>  

addressのあたりをユニークに設定するとうまくいくらしい。

で、これを使うWebサイトを作って、Web参照すると普通にSoapで使える。
ブラウザから「http://localhost:8080/Service1.svc/Rest/GetMessage/TestMessage/」なんて打てば、
IService1.GetMessage + TestMessage
こんなレスポンスがもらえると。

2010年1月31日日曜日

[C#] List.ConvertAll

C# 3.0以上で出来ます。(VBでも出来るはず)

Listの値をCSV文字列に変換出来ます。

  1. //List<int>をカンマ区切りの文字列に変換する  
  2. List<int> lst = new List<int> { 1, 3, 5, 7 };  
  3.   
  4. string csv =  
  5. string.Join(",", lst.ConvertAll<string>(  
  6. delegate(int value) { return value.ToString(); }).ToArray());  
  7.   
  8.   
  9. //カンマ区切りの文字列をList<int>に変換する  
  10. lst = csv.Split(',').ToList<string>().ConvertAll<int>(  
  11. delegate(string value) { return int.Parse(value); });  
  12.   
  13. </int></string></int></string></int></int></int>  


1行で書くことが良いかは別として出来るんですね。
# 勝手にHTMLタグが書き込まれて消せない。。。