Пример #1
0
        public IReadOnlyList <string> Index(string q = null)
        {
            IEnumerable <IContainer> containers = containerService.GetContainers();

            if (q != null)
            {
                var desiredProps = JsonConvert.DeserializeObject <Dictionary <string, string> >(q);

                containers = containers.Where((x) =>
                {
                    try
                    {
                        var properties = x.GetProperties();
                        return(desiredProps.All(p =>
                        {
                            string propValue;
                            var exists = properties.TryGetValue(p.Key, out propValue);
                            return exists && propValue == p.Value;
                        }));
                    }
                    catch (InvalidOperationException)
                    {
                        return(false);
                    }
                    catch (DirectoryNotFoundException)
                    {
                        return(true);
                    }
                });
            }
            return(containers.Select(x => x.Handle).ToList());
        }
Пример #2
0
        public void Describe(dynamic context)
        {
            Func <IShapeFactory, object> form =
                shape => {
                var f = New.Form(
                    Id: "List",
                    _Lists: New.SelectList(
                        Id: "listId", Name: "ListId",
                        Title: T("List"),
                        Description: T("Select a list."),
                        Multiple: false));

                foreach (var list in _containerService.GetContainers(VersionOptions.Latest).OrderBy(GetListName))
                {
                    f._Lists.Add(new SelectListItem {
                        Value = list.Id.ToString(CultureInfo.InvariantCulture), Text = GetListName(list)
                    });
                }

                return(f);
            };

            context.Form("ListFilter", form);
        }