Exemplo n.º 1
0
        private async Task <TargetGroup> GetTargetGroup(List <TargetGroup> targetGroups, string targetGroupName)
        {
            var targetGroup = await _get.Get <TargetGroup>(b => b.Name == targetGroupName) ??
                              targetGroups.SingleOrDefault(t => t.Name == targetGroupName);

            ;
            if (targetGroup == null)
            {
                targetGroup = new TargetGroup(targetGroupName);
            }
            return(targetGroup);
        }
Exemplo n.º 2
0
 public static IEnumerable <Task <ElementReference> > ToModel <TResource>(this ReferenceCollection collection, IGet <TResource> repository) where TResource : INamedResource
 {
     return(collection.Select(async id =>
     {
         var resource = await repository.Get(id);
         return new ElementReference(resource.Name);
     }));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Calculate total square of all figures
 /// </summary>
 /// <param name="figures">List of figures</param>
 /// <returns>total square</returns>
 static double CalculateSquare(IGet<Figure> figures)
 {
     double ret = 0.0;
     for (int index = 0; index < figures.Length; index++)
     {
         ret += figures.Get(index).GetSquare();
     }
     return ret;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the property value from the specified target.
 /// </summary>
 /// <param name="target">Target object.</param>
 /// <returns>Property value.</returns>
 public object Get(object target)
 {
     if (_canRead)
     {
         return(_emittedGet.Get(target));
     }
     throw new NotSupportedException(
               string.Format("Property \"{0}\" on type "
                             + "{1} doesn't have a get method.", _propertyName, _targetType));
 }
Exemplo n.º 5
0
        public void CoVariantIntefaces()
        {
            var employeGetter = new GetEmployee();
            var employees     = employeGetter.Get();

            Assert.AreEqual(1, employees.Count());

            IGet <Person> peopleGetter = employeGetter;
            var           people       = peopleGetter.Get();

            Assert.AreEqual(1, people.Count());
        }
 private static string TryGetReferenceName <TResource>(IGet <TResource> repository, string id) where TResource : INamedResource
 {
     try
     {
         return(repository.Get(id).Name);
     }
     catch (OctopusResourceNotFoundException ex)
     {
         Logger.Warn(ex.Message);
         return(null);
     }
 }
Exemplo n.º 7
0
        public async Task <string> TokenAsync()
        {
            var user = _users.Get(u => u.Email == _user.Email).First();

            if (user?.Password != _user.Password)
            {
                return(string.Empty);
            }

            var claims = new Claims(user.Name, "user", user.Name, user.Email, user.Scopes);

            return(await Task.FromResult(_factory.Create(_serialzer.Serialize(claims), _secret).Hash()));
        }
Exemplo n.º 8
0
 public async Task <T> Read()
 {
     try
     {
         return(await _Get.Get());
     }
     catch (FormatException ex)
     {
         throw new BusinessException("Error en la capa Bussines", ex);
     }
     catch (RepositoryException ex)
     {
         throw new BusinessException("Error de la capa Dao", ex);
     }
 }
Exemplo n.º 9
0
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            if (parameters.Count > 0)
            {
                var equipment = _equipmentGetService.Get(parameters.GetValue <int>("id"));
                if (equipment == null)
                {
                    await App.Current.MainPage.DisplayAlert("Info", "Equipment not found", "Ok");

                    await _navigationService.GoBackAsync();
                }
                else
                {
                    Title     = equipment.Name;
                    Equipment = equipment;
                    RaisePropertyChanged(nameof(Equipment));
                }
            }
        }
Exemplo n.º 10
0
        public async Task <T> Get <T>(Expression <Func <T, bool> > predicate) where T : class
        {
            var cachingKey = typeof(T).Name;

            var cachedEntites = await _distributedCache.GetAsync <List <T> >(cachingKey) ?? new List <T>();

            var cachedEntity = cachedEntites.AsQueryable().SingleOrDefault(predicate);

            if (cachedEntity == null)
            {
                cachedEntity = await _get.Get <T>(predicate);

                if (cachedEntity != null)
                {
                    cachedEntites.Add(cachedEntity);
                    await _distributedCache.SetAsync <List <T> >(cachingKey, cachedEntites, _distributedCacheEntryOptions);
                }
            }
            return(cachedEntity);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the value stored in the field for the specified target.
 /// </summary>
 /// <param name="target">Object to retrieve the field from.</param>
 /// <returns>The value.</returns>
 public object Get(object target)
 {
     return(_emittedGet.Get(target));
 }
Exemplo n.º 12
0
 public static IEnumerable <ElementReference> ToModel <TResource>(this ReferenceCollection collection, IGet <TResource> repository) where TResource : INamedResource
 {
     return(collection.Select(id => new ElementReference(repository.Get(id).Name)));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Printing types and squares of figures
 /// </summary>
 /// <param name="figures">List of figures</param>
 static void Print(IGet<Figure> figures)
 {
     for (int index = 0; index < figures.Length; index++)
     {
         Figure f = figures.Get(index);
         Console.WriteLine("Name: {0}, square: {1}", f.GetType().Name, f.GetSquare());
     }
 }