Beispiel #1
0
 private static void addFromItemFields(ItemFields tcmFields, Dictionary <string, Dynamic.Category> categories, BuildManager manager)
 {
     foreach (ItemField f in tcmFields)
     {
         if (f is KeywordField)
         {
             string           categoryId = ((KeywordFieldDefinition)f.Definition).Category.Id;
             Dynamic.Category dc;
             if (!categories.ContainsKey(categoryId))
             {
                 // create category since it doesn't exist yet
                 dc          = new Dynamic.Category();
                 dc.Id       = ((KeywordFieldDefinition)f.Definition).Category.Id;
                 dc.Title    = ((KeywordFieldDefinition)f.Definition).Category.Title;
                 dc.Keywords = new List <Dynamic.Keyword>();
                 categories.Add(dc.Id, dc);
             }
             else
             {
                 dc = categories[categoryId];
             }
             foreach (Keyword keyword in ((KeywordField)f).Values)
             {
                 bool alreadyThere = false;
                 foreach (Dynamic.Keyword dk in dc.Keywords)
                 {
                     if (dk.Id.Equals(keyword.Id))
                     {
                         alreadyThere = true;
                         break;
                     }
                 }
                 if (!alreadyThere)
                 {
                     dc.Keywords.Add(manager.BuildKeyword(keyword));
                 }
             }
         }
     }
 }
 private static void addFromItemFields(ItemFields tcmFields, Dictionary<string, Dynamic.Category> categories, BuildManager manager)
 {
     foreach (ItemField f in tcmFields)
      {
     if (f is KeywordField)
     {
        string categoryId = ((KeywordFieldDefinition)f.Definition).Category.Id;
        Dynamic.Category dc;
        if (!categories.ContainsKey(categoryId))
        {
           // create category since it doesn't exist yet
           dc = new Dynamic.Category();
           dc.Id = ((KeywordFieldDefinition)f.Definition).Category.Id;
           dc.Title = ((KeywordFieldDefinition)f.Definition).Category.Title;
           dc.Keywords = new List<Dynamic.Keyword>();
           categories.Add(dc.Id, dc);
        }
        else
        {
           dc = categories[categoryId];
        }
        foreach (Keyword keyword in ((KeywordField)f).Values)
        {
           bool alreadyThere = false;
           foreach (Dynamic.Keyword dk in dc.Keywords)
           {
              if (dk.Id.Equals(keyword.Id))
              {
                 alreadyThere = true;
                 break;
              }
           }
           if (!alreadyThere)
           {
              dc.Keywords.Add(manager.BuildKeyword(keyword));
           }
        }
     }
      }
 }