This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Role : Enumeration<Role> | |
{ | |
public static readonly Role System = new Role(0, "System", "System", true); | |
public static readonly Role Manager = new Role(1, "Manager", "Michelle", false); | |
public static readonly Role Employee = new Role(2, "Employee", "Eric", false); | |
public static readonly Role HumanResources = new Role(3, "Human Resources", "Harry", false); | |
private Role(int value, string displayName, string personaName, bool testrole) | |
: base(value, displayName) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Role manager = (Role)(1); | |
Role bogus = (Role)(-1); | |
Console.WriteLine(manager); | |
Console.WriteLine(bogus); | |
//Output: | |
// Manager | |
// -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ReceiveLambdaAsDelegate(Func<int, int> function) {...} | |
public void ReceiveLambdaAsExpression(Expression<Func<int, int>> expression) {...} | |
... | |
ReceiveLambdaAsDelegate(x => x*x); | |
ReceiveLambdaAsExpression(x => x*x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ReceiveLambdaAsDelegate(Func<int, int> function) {...} | |
public void ReceiveLambdaAsExpression(Expression<Func<int, int>> expression) {...} | |
... | |
ReceiveLambdaAsDelegate(x => x*x); | |
ReceiveLambdaAsExpression(x => x*x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Discovering all method declarations in a given tree: | |
IEnumerable<MethodDeclarationSyntax> methods = | |
tree.Root | |
.DescendentNodes() | |
.OfType<MethodDeclarationSyntax>().ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Customer GetCustomer(Guid customerID) | |
{ | |
return CustomerDataAccess.GetCustomer(customerID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Customer GetCustomer(Guid customerID) | |
{ | |
try | |
{ | |
return CustomerDataAccess.GetCustomer(customerID); | |
} | |
catch (SomeSpecialException) | |
{ | |
throw; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Customer GetCustomer(Guid customerID) | |
{ | |
try | |
{ | |
return CustomerDataAccess.GetCustomer(customerID); | |
} | |
catch (Exception ex) | |
{ | |
Handle(ex); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Customer GetCustomer(Guid customerID) | |
{ | |
try | |
{ | |
return CustomerDataAccess.GetCustomer(customerID); | |
} | |
catch (Exception ex) | |
{ | |
Handle(ex); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Some.Imaginary.Macro.Library; | |
public class Sample | |
{ | |
prop public string Name; | |
} |