public Mapping GetMapping(LinkElement source, LinkElement target) { return(this.GetUnitOfWork().GetReadOnlyRepository <Mapping>().Get().FirstOrDefault(m => m.Source.Id.Equals(source.Id) && m.Source.Type.Equals(source.Type) && m.Target.Id.Equals(target.Id) && m.Target.Type.Equals(target.Type))); }
public LinkElement CreateLinkElement(long elementId, LinkElementType type, LinkElementComplexity complexity, string name, string xpath, bool isSequence = false) { Contract.Requires(elementId >= 0); //LinkElement parent = this.GetLinkElement(parentId); LinkElement linkElement; linkElement = new LinkElement() { ElementId = elementId, Type = type, Name = name, XPath = xpath, IsSequence = isSequence, //Parent = parent, Complexity = complexity, }; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <LinkElement> repo = uow.GetRepository <LinkElement>(); repo.Put(linkElement); uow.Commit(); } return(linkElement); }
public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent) { var elements = new LinkedList<IWikiElement>(); foreach (Match match in _linkExpression.Matches(containerContent.ToString())) { var elementContent = new ElementContent(containerContent, match); var innerContent = new ElementContent(containerContent, match.Groups["content"]); string originalAddress, normalizedAddress; if (match.Groups["url"].Success) { originalAddress = match.Groups["url"].Value; normalizedAddress = FormatUrl(originalAddress); } else if (match.Groups["email"].Success) { originalAddress = match.Groups["email"].Value; normalizedAddress = FormatEmail(originalAddress); } else continue; string text = match.Groups["text"].Success ? match.Groups["text"].Value : originalAddress; bool noFollow = match.Groups["nofollow"].Success; var element = new LinkElement(parsingContext, elementContent, innerContent, normalizedAddress, text, noFollow); elements.AddLast(element); } return elements; }
public static void Run() { // ExStart:CreateStructureElements // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments(); // Create Pdf Document Document document = new Document(); // Get Content for work with TaggedPdf ITaggedContent taggedContent = document.TaggedContent; // Set Title and Language for Documnet taggedContent.SetTitle("Tagged Pdf Document"); taggedContent.SetLanguage("en-US"); // Create Grouping Elements PartElement partElement = taggedContent.CreatePartElement(); ArtElement artElement = taggedContent.CreateArtElement(); SectElement sectElement = taggedContent.CreateSectElement(); DivElement divElement = taggedContent.CreateDivElement(); BlockQuoteElement blockQuoteElement = taggedContent.CreateBlockQuoteElement(); CaptionElement captionElement = taggedContent.CreateCaptionElement(); TOCElement tocElement = taggedContent.CreateTOCElement(); TOCIElement tociElement = taggedContent.CreateTOCIElement(); IndexElement indexElement = taggedContent.CreateIndexElement(); NonStructElement nonStructElement = taggedContent.CreateNonStructElement(); PrivateElement privateElement = taggedContent.CreatePrivateElement(); // Create Text Block-Level Structure Elements ParagraphElement paragraphElement = taggedContent.CreateParagraphElement(); HeaderElement headerElement = taggedContent.CreateHeaderElement(); HeaderElement h1Element = taggedContent.CreateHeaderElement(1); // Create Text Inline-Level Structure Elements SpanElement spanElement = taggedContent.CreateSpanElement(); QuoteElement quoteElement = taggedContent.CreateQuoteElement(); NoteElement noteElement = taggedContent.CreateNoteElement(); // Create Illustration Structure Elements FigureElement figureElement = taggedContent.CreateFigureElement(); FormulaElement formulaElement = taggedContent.CreateFormulaElement(); // Methods are under development ListElement listElement = taggedContent.CreateListElement(); TableElement tableElement = taggedContent.CreateTableElement(); ReferenceElement referenceElement = taggedContent.CreateReferenceElement(); BibEntryElement bibEntryElement = taggedContent.CreateBibEntryElement(); CodeElement codeElement = taggedContent.CreateCodeElement(); LinkElement linkElement = taggedContent.CreateLinkElement(); AnnotElement annotElement = taggedContent.CreateAnnotElement(); RubyElement rubyElement = taggedContent.CreateRubyElement(); WarichuElement warichuElement = taggedContent.CreateWarichuElement(); FormElement formElement = taggedContent.CreateFormElement(); // Save Tagged Pdf Document document.Save(dataDir + "StructureElements.pdf"); // ExEnd:CreateStructureElements }
/// <summary> /// Map a node from xml to system key /// </summary> /// <param name="simpleNodeName">name or xpath</param> /// <param name="simpleType"></param> /// <param name="complexNodeName">name or xpath</param> /// <param name="complexType"></param> /// <param name="key"></param> /// <param name="root"></param> /// <param name="metadataRef"></param> /// <param name="mappingManager"></param> private void createToKeyMapping( string simpleNodeName, LinkElementType simpleType, string complexNodeName, LinkElementType complexType, Key key, Mapping root, XDocument metadataRef, MappingManager mappingManager, TransformationRule transformationRule = null) { if (transformationRule == null) { transformationRule = new TransformationRule(); } LinkElement le = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(key), key.ToString(), LinkElementType.Key, LinkElementComplexity.Simple); if (simpleNodeName.Equals(complexNodeName)) { List <XElement> elements = getXElements(simpleNodeName, metadataRef); foreach (XElement xElement in elements) { string sId = xElement.Attribute("id").Value; string name = xElement.Attribute("name").Value; LinkElement tmp = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(sId), name, simpleType, LinkElementComplexity.Simple); Mapping tmpMapping = MappingHelper.CreateIfNotExistMapping(tmp, le, 1, new TransformationRule(), root, mappingManager); MappingHelper.CreateIfNotExistMapping(tmp, le, 2, transformationRule, tmpMapping, mappingManager); } } else { IEnumerable <XElement> complexElements = getXElements(complexNodeName, metadataRef); foreach (var complex in complexElements) { string sIdComplex = complex.Attribute("id").Value; string nameComplex = complex.Attribute("name").Value; LinkElement tmpComplexElement = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(sIdComplex), nameComplex, complexType, LinkElementComplexity.Complex); Mapping complexMapping = MappingHelper.CreateIfNotExistMapping(tmpComplexElement, le, 1, new TransformationRule(), root, mappingManager); IEnumerable <XElement> simpleElements = XmlUtility.GetAllChildren(complex).Where(s => s.Name.LocalName.Equals(simpleNodeName)); foreach (XElement xElement in simpleElements) { string sId = xElement.Attribute("id").Value; string name = xElement.Attribute("name").Value; LinkElement tmp = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(sId), name, simpleType, LinkElementComplexity.Simple); MappingHelper.CreateIfNotExistMapping(tmp, le, 2, transformationRule, complexMapping, mappingManager); } } } }
public void have_href_attribute() { var link = new LinkElement(null); var writer = XmlWriter.Create(new MemoryStream()); Assert.Throws <AtomSpecificationViolationException>(() => link.WriteXml(writer)); writer.Close(); }
/// <summary> /// Removes the link element from the collection. /// </summary> /// <remarks> /// This member supports the NetRix infrastructure and supports the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </remarks> /// <param name="linkElement"></param> public void Remove(LinkElement linkElement) { if (linkElement == null) { return; } base.List.Remove(linkElement); }
/// <summary> /// Checks if the link element is part of the collection. /// </summary> /// <remarks> /// This member supports the NetRix infrastructure and supports the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </remarks> /// <param name="linkElement"></param> /// <returns></returns> public bool Contains(LinkElement linkElement) { if (linkElement == null) { return(false); } return(List.Contains(linkElement)); }
public IEnumerable <Mapping> GetChildMapping(LinkElement source, LinkElement target, long level) { long parentMappingId = GetMapping(source, target).Id; return(this.GetUnitOfWork().GetReadOnlyRepository <Mapping>().Query().Where(m => m.Parent != null && m.Parent.Id.Equals(parentMappingId) && m.Level.Equals(level))); }
public Mapping CreateMapping( long source_elementId, LinkElementType source_type, LinkElementComplexity source_complexity, string source_name, string source_xpath, long target_elementId, LinkElementType target_type, LinkElementComplexity target_complexity, string target_name, string target_xpath, bool source_isSequence = false, bool target_isSequence = false, TransformationRule rule = null, long parentMappingId = 0 ) { LinkElement source = CreateLinkElement( source_elementId, source_type, source_complexity, source_name, source_xpath, source_isSequence ); LinkElement target = CreateLinkElement( target_elementId, target_type, target_complexity, target_name, target_xpath, target_isSequence ); Mapping mapping = new Mapping(); mapping.Source = source; mapping.Target = target; mapping.TransformationRule = rule; if (parentMappingId > 0) { mapping.Parent = this.GetUnitOfWork().GetReadOnlyRepository <Mapping>().Get(parentMappingId); } using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <Mapping> repo = uow.GetRepository <Mapping>(); repo.Put(mapping); uow.Commit(); } return(mapping); }
public ActionResult SaveMapping(ComplexMappingModel model) { MappingManager mappingManager = new MappingManager(); //save link element if not exits //source try { #region save or update RootMapping //create source Parents if not exist LinkElement sourceParent = MappingHelper.CreateIfNotExistLinkElement(model.Source.Parent, mappingManager); //create source Parents if not exist LinkElement targetParent = MappingHelper.CreateIfNotExistLinkElement(model.Target.Parent, mappingManager); //create root mapping if not exist Mapping rootMapping = MappingHelper.CreateIfNotExistMapping(sourceParent, targetParent, 0, null, null, mappingManager); #endregion #region save or update complex mapping LinkElement source; LinkElement target; //create source source = MappingHelper.CreateIfNotExistLinkElement(model.Source, sourceParent.Id, mappingManager); model.Source.Id = source.Id; model.Source = MappingHelper.LoadChildren(model.Source); //create target target = MappingHelper.CreateIfNotExistLinkElement(model.Target, targetParent.Id, mappingManager); model.Target.Id = target.Id; model.Target = MappingHelper.LoadChildren(model.Target); //save mapping Mapping mapping = MappingHelper.CreateIfNotExistMapping(source, target, 1, null, rootMapping, mappingManager); model.Id = mapping.Id; model.ParentId = mapping.Parent.Id; #endregion #region create or update simple mapping MappingHelper.UpdateSimpleMappings(source.Id, target.Id, model.SimpleMappings, mapping, mappingManager); #endregion //load all mappings return(PartialView("Mapping", model)); } finally { mappingManager.Dispose(); MappingUtils.Clear(); } }
static bool SameLink(IHtmlLinkElement m, LinkElement a) { return(m.Relation == a.Rel && ( (new[] { "canonical", "prev", "next" }.Contains(a.Rel)) || (a.Rel == "icon" && (m.Sizes?.ToString() ?? "") == a.Sizes) || (a.Rel == "alternate" && m.Type == a.Type && m.Media == a.Media) || (Href(m.Href) == a.Href) )); };
// GET: DIM/Mapping public ActionResult Index(long sourceId = 1, long targetId = 0, LinkElementType type = LinkElementType.System) { MappingManager mappingManager = new MappingManager(); try { MappingMainModel model = new MappingMainModel(); // load from mds example model.Source = MappingHelper.LoadFromMetadataStructure(sourceId, LinkElementPostion.Source, mappingManager); switch (type) { case LinkElementType.System: { model.Target = MappingHelper.LoadfromSystem(LinkElementPostion.Target, mappingManager); model.SelectionList = MappingHelper.LoadSelectionList(); break; } case LinkElementType.MetadataStructure: { model.Target = MappingHelper.LoadFromMetadataStructure(targetId, LinkElementPostion.Target, mappingManager); model.SelectionList = MappingHelper.LoadSelectionList(); break; } } if (model.Source != null && model.Target != null) { //get linkelements LinkElement source = mappingManager.GetLinkElement(sourceId, LinkElementType.MetadataStructure); LinkElement target = mappingManager.GetLinkElement(targetId, type); if (source != null && target != null) { //get root mapping Mapping rootMapping = mappingManager.GetMapping(source, target); if (rootMapping != null) { //get complex mappings model.ParentMappings = MappingHelper.LoadMappings(rootMapping); } } } return(View(model)); } finally { mappingManager.Dispose(); } }
public ActionResult Edit(LinkElement linkElement) { LinkElement thelinkElement = db.LinkElements.FirstOrDefault(w => w.Id == linkElement.Id); if (thelinkElement != null) { thelinkElement.Answer = linkElement.Answer; thelinkElement.Question = linkElement.Question; db.SaveChanges(); } return(RedirectToAction("index")); }
static bool SameLink(IHtmlLinkElement m, LinkElement a) { return(m.Relation == a.Rel && (a.Rel switch { "canonical" => true, "prev" => true, "next" => true, "icon" => (m.Sizes?.ToString() ?? "") == (a.Sizes ?? ""), "alternate" => (m.Type ?? "") == (a.Type ?? "") && (m.Media ?? "") == (a.Media ?? ""), "preload" => Href(m.Href) == (a.Href ?? "") && (m.Media ?? "") == (a.Media ?? ""), _ => Href(m.Href) == (a.Href ?? "") }));
public ActionResult Delete(int Id) { LinkElement linkElement = db.LinkElements.Find(Id); if (linkElement == null) { return(HttpNotFound()); } db.LinkElements.Remove(linkElement); db.SaveChanges(); return(RedirectToAction("index")); }
public ActionResult Create(int[] LangId, string[] Question, string[] Answer) { for (int i = 0; i < LangId.Count(); i++) { LinkElement newLinkElement = new LinkElement(); newLinkElement.LangId = LangId[i]; newLinkElement.Question = Question[i]; newLinkElement.Answer = Answer[i]; db.LinkElements.Add(newLinkElement); } db.SaveChanges(); return(RedirectToAction("Index")); }
public static LinkElementModel CreateLinkElementModel(LinkElement le, LinkElementPostion position) { return(new LinkElementModel() { Id = le.Id, ElementId = le.ElementId, XPath = le.XPath, Name = le.Name, Position = position, Type = le.Type, Complexity = le.Complexity }); }
public static Mapping CreateIfNotExistMapping(LinkElement source, LinkElement target, long level, TransformationRule rule, Mapping parent, MappingManager mappingManager) { object tmp = new object(); IEnumerable <Mapping> mappings = tmp.GetUnitOfWork().GetReadOnlyRepository <Mapping>().Get(); Mapping mapping = null; if (parent != null) { mapping = mappings.FirstOrDefault( m => m.Parent != null && m.Parent.Id.Equals(parent.Id) && m.Source.Id.Equals(source.Id) && m.Source.Type.Equals(source.Type) && m.Target.Id.Equals(target.Id) && m.Target.Type.Equals(target.Type) && m.Level.Equals(level)); } else { mapping = mappings.FirstOrDefault( m => m.Parent == null && m.Source.Id.Equals(source.Id) && m.Source.Type.Equals(source.Type) && m.Target.Id.Equals(target.Id) && m.Target.Type.Equals(target.Type) && m.Level.Equals(level)); } if (mapping == null) { if (rule != null && rule.Id == 0 && rule.RegEx != null) { rule = mappingManager.CreateTransformationRule(rule.RegEx, rule.Mask); } mapping = mappingManager.CreateMapping(source, target, level, rule, parent); } else { if (rule != null) { rule = mappingManager.UpdateTransformationRule(rule.Id, rule.RegEx, rule.Mask); mapping.TransformationRule = rule; mappingManager.UpdateMapping(mapping); } } return(mapping); }
public static long GetId(long elementId, LinkElementType type, MappingManager mappingManager) { long linkElementId = 0; LinkElement linkElement = mappingManager.LinkElementRepo.Get() .FirstOrDefault(le => le.ElementId.Equals(elementId) && le.Type.Equals(type)); if (linkElement != null) { linkElementId = linkElement.Id; } return(linkElementId); }
public bool DeleteLinkElement(LinkElement entity) { Contract.Requires(entity != null); Contract.Requires(entity.Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <LinkElement> repo = uow.GetRepository <LinkElement>(); repo.Delete(entity); uow.Commit(); } // if any problem was detected during the commit, an exception will be thrown! return(true); }
/// <summary> /// Adds a new element to the collection. Always set values for CSS (type="text/css" and rel="stylesheet"). /// </summary> /// <remarks> /// This member supports the NetRix infrastructure and supports the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </remarks> /// <param name="linkElement"></param> public void Add(LinkElement linkElement) { if (linkElement == null) { return; } if (linkElement.type == null || linkElement.type.Equals(String.Empty)) { linkElement.type = "text/css"; } if (linkElement.rel == null || linkElement.rel.Equals(String.Empty)) { linkElement.rel = "stylesheet"; } base.List.Add(linkElement); }
public static LinkElementRootModel LoadFromMetadataStructure(long id, LinkElementPostion rootModelType, MappingManager mappingManager) { MetadataStructureManager metadataStructureManager = new MetadataStructureManager(); try { MetadataStructure metadataStructure = metadataStructureManager.Repo.Get(id); LinkElementRootModel model = new LinkElementRootModel(LinkElementType.MetadataStructure, id, metadataStructure.Name, rootModelType); if (metadataStructure != null) { LinkElement metadataStructureLinkElement = mappingManager.GetLinkElement(metadataStructure.Id, LinkElementType.MetadataStructure); long metadataStructureLinkElementId = 0; if (metadataStructureLinkElement != null) { metadataStructureLinkElementId = metadataStructureLinkElement.Id; } LinkElementModel LEModel = new LinkElementModel( metadataStructureLinkElementId, metadataStructure.Id, LinkElementType.MetadataStructure, metadataStructure.Name, "Metadata", rootModelType, LinkElementComplexity.Complex, metadataStructure.Description); foreach (var pUsage in metadataStructure.MetadataPackageUsages) { addUsageAsLinkElement(pUsage, "Metadata", model, LEModel); } model = CreateLinkElementContainerModels(model); model.Id = id; } return(model); } finally { metadataStructureManager.Dispose(); } }
public void GenerateLink(AttributeElement att, AttributesElement gridAtts) { // Process attributes that use links but don't have one already. if (att.Autolink && att.Link == null) { LevelElement levelToLink = FindLevelToLink(att,gridAtts); if (levelToLink != null) { LinkElement link = new LinkElement(); att.Links.Add(link); //link = new LinkElement(); link.Webpanel = levelToLink.View.ObjectName; bool isTemCallBack = false; if (gridAtts.Instance.Settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor) { link.Parameters.Add(new ParameterElement("TrnMode.Update")); } foreach (ParameterElement parameter in levelToLink.View.Parameters) { if (parameter.Name == "&" + HPatternInstance.PARMCALLBACK) { isTemCallBack = true; } link.Parameters.Add(parameter.Clone()); } if (isTemCallBack == false && gridAtts.Instance.Settings.Template.GenerateCallBackLink) { ParameterElement parm = new ParameterElement("&" + HPatternInstance.PARMCALLBACK); parm.Domain = Domain.Get(gridAtts.Instance.Model,HPatternInstance.PARMCALLBACK); link.Parameters.Add(parm); } /* bool isSuperTypeLink = (General.NodeName(attriNode) != levelToLink.Level.DescriptionAttribute); // Avoid self-links. if (IsAcceptableLink(filename, attriNode, levelToLink, isSuperTypeLink)) { attriNode.Attributes["link"].Value = ExtractLinkName(levelToLink.Filename); attriNode.Attributes["level"].Value = levelToLink.Level.Name; if (isSuperTypeLink) AddSupertypeLinkParams(attriNode, levelToLink); } */ } } }
private void createFromPartyTypeMapping( string simpleNodeName, LinkElementType simpleType, string complexNodeName, LinkElementType complexType, PartyCustomAttribute partyCustomAttr, PartyType partyType, Mapping root, XDocument metadataRef, MappingManager mappingManager, TransformationRule transformationRule = null) { if (transformationRule == null) { transformationRule = new TransformationRule(); } LinkElement le = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(partyType.Id), partyType.Title, LinkElementType.PartyType, LinkElementComplexity.Complex); XElement complex = getXElements(complexNodeName, metadataRef).FirstOrDefault(); string sIdComplex = complex.Attribute("id").Value; string nameComplex = complex.Attribute("name").Value; LinkElement tmpComplexElement = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(sIdComplex), nameComplex, complexType, LinkElementComplexity.Complex); Mapping complexMapping = MappingHelper.CreateIfNotExistMapping(le, tmpComplexElement, 1, new TransformationRule(), root, mappingManager); IEnumerable <XElement> simpleElements = XmlUtility.GetAllChildren(complex).Where(s => s.Name.LocalName.Equals(simpleNodeName)); LinkElement simpleLe = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(partyCustomAttr.Id), partyCustomAttr.Name, LinkElementType.PartyCustomType, LinkElementComplexity.Simple); foreach (XElement xElement in simpleElements) { string sId = xElement.Attribute("id").Value; string name = xElement.Attribute("name").Value; LinkElement tmp = createLinkELementIfNotExist(mappingManager, Convert.ToInt64(sId), name, simpleType, LinkElementComplexity.Simple); MappingHelper.CreateIfNotExistMapping(simpleLe, tmp, 2, transformationRule, complexMapping, mappingManager); } }
public static bool IsSimpleElement(long id) { MappingManager mappingManager = new MappingManager(); try { LinkElement le = mappingManager.GetLinkElement(id); if (le.Complexity == LinkElementComplexity.Simple) { return(true); } return(false); } finally { mappingManager.Dispose(); } }
private LinkElement createLinkELementIfNotExist( MappingManager mappingManager, long id, string name, LinkElementType type, LinkElementComplexity complexity) { LinkElement element = mappingManager.GetLinkElement(id, name, type); if (element == null) { element = mappingManager.CreateLinkElement( id, type, complexity, name, "" ); } return(element); }
public override string OnLinkOpen(LinkElement element) { switch (element.Link.Type) { case LinkType.Command: CommandLink command = (CommandLink)element.Link; return(this.prefix.Peek() + "command=" + command.Command + "\n"); case LinkType.Window: WindowLink el = (WindowLink)element.Link; Formatter f = new TextFormatter(this.prefix.Peek() + "| "); return(f.Format(el.Element)); case LinkType.Item: ItemLink item = (ItemLink)element.Link; return(this.prefix.Peek() + "lid=" + item.LowID.ToString() + " hid=" + item.HighID.ToString() + " ql=" + item.Quality.ToString() + "\n"); case LinkType.User: UserLink user = (UserLink)element.Link; return(this.prefix.Peek() + "character=" + user.Character + "\n"); case LinkType.Other: OtherLink other = (OtherLink)element.Link; return(this.prefix.Peek() + "uri=" + other.Uri.ToString() + "\n"); case LinkType.Invalid: InvalidLink invalid = (InvalidLink)element.Link; return(this.prefix.Peek() + "uri=" + invalid.Raw + "\n"); default: return(this.prefix.Peek() + "unknown LinkType: " + element.Link.Type.ToString() + "\n"); } }
public static SimpleMappingModel CreateSimpleMappingModel(Mapping mapping, LinkElement source, LinkElement target) { LinkElementModel sourceModel = CreateLinkElementModel(source, LinkElementPostion.Source); LinkElementModel targetModel = CreateLinkElementModel(target, LinkElementPostion.Target); TransformationRuleModel transformationRuleModel = null; if (mapping.TransformationRule != null) { transformationRuleModel = new TransformationRuleModel(); transformationRuleModel.Id = mapping.TransformationRule.Id; transformationRuleModel.RegEx = mapping.TransformationRule.RegEx; transformationRuleModel.Mask = mapping.TransformationRule.Mask; } else { transformationRuleModel = new TransformationRuleModel(); } long parentId = 0; if (mapping.Parent != null) { parentId = mapping.Parent.Id; } //ToDo Load Rules return(new SimpleMappingModel() { Id = mapping.Id, Source = sourceModel, Target = targetModel, TransformationRule = transformationRuleModel, ParentId = parentId }); }
private static Metadata ParseMetadata(XElement element) { Metadata result = null; if (element != null && element.Name.LocalName == ELEMENT_METADATA) { result = new Metadata(); foreach (var childElement in element.Elements()) { if (childElement.Name.Namespace == NAMESPACE_DC) { var dcElement = new DcElement { Id = childElement.Attribute(ATTRIBUTE_ID)?.Value, Language = childElement.Attribute(Const.ATTRIBUTE_LANGUAGE)?.Value, Dir = childElement.Attribute(ATTRIBUTE_DIR)?.Value, Value = childElement.Value }; switch (childElement.Name.LocalName) { case DC_ELEMENT_CONTRIBUTOR: result.Contributors.Add(dcElement); break; case DC_ELEMENT_COVERAGE: result.Coverages.Add(dcElement); break; case DC_ELEMENT_CREATOR: result.Creators.Add(dcElement); break; case DC_ELEMENT_DATE: result.Date = dcElement; break; case DC_ELEMENT_DESCRIPTION: result.Descriptions.Add(dcElement); break; case DC_ELEMENT_FORMAT: result.Formats.Add(dcElement); break; case DC_ELEMENT_IDENTIFIER: result.Identifiers.Add(dcElement); break; case DC_ELEMENT_LANGUAGE: result.Languages.Add(dcElement); break; case DC_ELEMENT_PUBLISHER: result.Publishers.Add(dcElement); break; case DC_ELEMENT_RELATION: result.Relations.Add(dcElement); break; case DC_ELEMENT_RIGHTS: result.Rights.Add(dcElement); break; case DC_ELEMENT_SOURCE: result.Sources.Add(dcElement); break; case DC_ELEMENT_SUBJECT: result.Subjects.Add(dcElement); break; case DC_ELEMENT_TITLE: result.Titles.Add(dcElement); break; case DC_ELEMENT_TYPE: result.Types.Add(dcElement); break; default: break; } } else { switch (childElement.Name.LocalName) { case ELEMENT_META: { var metaElement = new MetaElement { Id = childElement.Attribute(ATTRIBUTE_ID)?.Value, Language = childElement.Attribute(Const.ATTRIBUTE_LANGUAGE)?.Value, Dir = childElement.Attribute(ATTRIBUTE_DIR)?.Value, Scheme = childElement.Attribute(ATTRIBUTE_SCHEME)?.Value, Property = childElement.Attribute(ATTRIBUTE_PROPERTY)?.Value, Refines = childElement.Attribute(ATTRIBUTE_REFINES)?.Value, Value = childElement.Value, Name = childElement.Attribute(ATTRIBUTE_NAME)?.Value, Content = childElement.Attribute(ATTRIBUTE_CONTENT)?.Value, }; result.Metas.Add(metaElement); } break; case ELEMENT_LINK: { var linkElement = new LinkElement { Href = childElement.Attribute(ATTRIBUTE_HREF)?.Value, Rel = childElement.Attribute(ATTRIBUTE_REL)?.Value, Id = childElement.Attribute(ATTRIBUTE_ID)?.Value, Refines = childElement.Attribute(ATTRIBUTE_REFINES)?.Value, MediaType = childElement.Attribute(ATTRIBUTE_MEDIATYPE)?.Value, }; result.Links.Add(linkElement); } break; default: break; } } } } return(result); }
public override string OnLinkClose(LinkElement element) { return(""); }
public override string OnLinkOpen(LinkElement element) { return(""); }