public void Initialise(T obj) { entity = obj; doInitialise(); foreach (var c in GetComponents <IInitialisable <T> >()) { if (!(ReferenceEquals(c, this) || c is EntityControllerBehaviour)) { c.Initialise(entity); } } foreach (var c in GetComponents <ILifecycle>()) { c.Initialise(); } HasSpawned = true; OnInitialised.Invoke(); }
public Member(string memberUsername, string key) { // TODO: Make asyncronous string uri = String.Format("https://api.trello.com/1/members/{0}?key={1}", memberUsername, key); string data = Trello.ExtensionWideClient.GetStringAsync(uri).Result; try { BsonDocument memberInfo = BsonDocument.Parse(data); Id = memberInfo.GetValue("id").AsString; AvatarHash = memberInfo.GetValue("avatarHash") == null? null : memberInfo.GetValue("avatarHash").AsString; AvatarUrl = memberInfo.GetValue("avatarUrl") == null ? null : memberInfo.GetValue("avatarUrl").AsString; Initials = memberInfo.GetValue("initials").AsString; FullName = memberInfo.GetValue("fullName").AsString; Username = memberInfo.GetValue("username").AsString; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } OnInitialised?.Invoke(this, EventArgs.Empty); }