.NET Basic LTI XML file loader

32 views
Skip to first unread message

Steve Lewnau

unread,
Mar 10, 2010, 11:36:17 AM3/10/10
to IMS Developer Mailing List
Here's a .NET class to load a Basic LTI xml file. It definitely works
with the sample file "Example_CC1b.xml", but may need more properties.

---------------------------
Loading XML file example:

string XMLFileName = @"C:\blti.xml";
System.IO.StreamReader sr = new StreamReader(XMLFileName);
XmlSerializer xs = new XmlSerializer(typeof(Blti));
Blti blti = (Blti)xs.Deserialize(sr);
----------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;

[XmlRootAttribute("cartridge_basiclti_link", Namespace = "http://
www.imsglobal.org/xsd/imslticc_v1p0", IsNullable = false)]
public class Blti
{
[XmlRootAttribute("property", Namespace = "http://
www.imsglobal.org/xsd/imslticm_v1p0")]
public class CustomProperty
{
[XmlAttribute("name", Namespace = "http://
www.imsglobal.org/xsd/imslticm_v1p0")]
public string Name;

[XmlText]
public string Value;
}

[XmlRootAttribute("vendor", Namespace = "http://
www.imsglobal.org/xsd/imslticc_v1p0")]
public class VendorProperty
{
[XmlElement("code", Namespace = "http://www.imsglobal.org/
xsd/imslticp_v1p0")]
public string Code;

[XmlElement("name", Namespace = "http://www.imsglobal.org/
xsd/imslticp_v1p0")]
public string Name;

[XmlElement("description", Namespace = "http://
www.imsglobal.org/xsd/imslticp_v1p0")]
public string Description;

[XmlElement("url", Namespace = "http://www.imsglobal.org/
xsd/imslticp_v1p0")]
public string Url;

[XmlElement("contact", Namespace = "http://
www.imsglobal.org/xsd/imslticp_v1p0")]
public ContactProperty Contact;

//[XmlRootAttribute("Contact", Namespace = "http://
www.imsglobal.org/xsd/imslticp_v1p0")]
public class ContactProperty
{
[XmlElement("email", Namespace = "http://
www.imsglobal.org/xsd/imslticp_v1p0")]
public string Email;
}
}

[XmlElement("title", Namespace = "http://www.imsglobal.org/xsd/
imsbasiclti_v1p0")]
public string Title;

[XmlElement("description", Namespace = "http://
www.imsglobal.org/xsd/imsbasiclti_v1p0")]
public string Description;

[XmlArray("custom", Namespace = "http://www.imsglobal.org/xsd/
imsbasiclti_v1p0"), XmlArrayItem("property", Namespace = "http://
www.imsglobal.org/xsd/imslticm_v1p0")]
public CustomProperty[] Custom;

[XmlArray("extensions", Namespace = "http://www.imsglobal.org/
xsd/imsbasiclti_v1p0"), XmlArrayItem("property", Namespace = "http://
www.imsglobal.org/xsd/imslticm_v1p0")]
public CustomProperty[] Extensions;

[XmlElement("launch_url", Namespace = "http://
www.imsglobal.org/xsd/imsbasiclti_v1p0")]
public string LaunchUrl;

[XmlElement("secure_lauch_url", Namespace = "http://
www.imsglobal.org/xsd/imsbasiclti_v1p0")]
public string SecureLaunchUrl;

[XmlElement("icon", Namespace = "http://www.imsglobal.org/xsd/
imsbasiclti_v1p0")]
public string Icon;

[XmlElement("secure_icon", Namespace = "http://
www.imsglobal.org/xsd/imsbasiclti_v1p0")]
public string SecureIcon;

[XmlElement("vendor", Namespace = "http://www.imsglobal.org/
xsd/imsbasiclti_v1p0")]
public VendorProperty Vendor;
}

Message has been deleted

Steve Lewnau

unread,
Mar 10, 2010, 11:41:47 AM3/10/10
to IMS Developer Mailing List
I will add this file separately to prevent formatting errors.
Reply all
Reply to author
Forward
0 new messages