Class serves as reference point to all builders, allowing subclasses of the BuildManager to override specific points of implementation. In a way, this class provides a poor man's dependency injection.
Ejemplo n.º 1
0
        public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager, int linkLevels, bool resolveWidthAndHeight)
        {
            Dynamic.Page p = new Dynamic.Page();
            p.Title = tcmPage.Title;
            p.Id = tcmPage.Id.ToString();
            p.Filename = tcmPage.FileName;
            p.PageTemplate = manager.BuildPageTemplate(tcmPage.PageTemplate);
            p.Schema = manager.BuildSchema(tcmPage.MetadataSchema);
            p.Metadata = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
            if (linkLevels > 0) {
                try {
                    if (tcmPage.Metadata != null) {
                        var tcmMetadataFields = new Tridion.ContentManager.ContentManagement.Fields.ItemFields(tcmPage.Metadata, tcmPage.MetadataSchema);
                        p.Metadata = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
                    }
                } catch (ItemDoesNotExistException) {
                    // fail silently if there is no metadata schema
                }
            }

            p.ComponentPresentations = new List<Dynamic.ComponentPresentation>();
            foreach (TCM.ComponentPresentation cp in tcmPage.ComponentPresentations) {
                Dynamic.ComponentPresentation dynCp = manager.BuildComponentPresentation(cp, engine, linkLevels - 1, resolveWidthAndHeight);
                p.ComponentPresentations.Add(dynCp);
            }
            p.StructureGroup = manager.BuildOrganizationalItem((TCM.StructureGroup)tcmPage.OrganizationalItem);
            p.Publication = manager.BuildPublication(tcmPage.ContextRepository);
            p.Categories = manager.BuildCategories(tcmPage);

            return p;
        }
 public Dynamic.Page GetDynamicPage(BuildManager manager)
 {
     Item item = Package.GetByName(Package.PageName);
     if (item == null)
     {
         Log.Error("no page found (is this a component template?)");
         return null;
     }
     Page tcmPage = (Page)Engine.GetObject(item.GetAsSource().GetValue("ID"));
     int linkLevels;
     if (HasPackageValue(Package, "LinkLevels"))
     {
         linkLevels = Convert.ToInt32(Package.GetValue("LinkLevels"));
     }
     else
     {
         GeneralUtils.TimedLog("no link levels configured, using default level " + this.DefaultLinkLevels);
         linkLevels = this.DefaultLinkLevels;
     }
     bool resolveWidthAndHeight;
     if (HasPackageValue(Package, "ResolveWidthAndHeight"))
     {
         resolveWidthAndHeight = Package.GetValue("ResolveWidthAndHeight").ToLower().Equals("yes");
     }
     else
     {
         GeneralUtils.TimedLog("no ResolveWidthAndHeight configured, using default value " + this.DefaultResolveWidthAndHeight);
         resolveWidthAndHeight = this.DefaultResolveWidthAndHeight;
     }
     Log.Debug("found page with title " + tcmPage.Title + " and id " + tcmPage.Id);
     Log.Debug("constructing dynamic page, links are followed to level " + linkLevels + ", width and height are " + (resolveWidthAndHeight ? "" : "not ") + "resolved");
     return manager.BuildPage(tcmPage, Engine, linkLevels, resolveWidthAndHeight);
 }
Ejemplo n.º 3
0
        public static Dynamic.Schema BuildSchema(TCM.Schema tcmSchema, BuildManager manager)
        {
            if (tcmSchema == null) {
                return null;
            }
            Dynamic.Schema s = new Dynamic.Schema();
            s.Title = tcmSchema.Title;
            s.Id = tcmSchema.Id.ToString();
            s.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmSchema.OrganizationalItem);
            s.Publication = manager.BuildPublication(tcmSchema.ContextRepository);

            return s;
        }
 public static Dynamic.ComponentTemplate BuildComponentTemplate(TComm.ComponentTemplate tcmComponentTemplate, BuildManager manager)
 {
     Dynamic.ComponentTemplate ct = new Dynamic.ComponentTemplate();
     ct.Title = tcmComponentTemplate.Title;
     ct.Id = tcmComponentTemplate.Id.ToString();
     ct.OutputFormat = tcmComponentTemplate.OutputFormat;
      if (tcmComponentTemplate.Metadata != null && tcmComponentTemplate.MetadataSchema != null)
      {
     ct.MetadataFields = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
     TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponentTemplate.Metadata, tcmComponentTemplate.MetadataSchema);
     ct.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from component templates, never resolve binary widht/height
      }
      else
      {
     ct.MetadataFields = null;
      }
      ct.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmComponentTemplate.OrganizationalItem);
      ct.Publication = manager.BuildPublication(tcmComponentTemplate.ContextRepository);
     return ct;
 }
        public static Dynamic.PageTemplate BuildPageTemplate(TComm.PageTemplate tcmPageTemplate, BuildManager manager)
        {
            Dynamic.PageTemplate pt = new Dynamic.PageTemplate();
            pt.Title = tcmPageTemplate.Title;
            pt.Id = tcmPageTemplate.Id.ToString();
            pt.FileExtension = tcmPageTemplate.FileExtension;

             if (tcmPageTemplate.Metadata != null && tcmPageTemplate.MetadataSchema != null)
             {
            pt.MetadataFields = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
            TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmPageTemplate.Metadata, tcmPageTemplate.MetadataSchema);
            pt.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from page templates, never resolve binary widht/height
             }
             else
             {
            pt.MetadataFields = null;
             }
             pt.Publication = manager.BuildPublication(tcmPageTemplate.ContextRepository);
             pt.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmPageTemplate.OrganizationalItem);
             return pt;
        }
 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));
           }
        }
     }
      }
 }
        public static List<Dynamic.Category> BuildCategories(TCM.Component component, BuildManager manager)
        {
            // note that there might be multiple fields based on the same category, so we need to combine them
             // for that purpose we use a dictionary
             Dictionary<string, Dynamic.Category> categories = new Dictionary<string, Dynamic.Category>();

             // first, add categories from the content (note that mm components have no content!)
             if (component.Content != null)
             {
            GeneralUtils.TimedLog("start creating tcm ItemFields from Content");
            ItemFields tcmFields = new TCM.Fields.ItemFields(component.Content, component.Schema);
            GeneralUtils.TimedLog("finished creating tcm ItemFields from Content");
            GeneralUtils.TimedLog("start converting content ItemFields to dynamic fields");
            addFromItemFields(tcmFields, categories, manager);
            GeneralUtils.TimedLog("finished converting content ItemFields to dynamic fields");
             }

             // next, add categories from the metadata
             if (component.Metadata != null)
             {
            GeneralUtils.TimedLog("start creating tcm ItemFields from Metadata");
            ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(component.Metadata, component.Schema);
            GeneralUtils.TimedLog("finished creating tcm ItemFields from Metadata");
            GeneralUtils.TimedLog("start converting metadata ItemFields to dynamic fields");
            addFromItemFields(tcmMetadataFields, categories, manager);
            GeneralUtils.TimedLog("finished converting metadata ItemFields to dynamic fields");
             }

             // finally, create a List from the Dictionary and return it
             List<Dynamic.Category> categoryList = new List<Dynamic.Category>();
             foreach (Dynamic.Category cat in categories.Values)
             {
            categoryList.Add(cat);
             }
             return categoryList;
        }
        public static List<Dynamic.Category> BuildCategories(TComm.Page page, BuildManager manager)
        {
            // note that there might be multiple fields based on the same category, so we need to combine them
             // for that purpose we use a dictionary

             if (page.Metadata == null)
             {
            return new List<Dynamic.Category>();
             }

             Dictionary<string, Dynamic.Category> categories = new Dictionary<string, Dynamic.Category>();

             // first, add categires from the metadata
             ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(page.Metadata, page.MetadataSchema);
             addFromItemFields(tcmMetadataFields, categories, manager);

             // finally, create a List from the Dictionary and return it
             List<Dynamic.Category> categoryList = new List<Dynamic.Category>();
             foreach (Dynamic.Category cat in categories.Values)
             {
            categoryList.Add(cat);
             }
             return categoryList;
        }
        public static Dynamic.Component BuildComponent(TCM.Component tcmComponent, int linkLevels, bool resolveWidthAndHeight, BuildManager manager)
        {
            GeneralUtils.TimedLog("start BuildComponent");
            Dynamic.Component c = new Dynamic.Component();
            c.Title = tcmComponent.Title;
            c.Id = tcmComponent.Id.ToString();
             GeneralUtils.TimedLog("component title = " + c.Title);

             GeneralUtils.TimedLog("start building schema");
             c.Schema = manager.BuildSchema(tcmComponent.Schema);
             GeneralUtils.TimedLog("finished building schema");
             c.ComponentType = (ComponentType)Enum.Parse(typeof(ComponentType), tcmComponent.ComponentType.ToString());

             if (tcmComponent.ComponentType.Equals(TCM.ComponentType.Multimedia))
             {
            GeneralUtils.TimedLog("start building multimedia");
            Multimedia multimedia = new Multimedia();
            multimedia.MimeType = tcmComponent.BinaryContent.MultimediaType.MimeType;
            multimedia.Size = tcmComponent.BinaryContent.FileSize;
            multimedia.FileName = tcmComponent.BinaryContent.Filename;
            // remove leading dot from extension because microsoft returns this as ".gif"
            multimedia.FileExtension = System.IO.Path.GetExtension(multimedia.FileName).Substring(1);

            if (resolveWidthAndHeight)
            {
               MemoryStream memstream = new MemoryStream();
               tcmComponent.BinaryContent.WriteToStream(memstream);
               Image image = Image.FromStream(memstream);
               memstream.Close();

               multimedia.Width = image.Size.Width;
               multimedia.Height = image.Size.Height;
            }
            else
            {
               multimedia.Width = 0;
               multimedia.Height = 0;
            }
            c.Multimedia = multimedia;
            GeneralUtils.TimedLog("finished building multimedia");
             }
             else
             {
            c.Multimedia = null;
             }
             c.Fields = new Dynamic.SerializableDictionary<string,Field>();
            c.MetadataFields = new Dynamic.SerializableDictionary<string, Field>();
            if (linkLevels > 0) {
            if (tcmComponent.Content != null)
            {
               GeneralUtils.TimedLog("start retrieving tcm fields");
               TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmComponent.Content, tcmComponent.Schema);
               GeneralUtils.TimedLog("finished retrieving tcm fields");
               GeneralUtils.TimedLog("start building fields");
               c.Fields = manager.BuildFields(tcmFields, linkLevels, resolveWidthAndHeight);
               GeneralUtils.TimedLog("finished building fields");
            }
                if (tcmComponent.Metadata != null) {
               GeneralUtils.TimedLog("start retrieving tcm metadata fields");
               TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponent.Metadata, tcmComponent.MetadataSchema);
               GeneralUtils.TimedLog("finished retrieving tcm metadata fields");
               GeneralUtils.TimedLog("start building metadata fields");
               c.MetadataFields = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
               GeneralUtils.TimedLog("finished building metadata fields");
            }
            }

             GeneralUtils.TimedLog("start retrieving tcm publication");
             TCM.Repository pub = tcmComponent.ContextRepository;
             GeneralUtils.TimedLog("finished retrieving tcm publication");
             GeneralUtils.TimedLog("start building publication");
             c.Publication = manager.BuildPublication(pub);
             GeneralUtils.TimedLog("finished building publication");

             GeneralUtils.TimedLog("start retrieving tcm folder");
             TCM.Folder folder = (TCM.Folder) tcmComponent.OrganizationalItem;
             GeneralUtils.TimedLog("finished retrieving tcm folder");
             GeneralUtils.TimedLog("start building folder");
             c.Folder = manager.BuildOrganizationalItem(folder);
             GeneralUtils.TimedLog("finished building folder");
             GeneralUtils.TimedLog("start building categories");
             c.Categories = manager.BuildCategories(tcmComponent);
             GeneralUtils.TimedLog("finished building categories");

             GeneralUtils.TimedLog("finished BuildComponent " + c.Title);

             return c;
        }
 public static Dynamic.Component BuildComponent(TCM.Component tcmComponent, BuildManager manager)
 {
     return BuildComponent(tcmComponent, 1, false, manager);
 }
Ejemplo n.º 11
0
 public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager)
 {
     return BuildPage(tcmPage, engine, manager, 1, false);
 }
        private Dynamic.Component GetDynamicComponent(BuildManager manager)
        {
            GeneralUtils.TimedLog("start getting component from package");
            Item item = Package.GetByName(Package.ComponentName);
            GeneralUtils.TimedLog("finished getting component from package");
            if (item == null)
            {
                Log.Error("no component found (is this a page template?)");
                return null;
            }
            Component tcmComponent = (Component)Engine.GetObject(item.GetAsSource().GetValue("ID"));
            int linkLevels;
            if (HasPackageValue(Package, "LinkLevels"))
            {
                linkLevels = Convert.ToInt32(Package.GetValue("LinkLevels"));
            }
            else
            {
                GeneralUtils.TimedLog("no link levels configured, using default level " + this.DefaultLinkLevels);
                linkLevels = this.DefaultLinkLevels;
            }
            bool resolveWidthAndHeight;
            if (HasPackageValue(Package, "ResolveWidthAndHeight"))
            {
                resolveWidthAndHeight = Package.GetValue("ResolveWidthAndHeight").ToLower().Equals("yes");
            }
            else
            {
                GeneralUtils.TimedLog("no ResolveWidthAndHeight configured, using default value " + this.DefaultResolveWidthAndHeight);
                resolveWidthAndHeight = this.DefaultResolveWidthAndHeight;
            }

            GeneralUtils.TimedLog("found component with title " + tcmComponent.Title + " and id " + tcmComponent.Id);
            GeneralUtils.TimedLog("constructing dynamic component, links are followed to level " + linkLevels + ", width and height are " + (resolveWidthAndHeight ? "" : "not ") + "resolved");

            GeneralUtils.TimedLog("start building dynamic component");
            Dynamic.Component component = manager.BuildComponent(tcmComponent, linkLevels, resolveWidthAndHeight);
            GeneralUtils.TimedLog("finished building dynamic component");
            return component;
        }
Ejemplo n.º 13
0
        public static void AddFields(Dynamic.SerializableDictionary<string, Field> fields, TCM.Fields.ItemFields tcmItemFields, int linkLevels, bool resolveWidthAndHeight, Dynamic.MergeAction mergeAction, BuildManager manager)
        {
            foreach (TCM.Fields.ItemField tcmItemField in tcmItemFields)
             {
            try
            {
               if (fields.ContainsKey(tcmItemField.Name))
               {
                  if (mergeAction.Equals(Dynamic.MergeAction.Skip))
                  {
                     continue;
                  }
                  Dynamic.Field f = manager.BuildField(tcmItemField, linkLevels, resolveWidthAndHeight);
                  if (mergeAction.Equals(Dynamic.MergeAction.Replace))
                  {
                     fields.Remove(f.Name);
                     fields.Add(f.Name, f);
                  }
                  else
                  {
                     Field existingField = fields[f.Name];
                     switch (existingField.FieldType)
                     {

                        case FieldType.ComponentLink:
                        case FieldType.MultiMediaLink:
                           foreach (Component linkedComponent in f.LinkedComponentValues)
                           {
                              bool valueExists = false;
                              foreach (Component existingLinkedComponent in existingField.LinkedComponentValues)
                              {
                                 if (linkedComponent.Id.Equals(existingLinkedComponent.Id))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.LinkedComponentValues.Add(linkedComponent);
                              }
                           }
                           break;
                        case FieldType.Date:
                           foreach (DateTime dateTime in f.DateTimeValues)
                           {
                              bool valueExists = false;
                              foreach (DateTime existingDateTime in existingField.DateTimeValues)
                              {
                                 if (dateTime.Equals(existingDateTime))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.DateTimeValues.Add(dateTime);
                              }
                           }
                           break;
                        case FieldType.Number:
                           foreach (int nr in f.NumericValues)
                           {
                              bool valueExists = false;
                              foreach (int existingNr in existingField.NumericValues)
                              {
                                 if (nr == existingNr)
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.NumericValues.Add(nr);
                              }
                           }
                           break;
                        default:
                           foreach (string val in f.Values)
                           {
                              bool valueExists = false;
                              foreach (string existingVal in existingField.Values)
                              {
                                 if (val.Equals(existingVal))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.Values.Add(val);
                              }
                           }
                           break;
                     }
                  }
               }
               else
               {
                   Dynamic.Field f = manager.BuildField(tcmItemField, linkLevels, resolveWidthAndHeight);
                  fields.Add(f.Name, f);
               }
            }
            catch (FieldHasNoValueException)
            {
               // fail silently, field is not added to the list
            }
            catch (FieldTypeNotDefinedException)
            {
               // fail silently, field is not added to the list
            }
             }
        }
Ejemplo n.º 14
0
 public static Dynamic.Fields BuildFields(TCM.Fields.ItemFields tcmItemFields, int linkLevels, bool resolveWidthAndHeight, BuildManager manager)
 {
     var fields = new Fields();
      AddFields(fields, tcmItemFields, linkLevels, resolveWidthAndHeight, Dynamic.MergeAction.Replace, manager);
      return fields;
 }
        public static Dynamic.PageTemplate BuildPageTemplate(TComm.PageTemplate tcmPageTemplate, BuildManager manager)
        {
            Dynamic.PageTemplate pt = new Dynamic.PageTemplate();
            pt.Title         = tcmPageTemplate.Title;
            pt.Id            = tcmPageTemplate.Id.ToString();
            pt.FileExtension = tcmPageTemplate.FileExtension;

            if (tcmPageTemplate.Metadata != null && tcmPageTemplate.MetadataSchema != null)
            {
                pt.MetadataFields = new Dynamic.SerializableDictionary <string, Dynamic.Field>();
                TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmPageTemplate.Metadata, tcmPageTemplate.MetadataSchema);
                pt.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from page templates, never resolve binary widht/height
            }
            else
            {
                pt.MetadataFields = null;
            }
            pt.Publication = manager.BuildPublication(tcmPageTemplate.ContextRepository);
            pt.Folder      = manager.BuildOrganizationalItem((TCM.Folder)tcmPageTemplate.OrganizationalItem);
            return(pt);
        }
Ejemplo n.º 16
0
        public static Dynamic.Field BuildField(TCM.Fields.ItemField tcmItemField, int linkLevels, bool resolveWidthAndHeight, BuildManager manager)
        {
            Dynamic.Field f = new Dynamic.Field();

             if (tcmItemField == null)
             {
            throw new FieldHasNoValueException();
             }
             f.Name = tcmItemField.Name;
             if (tcmItemField is TCM.Fields.XhtmlField)
             {
            TCM.Fields.XhtmlField sField = (TCM.Fields.XhtmlField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            foreach (string v in sField.Values)
            {
               f.Values.Add(v);
            }
            f.FieldType = FieldType.Xhtml;
            return f;
             }
             if (tcmItemField is TCM.Fields.MultiLineTextField)
             {
            TCM.Fields.TextField sField = (TCM.Fields.MultiLineTextField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            foreach (string v in sField.Values)
            {
               f.Values.Add(v);
            }
            f.FieldType = FieldType.MultiLineText;
            return f;
             }
             if (tcmItemField is TCM.Fields.TextField)
             {
            TCM.Fields.TextField sField = (TCM.Fields.TextField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            foreach (string v in sField.Values)
            {
               f.Values.Add(v);
            }
            f.FieldType = FieldType.Text;
            return f;
             }
             if (tcmItemField is TCM.Fields.KeywordField)
             {
            TCM.Fields.KeywordField sField = (TCM.Fields.KeywordField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            // we will wrap each linked component in a ContentModel component
            f.Values = new List<string>();
            foreach (TCM.Keyword kw in sField.Values)
            {
               // todo: add binary to package, and add BinaryUrl property to the component
               f.Values.Add(kw.Title);
            }
            f.FieldType = FieldType.Keyword;
            KeywordFieldDefinition fieldDef = (KeywordFieldDefinition) sField.Definition;
            f.CategoryId = fieldDef.Category.Id;
            f.CategoryName = fieldDef.Category.Title;
            return f;
             }
             if (tcmItemField is TCM.Fields.NumberField)
             {
            TCM.Fields.NumberField sField = (TCM.Fields.NumberField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            f.NumericValues = (List<double>)sField.Values;
            f.Values = new List<string>();
            foreach (double d in f.NumericValues)
            {
               f.Values.Add(Convert.ToString(d));
            }
            f.FieldType = FieldType.Number;
            return f;
             }
             if (tcmItemField is TCM.Fields.DateField)
             {
            TCM.Fields.DateField sField = (TCM.Fields.DateField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            f.DateTimeValues = (List<DateTime>)sField.Values;
            f.Values = new List<string>();
            foreach (DateTime dt in f.DateTimeValues)
            {
               f.Values.Add(Convert.ToString(dt));
            }
            f.FieldType = FieldType.Date;
            return f;
             }
             if (tcmItemField is TCM.Fields.MultimediaLinkField)
             {
            TCM.Fields.MultimediaLinkField sField = (TCM.Fields.MultimediaLinkField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();

            // we will wrap each linked component in a ContentModel component
            f.LinkedComponentValues = new List<Dynamic.Component>();
            foreach (TCM.Component comp in sField.Values)
            {
               // todo: add binary to package, and add BinaryUrl property to the component
                f.LinkedComponentValues.Add(manager.BuildComponent(comp, linkLevels - 1, resolveWidthAndHeight));
            }
            f.Values = new List<string>();
            foreach (Dynamic.Component c in f.LinkedComponentValues)
            {
               f.Values.Add(c.Id);
            }
            f.FieldType = FieldType.MultiMediaLink;
            return f;
             }
             if (tcmItemField is TCM.Fields.ComponentLinkField)
             {
            TCM.Fields.ComponentLinkField sField = (TCM.Fields.ComponentLinkField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            // we will wrap each linked component in a ContentModel component
            f.LinkedComponentValues = new List<Dynamic.Component>();
            foreach (TCM.Component comp in sField.Values)
            {
                f.LinkedComponentValues.Add(manager.BuildComponent(comp, linkLevels - 1, resolveWidthAndHeight));
            }
            f.Values = new List<string>();
            foreach (Dynamic.Component c in f.LinkedComponentValues)
            {
               f.Values.Add(c.Id);
            }
            f.FieldType = FieldType.ComponentLink;
            return f;
             }

             if (tcmItemField is TCM.Fields.EmbeddedSchemaField)
             {
            TCM.Fields.EmbeddedSchemaField sField = (TCM.Fields.EmbeddedSchemaField)tcmItemField;
            if (sField.Values.Count == 0)
               throw new FieldHasNoValueException();
            // we will wrap each linked component in a ContentModel component
            f.EmbeddedValues = new List<Dynamic.Fields>();
            foreach (TCM.Fields.ItemFields embeddedFields in sField.Values)
            {
                f.EmbeddedValues.Add(manager.BuildFields(embeddedFields, linkLevels, resolveWidthAndHeight));
            }
            f.FieldType = FieldType.Embedded;
            return f;
             }

             throw new FieldTypeNotDefinedException();
        }