Esempio n. 1
0
        protected virtual void BuildArticleCore(IHostService host, FileModel model, IModelAttributeHandler handlers = null, HandleModelAttributesContext handlerContext = null, bool shouldSkipMarkup = false)
        {
            if (handlers == null)
            {
                handlers = _defaultHandler;
            }
            if (handlerContext == null)
            {
                handlerContext = new HandleModelAttributesContext
                {
                    EnableContentPlaceholder = false,
                    Host        = host,
                    FileAndType = model.OriginalFileAndType,
                    SkipMarkup  = shouldSkipMarkup,
                };
            }

            handlers.Handle(model.Content, handlerContext);

            model.LinkToUids      = model.LinkToUids.Union(handlerContext.LinkToUids);
            model.LinkToFiles     = model.LinkToFiles.Union(handlerContext.LinkToFiles);
            model.FileLinkSources = model.FileLinkSources.ToDictionary(v => v.Key, v => v.Value.ToList())
                                    .Merge(handlerContext.FileLinkSources.Select(i => new KeyValuePair <string, IEnumerable <LinkSourceInfo> >(i.Key, i.Value)))
                                    .ToImmutableDictionary(v => v.Key, v => v.Value.ToImmutableList());
            model.UidLinkSources = model.UidLinkSources.ToDictionary(v => v.Key, v => v.Value.ToList())
                                   .Merge(handlerContext.UidLinkSources.Select(i => new KeyValuePair <string, IEnumerable <LinkSourceInfo> >(i.Key, i.Value)))
                                   .ToImmutableDictionary(v => v.Key, v => v.Value.ToImmutableList());
        }
Esempio n. 2
0
 protected ApplyOverwriteDocument()
 {
     _merger  = new MergerFacade(GetMerger());
     _handler = new CompositeModelAttributeHandler(
         new UniqueIdentityReferenceHandler(),
         new MarkdownContentHandler()
         );
 }
Esempio n. 3
0
        protected BaseModelAttributeHandler(Type type, IModelAttributeHandler handler)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }
            _type     = type;
            _typeInfo = GetTypeInfo(type);
            Handler   = handler;
        }
Esempio n. 4
0
 public UniqueIdentityHandlerImpl(Type type, IModelAttributeHandler handler) : base(type, handler)
 {
 }
Esempio n. 5
0
 public MarkdownContentHandlerImpl(Type type, IModelAttributeHandler handler) : base(type, handler)
 {
 }