AttributeExtensions

 

The Resource class in the Live Framework API provides an AttributeExtensions property allowing user-provided attributes to be accessed in a DataEntryResource. AttributeExtensions is declared as follows:

public Dictionary<XmlQualifiedName, string> AttributeExtensions { get; }

AttributeExtensions provides access to user attributes to the <entry> element in the Atom feed representation of a DataEntry. ElementExtensions provides access to a user-defined child element of the <entry> element.

AttributeExtensions can be used as follows to add an attribute named "bird" with value "Emu" to a data entry: 

XmlQualifiedName xmlQualifiedName = new XmlQualifiedName("bird", String.Empty);  
dataEntry.Resource.AttributeExtensions.Add(xmlQualifiedName, "Emu");
dataEntry.Update();

This changes the Atom representation of the <entry> element to the following:

<entry bird="Emu">

Attribute extensions can be accessed as follows:

Dictionary<XmlQualifiedName, String> attributeExtensions = dataEntry.Resource.AttributeExtensions;
foreach (KeyValuePair<XmlQualifiedName, String> attributeExtension in attributeExtensions)
{
    String attributeName = attributeExtension.Key.ToString();
    String attributeValue = attributeExtension.Value;
}

Technorati Tags:

About Neil Mackenzie

Cloud Solutions Architect. Microsoft
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to AttributeExtensions

  1. Vikas says:

    your blog post has been tagged athttp://delicious.com/LiveFrameworkand linked to Live Framework Forum thread:http://social.msdn.microsoft.com/Forums/en-US/liveframework/thread/828d9a48-239a-4af8-8239-35931e514d37

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s