EntityModel/Extensions/EntityExtensions.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ComLib.Entities;
using ComLib.Authentication;
using ComLib.Feeds;

namespace ComLib.Entities.Extensions
{
    /// <summary>
    /// Extension methods for an entity.
    /// </summary>
    public static class EntityExtensions
    {
        /// <summary>
        /// Whether or not the user supplied is the owner.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool IsOwner(this IEntity entity)
        {
            if (entity == null)
                return false;
            return Auth.IsUser(entity.CreateUser);
        }


        /// <summary>
        /// Whether or not the user supplied is the owner.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool IsOwner(this IEntity entity, string user)
        {
            if (entity == null)
                return false;
            return string.Compare(entity.CreateUser, user, true) == 0;
        }


        /// <summary>
        /// Whether or not the current user is the entity owner or admin.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool IsOwnerOrAdmin(this IEntity entity)
        {
            if (entity == null)
                return false;

            return Auth.IsUserOrAdmin(entity.CreateUser);
        }


        /// <summary>
        /// Whether or not the current user is the entity owner or admin.
        /// </summary>
后面还有 155 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。