Skip to content

Commit 7b62782

Browse files
committed
Updated examples with NuGet references, additional comments. Removed unnecessary DataMember and DataContract.
1 parent 1080cc3 commit 7b62782

File tree

275 files changed

+14725
-5805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+14725
-5805
lines changed

lib/ServiceStack.Common.dll

-199 KB
Binary file not shown.

lib/ServiceStack.Interfaces.dll

-84.5 KB
Binary file not shown.
-7.5 KB
Binary file not shown.

lib/ServiceStack.OrmLite.Sqlite.dll

-12 KB
Binary file not shown.

lib/ServiceStack.OrmLite.dll

-119 KB
Binary file not shown.

lib/ServiceStack.Razor.dll

-114 KB
Binary file not shown.

lib/ServiceStack.Razor.dll.config

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/ServiceStack.RazorEngine.dll

-60.5 KB
Binary file not shown.

lib/ServiceStack.RazorEngine.dll.config

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/ServiceStack.Redis.dll

-205 KB
Binary file not shown.

lib/ServiceStack.ServiceInterface.dll

-222 KB
Binary file not shown.

lib/ServiceStack.Text.dll

-141 KB
Binary file not shown.

lib/ServiceStack.dll

-620 KB
Binary file not shown.

src/Backbone.Todos/Backbone.Todos.csproj

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,26 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35-
<Reference Include="ServiceStack, Version=2.0.7.20458, Culture=neutral, processorArchitecture=MSIL">
36-
<SpecificVersion>False</SpecificVersion>
37-
<HintPath>..\..\lib\ServiceStack.dll</HintPath>
35+
<Reference Include="ServiceStack, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
36+
<HintPath>..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.dll</HintPath>
3837
</Reference>
39-
<Reference Include="ServiceStack.Common, Version=1.0.4095.20455, Culture=neutral, processorArchitecture=MSIL">
40-
<SpecificVersion>False</SpecificVersion>
41-
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
38+
<Reference Include="ServiceStack.Common, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
39+
<HintPath>..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Common.dll</HintPath>
4240
</Reference>
43-
<Reference Include="ServiceStack.Interfaces, Version=1.0.4095.20451, Culture=neutral, processorArchitecture=MSIL">
44-
<SpecificVersion>False</SpecificVersion>
45-
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
41+
<Reference Include="ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
42+
<HintPath>..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Interfaces.dll</HintPath>
4643
</Reference>
47-
<Reference Include="ServiceStack.Redis, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
48-
<SpecificVersion>False</SpecificVersion>
49-
<HintPath>..\..\lib\ServiceStack.Redis.dll</HintPath>
44+
<Reference Include="ServiceStack.OrmLite.SqlServer">
45+
<HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.9\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
5046
</Reference>
51-
<Reference Include="ServiceStack.ServiceInterface, Version=1.0.4080.41519, Culture=neutral, processorArchitecture=MSIL">
52-
<SpecificVersion>False</SpecificVersion>
53-
<HintPath>..\..\lib\ServiceStack.ServiceInterface.dll</HintPath>
47+
<Reference Include="ServiceStack.Redis, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
48+
<HintPath>..\packages\ServiceStack.Redis.3.9.11\lib\net35\ServiceStack.Redis.dll</HintPath>
5449
</Reference>
55-
<Reference Include="ServiceStack.Text">
56-
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
50+
<Reference Include="ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
51+
<HintPath>..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
52+
</Reference>
53+
<Reference Include="ServiceStack.Text, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
54+
<HintPath>..\packages\ServiceStack.Text.3.9.11\lib\net35\ServiceStack.Text.dll</HintPath>
5755
</Reference>
5856
<Reference Include="System" />
5957
<Reference Include="System.Core" />
@@ -62,7 +60,7 @@
6260
</ItemGroup>
6361
<ItemGroup>
6462
<Content Include="default.htm" />
65-
<Content Include="destroy.png" />
63+
<Content Include="Content\Images\destroy.png" />
6664
<Content Include="docs\backbone-localstorage.html" />
6765
<Content Include="docs\backbone.html" />
6866
<Content Include="docs\docco.css" />
@@ -80,11 +78,11 @@
8078
<Content Include="docs\images\tzigla.png" />
8179
<Content Include="docs\todos.html" />
8280
<Content Include="Global.asax" />
83-
<Content Include="js\backbone.js" />
84-
<Content Include="js\jquery-1.5.js" />
85-
<Content Include="js\underscore-1.1.5.js" />
86-
<Content Include="todos.css" />
87-
<Content Include="todos.js" />
81+
<Content Include="Scripts\backbone.js" />
82+
<Content Include="Scripts\jquery-1.5.js" />
83+
<Content Include="Scripts\underscore-1.1.5.js" />
84+
<Content Include="Content\Css\todos.css" />
85+
<Content Include="Scripts\todos.js" />
8886
<Content Include="Web.config" />
8987
</ItemGroup>
9088
<ItemGroup>
@@ -93,7 +91,9 @@
9391
</Compile>
9492
<Compile Include="Properties\AssemblyInfo.cs" />
9593
</ItemGroup>
96-
<ItemGroup />
94+
<ItemGroup>
95+
<Content Include="packages.config" />
96+
</ItemGroup>
9797
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
9898
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
9999
<ProjectExtensions>

src/Backbone.Todos/todos.css renamed to src/Backbone.Todos/Content/Css/todos.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ html {
147147
cursor: pointer;
148148
width: 20px;
149149
height: 20px;
150-
background: url(destroy.png) no-repeat 0 0;
150+
background: url(../Images/destroy.png) no-repeat 0 0;
151151
}
152152
#todo-list li:hover .todo-destroy {
153153
display: block;

src/Backbone.Todos/Global.asax.cs

Lines changed: 94 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,113 @@
22
using ServiceStack.Redis;
33
using ServiceStack.ServiceInterface;
44
using ServiceStack.WebHost.Endpoints;
5+
using Funq;
6+
using ServiceStack.Text;
57

68
//The entire C# source code for the ServiceStack + Redis TODO REST backend. There is no other .cs :)
79
namespace Backbone.Todos
810
{
9-
//REST Resource DTO
10-
public class Todo
11-
{
12-
public long Id { get; set; }
13-
public string Content { get; set; }
14-
public int Order { get; set; }
15-
public bool Done { get; set; }
16-
}
11+
/// <summary>
12+
/// Define your ServiceStack web service request (i.e. Request DTO).
13+
/// </summary>
14+
public class Todo
15+
{
16+
public long Id { get; set; }
17+
public string Content { get; set; }
18+
public int Order { get; set; }
19+
public bool Done { get; set; }
20+
}
1721

18-
//Todo REST Service implementation
19-
public class TodoService : RestServiceBase<Todo>
20-
{
21-
public IRedisClientsManager RedisManager { get; set; } //Injected by IOC
22+
/// <summary>
23+
/// Create your ServiceStack rest-ful web service implementation.
24+
/// </summary>
25+
public class TodoService : RestServiceBase<Todo>
26+
{
27+
/// <summary>
28+
/// Gets or sets the Redis Manager. The built-in IoC used with ServiceStack autowires this property.
29+
/// </summary>
30+
public IRedisClientsManager RedisManager { get; set; }
2231

23-
public override object OnGet(Todo request)
24-
{
25-
//return single todo
26-
if (request.Id != default(long))
27-
return RedisManager.ExecAs<Todo>(r => r.GetById(request.Id));
32+
public override object OnGet(Todo todo)
33+
{
34+
//Return a single Todo if the id is provided.
35+
if (todo.Id != default(long))
36+
{
37+
return RedisManager.ExecAs<Todo>(r => r.GetById(todo.Id));
38+
}
2839

29-
//return all todos
30-
return RedisManager.ExecAs<Todo>(r => r.GetAll());
31-
}
40+
//Return all Todos items.
41+
return RedisManager.ExecAs<Todo>(r => r.GetAll());
42+
}
3243

33-
//Handles creaing a new and updating existing todo
34-
public override object OnPost(Todo todo)
35-
{
36-
RedisManager.ExecAs<Todo>(r => {
37-
//Get next id for new todo
38-
if (todo.Id == default(long)) todo.Id = r.GetNextSequence();
39-
r.Store(todo);
40-
});
41-
return todo;
42-
}
44+
/// <summary>
45+
/// Handles creating and updating the Todo items.
46+
/// </summary>
47+
/// <param name="todo">The todo.</param>
48+
/// <returns></returns>
49+
public override object OnPost(Todo todo)
50+
{
51+
RedisManager.ExecAs<Todo>(r =>
52+
{
53+
//Get next id for new todo
54+
if (todo.Id == default(long)) todo.Id = r.GetNextSequence();
55+
r.Store(todo);
56+
});
57+
return todo;
58+
}
4359

44-
public override object OnPut(Todo request)
45-
{
46-
return OnPost(request);
47-
}
60+
/// <summary>
61+
/// Handles creating and updating the Todo items.
62+
/// </summary>
63+
/// <param name="todo">The todo.</param>
64+
/// <returns></returns>
65+
public override object OnPut(Todo todo)
66+
{
67+
return OnPost(todo);
68+
}
4869

49-
public override object OnDelete(Todo request)
50-
{
51-
RedisManager.ExecAs<Todo>(r => r.DeleteById(request.Id));
52-
return null;
53-
}
54-
}
70+
public override object OnDelete(Todo todo)
71+
{
72+
RedisManager.ExecAs<Todo>(r => r.DeleteById(todo.Id));
73+
return null;
74+
}
75+
}
5576

56-
//Configure ServiceStack.NET web service host
57-
public class AppHost : AppHostBase
58-
{
59-
//Tell ServiceStack the name and where to find your web services
60-
public AppHost() : base("Backbone.js TODO", typeof(TodoService).Assembly) { }
77+
/// <summary>
78+
/// Create your ServiceStack web service application with a singleton AppHost.
79+
/// </summary>
80+
public class ToDoAppHost : AppHostBase
81+
{
82+
/// <summary>
83+
/// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
84+
/// </summary>
85+
public ToDoAppHost() : base("Backbone.js TODO", typeof(TodoService).Assembly) { }
6186

62-
public override void Configure(Funq.Container container)
63-
{
64-
//Set JSON web services to return idiomatic JSON camelCase properties
65-
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
87+
/// <summary>
88+
/// Configure the container with the necessary routes for your ServiceStack application.
89+
/// </summary>
90+
/// <param name="container">The built-in IoC used with ServiceStack.</param>
91+
public override void Configure(Container container)
92+
{
93+
//Configure ServiceStack Json web services to return idiomatic Json camelCase properties.
94+
JsConfig.EmitCamelCaseNames = true;
6695

67-
//Register Redis factory in Funq IOC
68-
container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));
96+
//Register Redis factory in Funq IoC. The default port for Redis is 6379.
97+
container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));
6998

70-
//Register user-defined REST Paths
71-
Routes
72-
.Add<Todo>("/todos")
73-
.Add<Todo>("/todos/{Id}");
74-
}
75-
}
99+
//Register user-defined REST Paths
100+
Routes
101+
.Add<Todo>("/todos")
102+
.Add<Todo>("/todos/{Id}");
103+
}
104+
}
76105

77-
public class Global : System.Web.HttpApplication
78-
{
79-
protected void Application_Start(object sender, EventArgs e)
80-
{
81-
new AppHost().Init(); //Start ServiceStack App
82-
}
83-
}
106+
public class Global : System.Web.HttpApplication
107+
{
108+
protected void Application_Start(object sender, EventArgs e)
109+
{
110+
//Initialize your application
111+
(new ToDoAppHost()).Init();
112+
}
113+
}
84114
}
File renamed without changes.

0 commit comments

Comments
 (0)