コード例 #1
0
        public void TestAnalyze()
        {
            var previousVersion = new DocsFile(
                new []
            {
                new ItemDescriptor("I1", "Item 1", StackSize.Small, "", ""),
                new ItemDescriptor("I2", "Item 2", StackSize.Small, "", "")
            }
                );
            var currentVersion = new DocsFile(
                new []
            {
                new ItemDescriptor("I1", "Item 1", StackSize.Small, "", ""),
                new ItemDescriptor("I2", "Item 2", StackSize.Huge, "", "")
            }
                );

            var result = DocsAnalyzer.Analyze(previousVersion, currentVersion);

            Assert.That.SequenceEqual(
                new []
            {
                new AnalysisResult.ItemChange(
                    previousVersion.ItemDescriptors[1],
                    currentVersion.ItemDescriptors[1]
                    )
            },
                result.Changes
                );
        }
コード例 #2
0
        public static AnalysisResult Analyze(DocsFile previousVersion, DocsFile currentVersion)
        {
            var changes = new List <AnalysisResult.ItemChange>();

            var itemPairs =
                previousVersion
                .ItemDescriptors
                .Concat(currentVersion.ItemDescriptors)
                .GroupBy(c => c.ClassName);

            foreach (var itemPair in itemPairs.Where(p => p.Count() == 2))
            {
                var oldItem = itemPair.ElementAt(0);
                var newItem = itemPair.ElementAt(1);

                if (oldItem.StackSize != newItem.StackSize)
                {
                    var change = new AnalysisResult.ItemChange(oldItem, newItem);

                    changes.Add(change);
                }
            }

            var result = new AnalysisResult(changes.ToArray());

            return(result);
        }
コード例 #3
0
ファイル: DocsParser.cs プロジェクト: LuizZak/SatistackDiffer
        private static void ParseClassEntry(ref DocsFile file, JToken classEntry)
        {
            string className = classEntry["NativeClass"].Value <string>();

            switch (className)
            {
            case "Class'/Script/FactoryGame.FGItemDescriptor'":
                file.ItemDescriptors = ParseItemDescriptors(classEntry);
                break;
            }
        }
コード例 #4
0
        private async ValueTask SetDocUrl()
        {
            if (!string.IsNullOrEmpty(FileName))
            {
                var baseUrl = NavigationManager.ToAbsoluteUri(NavigationManager.BaseUri);
                var docUrl  = new Uri(baseUrl, $"_content/AntDesign.Docs/docs/{FileName}.{CurrentLanguage}.json").ToString();
                _file = await HttpClient.GetFromJsonAsync <DocsFile>(docUrl);

                _waitingHighlight = true;

                await MainLayout.ChangePrevNextNav(FileName);
            }
        }
コード例 #5
0
        public void TestItemWithClassName()
        {
            // Arrange
            var docsFile = new DocsFile
            {
                ItemDescriptors = new [] {
                    new ItemDescriptor("I1", "Item 1", StackSize.One, "", ""),
                    new ItemDescriptor("I2", "Item 2", StackSize.One, "", "")
                }
            };

            Assert.AreEqual("Item 1", docsFile.ItemWithClassName("Item 1")?.DisplayName);
            Assert.AreEqual("Item 2", docsFile.ItemWithClassName("Item 2")?.DisplayName);
        }
コード例 #6
0
ファイル: DocsParser.cs プロジェクト: LuizZak/SatistackDiffer
        public static DocsFile Parse(JToken document)
        {
            var file = new DocsFile {
                ItemDescriptors = new ItemDescriptor[] {}
            };

            if (document.Type != JTokenType.Array)
            {
                throw new ArgumentException($"Expected root JSON element to be an Array, received {document.Root.Type}");
            }

            foreach (var element in document)
            {
                if (element["NativeClass"] != null)
                {
                    ParseClassEntry(ref file, element);
                }
            }

            return(file);
        }
コード例 #7
0
        public void TestItemWithClassName_ReturnsNullOnNotFound()
        {
            var docsFile = new DocsFile(new ItemDescriptor[0]);

            Assert.IsNull(docsFile.ItemWithClassName("Item"));
        }
コード例 #8
0
 public static DocsFile UseEngine(this DocsFile file, IFileGenerator generator)
 {
     file.FileGenerator = generator;
     return(file);
 }