Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ Generated_Code #added for RIA/Silverlight projects
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML

.DS_Store
*.swp
tmp/
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
TinCanCSharp
============
A C#/.NET library for implementing Tin Can API.

C#/.NET library for Tin Can API
For hosted API documentation, basic usage instructions, supported version listing, etc. visit the main project website at:

http://rusticisoftware.github.io/TinCanCSharp/

For more information about the Tin Can API visit:

http://tincanapi.com/

Requires .NET 3.5 or later.
26 changes: 26 additions & 0 deletions TinCan.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinCan", "TinCan\TinCan.csproj", "{27D0FCA1-E869-440C-9D16-F62D7A068C53}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinCanTests", "TinCanTests\TinCanTests.csproj", "{854413C2-2F81-4A82-9949-DE2868A10078}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Release|Any CPU.Build.0 = Release|Any CPU
{854413C2-2F81-4A82-9949-DE2868A10078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{854413C2-2F81-4A82-9949-DE2868A10078}.Debug|Any CPU.Build.0 = Debug|Any CPU
{854413C2-2F81-4A82-9949-DE2868A10078}.Release|Any CPU.ActiveCfg = Release|Any CPU
{854413C2-2F81-4A82-9949-DE2868A10078}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
66 changes: 66 additions & 0 deletions TinCan/About.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using TinCan.json;

namespace TinCan
{
public class About : JSONBase
{
public List<TCAPIVersion> version { get; set; }
public Extensions extensions { get; set; }

public About(String str) : this(new StringOfJSON(str)) {}
public About(StringOfJSON json) : this(json.toJObject()) {}

public About(JObject jobj)
{
if (jobj["version"] != null)
{
version = new List<TCAPIVersion>();
foreach (var item in jobj.Value<JArray>("version"))
{
version.Add(TCAPIVersion.FromString((String)item));
}
}
if (jobj["extensions"] != null)
{
extensions = new Extensions(jobj.Value<JObject>("extensions"));
}
}

public override JObject toJObject(TCAPIVersion version) {
JObject result = new JObject();
if (version != null)
{
var versions = new JArray();
foreach (var v in this.version) {
versions.Add(v.ToString());
}
result.Add("version", versions);
}

if (extensions != null && ! extensions.isEmpty())
{
result.Add("extensions", extensions.toJObject(version));
}

return result;
}
}
}
54 changes: 54 additions & 0 deletions TinCan/Activity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using Newtonsoft.Json.Linq;
using TinCan.json;

namespace TinCan
{
public class Activity : StatementTarget
{
private String objectType = "Activity";

public Uri id { get; set; }
//public ActivityDefinition definition { get; set; }

public Activity() { }

public Activity(StringOfJSON json) : this(json.toJObject()) { }

public Activity(JObject jobj)
{
if (jobj["id"] != null)
{
id = new Uri(jobj.Value<String>("id"));
}
}

public override JObject toJObject(TCAPIVersion version)
{
JObject result = new JObject();
result.Add("objectType", objectType);

if (id != null)
{
result.Add("id", id.ToString());
}

return result;
}
}
}
57 changes: 57 additions & 0 deletions TinCan/Agent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using Newtonsoft.Json.Linq;
using TinCan.json;

namespace TinCan
{
public class Agent : StatementTarget
{
private String objectType = "Agent";

public String name { get; set; }
public String mbox { get; set; }
public String mbox_sha1sum { get; set; }
public String openid { get; set; }
public AgentAccount account { get; set; }

public Agent() { }

public Agent(StringOfJSON json) : this(json.toJObject()) { }

public Agent(JObject jobj)
{
if (jobj["mbox"] != null)
{
mbox = jobj.Value<String>("mbox");
}
}

public override JObject toJObject(TCAPIVersion version)
{
JObject result = new JObject();
result.Add("objectType", objectType);

if (mbox != null)
{
result.Add("mbox", mbox);
}

return result;
}
}
}
65 changes: 65 additions & 0 deletions TinCan/AgentAccount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using Newtonsoft.Json.Linq;
using TinCan.json;

namespace TinCan
{
public class AgentAccount : JSONBase
{
// TODO: check to make sure is absolute?
public Uri homePage { get; set; }
public String name { get; set; }

public AgentAccount() { }

public AgentAccount(StringOfJSON json) : this(json.toJObject()) { }

public AgentAccount(JObject jobj)
{
if (jobj["homePage"] != null)
{
homePage = new Uri(jobj.Value<String>("homePage"));
}
if (jobj["name"] != null)
{
name = jobj.Value<String>("name");
}
}

public AgentAccount(Uri homePage, String name)
{
this.homePage = homePage;
this.name = name;
}

public override JObject toJObject(TCAPIVersion version)
{
JObject result = new JObject();
if (homePage != null)
{
result.Add("homePage", homePage.ToString());
}
if (name != null)
{
result.Add("name", name);
}

return result;
}
}
}
24 changes: 24 additions & 0 deletions TinCan/Document/ActivityProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;

namespace TinCan.Document
{
public class ActivityProfile : Base
{
public Activity activity { get; set; }
}
}
24 changes: 24 additions & 0 deletions TinCan/Document/AgentProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;

namespace TinCan.Document
{
public class AgentProfile : Base
{
public Agent agent { get; set; }
}
}
29 changes: 29 additions & 0 deletions TinCan/Document/Base.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2014 Rustici Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections.Generic;

namespace TinCan.Document
{
public abstract class Base
{
public String id { get; set; }
public String etag { get; set; }
public DateTime timestamp { get; set; }
public String contentType { get; set; }
public byte[] content { get; set; }
}
}
Loading