public RecipeAttachment(RecipeAttachmentType type, String name, String key, String source) { _Name = name; _Type = type; _Key = key; _Source = source; }
public RecipeAttachment(RecipeAttachmentType type, string name, string key, string path) { m_Name = name; m_Type = type; m_Key = key; m_Path = path; }
public AttachmentHeader(string name, string key, RecipeAttachmentType mediaType) { this.name = name; this.key = key; this.mediaType = mediaType; }
public RecipeListEntry(FileInfo recipeFile) { keywords = new List <String>(); attachments = new RecipeAttachmentCollection(); filePath = recipeFile.FullName; XmlReaderSettings settings = new XmlReaderSettings(); using (XmlReader recipeXml = XmlReader.Create(recipeFile.FullName, settings)) { try { // Retrieve the recipe title recipeXml.ReadStartElement("Recipe"); if (recipeXml.ReadToFollowing("Title")) { recipeXml.MoveToContent(); recipeName = recipeXml.ReadElementContentAsString(); } // Retrieve the keywords if (recipeXml.ReadToNextSibling("RecipeKeywords")) { bool success = recipeXml.ReadToDescendant("Keyword"); while (success) { recipeXml.MoveToContent(); keywords.Add(recipeXml.ReadElementContentAsString()); success = recipeXml.ReadToNextSibling("Keyword"); } } // Retrieve the rating if (recipeXml.ReadToFollowing("Rating")) { recipeXml.MoveToContent(); recipeRating = (int)recipeXml.ReadElementContentAs(typeof(int), null); } // Retrieve the Attachments if (recipeXml.ReadToFollowing("Attachments")) { String name = null; String source = null; RecipeAttachmentType type = RecipeAttachmentType.Unknown; bool success = recipeXml.Read(); while (success && recipeXml.NodeType != XmlNodeType.EndElement) { if (recipeXml.NodeType == XmlNodeType.Element) { if (recipeXml.Name == "Picture") { type = RecipeAttachmentType.Photo; } else if (recipeXml.Name == "Video") { type = RecipeAttachmentType.Video; } else { type = RecipeAttachmentType.Unknown; } if (type != RecipeAttachmentType.Unknown) { bool gotAttr = recipeXml.MoveToNextAttribute(); while (gotAttr) { if (recipeXml.Name == "Name") { name = recipeXml.Value.ToString(); } else if (recipeXml.Name == "Source") { source = recipeXml.Value.ToString(); } gotAttr = recipeXml.MoveToNextAttribute(); } RecipeAttachment attachment = new RecipeAttachment(type, name, source, source); attachments.Add(attachment); } } success = recipeXml.Read(); } } } catch (XmlException) { // TODO: what should we do with XML exceptions } } }