Ȥ Blog

Ruby,C#

mono

Mono3.4 Buildǥ顼

Ubuntu Mono3.4򥽡褦ȤȤʥ顼ˤʤä

 cannot stat `targets/Microsoft.Portable.Common.targets': No such file or directory

Mono3.4ǤϤΥե뤬礱Ƥ餷
ȤȤʤΤǼʬǥեäƤ⤦ sudo make install ƤФ
Ȥ

  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="..\Microsoft.Portable.Core.props" />
   <Import Project="..\Microsoft.Portable.Core.targets" />
 </Project>

ϡ
http://stackoverflow.com/questions/22844569/build-error-mono-3-4-0-centos 

BtonicMacǤC#ǻƤߤ

ȥ饤ƤߤC#ˤiPhone,Android񥢥ץǤäʤΤMonoMacƱͤMacǥȥåǤäƤߤޤ

褯ַUIۤʤ뤫餽줾ΥץåȥեǺꤳߤɬפǤ硩פȸΤǤդUIʳʬ϶ͭǤ櫓ǡθ̤ʾǤ

PhoneGapƤߤޤץˤäƤϤΤȻפޤHTMLJavaScriptʤΤǡ줳JobsǰƤŪʵǽѤǤʤơޤ꿩ؤưޤǤʪˤäƤϤʤͭˤʤȤϻפޤ
 
 5557

C#Spec NSpec on Mono Mac

ä.NETSpecƥȥե졼SpecFlowȤΤΤǤʤ󤫤äȰ㤦ʡȴƤϤޤפRSpecƱ褦SpecñΥƥȤäʤΤǤ SpecFlowϤɤ餫ȤȼƥȸΤΤΤ褦Ǥ͡Τ˥ɤȤ̤ˤʤ󤫥ʥꥪߤν񤯤äơʤ󤫥ɡʡȡ
ǡäѤRubyˤRSpec褦ˡC#Ĥޤ.NETˤNSpecʤΤޤ
䤬õƤΤϤäääƴ®äƤߤޤ
ȤǤNuget(VisualStudioΥѥåġߤʤġ˸ΥɥȤǤȤDLLEXEեʤΤMonoǤǤϤȤǺMonoǤ
äѤSpecƥȤϤʴɤǤ͡

20


C# IPhone Xcode4.1ǤǤ褦ˤʤä

InterfaceBuilderXcode礵ƤޤäǤäѤ狼ʤʤäƤޤäMonoTouchǤXcode4бСAlphaǤǽФ餷Τǡ®äƤߤޤ
Τ˰Ȥ䤹ʤäƤϤޤ͡

LinuxASP.NET MVC3(ӥ塼󥸥Razor)ư

褦䤯ŻǤRails3ˤʤäΤǡФ餯ϥץ饤١ȤǤC#ǿꤿ
Ȥ櫓ǡASP.NET MVC3DZӥ塼󥸥RazorѤƺäWebץLinuxmono
ưƤߤޤ

MonoDevelop(ޥå)MVC3RazorˤϤޤбƤʤΤǡȯVisualStudio2010ǺơLinuxCent5.5)Mono˥ǥץ뤳Ȥˡ

ȯWindows7, VS2010, MVC3, Razor
ۥ: Linux(Cent5.5), Apache

ȤꤢưǧΤᡢǥեȤMVCץȤ򥳥ѥ뤷Linux˥ԡ
monoASP.NETưˤϡ
http://www.mono-project.com/ASP.NET
˽񤤤Ƥ뤳Ȥˤȡ
mod_mono
xsp
ɬפȤΤȡ
줾쥽Ȥƥѥ󥹥ȡ롣
󥹥ȡ뤬λȡmod_mono.conf ȤApacheե뤬ƤΤǴŪˤϤΤޤޤOK
ξ /etc/httpd/ ľˤǤƤΤǡconf.d˰ư

³ƥȤɤǤȡAutoHostingʤΤ餷
http://www.mono-project.com/AutoHosting
ˤAutoHostingʤ塹ASP.NETץȤۥȤǤ⤤ApacheեϮɬפʤǤ衼ȤΤȡؼ̤ե򤤤äƤ顢MVCץȤξϥ롼ƥ󥰤˥եĥҤѤʤ鱾ȤǡAutoHostingϿ侩ޤ󡢤äơʤꥬåꡣ
ǡʤΤǡ̤ˡASP.NETΥץñ̤Apacheե뤳Ȥˡ

http://go-mono.com/config-mod-mono/
ΥȤǤɬפʹܤϤФ򸵤եƤ褦ʤΤǡС̾ȤץȤΥǥ쥯ȥѥȤɬפʹܤϤƺäƤ餦
mod-mono-serverΥѥ/usr/binˤʤäƤ㴳ʬδĶȰۤʤäƤΤǡϼʬǽmod-mono-server2ȤʤäƤΤmod-mono-server4ѹ
Ĥ򥳥ԡơApacheconf.d my_mvc_project.conf ߤ̾ΥեäƤ¸

ApacheƵưƥ֥饦ɽƤߤȡʤ󤫥顼
⡼ȥޥʤΤǥ顼Ƥ狼ʤᡢWeb.config <customErrors mode="Off" />ˤƺ٥ȥ饤
ʤDLLĤʤ衼ߤʤȤΤǡVS2010äɬפDLL򻲾ɲäơˤĤΥץѥƥǥ륳ԡTrueˤƺƥǥץ
Ȥޤ̤DLLʤ衼ȸΤǡƱͤκȤ򷫤֤
WindowsäƤʤʤʤDLL
  • System.Web.Mvc.dll 
  • System.Web.Razor.dll 
  • System.Web.WebPages.dll 
  • System.Web.WebPages.Deployment.dll 
  • System.Web.WebPages.Razor.dll
  • System.Data.Entity
  • System.Web.Helpers.dll
 EntityȤȤäƤʤɤʡ

ǤȤꤢڡɽޤ

C#RedisƤߤ

MemcachedRubyͽäɡȾʬޤRedisC#Ƥߤ뤳Ȥˤޤ ŻǤϤɤäRailsǤͽʤǡȤǿʤC#ǤäƤȤǡ

ȤꤢRedis򥤥󥹥ȡ롣

wget http://redis.googlecode.com/files/redis-2.2.11.tar.gz
tar xzvf redis-2.2.11.tar.gz
cd redis-2.2.11
make
sudo make install

ߤhttp://redis.googlecode.com/
ΥȤǤϥ֥饦ǥ󥿥饯ƥ֤RedisΥޥɤáTutorialä򤫤äǤ

RedisСưƤߤ롣
redis-server
饤ȤưƤĤŬʥޥɤáưǧ
redis-cli #饤ȵư

#rootȤ̾ satoyan ʸ򥻥å
redis 127.0.0.1:6379> set root satoyan
OK

#Ф
redis 127.0.0.1:6379> get root
"satoyan"

#queen:membersꥹȤκǸ Fready ɲ
redis 127.0.0.1:6379> rpush queen:members Fready
(integer) 1

#ƱͤBrian ɲ
redis 127.0.0.1:6379> rpush queen:members Brian
(integer) 2

#ꥹȤȤɽ 0-1ȤΤϤĤޤƬǸޤǤȤ
redis 127.0.0.1:6379> lrange queen:members 0 -1
1) "Fready"
2) "Brian"

C#Redis򰷤饤֥ɤ롣ʤ󤫴Ĥ褦ǤServiceStack.RedisȤΤǻƤߤ롣

https://github.com/ServiceStack/ServiceStack.Redis
DLL켰ɡ

MonoDevelopưŬʥץȤDLLȤɲá
ʴ

C#iPhone - ܡɤ̵ͭˤäƥƥԽꥢΥѹ

ƥȥꥢΥեܤȼưŪ˥ܡɤɽ褦ˤʤäƤޤƥȥꥢ̤äѤɽƤꤹȡɽ줿ܡɤƥȥꥢΰ򱣤Ƥޤ礬ޤ
Τ褦ʲ̥쥤Ȥξϡܡɤɽɽ˱ƥƥȥꥢΥѹɬפФƤޤ
Ȥ櫓ǤäƤߤޤ
ݥȤ
  • NSNotificationCenter.DefaultCenter.AddObserver ܡɤɽɽΤ褦ˤ
  • ResignFirstResponder - ȥ뤫ե򳰤 - .NETǸȤLostFocus
äƤȤǤ礦

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;

namespace HelloIPhoneTextView
{
	public class Application
	{
		static void Main (string[] args)
		{
			UIApplication.Main (args);
		}
	}
	
	// The name AppDelegate is referenced in the MainWindow.xib file.
	public partial class AppDelegate : UIApplicationDelegate
	{
		
		NSObject kbdShow, kbdHide;
		
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			doneButton.Enabled = false;
			
			kbdShow = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillShowNotification, delegate(NSNotification n) {
				var kbdFrame = UIKeyboard.BoundsFromNotification (n);
				var frame = textView.Frame;
				frame.Height -= kbdFrame.Height;
				textView.Frame = frame;
				doneButton.Enabled = true;
			});
			
			kbdHide = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, delegate(NSNotification n) {
				var kbdFrame = UIKeyboard.BoundsFromNotification (n);
				var frame = textView.Frame;
				frame.Height += kbdFrame.Height;
				textView.Frame = frame;
				doneButton.Enabled = false;
			});
			
			doneButton.TouchDown += (sender, e) => {
				textView.ResignFirstResponder ();
			};
			
			
			window.MakeKeyAndVisible ();
	
			return true;
		}
	
		// This method is required in iPhoneOS 3.0
		public override void OnActivated (UIApplication application)
		{
		}
		
		public override void WillTerminate (UIApplication application)
		{
			NSNotificationCenter.DefaultCenter.RemoveObserver (kbdShow);
			NSNotificationCenter.DefaultCenter.RemoveObserver (kbdHide);
		}
		
	}
}



C#iPhone - UiWebViewWeb֥饦Ƥߤ

ǤΥå٥ȤȤե٥ȤȤåǤоݤDOMǤȤȽФɡˡΤʤ

ץ˥Ѥ˥ǥ륹η뺧Կʶʤ򥮥ǺäƤߤޤ뤵Τ褯狼ʤʤäƤ

ѡ1

ѡ2
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace HelloIPhoneWebBrowser
{
	public class Application
	{
		static void Main (string[] args)
		{
			UIApplication.Main (args);
		}
	}
	
	// The name AppDelegate is referenced in the MainWindow.xib file.
	public partial class AppDelegate : UIApplicationDelegate
	{
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
		
			myWebBrowser.ShouldStartLoad = delegate(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) {
				if (navigationType == UIWebViewNavigationType.LinkClicked) {
					UIApplication.SharedApplication.OpenUrl (request.Url);
					return false;
				}
				return true;
			};
			
			goButton.TouchDown += (sender, e) => {
				myWebBrowser.LoadRequest (new NSUrlRequest (new NSUrl (myUrlText.Text)));
			};
			
			myWebBrowser.LoadStarted += (sender, e) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
				myUrlText.Text = myWebBrowser.Request.Url.AbsoluteString;
			};
			
			myWebBrowser.LoadFinished += (sender, e) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
				myUrlText.Text = myWebBrowser.Request.Url.AbsoluteString;
				this.updateNavigateButtonEnabled ();
			};
			
			
			myWebBrowser.LoadError += (object sender, UIWebErrorArgs e) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
				using (var alert = new UIAlertView("Error!!", e.Error.LocalizedDescription, null, "OK", null)) {
					alert.Show ();
				}
				this.updateNavigateButtonEnabled ();
			};
			
			backButton.TouchDown += (sender, e) => {
				myWebBrowser.GoBack ();
			};
			
			forwardButton.TouchDown += (sender, e) => {
				myWebBrowser.GoForward ();
			};
			

			window.MakeKeyAndVisible ();
	
			return true;
		}
		
		void updateNavigateButtonEnabled ()
		{ 
			backButton.Enabled = myWebBrowser.CanGoBack;
			forwardButton.Enabled = myWebBrowser.CanGoForward;
		}
		
	
		// This method is required in iPhoneOS 3.0
		public override void OnActivated (UIApplication application)
		{
		}
	}
}


NUnitη̤HTMLɽ

.NETǤSpecFlowɥˤäSpecƥȤ뤳ȤϤ狼äΤǤ̤HTMLɽǤߤʤȤ⥬ɤ˽񤤤Ƥޤ
ǡɤ Ȥ褯ɤǤߤ
  1. nunit-console ǥƥȥץȤ¹ԤXMLե
  2. specflow.exe HTML
ƤʼǤ褦Ǥ


ʴ
ĶMacmonoǤ


#MySpec.dllϥƥȥץ(nUnit)
nunit-console -labels -out=TestResult.txt -xml=TestResult.xml ./bin/Debug/MySpec.dll


mono specFlowषǥ쥯ȥ/tools/specflow.exe nunitexecutionreport ./MySpec.csproj


ȤäƤȡʴHTML롣
ƥ3Ĥʤ䤷features 0 äƤΤ褯狼ʤ
10



ץե

Ȥ

C#ɻŻRubyФʳȯԡ
ǶDockerȤؿȤAngularJS˥ϥޤäƤ롣
¢ȤĮȤȤ˽ס

QR
QR
  • 饤֥ɥ֥