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 Execute() { | |
var employee = PayrollDatabase.Instance.GetEmployee(_empId); | |
if(employee!=Employee.NotFound) { | |
Change(employee); | |
} | |
} |
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 Execute() { | |
EmployeeResult result = PayrollDatabase.Instance.GetEmployee(_empId); | |
if(result!=EmployeeResult.NotFound) { | |
Change(result.Employee); | |
} | |
} |
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
string PrintMaxValue() { | |
int maxValue = intSet.Max(); | |
if(maxValue == 0) { | |
return "Not available"; | |
} | |
return maxValue.ToString(); | |
} |
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 AddCommissionedEmployee(int empId,string name,string address,decimal salary,decimal commissionRate) | |
: base(empId, name,address) { | |
_salary = salary; | |
_commissionRate = commissionRate; | |
} |
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 AddCommissionedEmployee(EmployeeId empId,Name name, Address address, Salary salary, CommissionRate commissionRate) | |
: base(empId, name,address) { | |
_salary = salary; | |
_commissionRate = commissionRate; | |
} |
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 PFXGenerator { | |
//adapted from https://github.com/mono/mono/blob/master/mcs/tools/security/makecert.cs | |
public static byte[] GeneratePfx(string certificateName,string password) { | |
byte[] sn = GenerateSerialNumber(); | |
string subject = string.Format("CN={0}",certificateName); | |
DateTime notBefore = DateTime.Now; | |
DateTime notAfter = DateTime.Now.AddYears(20); | |
RSA subjectKey = new RSACryptoServiceProvider(2048); |
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
const string password= "testpassword"; | |
var pfx= PFXGenerator.GeneratePfx("testcertificate", password); | |
File.WriteAllBytes("cert.pfx", pfx); | |
File.WriteAllBytes("cert.cer", PFXGenerator.GetCertificateForBytes(pfx,password)); |
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
private static void PrintServicePointConnections(ServicePoint sp) { | |
var spType = sp.GetType(); | |
var privateOrPublicInstanceField = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance; | |
var connectionGroupField = spType.GetField("m_ConnectionGroupList",privateOrPublicInstanceField); | |
var value = (Hashtable)connectionGroupField.GetValue(sp); | |
foreach(var key in value.Keys) { | |
var connectionGroup = value[key]; | |
var groupType = connectionGroup.GetType(); | |
var listField = groupType.GetField("m_ConnectionList",privateOrPublicInstanceField); | |
var listValue = (ArrayList)listField.GetValue(connectionGroup); |
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; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading; | |
namespace WadGraphEs.MetricsEndpoint.Console { | |
using System.Reflection; |
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
class Vector { | |
private readonly double _x; | |
private readonly double _y; | |
public Vector(double x, double y) { | |
_x = x; | |
_y = y; | |
} | |
public Vector Add(Vector addend) { |