コード例 #1
0
        private System.String GenerateListURL(
            System.Collections.Generic.Dictionary <System.String, System.String> Parameters = null,
            System.Collections.Generic.List <System.String> Fields = null,
            System.Collections.Generic.List <SoftmakeAll.SDK.Fluent.ResourceActions.ListFilter> Filter = null, // NOT YET IMPLEMENTED
            System.Collections.Generic.List <System.String> Group = null,
            System.Collections.Generic.Dictionary <System.String, System.Boolean> Sort = null,
            System.Int32 Skip = 0, System.Int32 Take = 20
            )
        {
            System.String URL = $"{base.Route}?skip={Skip}&take={Take}";

            if ((Parameters != null) && (Parameters.Any()))
            {
                URL = $"{URL}&{System.String.Join('&', Parameters.Select(p => $"{p.Key}={p.Value}"))}";
            }
            if ((Fields != null) && (Fields.Any()))
            {
                URL = $"{URL}&fields={System.String.Join(',', Fields)}";
            }
            if ((Group != null) && (Group.Any()))
            {
                URL = $"{URL}&group={System.String.Join(',', Group)}";
            }
            if ((Sort != null) && (Sort.Any()))
            {
                URL = $"{URL}&sort={System.String.Join('&', Sort.Select(p => $"{(p.Value ? '-' : '+')}{p.Key}"))}";
            }

            return(URL);
        }
コード例 #2
0
 private bool isMatchingFilePath(string filePath, System.Collections.Generic.Dictionary <string, System.Text.RegularExpressions.Regex> extensionAndFileNameMap)
 {
     if (extensionAndFileNameMap == null || extensionAndFileNameMap.Count == 0)
     {
         return(false);
     }
     return(extensionAndFileNameMap.Any(extension => filePath.EndsWith(extension.Key, true, System.Globalization.CultureInfo.InvariantCulture) && extension.Value.IsMatch(System.IO.Path.GetFileNameWithoutExtension(filePath))));
 }
コード例 #3
0
        public bool EstaAutenticado(AuthorizationFilterContext context, string username, string password, string data)
        {
            //BUSCAR INFORMAÇÕES EM MEMÓRIA CACHE
            var listaDeUsuarios = new System.Collections.Generic.Dictionary <string, string> {
                { "uniaraxa", "uni@r@x@" },
                { "bembrasil", "b3mbr4s1l" },
                { "eletrozema", "3l3tr0z3m4" },
                { "cbmm", "semsenha" }
            };

            return(listaDeUsuarios.Any(f => f.Key == username && f.Value == password) && Convert.ToDateTime(data).AddMinutes(5) < DateTime.Now);
        }
コード例 #4
0
        public void PutAllHeader(System.Collections.Generic.Dictionary <string, string> headers)
        {
            if (headers == null || !headers.Any())
            {
                return;
            }

            foreach (var item in headers)
            {
                this.Headers[item.Key] = item.Value;
            }
        }
コード例 #5
0
            public void Derive(DynamicChangeSet changeSet)
            {
                System.Collections.Generic.Dictionary <DynamicObject, object> fullNames = changeSet.ChangedRoles <Person>("FullName");

                if (fullNames?.Any() == true)
                {
                    System.Collections.Generic.IEnumerable <DynamicObject> people = fullNames.Select(v => v.Key).Distinct();

                    foreach (dynamic person in people)
                    {
                        person.Greeting = $"Hello {person.FullName}!";
                    }
                }
            }
コード例 #6
0
            public void Derive(DynamicChangeSet changeSet)
            {
                this.derivation.Derive(changeSet);

                System.Collections.Generic.Dictionary <DynamicObject, object> firstNames = changeSet.ChangedRoles <Person>("FirstName");
                System.Collections.Generic.Dictionary <DynamicObject, object> lastNames  = changeSet.ChangedRoles <Person>("LastName");

                if (firstNames?.Any() == true || lastNames?.Any() == true)
                {
                    System.Collections.Generic.IEnumerable <DynamicObject> people = firstNames.Union(lastNames).Select(v => v.Key).Distinct();

                    foreach (dynamic person in people)
                    {
                        person.FullName = $"{person.FullName} Chained";
                    }
                }
            }
コード例 #7
0
            public void Derive(DynamicChangeSet changeSet)
            {
                System.Collections.Generic.Dictionary <DynamicObject, object> firstNames = changeSet.ChangedRoles <Person>("FirstName");
                System.Collections.Generic.Dictionary <DynamicObject, object> lastNames  = changeSet.ChangedRoles <Person>("LastName");

                if (firstNames?.Any() == true || lastNames?.Any() == true)
                {
                    System.Collections.Generic.IEnumerable <DynamicObject> people = firstNames.Union(lastNames).Select(v => v.Key).Distinct();

                    foreach (dynamic person in people)
                    {
                        // Dummy updates ...
                        person.FirstName = person.FirstName;
                        person.LastName  = person.LastName;

                        person.DerivedAt = DateTime.Now;

                        person.FullName = $"{person.FirstName} {person.LastName}";
                    }
                }
            }
コード例 #8
0
        private static void DrawCompletionText(string completionCount, SolidColorBrush PrimaryColor, SolidColorBrush SecondaryColor, int y)
        {
            Typeface typeface = new Typeface(FProp.Default.FLanguage.Equals("Japanese") ? TextsUtility.JPBurbank : TextsUtility.Burbank, FontStyles.Normal, FontWeights.Black, FontStretches.Normal);

            #region DESIGN
            IconCreator.ICDrawingContext.DrawRectangle(ChallengesUtility.DarkBrush(PrimaryColor, 0.3f), null, new Rect(0, y, 1024, 90));
            IconCreator.ICDrawingContext.DrawRectangle(PrimaryColor, null, new Rect(25, y, 1024 - 50, 70));

            Point         dStart    = new Point(32, y + 5);
            LineSegment[] dSegments = new[]
            {
                new LineSegment(new Point(29, y + 67), true),
                new LineSegment(new Point(1024 - 160, y + 62), true),
                new LineSegment(new Point(1024 - 150, y + 4), true)
            };
            PathFigure   dFigure = new PathFigure(dStart, dSegments, true);
            PathGeometry dGeo    = new PathGeometry(new[] { dFigure });
            IconCreator.ICDrawingContext.DrawGeometry(ChallengesUtility.LightBrush(PrimaryColor, 0.04f), null, dGeo);

            dStart    = new Point(39, y + 35);
            dSegments = new[]
            {
                new LineSegment(new Point(45, y + 32), true),
                new LineSegment(new Point(48, y + 37), true),
                new LineSegment(new Point(42, y + 40), true)
            };
            dFigure = new PathFigure(dStart, dSegments, true);
            dGeo    = new PathGeometry(new[] { dFigure });
            IconCreator.ICDrawingContext.DrawGeometry(SecondaryColor, null, dGeo);
            #endregion

            string all = "Complete ALL CHALLENGES to earn the reward item";
            string any = "Complete ANY " + completionCount + " CHALLENGES to earn the reward item";
            if (!string.Equals(FProp.Default.FLanguage, "English"))
            {
                all = AssetTranslations.SearchTranslation("AthenaChallengeDetailsEntry", "CompletionRewardFormat_All", "Complete ALL CHALLENGES to earn the reward item");
                any = AssetTranslations.SearchTranslation("AthenaChallengeDetailsEntry", "CompletionRewardFormat", "Complete ANY " + completionCount + " CHALLENGES to earn the reward item");

                #region FIX TRANSLATIONS
                //because HtmlAgilityPack fail to detect the end of the tag when it's </>
                if (all.Contains("</>"))
                {
                    all = all.Replace("</>", "</text>");
                }
                if (any.Contains("</>"))
                {
                    any = any.Replace("</>", "</text>");
                }

                // Polish
                if (all.Contains("|plural"))
                {
                    int    indexStart   = all.IndexOf("|plural(") + 8;
                    int    indexEnd     = all.IndexOf(")", indexStart);
                    string extractDatas = all.Substring(indexStart, indexEnd - indexStart);

                    // one = 1, few >= 2 and <= 4, many > 4, other = ??
                    System.Collections.Generic.Dictionary <string, string> various = extractDatas.Split(',').Select(x => x.Split('=')).Where(x => x.Length == 2).ToDictionary(x => x[0], x => x[1]);
                    if (various != null && various.Any())
                    {
                        int    compCount   = int.Parse(completionCount);
                        string variousText = various.ContainsKey("other") ? various["other"] : "";
                        if (compCount == 1 && various.ContainsKey("one"))
                        {
                            variousText = various["one"];
                        }
                        else if (compCount >= 2 && compCount <= 4 && various.ContainsKey("few"))
                        {
                            variousText = various["few"];
                        }
                        else if (compCount > 4 && various.ContainsKey("many"))
                        {
                            variousText = various["many"];
                        }

                        all = all.Replace($"|plural({extractDatas})", "").Replace("{0} {0}", "{0} " + variousText);
                    }
                }

                // Polish
                if (any.Contains("|plural"))
                {
                    int    indexStart   = any.IndexOf("|plural(") + 8;
                    int    indexEnd     = any.IndexOf(")", indexStart);
                    string extractDatas = any.Substring(indexStart, indexEnd - indexStart);

                    // one = 1, few >= 2 and <= 4, many > 4, other = ??
                    System.Collections.Generic.Dictionary <string, string> various = extractDatas.Split(',').Select(x => x.Split('=')).Where(x => x.Length == 2).ToDictionary(x => x[0], x => x[1]);
                    if (various != null && various.Any())
                    {
                        int    compCount   = int.Parse(completionCount);
                        string variousText = various.ContainsKey("other") ? various["other"] : "";
                        if (compCount == 1 && various.ContainsKey("one"))
                        {
                            variousText = various["one"];
                        }
                        else if (compCount >= 2 && compCount <= 4 && various.ContainsKey("few"))
                        {
                            variousText = various["few"];
                        }
                        else if (compCount > 4 && various.ContainsKey("many"))
                        {
                            variousText = various["many"];
                        }

                        any = any.Replace($"|plural({extractDatas})", "").Replace("{0} {0}", "{0} " + variousText);
                    }
                }

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(all);
                if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space
                {
                    if (all.Contains("</text>"))
                    {
                        all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        all = all.Replace(" {0}", string.Empty);
                    }
                    else
                    {
                        all = doc.DocumentNode.InnerText.Replace(" {0}", string.Empty);
                    }
                }
                else
                {
                    if (all.Contains("</text>"))
                    {
                        all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        all = all.Replace("{0}", string.Empty);
                    }
                    else
                    {
                        all = doc.DocumentNode.InnerText.Replace("{0}", string.Empty);
                    }
                }

                doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(any);
                if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian
                {
                    if (any.Contains("</text>"))
                    {
                        any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        any = any.Replace("{QuestNumber}", completionCount);
                    }
                    else
                    {
                        any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", completionCount);
                    }
                }
                else
                {
                    if (any.Contains("</text>"))
                    {
                        any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
                        any = string.Format(any, completionCount);
                    }
                    else
                    {
                        any = string.Format(doc.DocumentNode.InnerText, completionCount);
                    }
                }

                if (all.Contains("  "))
                {
                    all = all.Replace("  ", " ");
                }                                                         //double space in Spanish (LA)               i.e. with QuestBundle_PirateParty
                if (any.Contains("  "))
                {
                    any = any.Replace("  ", " ");
                }
                #endregion
            }

            FormattedText formattedText =
                new FormattedText(
                    string.Equals(completionCount, "-1") ? all : any,
                    CultureInfo.CurrentUICulture,
                    FlowDirection.LeftToRight,
                    typeface,
                    30,
                    Brushes.White,
                    IconCreator.PPD
                    );
            formattedText.TextAlignment = TextAlignment.Left;
            formattedText.MaxTextWidth  = 800;
            formattedText.MaxLineCount  = 1;
            Point textLocation = new Point(60, y + (FProp.Default.FLanguage.Equals("Japanese") ? 17 : 23));
            IconCreator.ICDrawingContext.DrawText(formattedText, textLocation);
        }