public void Interract(IMobile from, IOwnable to) { if (to.Disable) { return; } else { to.SetOwnerID(from.GetOwnerID()); } }
public void EnsureOwnership(IOwnable ownable) { if (ownable == null) { throw new ArgumentNullException(nameof(ownable)); } if (!string.Equals(ownable.CreatedBy, GetCurrentIdentityName(), StringComparison.InvariantCultureIgnoreCase)) { throw new SecurityException(); } }
/// <summary> /// Gets the hull name of a vehicle/design, or the type name if it's not a vehicle/design (e.g. if it's a planet). /// </summary> /// <param name="obj"></param> private static string GetHullName(IOwnable obj) { if (obj is IVehicle) { return(((IVehicle)obj).Design.Hull.Name); } if (obj is IDesign) { return(((IDesign)obj).Hull.Name); } return(obj.GetType().Name); }
/// <summary> /// Gets the icon of a vehicle/design, or a generic icon if it's not a vehicle/design (e.g. if it's a planet). /// </summary> /// <param name="obj"></param> private static Image GetHullIcon(IOwnable obj) { if (obj is IVehicle) { return(((IVehicle)obj).Design.Hull.GetIcon(obj.Owner.ShipsetPath).Resize(32)); } if (obj is IDesign) { return(((IDesign)obj).Hull.GetIcon(obj.Owner.ShipsetPath)); } return(Pictures.GetGenericImage(obj.GetType())); }
/// <summary> /// Gets the hull size of a vehicle/design, or int.MaxValue if it's not a vehicle/design (e.g. if it's a planet). /// </summary> /// <param name="obj"></param> private static int GetHullSize(IOwnable obj) { if (obj is IVehicle v) { return(v.Design.Hull.Size); } if (obj is IDesign d) { return(d.Hull.Size); } if (obj is Seeker s) { return(s.MaxHitpoints); } if (obj is Planet p) { return(p.Size.MaxCargo); } return(42); }
public bool Equals(IEnumerable <T> other) { if (other.Count() == this.Count()) { for (int i = 0; i < this.Count(); i++) { IOwnable _item = this[i]; if (_item.SourceIP != other.ToList()[i].SourceIP) { return(false); } } } else { return(false); } return(true); }
HandleRequirementAsync( AuthorizationHandlerContext context, ResourceAuthorizationRequirement requirement, IOwnable <string> resource) { if (context.User == null || resource == null) { return(Task.CompletedTask); } if (context.User.IsInRole(GlobalConstants.AdministratorRoleName)) { context.Succeed(requirement); return(Task.CompletedTask); } if (resource.AuthorId == this.userManager.GetUserId(context.User)) { context.Succeed(requirement); } return(Task.CompletedTask); }
public static bool Owns(this IUser _this, IOwnable ownable) { return(ownable.BelongsTo(_this)); }
public static void Assign(IOwnable ownable, IMovidAppContext appContext) { ownable.AccountId = appContext.Account.Id; ownable.ClinicId = appContext.Clinic.Id; ownable.UserId = appContext.LoggedInUser.Id; }
public static bool Owns(IOwnable ownable, IMovidAppContext appContext) { return(!(ownable.AccountId != appContext.LoggedInUser.AccountId) || appContext.ApplicationAdministrator); }
public void EnsureOwnership(IOwnable ownable) { }
public BuildingPurchasedEvent(IOwnable building, Player purchasingPlayer) { this.Building = building; this.PurchasingPlayer = purchasingPlayer; this.DateTimeEventOccurred = DateTime.UtcNow; }