public readonly struct Shape
{
public void Render (Graphics graphics)
{
// Do complex manipulation to draw the shape using the `graphics` object.
graphics.DrawLine(Pens.Red, this.Point1, this.Point2);
graphics.DrawLine(Pens.Red, this.Point2, this.Point3);
...
}
}
< /code>
und der aufrufende Code aus einer WinForms -App: < /p>
private void PictureBox_Paint (object? sender, PaintEventArgs e)
{
var shape = new Shape(...);
shape.Render(e.Graphics);
}
Die Form kümmert sich um ihre eigene Renderung und hält den Anrufcode einfach. Ein Verweis auf das Objekt von Grafiken in der Form ist jedoch eine rote Flag, da diese App in Zukunft auf mehrere Plattformen abzielt. Dies, um die Klassen locker gekoppelt zu halten?
Betrachten Sie die folgende Klasse: < /p> [code]public readonly struct Shape { public void Render (Graphics graphics) { // Do complex manipulation to draw the shape using the `graphics` object. graphics.DrawLine(Pens.Red, this.Point1, this.Point2); graphics.DrawLine(Pens.Red, this.Point2, this.Point3); ... } } < /code> und der aufrufende Code aus einer WinForms -App: < /p> private void PictureBox_Paint (object? sender, PaintEventArgs e) { var shape = new Shape(...);
shape.Render(e.Graphics); } [/code] Die Form kümmert sich um ihre eigene Renderung und hält den Anrufcode einfach. Ein Verweis auf das Objekt von Grafiken in der Form ist jedoch eine rote Flag, da diese App in Zukunft auf mehrere Plattformen abzielt. Dies, um die Klassen locker gekoppelt zu halten?
Ich versuche, ein neues React Native-Projekt auf meinem Mac (macOS 12.7.6, Xcode 14.2) mit dem folgenden Befehl zu erstellen:
npx @react-native-community/cli init Projektname
Allerdings Während des...
Kann :not(:hover) im folgenden CSS umgestaltet werden, um Wiederholungen zu vermeiden?
a.label {
& :not(:hover),
& :not(:hover),
/* ... */
& :not(:hover) {
color: #f50;
}
}
Ist es möglich, eine Methode, die iAsyncenumerable ? public async IAsyncEnumerable GetFoosFromFile(string filename)
{
using (FileStream fs = File.OpenRead(filename))
{
var items =...