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
async Task First() | |
{ | |
await Second(); | |
} | |
async Task Second() | |
{ | |
DoExpensiveCalculation1(); | |
await Task.Run(() => | |
{ |
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
void main() { | |
final accessor = Accessor(); | |
final property = ValueProperty<int>(accessor, 'foo', 5); | |
print(property.getValue()); | |
} | |
class Accessor { | |
final Map<String, Object?> _values = <String, Object?>{}; | |
T getValue<T>(String propertyName) => _values[propertyName] as T; |
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
IQueryable<Powerup> PowerupsAroundLocation(Vector3 location, float radius) | |
{ | |
// Note that this query returns a cube around the location, not a sphere. | |
var powerups = realm.All<Powerup>().Filter( | |
"Position.x > $0 AND Position.x < $1 AND Position.y > $2 AND Position.y < $3 AND Position.z > $4 AND Position.z < $5", | |
location.x - radius, location.x + radius, | |
location.y - radius, location.y + radius, | |
location.z - radius, location.z + radius); | |
} |
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 Vector3Model : EmbeddedObject | |
{ | |
// Casing of the properties here is unusual for C#, | |
// but consistent with the Unity casing. | |
private float x { get; set; } | |
private float y { get; set; } | |
private float z { get; set; } | |
public Vector3Model(Vector3 vector) | |
{ |
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
enum TransactionState | |
{ | |
Pending, | |
Settled, | |
Error | |
} | |
class Transaction : RealmObject | |
{ | |
private string _State { get; set; } |
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
// _Name is mapped to 'Name' which is what we use here | |
var peters = realm.All<Person>().Filter("Name == 'Peter'"); |
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 Person : RealmObject | |
{ | |
protected override void OnPropertyChanged(string propertyName) | |
{ | |
base.OnPropertyChanged(propertyName); | |
if (propertyName == nameof(_Name)) | |
{ | |
RaisePropertyChanged(nameof(Name)); | |
} |
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 Person : RealmObject | |
{ | |
[MapTo("Name")] | |
private string _Name { get; set; } | |
public string Name | |
{ | |
get => _Name; | |
set | |
{ |
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 Transaction : RealmObject | |
{ | |
public Guid Id { get; private set; } = Guid.NewGuid(); | |
} |
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 Person : RealmObject | |
{ | |
public string Name { get; private set; } | |
public Person(string name) | |
{ | |
// ... | |
} | |
} |
NewerOlder