Skip to content

Commit 0c9eab7

Browse files
committed
fix mono build errors
1 parent 96dbc60 commit 0c9eab7

File tree

15 files changed

+699
-0
lines changed

15 files changed

+699
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
5+
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
6+
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
7+
</sectionGroup>
8+
</configSections>
9+
<system.web.webPages.razor>
10+
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
11+
<pages pageBaseType="ServiceStack.Razor.ViewPage">
12+
<namespaces>
13+
<add namespace="ServiceStack.Html" />
14+
<add namespace="ServiceStack.Razor" />
15+
<add namespace="ServiceStack.Text" />
16+
<add namespace="ServiceStack.OrmLite" />
17+
<add namespace="RazorRockstars.Console" />
18+
</namespaces>
19+
</pages>
20+
</system.web.webPages.razor>
21+
<startup>
22+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
23+
</startup>
24+
<runtime>
25+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
26+
<dependentAssembly>
27+
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
28+
<bindingRedirect oldVersion="0.0.0.0-1.0.81.0" newVersion="1.0.81.0" />
29+
</dependentAssembly>
30+
</assemblyBinding>
31+
</runtime>
32+
</configuration>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
using Funq;
4+
using ServiceStack.Common;
5+
using ServiceStack.DataAnnotations;
6+
using ServiceStack.OrmLite;
7+
using ServiceStack.OrmLite.Sqlite;
8+
using ServiceStack.Razor;
9+
using ServiceStack.ServiceHost;
10+
using ServiceStack.ServiceInterface;
11+
using ServiceStack.WebHost.Endpoints;
12+
13+
//The entire C# code for the stand-alone RazorRockstars demo.
14+
namespace RazorRockstars.Console
15+
{
16+
public class AppHost : AppHostHttpListenerBase
17+
{
18+
public AppHost() : base("Test Razor", typeof(AppHost).Assembly) { }
19+
20+
public override void Configure(Container container)
21+
{
22+
Plugins.Add(new RazorFormat());
23+
24+
container.Register<IDbConnectionFactory>(
25+
new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance));
26+
27+
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
28+
{
29+
db.CreateTable<Rockstar>(overwrite: false); //Create table if not exists
30+
db.Insert(Rockstar.SeedData); //Populate with seed data
31+
}
32+
}
33+
34+
private static void Main(string[] args)
35+
{
36+
var appHost = new AppHost();
37+
appHost.Init();
38+
appHost.Start("http://*:1337/");
39+
System.Console.WriteLine("Listening on http://localhost:1337/ ...");
40+
System.Console.ReadLine();
41+
}
42+
}
43+
44+
public class Rockstar
45+
{
46+
public static Rockstar[] SeedData = new[] {
47+
new Rockstar(1, "Jimi", "Hendrix", 27),
48+
new Rockstar(2, "Janis", "Joplin", 27),
49+
new Rockstar(3, "Jim", "Morrisson", 27),
50+
new Rockstar(4, "Kurt", "Cobain", 27),
51+
new Rockstar(5, "Elvis", "Presley", 42),
52+
new Rockstar(6, "Michael", "Jackson", 50),
53+
};
54+
55+
[AutoIncrement]
56+
public int Id { get; set; }
57+
public string FirstName { get; set; }
58+
public string LastName { get; set; }
59+
public int? Age { get; set; }
60+
61+
public Rockstar() { }
62+
public Rockstar(int id, string firstName, string lastName, int age)
63+
{
64+
Id = id;
65+
FirstName = firstName;
66+
LastName = lastName;
67+
Age = age;
68+
}
69+
}
70+
71+
[RestService("/rockstars")]
72+
[RestService("/rockstars/aged/{Age}")]
73+
[RestService("/rockstars/delete/{Delete}")]
74+
[RestService("/rockstars/{Id}")]
75+
public class Rockstars
76+
{
77+
public int Id { get; set; }
78+
public string FirstName { get; set; }
79+
public string LastName { get; set; }
80+
public int? Age { get; set; }
81+
public string Delete { get; set; }
82+
}
83+
84+
[DataContract] //Attrs for CSV Format to recognize it's a DTO and serialize the Enumerable property
85+
public class RockstarsResponse
86+
{
87+
[DataMember] public int Total { get; set; }
88+
[DataMember] public int? Aged { get; set; }
89+
[DataMember] public List<Rockstar> Results { get; set; }
90+
}
91+
92+
public class RockstarsService : RestServiceBase<Rockstars>
93+
{
94+
public IDbConnectionFactory DbFactory { get; set; }
95+
96+
public override object OnGet(Rockstars request)
97+
{
98+
using (var db = DbFactory.OpenDbConnection())
99+
{
100+
if (request.Delete == "reset")
101+
{
102+
db.DeleteAll<Rockstar>();
103+
db.Insert(Rockstar.SeedData);
104+
}
105+
else if (request.Delete.IsInt())
106+
{
107+
db.DeleteById<Rockstar>(request.Delete.ToInt());
108+
}
109+
110+
return new RockstarsResponse {
111+
Aged = request.Age,
112+
Total = db.GetScalar<int>("select count(*) from Rockstar"),
113+
Results = request.Id != default(int) ?
114+
db.Select<Rockstar>(q => q.Id == request.Id)
115+
: request.Age.HasValue ?
116+
db.Select<Rockstar>(q => q.Age == request.Age.Value)
117+
: db.Select<Rockstar>()
118+
};
119+
}
120+
}
121+
122+
public override object OnPost(Rockstars request)
123+
{
124+
using (var db = DbFactory.OpenDbConnection())
125+
{
126+
db.Insert(request.TranslateTo<Rockstar>());
127+
return OnGet(new Rockstars());
128+
}
129+
}
130+
}
131+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@inherits ViewPage
2+
3+
@{
4+
Layout = "SimpleLayout";
5+
ViewBag.Title = "Page with no model and no C# controller - just this page :)";
6+
int age = 0;
7+
var hasAge = Request.QueryString["Age"] != null && int.TryParse(Model.Age, out age);
8+
var rockstars = hasAge
9+
? Db.Select<Rockstar>(q => q.Age == age)
10+
: Db.Select<Rockstar>();
11+
var title = hasAge ? "{0} year old rockstars".Fmt(age) : "All Rockstars";
12+
}
13+
14+
<div>@title</div>
15+
<ul>
16+
@foreach (var rockstar in rockstars) {
17+
<li>@rockstar.FirstName - @rockstar.LastName (<a href="?Age=@rockstar.Age">@rockstar.Age</a>)</li>
18+
}
19+
</ul>
20+
21+
<p><a href="?">Show all Rockstars</a></p>
22+
23+
<h3>Other Pages</h3>
24+
<div><a href="/rockstars">/rockstars</a></div>
25+
<div><a href="/TypedModelNoController">/TypedModelNoController</a></div>
26+
<div><a href="/NoModelNoController">/NoModelNoController</a></div>
27+
28+
<h2>Razor View</h2>
29+
<script src="https://gist.github.com/3162494.js"></script>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("RazorRockstars.Console")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("RazorRockstars.Console")]
13+
[assembly: AssemblyCopyright("Copyright © 2012")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("cd5475ca-d88f-4fab-a71f-1d35ea72bda7")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Requires sqlite3.dll module in same /bin directory as .exe or available in the OS System $PATH
2+
3+
In VS.NET this is done by copying the sqlite3.dll for your architecture into your projects root path:
4+
5+
for 32bit pc
6+
- copy `\sqlite\x86\sqlite3.dll` to `\`
7+
or for 64bit
8+
- copy `\sqlite\x64\sqlite3.dll` to `\`
9+
10+
Then go to `\sqlite3.dll` properties (in VS.NET) and change the Build Action to: 'Copy if Newer'
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{30BA8DF9-4698-4051-B8E9-84C81E330E24}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>RazorRockstars.Console</RootNamespace>
12+
<AssemblyName>RazorRockstars.Console</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>
15+
</TargetFrameworkProfile>
16+
<FileAlignment>512</FileAlignment>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
19+
<PlatformTarget>x86</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Mono.Data.Sqlite">
40+
<HintPath>..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.3\lib\net35\Mono.Data.Sqlite.dll</HintPath>
41+
</Reference>
42+
<Reference Include="ServiceStack">
43+
<HintPath>..\packages\ServiceStack.3.9.2\lib\net40\ServiceStack.dll</HintPath>
44+
</Reference>
45+
<Reference Include="ServiceStack.Common">
46+
<HintPath>..\packages\ServiceStack.Common.3.9.0\lib\net35\ServiceStack.Common.dll</HintPath>
47+
</Reference>
48+
<Reference Include="ServiceStack.Interfaces">
49+
<HintPath>..\packages\ServiceStack.Common.3.9.0\lib\net35\ServiceStack.Interfaces.dll</HintPath>
50+
</Reference>
51+
<Reference Include="ServiceStack.OrmLite, Version=3.9.2.0, Culture=neutral, processorArchitecture=MSIL">
52+
<HintPath>..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.3\lib\net35\ServiceStack.OrmLite.dll</HintPath>
53+
</Reference>
54+
<Reference Include="ServiceStack.OrmLite.Sqlite">
55+
<HintPath>..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.3\lib\net35\ServiceStack.OrmLite.Sqlite.dll</HintPath>
56+
</Reference>
57+
<Reference Include="ServiceStack.OrmLite.SqlServer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
58+
<HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.2\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
59+
</Reference>
60+
<Reference Include="ServiceStack.Razor">
61+
<HintPath>..\packages\ServiceStack.3.9.2\lib\net40\ServiceStack.Razor.dll</HintPath>
62+
</Reference>
63+
<Reference Include="ServiceStack.Redis">
64+
<HintPath>..\packages\ServiceStack.Redis.3.9.0\lib\net35\ServiceStack.Redis.dll</HintPath>
65+
</Reference>
66+
<Reference Include="ServiceStack.ServiceInterface">
67+
<HintPath>..\packages\ServiceStack.3.9.2\lib\net40\ServiceStack.ServiceInterface.dll</HintPath>
68+
</Reference>
69+
<Reference Include="ServiceStack.Text, Version=3.9.0.0, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\packages\ServiceStack.Text.3.9.2\lib\net35\ServiceStack.Text.dll</HintPath>
71+
</Reference>
72+
<Reference Include="System" />
73+
<Reference Include="System.Core" />
74+
<Reference Include="System.Runtime.Serialization" />
75+
<Reference Include="System.Xml.Linq" />
76+
<Reference Include="System.Data.DataSetExtensions" />
77+
<Reference Include="Microsoft.CSharp" />
78+
<Reference Include="System.Data" />
79+
<Reference Include="System.Xml" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<Compile Include="AppHost.cs" />
83+
<Compile Include="Properties\AssemblyInfo.cs" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<None Include="App.config" />
87+
<EmbeddedResource Include="TypedModelNoController.cshtml" />
88+
<EmbeddedResource Include="NoModelNoController.cshtml" />
89+
<EmbeddedResource Include="Views\Rockstars.cshtml" />
90+
<EmbeddedResource Include="Views\Shared\HtmlReport.cshtml" />
91+
<EmbeddedResource Include="Views\Shared\SimpleLayout.cshtml" />
92+
<EmbeddedResource Include="Views\_Layout.cshtml" />
93+
<None Include="packages.config" />
94+
</ItemGroup>
95+
<ItemGroup>
96+
<Content Include="README.txt" />
97+
<Content Include="sqlite3.dll">
98+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
99+
</Content>
100+
<Content Include="sqlite\x64\sqlite3.dll" />
101+
<Content Include="sqlite\x86\sqlite3.dll" />
102+
<Content Include="sqlite\x86\sqlite3.exe" />
103+
</ItemGroup>
104+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
105+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
106+
Other similar extension points exist, see Microsoft.Common.targets.
107+
<Target Name="BeforeBuild">
108+
</Target>
109+
<Target Name="AfterBuild">
110+
</Target>
111+
-->
112+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@inherits ViewPage<Rockstars>
2+
3+
@{
4+
Layout = "SimpleLayout";
5+
ViewBag.Title = "Page with typed 'Rockstars' model and no C# controller";
6+
var rockstars = Model.Age.HasValue
7+
? Db.Select<Rockstar>(q => q.Age == Model.Age.Value)
8+
: Db.Select<Rockstar>();
9+
var title = Model.Age.HasValue ? "{0} year old rockstars".Fmt(Model.Age) : "All Rockstars";
10+
}
11+
12+
<div>@title</div>
13+
<ul>
14+
@foreach (var rockstar in rockstars) {
15+
<li>@rockstar.FirstName - @rockstar.LastName (<a href="?Age=@rockstar.Age">@rockstar.Age</a>)</li>
16+
}
17+
</ul>
18+
19+
<p><a href="?">Show all Rockstars</a></p>
20+
21+
<h3>Other Pages</h3>
22+
<div><a href="/rockstars">/rockstars</a></div>
23+
<div><a href="/TypedModelNoController">/TypedModelNoController</a></div>
24+
<div><a href="/NoModelNoController">/NoModelNoController</a></div>
25+
26+
<h2>Razor View</h2>
27+
<script src="https://gist.github.com/3162493.js"></script>

0 commit comments

Comments
 (0)