Exemple #1
0
 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();
            }
        }
Exemple #3
0
 /// <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);
 }
Exemple #4
0
 /// <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()));
 }
Exemple #5
0
 /// <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);
 }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
 public static bool Owns(this IUser _this, IOwnable ownable)
 {
     return(ownable.BelongsTo(_this));
 }
Exemple #9
0
 public static void Assign(IOwnable ownable, IMovidAppContext appContext)
 {
     ownable.AccountId = appContext.Account.Id;
     ownable.ClinicId  = appContext.Clinic.Id;
     ownable.UserId    = appContext.LoggedInUser.Id;
 }
Exemple #10
0
 public static bool Owns(IOwnable ownable, IMovidAppContext appContext)
 {
     return(!(ownable.AccountId != appContext.LoggedInUser.AccountId) || appContext.ApplicationAdministrator);
 }
Exemple #11
0
 public void EnsureOwnership(IOwnable ownable)
 {
 }
Exemple #12
0
 public BuildingPurchasedEvent(IOwnable building, Player purchasingPlayer)
 {
     this.Building              = building;
     this.PurchasingPlayer      = purchasingPlayer;
     this.DateTimeEventOccurred = DateTime.UtcNow;
 }