erotik film
bodyheat full moves www xxx kajal video la figa che sborra ver video de sexo porno
Luxury replica watches
sex
asyabahis
escort antalya

** THIS SITE IS AN ARCHIVE ** - New Content is at:
BlazorHelpWebsite.com

Jul 13

Written by: kchristo
Friday, July 13, 2012  RssIcon

As soon as I started writing LightSwitch applications I noticed that many times I was repeating the same code over and over for trivial tasks. So after all this time I have collected a number of extension methods that I widely use in my apps.
For me reusing code is a must and although the implementation of LS (IMHO) does not provide for this out of the box the underlying framework is ideal for writing extension classes and methods that are a major step towards code reusability. If you have downloaded any of my samples from msdn or have seen my Application Logo post, you already suspect I am an “extension method fanatic”.
So I will present a small series (I don’t know how small) of posts with extension methods from my Base.LightSwitch.Client library.
The first method is one of the first (if not the first one) extension methods I wrote. As soon as you want to override the code for default commands like Edit and Delete for a collection (let’s name it MyCollection) you have to write something like that:
partial  void MyCollectionDelete_CanExecute(ref bool result){
if (this.MyCollection is null || this.MyCollection.SelectedItem == null)
result = false;
else
result = true;
}

This is the minimum code (it can be written more elegantly I know but this is the concept) you need to write. I don’t take into account the permissions issue.

A similar chunk of code has to be written for Edit.

Isn’t the code listed below easier to read:
partial  void MyCollectionDelete_CanExecute(ref bool result){
result = this.HasSelection("MyCollection");
}
It’s not only easier to read but is less error prone than the original. Plus you can inject any security logic in this HasSelection method.
And this is the code:
public static bool HasSelection(this IScreenObject screen, string collectionName) {
if (!screen.Details.Properties.Contains(collectionName))
return false;
IVisualCollection collection =
screen.Details.Properties[collectionName].Value as IVisualCollection;
return collection != null &&
collection.SelectedItem != null &&

(collection.SelectedItem as IEntityObject).Details.EntityState != EntityState.Deleted
;
}
For the ones that dislike using string property names I can suggest this version :
public static bool HasSelection<T>(this VisualCollection<T> collection) where T : class, IEntityObject {
return collection != null &&
collection.SelectedItem != nul &&
collection.SelectedItem.Details.EntityState != EntityState.Deleted;
}


This version is more concrete is generic and also does not have to do the (out of thin air) conversion of SelectedItem to IEntityObject. If you use this version though you have to change your partial method as you cannot extend null:
partial void MyCollectionDelete_CanExecute(ref bool result){
result = MyCollection!= null && MyCollection.HasSelection();
}
The choice is yours…Smile

Tags:
Categories:

1 comment(s) so far...


Air Jordans
Air Jordan 11
Jordan 4
Air Jordan Sneakers
Golden Goose
Yeezys
Jordan Retro 12
Red Bottom Shoes
Pandora Jewelry
Jordan 6
Adidas NMD
Pandora Bracelet
Sneakers Golden Goose
Nike Official
Christian Louboutin
Kyrie Irving Shoes
Adidas Yeezy
Moncler
Nike Outlet
Fitflops Sale Clearance
Yeezy Shoes
Mens Nike Shoes
New Jordans 2021
New Jordan 11
Jordans Retro
Jordans Retro
Air Jordan Sneakers
Moncler Jackets For Men
Shoes GGDB
Golden Goose Sneakers
Soccer Shoes
Jordan 11s
Nike Outlet Store Online
Nike Air Force One
Jordan 11s
Nike Running Shoes Sale
Yeezy
Jordan 8
Ferragamo Outlet
Air Max 95
Golden Goose Outlet
Air Jordan 9
Pandora Charms
Jordans 4
Air Jordan Sneakers
Air Jordan
Yeezys
Moncler Vest
Pandora Ring
Pandora Rings
Air Max 90
Jordan 11
ECCO Shoes For Women
Jordans Sneakers
Nike Shoes
Fitflop Shoes
Jordan Retro 12
Jordan Shoes
Jordan 11
Nike Shoes
Nike Shoes For Women
James Harden shoes
Air Jordan 4 Retro
Air Max 270
Nike Air Force 1 High
Air Jordan 10
Air Jordan 11
Fjallraven Kanken Backpack
Nike Air Max 98
Golden Goose Outlet
Nike Factory
Jordan Retro 11 Mens
Birkin Bag
Moncler
Jordans 11
Jordan Retro 5
New Jordans
Louboutin Shoes
GGDB Shoes
Cheap Jordans
Jordan Shoes
Nike Air Max 2018
Sneakers GGDB
Jordan Retro 3
Adidas NMD
Adidas Yeezy
Moncler Outlet
Jordans 11
Red Jordan 11
Nike Huarache
Air Jordan Sneakers
Golden Gooses For Sale
Jordan 14
Jordan Retro
Jordan Shoes
Pandoras Jewelry
Jordan 3
Balenciaga
Air Jordan 12 Retro
Pandora
Cheap Nike Air Max
Outlet Moncler
Balenciaga Triple S
New Nike Shoes
Red Bottom Shoes
Pandora Charms
Nike Factory Outlet
Air Jordan 5 Retro
Jordan 13s
Valentino Sneakers
James Harden Shoes
Pandora Jewelry Official Site
Jordan Retro 6
Pandora Official Site
Golden Goose Mid Stars
Golden Goose For Sale
Red Bottoms
Moncler Jackets
Jordan 1
Nike Shoes For Women
Air Jordan 6
Golden Goose Shoes Men
Jordan Shoes
Jordan 4
Moncler Jacket
Snkrs Nike
Ferragamo Shoes
Pandora
Jordan 12
Jordan Win Like 96
Moncler Jackets
Jordans Retro
Nike Outlet Shoes
Pandora Charms
Jordan 5
Pandora

By Lisa on   Sunday, November 28, 2021

Your name:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 
Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation