This file contains hidden or 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
| import SwiftUI | |
| extension Color { | |
| public static func fromHexString (_ hex: String) -> Color { | |
| let hexString = prepareHexString(hex) | |
| guard hexString.count == 6 else { return Color.gray } | |
| return Color(makeUIColorFromRgbValue(makeHexInteger(hexString))) | |
| } | |
| private static func prepareHexString(_ hexString: String) -> String { |
This file contains hidden or 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.Threading; | |
| using System.Threading.Tasks; | |
| namespace AsyncTest | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { |
This file contains hidden or 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
| extension Collection where Indices.Iterator.Element == Index { | |
| subscript (safe index: Index) -> Generator.Element? { | |
| return indices.contains(index) ? self[index] : nil | |
| } | |
| } | |
| class ArrayLookup { | |
| private let array = ["Hello", "World"] | |
This file contains hidden or 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
| guard let settingsURL = URL.init(string: UIApplicationOpenSettingsURLString) else { return } | |
| guard UIApplication.shared.canOpenURL(settingsURL) else { return } | |
| UIApplication.shared.open(settingsURL, completionHandler: nil ) |
This file contains hidden or 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 List<T> { | |
| private let listItems: [T] | |
| init() { | |
| self.listItems = [T]() | |
| } | |
| init(listItems: [T]) { | |
| self.listItems = listItems | |
| } |
This file contains hidden or 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 ImmutableList<T> { | |
| private let listItems: [T] | |
| init() { | |
| self.listItems = [T]() | |
| } | |
| init(listItems: [T]) { | |
| self.listItems = listItems | |
| } |
This file contains hidden or 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 sensorValid = | |
| new Valid.Sensor("TemSensor 2", new List<double> { 12.4D, 77.2D, 88.1D }); | |
| var reportGenerator = | |
| new Valid.SensorReportGenerator( | |
| new FileSystem(), | |
| new PlainTextSensorReportGenerator(sensorValid) | |
| ); | |
| reportGenerator.GenerateAndStoreReport("Report_2.txt"); |
This file contains hidden or 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
| [TestFixture] | |
| public class Valid | |
| { | |
| [Test] | |
| public void TestReportGeneration() | |
| { | |
| var sensorName = "TempSensor 1"; | |
| var sensor = new Sensor(sensorName, new List<double>() { 1.0D }); | |
| var expectedContent = |
NewerOlder

