Location/LocationEntityService.cs

(开头部分) 1KB

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

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

using ComLib.Entities;


namespace ComLib.LocationSupport
{
    /// <summary>
    /// Location entity class that sub-classes EntityServiceT and does some additional configuration on the city/state/country before saving
    /// to underlying repository.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class LocationEntityService<T> : EntityService<T> where T : LocationBase, IEntity
    {
        /// <summary>
        /// Initialize
        /// </summary>
        public LocationEntityService()
        {
        }


        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="repo"></param>
        public LocationEntityService(IRepository<T> repo)
        {
            _repository = repo;
        }


        /// <summary>
        /// Create the entity.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="executor"></param>
        protected override void InternalCreate(IActionContext ctx, Action<IActionContext> executor)
        {
            IEntity entity = ctx.Item as IEntity;
            ConfigureLocationEntity(entity);
            base.InternalCreate(ctx, executor);
        }


        private void ConfigureLocationEntity(IEntity entity)
        {
            LocationBase location = entity as LocationBase;
            if (entity is City )
            {
                LocationHelper.ApplyCountryState(entity as City);
            }
            else if (entity is State)
            {
                LocationHelper.ApplyCountry(entity as State);
            }
            else if (entity is Country)
后面还有 6 行代码,解锁后查看完整代码

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

AI 解读

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

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