View PerWebRequestLifestyleOverrider.cs
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 PerWebRequestLifestyleOverrider : IContributeComponentModelConstruction | |
{ | |
public void ProcessModel(IKernel kernel, ComponentModel model) | |
{ | |
if (model.LifestyleType == LifestyleType.PerWebRequest) | |
{ | |
model.LifestyleType = LifestyleType.Singleton; | |
} | |
} | |
} |
View WindsorContainerRegistration.cs
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
var conatiner = new WindsorContainer(); | |
container.Kernel.ComponentModelBuilder.AddContributor(new PerWebRequestLifestyleOverrider()); | |
// Rest of your code |
View EditCsProj.cs
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 System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.Build.Evaluation; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var projectList = new List<string>() | |
{ |
View DebuggerBrowsableExample
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 Employee | |
{ | |
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] | |
public string FirstName { get; set; } | |
[DebuggerBrowsable(DebuggerBrowsableState.Never)] | |
public string Surname { get; set; } | |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
View DebuggerDisplayExample
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
[DebuggerDisplay("Name of employee is {FirstName} {Surname} and his department is {Department}")] | |
public class Employee | |
{ | |
public string FirstName { get; set; } | |
public string Surname { get; set; } | |
public string Department { get; set; } | |
} |
View ObsoleteAttributeExample
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 class Logger | |
{ | |
public static void Log(string message, | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int sourceLineNumber = 0, | |
[CallerMemberName] string callerMemberName = "") | |
{ | |
Log($"[Message]: {message}; [Source File Path]: {sourceFilePath}; " + | |
$"[Source Line Number]: {sourceLineNumber}; [Caller Member Name]: {callerMemberName}; "); | |
} |
View Logger.cs
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 System.Diagnostics; | |
using System.Runtime.CompilerServices; | |
namespace ConditionalAttributeExample | |
{ | |
public static class Logger | |
{ | |
public static void Log(string message, | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int sourceLineNumber = 0, |
View GetUnicodeCategoryExample
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 System; | |
namespace GetUnicodeCategoryExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var sampleString = @"1aB%$^()-"; | |
for (int i = 0; i < sampleString.Length; i++) |
View Logger.cs
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 System.Diagnostics; | |
using System.Runtime.CompilerServices; | |
namespace staticUsingExample | |
{ | |
public static class Logger | |
{ | |
public static void Log(string message, | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int sourceLineNumber = 0, |
View Program.cs
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 static staticUsingExample.Logger; | |
namespace staticUsingExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
DebugLog("Member Start"); |
OlderNewer