Thursday, 19 July 2012

Lightswitch: Get choice value of a property

I have found quite a number of things from the internet when I was doing my Lightswitch development, but I cannot remember most of the source now. So thanks for people in the community who have contributed but sorry I cannot acknowledge them properly.

 

Here is an extension method for getting the choice value of a property in code:

public static string GetDisplayedChoiceValue(this IEntityStorageProperty property)
{
// If the value is null, it has no display value
if (null == property.Value)
return null;

string valueAsString = property.Value.ToString();
// Get the list of choices for this property
IEnumerable<ISupportedValueAttribute> choices = property.
GetModel().Attributes.OfType<ISupportedValueAttribute>();
// Find the choice that matches the property value
ISupportedValueAttribute choice = choices.Single(
c => String.Equals(c.Value, valueAsString, StringComparison.Ordinal));

// If the choice does not have a display name, return the choice value instead
if (String.IsNullOrEmpty(choice.DisplayName))
return choice.Value;
else
return choice.DisplayName;
}

To use it with your object:

CodeName = o.Details.Properties.Code.GetDisplayedChoiceValue(),

Wednesday, 29 February 2012

Job Ad.

Actually, not just Graduate Software Developers we are looking for, but Intermediate, Senior… whoever interested…

clip_image002

Tuesday, 6 December 2011

Ellerslie .NET User Group Website is revived!

http://ellerslieusergroup.net.nz/

image

Ellerslie .NET User Group 22/12/2011 C# 5.0

Hello everyone,

After 9 months pregnancy and 2 months learning to be a mum, I am back and yes, Ellerslie .NET User Group is time to revive! Right before Christmas and Christmas holiday we will have a talk about C# 5.0 by Alex Davies, Software Engineer at Olympic Software. Hope we can meet up after not seeing each other for so long! A good geeky event right before the holiday season! Yay!

Again, really look forward to meet you all, register to let me know aye!

Date: 22nd December 2011 Thursday

Same time, same place. which is...

Gather at 5:45pm, starting at 6:00pm
Catering: Pizza & Drinks
Door Charge: Free!
Venue: Olympic Software, 10 Cawley Street, Ellerslie, Auckland (find a map here)

Register here: jacqc@olympic.co.nz

Title: C# 5.0

C# 5.0 brings two new keywords to assist in writing responsive asynchronous applications. We will have a look at the existing problems of synchronous code and how we can utilize the new language features to improve your applications to make them respond faster and perform better.

Speaker: Alex Davies, Software Engineer at Olympic Software NZ Ltd

Cheers,

Jacqualine Chow
Business Development Evangelist

DDI: 09 980 3999

Mobile: 029 770 0999

www.olympic.co.nz