示例#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);
        }
示例#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);
     }));
 }
示例#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;
 }
示例#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));
 }
示例#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);
     }
 }
示例#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()));
        }
示例#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);
     }
 }
示例#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));
                }
            }
        }
示例#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);
        }
示例#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));
 }
示例#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)));
 }
示例#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());
     }
 }