コード例 #1
0
        public void EnsureThatHelpLinkUriIsCorrect(DescriptorInfo descriptorInfo)
        {
            Assert.That(descriptorInfo.Descriptor.HelpLinkUri, Is.Not.Null.And.Not.Empty);
            var expectedUri = $"https://github.com/nunit/nunit.analyzers/tree/master/documentation/{descriptorInfo.Descriptor.Id}.md";

            Assert.That(descriptorInfo.Descriptor.HelpLinkUri, Is.EqualTo(expectedUri));
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: mikkelbu/AspNetCoreAnalyzers
        public void Title(DescriptorInfo descriptorInfo)
        {
            var expected = $"## {descriptorInfo.Descriptor.Title}";
            var actual   = File.ReadLines(descriptorInfo.DocFileName).Skip(1).First().Replace("`", string.Empty, StringComparison.Ordinal);

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public static void ConfigSeverity(DescriptorInfo descriptorInfo)
        {
            var expected = GetConfigSeverity(descriptorInfo.Stub);

            DumpIfDebug(expected);
            var actual = GetConfigSeverity(descriptorInfo.DocumentationFile.AllText);

            CodeAssert.AreEqual(expected, actual);
コード例 #4
0
ファイル: Tests.cs プロジェクト: mikkelbu/AspNetCoreAnalyzers
        public void ConfigSeverity(DescriptorInfo descriptorInfo)
        {
            var expected = GetConfigSeverity(CreateStub(descriptorInfo));

            DumpIfDebug(expected);
            var actual = GetConfigSeverity(File.ReadAllText(descriptorInfo.DocFileName));

            CodeAssert.AreEqual(expected, actual);
        }
コード例 #5
0
ファイル: Tests.cs プロジェクト: varunvasisht84/Gu.Analyzers
        public void ConfigSeverity(DescriptorInfo descriptorInfo)
        {
            var expected = new CodeReader(GetConfigSeverity(CreateStub(descriptorInfo)));

            DumpIfDebug(expected.ToString());
            var actual = new CodeReader(GetConfigSeverity(File.ReadAllText(descriptorInfo.DocFileName)));

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void Table(DescriptorInfo descriptorInfo)
        {
            var expected = GetTable(CreateStub(descriptorInfo));

            DumpIfDebug(expected);
            var actual = GetTable(descriptorInfo.DocumentationFile.AllText);

            CodeAssert.AreEqual(expected, actual);
        }
コード例 #7
0
ファイル: Tests.cs プロジェクト: candyzkn/WpfAnalyzers
        public void Table(DescriptorInfo descriptorInfo)
        {
            var expected = GetTable(CreateStub(descriptorInfo)).NormalizeNewLine();

            DumpIfDebug(expected);
            var actual = GetTable(File.ReadAllText(descriptorInfo.DocFileName)).NormalizeNewLine();

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
        public static void Title(DescriptorInfo descriptorInfo)
        {
            var expected = $"## {descriptorInfo.Descriptor.Title}";
            var actual   = descriptorInfo.DocumentationFile.AllLines
                           .Skip(1)
                           .First()
                           .Replace("`", string.Empty);

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public static void Table(DescriptorInfo descriptorInfo)
        {
            const string headerRow = "| Topic    | Value";
            var          expected  = GetTable(descriptorInfo.Stub, headerRow);

            DumpIfDebug(expected);
            var actual = GetTable(descriptorInfo.DocumentationFile.AllText, headerRow);

            CodeAssert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void EnsureThatTitleIsAsExpected(DescriptorInfo descriptorInfo)
        {
            var expected = new[] { "", $"## {descriptorInfo.Descriptor.Title}" };
            var actual   = descriptorInfo
                           .DocumentationFile.AllLines
                           .Skip(1)
                           .Select(l => l.Replace(@"\<", "<"))
                           .Take(2);

            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
ファイル: Tests.cs プロジェクト: mikkelbu/AspNetCoreAnalyzers
 public void MissingDocs(DescriptorInfo descriptorInfo)
 {
     if (!descriptorInfo.DocExists)
     {
         var descriptor = descriptorInfo.Descriptor;
         var id         = descriptor.Id;
         DumpIfDebug(CreateStub(descriptorInfo));
         File.WriteAllText(descriptorInfo.DocFileName + ".generated", CreateStub(descriptorInfo));
         Assert.Fail($"Documentation is missing for {id}");
     }
 }
コード例 #12
0
 public void EnsureAllDescriptorsHaveDocumentation(DescriptorInfo descriptorInfo)
 {
     if (!descriptorInfo.DocumentationFile.Exists)
     {
         var descriptor = descriptorInfo.Descriptor;
         var id         = descriptor.Id;
         DumpIfDebug(descriptorInfo.Stub);
         File.WriteAllText(descriptorInfo.DocumentationFile.Name + ".generated", descriptorInfo.Stub);
         Assert.Fail($"Documentation is missing for {id}");
     }
 }
コード例 #13
0
        public void Description(DescriptorInfo descriptorInfo)
        {
            var expected = File.ReadLines(descriptorInfo.DocFileName)
                           .SkipWhile(l => !l.StartsWith("## Description"))
                           .Skip(1)
                           .FirstOrDefault(l => !string.IsNullOrWhiteSpace(l));
            var actual = descriptorInfo.Descriptor.Description.ToString();

            DumpIfDebug(expected);
            DumpIfDebug(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
ファイル: Tests.cs プロジェクト: forki/WpfAnalyzers
        private static string CreateStub(DescriptorInfo descriptorInfo)
        {
            var descriptor = descriptorInfo.DiagnosticDescriptor;

            return(CreateStub(
                       descriptor.Id,
                       descriptor.Title.ToString(),
                       descriptor.DefaultSeverity,
                       descriptorInfo.CodeFileUri,
                       descriptor.Category,
                       descriptorInfo.DiagnosticAnalyzer.GetType().Name,
                       descriptor.Description.ToString()));
        }
コード例 #15
0
        private static object ConvertToListValue(object value, DescriptorInfo d)
        {
            //list不为空,把原始数据转化为property对象
            var tmpList   = value as IEnumerable;
            var listValue = new ObservableCollection <object>();

            foreach (var tmpData in tmpList)
            {
                var tmpVM = GetNode(tmpData, d);
                listValue.Add(tmpVM.Properties);
            }
            return(listValue);
        }
コード例 #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DescriptorInfo d = null;

            if (value is ConfigItemNode node)
            {
                d = node.Descriptor;
            }
            else if (value is ConfigItemProperty property)
            {
                d = property.Descriptor;
            }
            else if (value is DescriptorInfo)
            {
                d = value as DescriptorInfo;
            }

            if (d != null)
            {
                if (ReadDesc)
                {
                    if (!string.IsNullOrEmpty(d.Desc))
                    {
                        return(d.Desc);
                    }

                    if (!string.IsNullOrEmpty(d.DescKey))
                    {
                        string lan = LanService.Get(d.DescKey).Result;
                        return(lan);
                    }
                    return(null);
                }
                else
                {
                    if (!string.IsNullOrEmpty(d.Text))
                    {
                        return(d.Text);
                    }

                    if (!string.IsNullOrEmpty(d.TextKey))
                    {
                        string lan = LanService.Get(d.TextKey).Result;
                        return(lan);
                    }
                }
                //return d.Name;
            }

            return(value);
        }
コード例 #17
0
ファイル: Tests.cs プロジェクト: AArnott/Gu.Analyzers
        private static string CreateStub(DescriptorInfo descriptorInfo)
        {
            var descriptor = descriptorInfo.Descriptor;

            return(CreateStub(
                       id: descriptor.Id,
                       title: descriptor.Title.ToString(),
                       severity: descriptor.DefaultSeverity,
                       enabled: descriptor.IsEnabledByDefault,
                       codeFileUrl: descriptorInfo.CodeFileUri,
                       category: descriptor.Category,
                       typeName: descriptorInfo.Analyzer.GetType().Name,
                       description: descriptor.Description.ToString()));
        }
コード例 #18
0
        internal static List <ConfigItemNode> GetNodes(object[] configs, DescriptorInfoDict descriptor)
        {
            List <ConfigItemNode> result = new List <ConfigItemNode>();

            foreach (var configItem in configs)
            {
                var            type     = configItem.GetType();
                var            attr     = type.GetCustomAttribute(typeof(DescriptorAttribute)) as DescriptorAttribute;
                DescriptorInfo descInfo = GetOrCreateDescriptorInfo(type.Name, type, descriptor, attr);
                var            node     = GetNode(configItem, descInfo);
                result.Add(node);
            }
            return(result);
        }
コード例 #19
0
        private static DescriptorInfo GetOrCreateDescriptorInfo(string key, Type sourceType, DescriptorInfoDict descriptor, DescriptorAttribute attr = null)
        {
            DescriptorInfo descInfo;

            if (descriptor != null && descriptor.ContainsKey(key))
            {
                descInfo = descriptor[key];
            }
            else
            {
                //生成默认描述信息
                descInfo = new DescriptorInfo();
            }

            //定义了attribute
            if (attr != null)
            {
                descInfo.Text = attr.Text;
                descInfo.Type = attr.Type;
            }

            //补充必填信息
            if (string.IsNullOrEmpty(descInfo.Text))
            {
                descInfo.Text = key;
            }

            if (descInfo.Type == PropertyType.None)
            {
                descInfo.Type = GetDefaultType(sourceType);
            }

            if (descInfo.SourceType == null)
            {
                descInfo.SourceType = sourceType;
            }

            if (sourceType.IsEnum && descInfo.Options == null)
            {
                var items   = sourceType.GetEnumNames();
                var options = items.Select(m => new DescriptorInfo()
                {
                    Text = m, DefaultValue = Enum.Parse(sourceType, m)
                });
                descInfo.Options = new ObservableCollection <DescriptorInfo>(options);
            }

            DescriptorInfo.SetPropertyName(key, descInfo);
            return(descInfo);
        }
コード例 #20
0
ファイル: Tests.cs プロジェクト: AArnott/Gu.Analyzers
        public void Table(DescriptorInfo descriptorInfo)
        {
            switch (descriptorInfo.Descriptor.Id)
            {
            case GU0012NullCheckParameter.DiagnosticId when descriptorInfo.Analyzer is ParameterAnalyzer:
                return;
            }

            var expected = GetTable(CreateStub(descriptorInfo));

            DumpIfDebug(expected);
            var actual = GetTable(File.ReadAllText(descriptorInfo.DocFileName));

            CodeAssert.AreEqual(expected, actual);
        }
コード例 #21
0
ファイル: Tests.cs プロジェクト: mikkelbu/AspNetCoreAnalyzers
        public void Description(DescriptorInfo descriptorInfo)
        {
            var expected = descriptorInfo.Descriptor
                           .Description
                           .ToString(CultureInfo.InvariantCulture)
                           .Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
                           .First();
            var actual = File.ReadLines(descriptorInfo.DocFileName)
                         .SkipWhile(l => !l.StartsWith("## Description", StringComparison.OrdinalIgnoreCase))
                         .Skip(1)
                         .FirstOrDefault(l => !string.IsNullOrWhiteSpace(l))
                         ?.Replace("`", string.Empty, StringComparison.Ordinal);

            DumpIfDebug(expected);
            DumpIfDebug(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #22
0
        public void Table(DescriptorInfo descriptorInfo)
        {
            switch (descriptorInfo.Descriptor.Id)
            {
            case INPC004UseCallerMemberName.DiagnosticId when descriptorInfo.Analyzer is INPC004UseCallerMemberName:
                return;

            case INPC009DontRaiseChangeForMissingProperty.DiagnosticId when descriptorInfo.Analyzer is InvocationAnalyzer:
                return;
            }

            var expected = GetTable(CreateStub(descriptorInfo));

            DumpIfDebug(expected);
            var actual = GetTable(File.ReadAllText(descriptorInfo.DocFileName));

            CodeAssert.AreEqual(expected, actual);
        }
コード例 #23
0
        public void Description(DescriptorInfo descriptorInfo)
        {
            var expected =
                descriptorInfo.Descriptor
                .Description
                .ToString(CultureInfo.InvariantCulture)
                .Split('\n')
                .First();
            var actualRaw =
                descriptorInfo.DocumentationFile.AllLines
                .SkipWhile(l => !l.StartsWith("## Description", StringComparison.OrdinalIgnoreCase))
                .Skip(1)
                .FirstOrDefault(l => !string.IsNullOrWhiteSpace(l));
            var actual = Replace(actualRaw, "`", string.Empty);

            DumpIfDebug(expected);
            DumpIfDebug(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #24
0
        public static void ConfigSeverity(DescriptorInfo descriptorInfo)
        {
            var expected = GetConfigSeverity(descriptorInfo.Stub);

            DumpIfDebug(expected);
            var actual = GetConfigSeverity(descriptorInfo.DocumentationFile.AllText);

            CodeAssert.AreEqual(expected, actual);

            string GetConfigSeverity(string doc)
            {
                return(GetSection(doc, "<!-- start generated config severity -->", "<!-- end generated config severity -->"));
            }

            string GetSection(string doc, string startToken, string endToken)
            {
                var start = doc.IndexOf(startToken, StringComparison.Ordinal);
                var end   = doc.IndexOf(endToken, StringComparison.Ordinal) + endToken.Length;

                return(doc[start..end]);
            }
        internal override bool IsDescriptor(HeapCell aCell, out DescriptorInfo aInfo)
        {
            // Base-class makes first pass.
            bool isDes = base.IsDescriptor(aCell, out aInfo);

            //
            if (isDes)
            {
                DescriptorInfo           info = new DescriptorInfo(aCell);
                HeapCell.TDescriptorType type = info.Type;

                // There needs to be at least two raw items, one for the descriptor type & length, and
                // another for the max length.
                if (type != HeapCell.TDescriptorType.EUnknown && RawItems.Count > 2 && type == HeapCell.TDescriptorType.EBuf)
                {
                    // Now we can check if it meet our requirements...
                    int length    = base.CalculatedDescriptorLength;
                    int maxLength = base.CalculatedDescriptorMaxLength;
                    //
                    bool allWerePrintableCharacers = false;
                    int  printCharCount            = PrintableCharacterCount(length, DesAsciiAlgorithmBase.KDescriptorRawItemOffsetEBufC, out allWerePrintableCharacers);
                    //
                    if (printCharCount == length && length <= maxLength)
                    {
                        aInfo      = info;
                        aInfo.Text = ConvertToText(length, DesAsciiAlgorithmBase.KDescriptorRawItemOffsetEBufC);
                        isDes      = true;
                    }
                }
                else if (type == HeapCell.TDescriptorType.EBufCPtr)
                {
                    int x = 0;
                    x++;
                }
            }
            //
            return(isDes);
        }
コード例 #26
0
        internal override bool IsDescriptor(HeapCell aCell, out DescriptorInfo aInfo)
        {
            // Base-class makes first pass.
            bool isDes = base.IsDescriptor(aCell, out aInfo);

            //
            if (isDes)
            {
                // Now we can check if it meet our requirements...
                int  length = base.CalculatedDescriptorLength;
                bool allWerePrintableCharacers = false;
                int  printCharCount            = PrintableCharacterCount(length, out allWerePrintableCharacers);
                //
                if (printCharCount == length)
                {
                    aInfo      = new DescriptorInfo(aCell, true);
                    aInfo.Text = ConvertToText(length);
                    isDes      = true;
                }
            }
            //
            return(isDes);
        }
コード例 #27
0
ファイル: Tests.cs プロジェクト: jnm2/ReflectionAnalyzers
        private static string CreateStub(DescriptorInfo descriptorInfo)
        {
            var descriptor = descriptorInfo.Descriptor;
            var stub       = Properties.Resources.DiagnosticDocTemplate
                             .AssertReplace("{ID}", descriptor.Id)
                             .AssertReplace("## ADD TITLE HERE", $"## {descriptor.Title.ToString(CultureInfo.InvariantCulture)}")
                             .AssertReplace("{SEVERITY}", descriptor.DefaultSeverity.ToString())
                             .AssertReplace("{ENABLED}", descriptor.IsEnabledByDefault ? "true" : "false")
                             .AssertReplace("{CATEGORY}", descriptor.Category)
                             .AssertReplace("ADD DESCRIPTION HERE", descriptor.Description.ToString(CultureInfo.InvariantCulture))
                             .AssertReplace("{TITLE}", descriptor.Title.ToString(CultureInfo.InvariantCulture));

            if (Analyzers.Count(x => x.SupportedDiagnostics.Any(d => d.Id == descriptor.Id)) == 1)
            {
                return(stub.AssertReplace("{TYPENAME}", descriptorInfo.Analyzer.GetType().Name)
                       .AssertReplace("{URL}", descriptorInfo.CodeFileUri));
            }

            var builder = StringBuilderPool.Borrow();
            var first   = true;

            foreach (var analyzer in Analyzers.Where(x => x.SupportedDiagnostics.Any(d => d.Id == descriptor.Id)))
            {
                _ = builder.AppendLine("  <tr>")
                    .AppendLine($"    <td>{(first ? "Code" : string.Empty)}</td>")
                    .AppendLine($"     <td><a href=\"{DescriptorInfo.GetCodeFileUri(analyzer)}\">{analyzer.GetType().Name}</a></td>")
                    .AppendLine("  </tr>");

                first = false;
            }

            var text = builder.Return();

            return(stub.Replace("  <tr>\r\n    <td>Code</td>\r\n    <td><a href=\"{URL}\">{TYPENAME}</a></td>\r\n  </tr>\r\n", text)
                   .Replace("  <tr>\n    <td>Code</td>\n    <td><a href=\"{URL}\">{TYPENAME}</a></td>\n  </tr>\n", text));
        }
コード例 #28
0
 public void EnsureThatAllIdsAreUnique(DescriptorInfo descriptorInfo)
 {
     Assert.AreEqual(1, descriptorInfos.Select(x => x.Descriptor)
                     .Distinct()
                     .Count(d => d.Id == descriptorInfo.Descriptor.Id));
 }
コード例 #29
0
        /// <summary>
        /// Updates an existing product.
        /// A field is only updated if the CSV field is non-empty.
        /// Existing Product Categories are kept, and new Categories are added from the CSV file.
        /// Existing Product Photos are kept, and new Photos are added.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="csvProduct"></param>
        private void UpdateProduct(Product p, CsvProductInfo csvProduct)
        {
            if (NotEmpty(csvProduct.Name))
            {
                p.Name = csvProduct.Name;
            }
            if (NotEmpty(csvProduct.Sku))
            {
                p.Sku = csvProduct.Sku;
            }
            if (NotEmpty(csvProduct.UrlName))
            {
                p.Slug = csvProduct.UrlName.IsValidSlug() ? csvProduct.UrlName : csvProduct.UrlName.CreateSlug();
            }
            if (csvProduct.Price.HasValue)
            {
                p.Price = csvProduct.Price;
            }
            if (csvProduct.Weight.HasValue)
            {
                p.Weight = csvProduct.Weight;
            }
            if (NotEmpty(csvProduct.SeoTitle))
            {
                p.SeoTitle = csvProduct.SeoTitle;
            }
            if (NotEmpty(csvProduct.SeoDescription))
            {
                p.SeoDescription = csvProduct.SeoDescription;
            }
            if (NotEmpty(csvProduct.SeoKeywords))
            {
                p.SeoKeywords = csvProduct.SeoKeywords;
            }
            if (csvProduct.IsActive.HasValue)
            {
                p.IsActive = csvProduct.IsActive;
            }
            if (csvProduct.TaxableItem.HasValue)
            {
                p.IsTaxable = csvProduct.TaxableItem;
            }
            if (csvProduct.ShowPrice.HasValue)
            {
                p.IsPriceDisplayed = csvProduct.ShowPrice;
            }
            if (csvProduct.AvailableForPurchase.HasValue)
            {
                p.IsAvailableForPurchase = csvProduct.AvailableForPurchase;
            }
            if (csvProduct.EnableInventoryManagement.HasValue)
            {
                p.InventoryIsEnabled = csvProduct.EnableInventoryManagement;
            }
            p.InventoryQtyInStock = csvProduct.StockLevel.HasValue ? csvProduct.StockLevel : null;

            if (csvProduct.AllowNegativeStock.HasValue)
            {
                p.InventoryAllowNegativeStockLevel = csvProduct.AllowNegativeStock;
            }

            if (!p.Slug.IsValidSlug())
            {
                csvLine.Status     = ProductImportStatus.Error;
                csvLine.StatusMsg += string.Format(@"Invalid Slug '{0}' must match the pattern '{1}'", p.Slug, RegexPatterns.IsValidSlug);
                return;
            }
            if (!string.IsNullOrEmpty(p.Sku) && !p.Sku.IsValidSku())
            {
                csvLine.Status     = ProductImportStatus.Error;
                csvLine.StatusMsg += string.Format(@"Invalid Sku '{0}' must match the pattern '{1}'", p.Sku, RegexPatterns.IsValidSku);
                return;
            }

            //--- Digital File
            if (NotEmpty(csvProduct.DigitalFilename))
            {
                if (NotEmpty(p.DigitalFilename))
                {
                    File.Delete(Path.Combine(productFilesFolderFileRoot, p.DigitalFilename));
                }
                ImportDigitalFile(p, csvProduct.DigitalFilename);
            }

            //--- Descriptors (update/add if different, but preserve existing)
            using (esTransactionScope transaction = new esTransactionScope())
            {
                var existingDescriptors = p.GetProductDescriptors();
                var newDescriptors      = new Dictionary <int, DescriptorInfo>();
                for (short i = 0; i < 5; i++)
                {
                    //var descriptor = (i < existingDescriptors.Count) ? existingDescriptors[i] : new ProductDescriptor();
                    //descriptor.SortOrder = i;
                    //newDescriptors[i] = descriptor;

                    if (i < existingDescriptors.Count)
                    {
                        newDescriptors[i] = new DescriptorInfo()
                        {
                            Name = existingDescriptors[i].Name, Text = existingDescriptors[i].Text
                        };
                    }
                    else
                    {
                        newDescriptors[i] = new DescriptorInfo();
                    }
                }
                if (NotEmpty(csvProduct.Desc1Name))
                {
                    newDescriptors[0].Name = csvProduct.Desc1Name;
                }
                if (NotEmpty(csvProduct.Desc2Name))
                {
                    newDescriptors[1].Name = csvProduct.Desc2Name;
                }
                if (NotEmpty(csvProduct.Desc3Name))
                {
                    newDescriptors[2].Name = csvProduct.Desc3Name;
                }
                if (NotEmpty(csvProduct.Desc4Name))
                {
                    newDescriptors[3].Name = csvProduct.Desc4Name;
                }
                if (NotEmpty(csvProduct.Desc5Name))
                {
                    newDescriptors[4].Name = csvProduct.Desc5Name;
                }
                if (NotEmpty(csvProduct.Desc1Html))
                {
                    newDescriptors[0].Text = csvProduct.Desc1Html;
                }
                if (NotEmpty(csvProduct.Desc2Html))
                {
                    newDescriptors[1].Text = csvProduct.Desc2Html;
                }
                if (NotEmpty(csvProduct.Desc3Html))
                {
                    newDescriptors[2].Text = csvProduct.Desc3Html;
                }
                if (NotEmpty(csvProduct.Desc4Html))
                {
                    newDescriptors[3].Text = csvProduct.Desc4Html;
                }
                if (NotEmpty(csvProduct.Desc5Html))
                {
                    newDescriptors[4].Text = csvProduct.Desc5Html;
                }

                p.ProductDescriptorCollectionByProductId.MarkAllAsDeleted();
                for (short i = 0; i < newDescriptors.Count; i++)
                {
                    var descr = newDescriptors[i];
                    if (NotEmpty(descr.Name) || NotEmpty(descr.Text))
                    {
                        AddProductDescriptor(p, i, descr.Name, descr.Text);
                    }
                }

                transaction.Complete();
            }

            //--- Categories (add new, but don't delete existing)
            List <Category> existingProductCategories = p.GetCategories(true);
            List <string>   newCategoryNames          = csvProduct.CategoryNames.ToList(",", true);

            newCategoryNames.RemoveAll(x => existingProductCategories.Exists(c => c.Name == x));
            foreach (string newCat in newCategoryNames)
            {
                var c = Category.GetByName(storeId, newCat) ?? CreateCategory(newCat);
                p.AddCategory(c);
            }

            //--- Photos (add new, but don't delete existing)
            IEnumerable <string> importPhotoFiles = GetPhotoFilePathsForImport(p, csvProduct);

            foreach (string filepath in importPhotoFiles)
            {
                AddPhoto(p, filepath);
            }

            p.Save();
        }
コード例 #30
0
ファイル: Tests.cs プロジェクト: mikkelbu/AspNetCoreAnalyzers
 public void TitleId(DescriptorInfo descriptorInfo)
 {
     Assert.AreEqual($"# {descriptorInfo.Descriptor.Id}", File.ReadLines(descriptorInfo.DocFileName).First());
 }