Ejemplo n.º 1
0
        public WidgetMCG()
        {
            InitializeComponent();
            var none = new KeyValuePair <string, byte>[] { new KeyValuePair <string, byte> (arcStrings.ArcIgnoreEncryption, 0) };

            Title.ItemsSource = none.Concat(McgFormat.KnownKeys.OrderBy(x => x.Key));
        }
Ejemplo n.º 2
0
 public WidgetGAL()
 {
     InitializeComponent();
     var first_item = new KeyValuePair<string, string> (arcStrings.ArcIgnoreEncryption, "");
     var items = new KeyValuePair<string, string>[] { first_item };
     this.Title.ItemsSource = items.Concat (GalFormat.KnownKeys.OrderBy (x => x.Key));
 }
Ejemplo n.º 3
0
        public WidgetGAL(IDictionary <string, string> known_keys)
        {
            InitializeComponent();
            var first_item = new KeyValuePair <string, string> (arcStrings.ArcIgnoreEncryption, "");
            var items      = new KeyValuePair <string, string>[] { first_item };

            this.Title.ItemsSource = items.Concat(known_keys.OrderBy(x => x.Key));
        }
        private static async Task <IEnumerable <KeyValuePair <String, JsonProperty> > > AdditionalProperties(JsonSchema4 schema, Dictionary <String, JsonSchema4> others)
        {
            IEnumerable <KeyValuePair <String, JsonProperty> > props = new KeyValuePair <String, JsonProperty> [0];

            foreach (var relationship in schema.GetRelationshipSettings())
            {
                if (relationship.IsLeftModel)
                {
                    switch (relationship.Kind)
                    {
                    case RelationKind.ManyToMany:
                    case RelationKind.ManyToOne:
                        props = props.Concat(await WriteManySide(schema, others[relationship.OtherModelName], relationship));
                        break;

                    case RelationKind.OneToOne:
                    case RelationKind.OneToMany:
                        props = props.Concat(await WriteOneSide(schema, others[relationship.OtherModelName], relationship));
                        break;
                    }
                }
                else
                {
                    switch (relationship.Kind)
                    {
                    case RelationKind.ManyToMany:
                    case RelationKind.OneToMany:
                        props = props.Concat(await WriteManySide(schema, others[relationship.OtherModelName], relationship));
                        break;

                    case RelationKind.OneToOne:
                    case RelationKind.ManyToOne:
                        props = props.Concat(await WriteOneSide(schema, others[relationship.OtherModelName], relationship));
                        break;
                    }
                }
            }
            return(props);
        }
Ejemplo n.º 5
0
        private IReadOnlyList <KeyValuePair <string, Size> > getResolutions()
        {
            var resolutions = new KeyValuePair <string, Size>("Default", new Size(9999, 9999)).Yield();

            if (game.Window != null)
            {
                resolutions = resolutions.Concat(game.Window.AvailableResolutions
                                                 .Where(r => r.Width >= 800 && r.Height >= 600)
                                                 .OrderByDescending(r => r.Width)
                                                 .ThenByDescending(r => r.Height)
                                                 .Select(res => new KeyValuePair <string, Size>($"{res.Width}x{res.Height}", new Size(res.Width, res.Height)))
                                                 .Distinct());
            }
            return(resolutions.ToList());
        }
Ejemplo n.º 6
0
        public static IEnumerable <KeyValuePair <DateTime, TimeSpan> > GetOpenSlots(DateTime orderReady, IEnumerable <IWorkingHours> openHours, IEnumerable <PublicHoliday> holidays, IEnumerable <Vacation> vacations)
        {
            IEnumerable <DateTime> days = Enumerable.Range(0, 365).Select(i => orderReady.Date.AddDays(i));


            /*List<DateTime> daysCountingVacation = new List<DateTime>();
             * foreach(var day in days)
             * {
             * if (vacations.Count(x => x.StartDate.Date <= day && x.EndDate >= day) == 0)
             * daysCountingVacation.Add(day);
             * }*/

            IEnumerable <DateTime> daysCountingVacation = days.Where(day => vacations.Count(x => x.StartDate.Date <= day && x.EndDate >= day) == 0);

            //List<KeyValuePair<DateTime, TimeSpan>> preliminarResults = new List<KeyValuePair<DateTime, TimeSpan>>();

            var preliminarResultsGroups = daysCountingVacation.Select(day =>
            {
                var openHoursSlotsInHolidays = holidays.Where(x => x.Date.Date == day.Date);
                if (openHoursSlotsInHolidays.Count() > 0)
                {
                    return(openHoursSlotsInHolidays.Where(x => x.OpenHours != null)
                           .Select(x => new KeyValuePair <DateTime, TimeSpan>(day.Add(x.OpenHours.StartingAt), x.OpenHours.Duration)));
                }
                else
                {
                    var ordinaryHours = openHours.Where(x => x.DayId == (int)day.DayOfWeek).Select(x => new KeyValuePair <DateTime, TimeSpan>(day.Add(x.StartingAt), x.Duration));
                    return(ordinaryHours);
                }
            }).ToArray();

            IEnumerable <KeyValuePair <DateTime, TimeSpan> > preliminarResults = new KeyValuePair <DateTime, TimeSpan> [0];

            for (int i = 0; i < preliminarResultsGroups.Count(); i++)
            {
                preliminarResults = preliminarResults.Concat(preliminarResultsGroups[i]);
            }


            foreach (var day in daysCountingVacation)
            {
                var openHoursSlotsInHolidays = holidays.Where(x => x.Date.Date == day.Date);
                if (openHoursSlotsInHolidays.Count() > 0)
                {
                    var holidayHours = openHoursSlotsInHolidays.Where(x => x.OpenHours != null)
                                       .Select(x => new KeyValuePair <DateTime, TimeSpan>(day.Add(x.OpenHours.StartingAt), x.OpenHours.Duration));
                    preliminarResults = preliminarResults.Concat(holidayHours);
                }
                else
                {
                    var ordinaryHours = openHours.Where(x => x.DayId == (int)day.DayOfWeek)
                                        .Select(x => new KeyValuePair <DateTime, TimeSpan>(day.Add(x.StartingAt), x.Duration));
                    preliminarResults = preliminarResults.Concat(ordinaryHours);
                }
            }

            var onlyAfterOrIncludingOrderReady = preliminarResults.Where(x => x.Key.Add(x.Value) > orderReady);

            IEnumerable <KeyValuePair <DateTime, TimeSpan> > results = new KeyValuePair <DateTime, TimeSpan> [0];

            foreach (var item in onlyAfterOrIncludingOrderReady)
            {
                if (item.Key <= orderReady)
                {
                    TimeSpan offset = orderReady.Subtract(item.Key);
                    results = results.Append(new KeyValuePair <DateTime, TimeSpan>(orderReady, item.Value.Subtract(offset)));
                }
                else
                {
                    results = results.Append(item);
                }
            }

            return(results);
        }
Ejemplo n.º 7
0
 public WidgetMCG()
 {
     InitializeComponent();
     var none = new KeyValuePair<string, byte>[] { new KeyValuePair<string, byte> (arcStrings.ArcIgnoreEncryption, 0) };
     Title.ItemsSource = none.Concat (McgFormat.KnownKeys.OrderBy (x => x.Key));
 }
        protected void _GetSearchResults(CMSPageRequest pageRequest)
        {
            int  pagesize, page;
            bool all;

            Search.SiteSearch siteSearch;
            SearchInstruction instructions = getSearchInstructions(pageRequest,
                                                                   out page,
                                                                   out pagesize,
                                                                   out all,
                                                                   out siteSearch);

            //override pagesize from Schema
            var pgSize = pageRequest.GetElementValue("ResultsPageSize");

            if (pgSize != null)
            {
                pagesize = pgSize.ToInt() ?? 10;
            }

            Search.Search search = new Search.Search(Request);

            int count = 0;

            if (search != null)
            {
                //use the SearchInstruction based overload method to achieve max flexibility (non-paginated results)
                var pageResults = search.QueryFinal(siteSearch, out count, instructions, 200, true);

                //find matches for both member records and pages
                var    M           = new MembersWrapper();
                string termsString = pageRequest.QueryString["terms"] ?? "";
                //var memDic = M.Search(termsString);
                var memDic       = new List <KeyValuePair <string, Member> >();
                var pgCollection = pageResults
                                   .Select(r => new KeyValuePair <float, SearchResultItem>(r.Score, r));

                //apply sourceFilter and merge the two dictionaries
                string sourceFilter = pageRequest.QueryString["sourceFilter"] ?? "";
                IEnumerable <KeyValuePair <float, object> > mergedCollection = new KeyValuePair <float, object> [0];
                if (sourceFilter == "" || sourceFilter != "members")
                {
                    mergedCollection = pgCollection
                                       .Where(x =>
                    {
                        bool externalItem = (x.Value.Type == "ingeniux.search.htmlsitesource");
                        return(sourceFilter == "" ||
                               (sourceFilter == "local" && !externalItem) ||
                               (sourceFilter == "bni.com" && externalItem));
                    })
                                       .Select(x =>
                                               new KeyValuePair <float, object>(x.Key, x.Value));
                }

                if (sourceFilter == "" || sourceFilter == "members")
                {
                    mergedCollection = mergedCollection
                                       .Concat(memDic
                                               .Select(x => new KeyValuePair <float, object>(float.Parse(x.Key.SubstringBefore("_")), x.Value)));
                }

                //sort results
                var returnResults = mergedCollection.OrderByDescending(x => x.Key).Select(x => x.Value).ToList();

                //apply pagination
                ViewBag.totalResults = returnResults.Count;
                ViewBag.pageSize     = pagesize;
                pageRequest.Tag      = returnResults.Skip((page - 1) * pagesize).Take(pagesize).ToList();
                //pageRequest.Tag = mergedDic;  //no pagination
            }
        }