//public delegate double PerformCalculation(double x, double y); //public static double Addition(double a, double b) //{ // Console.WriteLine("a+b is : " + (a+b)); // return a + b; //} //public static double Division(double a, double b) //{ // Console.WriteLine("a/b is : " + (a / b)); // return a / b; //} //public static double Subtraction(double a, double b) //{ // Console.WriteLine("a-b is : " + (a - b)); // return a - b; //} //public delegate string GetTextDelegate(string name); //public delegate double GetResultDelegate(double a, double b); static void Main(string[] args) { // Creating an anonymous method or inline delegate //GetTextDelegate getTextDelegate = delegate (string name) //{ // return "Hello, " + name; //}; //Lambda expression //GetTextDelegate getHelloText = (string name) => { return "Hello, " + name; }; //Statement lambda //GetTextDelegate getGoodbyeText = (string name) => //{ // Console.WriteLine("I'm inside of a statement lambda"); // return "Goodbye, " + name; //}; //GetTextDelegate getWelcomeText = name => "Welcome, " + name; //GetResultDelegate getSum = (a, b) => a + b; //GetResultDelegate getProductDelegate = (a, b) => a * b; //DisplayNum(getSum); //DisplayNum1(getProductDelegate); //Console.WriteLine(getWelcomeText("Sophie")); //Display(getTextDelegate); //PerformCalculation getSum = Addition; ////getSum(5.0, 5.0); //PerformCalculation getQuotient = Division; ////getQuotient(5.0, 5.0); //PerformCalculation multiCalc = getSum + getQuotient; //multiCalc += Subtraction; //multiCalc -= getSum; //multiCalc(3.2, 3.2); var file = new File() { Title = "File 1" }; var downloadHelper = new DownloadHelper(); //publisher var unpackService = new UnpackService(); //reciever var notificationService = new NotificationService(); downloadHelper.FileDownloaded += unpackService.OnFileDownloaded; downloadHelper.FileDownloaded += notificationService.OnFileDownloaded; downloadHelper.Download(file); }
static void Main(string[] args) { var file = new File() { Title = "File 1" }; var downloadHelper = new DownloadHelper(); // Publisher var unpackService = new UnpackService(); // Receiver var notificationOfDownload = new NotificationOfDownload(); // Receiver downloadHelper.FileDownloaded += unpackService.OnFileDownloaded; downloadHelper.FileDownloaded += notificationOfDownload.OnFileDownloaded; downloadHelper.Download(file); }
public void TestUnpackTarGzWithInvalidFilename() { var unpackService = new UnpackService(); DirectoryInfo outDirectory = unpackService.ExtractArchive(new FileInfo(InvalidCharacterTestTarGzFile), ArchiveType.TarGz); string expectedResultFile = Path.Combine(outDirectory.FullName, InvalidFilename); Assert.True(File.Exists(expectedResultFile)); string[] fileContents = File.ReadAllLines(expectedResultFile); Assert.Single(fileContents); Assert.Equal("test", fileContents[0]); outDirectory.Delete(true); }
static void Main(string[] args) { var file = new File() { Title = "File1" }; var downloadHelper = new DownloadHelper(); var unpackService = new UnpackService(); var notifLed = new Notification(); downloadHelper.FileDownloaded += unpackService.OnFileDownloaded; downloadHelper.FileDownloaded += notifLed.onDownloadedNotif; // event+= downloadHelper.Download(file); }
public override Task <IEnumerable <DumpMetainfo> > CreateDumpInfos(string bundleId, DirectoryInfo directory) { //Should only create a dump if it is the lowest directory level and it is not empty. if (!directory.GetDirectories().Any() && directory.GetFiles().Any(file => !UnpackService.IsSupportedArchive(file.Name))) { return(Task.FromResult(Enumerable.Repeat(dumpRepository.CreateEmptyDump(bundleId), 1))); } return(Task.FromResult(Enumerable.Empty <DumpMetainfo>())); }