Ejemplo n.º 1
0
 public IRole Represent(IRepresentationContext <long> representationContext)
 {
     if (representationContext == null)
     {
         representationContext = new RepresentationContext <long>();
     }
     return(representationContext.GetOrAdd(Id, () => new RoleImpl(Name, Permisions)));
 }
Ejemplo n.º 2
0
 protected override IRole Represent(Role entity, IRepresentationContext <long> representationContext = null)
 {
     if (entity == null)
     {
         return(null);
     }
     return(entity.Represent(representationContext));
 }
        protected override IUserReference Represent(UserReference entity, IRepresentationContext <long> representationContext = null)
        {
            if (entity == null)
            {
                return(null);
            }

            return(entity.Represent(representationContext));
        }
Ejemplo n.º 4
0
        public IIpV6Client Represent(IRepresentationContext context = null)
        {
            if (context == null)
            {
                context = new RepresentationContext();
            }

            return(RepresentFactory.CreateIpClient(this, context));
        }
Ejemplo n.º 5
0
        public ICity Represent(IRepresentationContext context = null)
        {
            if (context == null)
            {
                context = new RepresentationContext();
            }

            return(RepresentFactory.CreateCity(this, context));
        }
Ejemplo n.º 6
0
        internal static ILocation CreateLocation(Location location, IRepresentationContext context)
        {
            if (location == null)
            {
                return(null);
            }

            return(context.GetOrAdd(location.Id, () => new LocationImpl(
                                        location.AccuracyRadius,
                                        location.Latitude,
                                        location.Longitude,
                                        location.TimeZone)));
        }
Ejemplo n.º 7
0
        private static IReadOnlyList <ICity> CreateCities(List <City> cities, IRepresentationContext context, ReprecentType type)
        {
            var result = new List <ICity>(capacity: cities.Count);

            if (cities.Count > 0)
            {
                for (var i = 0; i < cities.Count; i++)
                {
                    result.Add(CreateCity(cities[i], context, type));
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public IUserReference Represent(IRepresentationContext <long> representationContext)
        {
            if (representationContext == null)
            {
                representationContext = new RepresentationContext <long>();
            }

            var role = default(IRole);

            if (Role != null)
            {
                role = Role.Represent(representationContext);
            }

            return(representationContext.GetOrAdd(Id, () => new UserReferenceImpl(UserId, role)));
        }
Ejemplo n.º 9
0
        public IStarredTread Represent(IRepresentationContext <long> representationContext)
        {
            if (representationContext == null)
            {
                representationContext = new RepresentationContext <long>();
            }

            var userReference = default(IUserReference);

            if (UserReference != null)
            {
                userReference = UserReference.Represent(representationContext);
            }

            return(representationContext.GetOrAdd(Id, () => new StarredThreadImpl(ThreadKey, FromCode, ToCode, TimeToMailling, userReference)));
        }
Ejemplo n.º 10
0
        internal static ICity CreateCity(City city, IRepresentationContext context, ReprecentType type = ReprecentType.Full)
        {
            if (city == null)
            {
                return(null);
            }

            var counrty = default(ICounty);

            if (type == ReprecentType.Full)
            {
                if (city.County != null)
                {
                    counrty = CreateCountry(city.County, context);
                }
            }

            return(context.GetOrAdd(city.Id, () => new CityImpl(city.Name, counrty)));
        }
Ejemplo n.º 11
0
        internal static IContinent CreateContinent(Continent continent, IRepresentationContext context, ReprecentType type = ReprecentType.Full)
        {
            if (continent == null)
            {
                return(null);
            }
            var countries = new List <ICounty>();

            if (type == ReprecentType.Full)
            {
                if (continent.Counties.Count > 0)
                {
                    for (var i = 0; i < continent.Counties.Count; i++)
                    {
                        countries.Add(CreateCountry(continent.Counties[i], context, ReprecentType.Partial));
                    }
                }
            }

            return(context.GetOrAdd(continent.Id, () => new ContinentImpl(continent.Name, continent.Code, countries)));
        }
Ejemplo n.º 12
0
        internal static IIpV4Client CreateIpClient(IpV4Client client, IRepresentationContext context, ReprecentType type = ReprecentType.Full)
        {
            var city      = default(ICity);
            var country   = default(ICounty);
            var continent = default(IContinent);
            var location  = default(ILocation);

            switch (type)
            {
            case ReprecentType.Full:
                city      = CreateCity(client.City, context);
                country   = CreateCountry(client.County, context);
                continent = CreateContinent(client.Continent, context, ReprecentType.OnlyEntity);
                location  = CreateLocation(client.Location, context);
                break;

            case ReprecentType.Partial:
                location = CreateLocation(client.Location, context);
                break;
            }

            return(context.GetOrAdd(client.Id, () => new IpV4ClientImpl(client.IpV4, city, country, continent, location)));
        }
Ejemplo n.º 13
0
        internal static ICounty CreateCountry(County county, IRepresentationContext context, ReprecentType type = ReprecentType.Full)
        {
            if (county == null)
            {
                return(null);
            }

            var continent = default(IContinent);
            var cities    = new List <ICity>();

            switch (type)
            {
            case ReprecentType.Full:
                continent = CreateContinent(county.Continent, context, ReprecentType.OnlyEntity);
                CreateCities(county.Cities, context, ReprecentType.OnlyEntity);
                break;

            case ReprecentType.Partial:
                CreateCities(county.Cities, context, ReprecentType.OnlyEntity);
                break;
            }

            return(context.GetOrAdd(county.Id, () => new CountyImpl(county.Name, county.Code, continent, cities)));
        }
Ejemplo n.º 14
0
 public IUser Represent(IRepresentationContext <string> representationContext)
 {
     return(new UserImpl(Id, Email));
 }
Ejemplo n.º 15
0
 protected override IIpV4Client Represent(IpV4Client entity, IRepresentationContext representationContext = null)
 {
     return(entity.Represent(representationContext));
 }
Ejemplo n.º 16
0
 public ILocation Represent(IRepresentationContext context = null)
 {
     return(RepresentFactory.CreateLocation(this, context));
 }
Ejemplo n.º 17
0
 protected abstract TEntityImpl Represent(TEntity entity, IRepresentationContext representationContext = null);
Ejemplo n.º 18
0
 protected override ILocation Represent(Location entity, IRepresentationContext representationContext = null)
 {
     return(entity.Represent(representationContext));
 }
Ejemplo n.º 19
0
 protected override IStarredTread Represent(StarredThread entity, IRepresentationContext <long> representationContext = null)
 {
     return(entity.Represent(representationContext));
 }
Ejemplo n.º 20
0
 protected override ICity Represent(City entity, IRepresentationContext representationContext = null)
 {
     return(entity.Represent(representationContext));
 }