public static MvcHtmlString FeedUrl(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); DexterModelBase model = (DexterModelBase)helper.ViewData.Model; return(new MvcHtmlString(string.Format("<link href=\"{0}\" rel=\"alternate\" type=\"application/rss+xml\" title=\"{1}\" />", u.Feed.MainFeed(), model.Title))); }
public static MvcHtmlString Index(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); DexterModelBase model = (DexterModelBase)helper.ViewData.Model; return(new MvcHtmlString(string.Format("<link rel=\"index\" title=\"{0}\" href=\"{1}\" />", model.Title, u.Home))); }
private void BuildSyndicationFeed(object models, Stream stream, string contenttype) { List <PostDto> urls = new List <PostDto>(); if (models is IEnumerable <ItemDto> ) { urls.AddRange((IEnumerable <PostDto>)models); } else { urls.Add((PostDto)models); } BlogConfigurationDto config = DexterContainer.Resolve <IConfigurationService>().GetConfiguration(); //Main info SyndicationFeed feed = new SyndicationFeed { Title = new TextSyndicationContent(config.Name), Description = new TextSyndicationContent(config.SeoConfiguration.DefaultDescription ?? config.Name), Copyright = new TextSyndicationContent(String.Format("{0} (c) {1}", config.SeoConfiguration.CopyRight, DateTime.Now.Year)) }; //Adding link feed.Links.Add(new SyndicationLink(this.UrlBuilder.Home)); //Adding categoris config.SeoConfiguration.DefaultKeyWords.ForEach(keyword => feed.Categories.Add(new SyndicationCategory(keyword))); if (urls.Any()) { feed.LastUpdatedTime = urls.OrderByDescending(model => model.PublishAt).First().PublishAt; //Adding authors urls.GroupBy(x => x.Author).Select(x => x.Key) .ForEach(author => feed.Authors.Add(new SyndicationPerson(null, author, this.UrlBuilder.Home))); } //Adding items List <SyndicationItem> items = new List <SyndicationItem>(); urls.ForEach(item => items.Add(this.BuildSyndicationItem(item))); feed.Items = items; using (XmlWriter writer = XmlWriter.Create(stream)) { if (string.Equals(contenttype, Atom)) { Atom10FeedFormatter atomformatter = new Atom10FeedFormatter(feed); atomformatter.WriteTo(writer); } else { Rss20FeedFormatter rssformatter = new Rss20FeedFormatter(feed); rssformatter.WriteTo(writer); } } }
public static MvcHtmlString WindowsLiveWriterManifest(this HtmlHelper helper) { IUrlBuilder urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); string tag = string.Format(@"<link rel=""wlwmanifest"" type=""application/wlwmanifest+xml"" href=""{0}/wlwmanifest.xml""/>", urlBuilder.Home); return(new MvcHtmlString(tag)); }
public void ResolveByGenerics_ShouldInvokeMockMethod() { DexterContainer.SetCurrent(this.mockContainer.Object); DexterContainer.Resolve <DexterContainerTest>(); this.mockContainer.Verify(x => x.Resolve <DexterContainerTest>(), Times.Once()); }
public static MvcHtmlString OpenSearch(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); DexterModelBase model = (DexterModelBase)helper.ViewData.Model; return(new MvcHtmlString(string.Format("<link href=\"{0}\" rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"{1}\" />", u.Service.OpenSearch(), model.Title))); }
public void ResolveByTypeAndKey_WithValidData_ShouldInvokeMockMethod() { DexterContainer.SetCurrent(this.mockContainer.Object); DexterContainer.Resolve(typeof(DexterContainerTest)); this.mockContainer.Verify(x => x.Resolve(typeof(DexterContainerTest)), Times.Once()); }
public MetaWeblogHandler() { this.categoryService = DexterContainer.Resolve <ICategoryService>(); this.configurationService = DexterContainer.Resolve <IConfigurationService>(); this.pageService = DexterContainer.Resolve <IPageService>(); this.postService = DexterContainer.Resolve <IPostService>(); this.routingService = DexterContainer.Resolve <IRoutingService>(); this.urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); }
public void EnablePlugin(string pluginId, Version version) { PluginDto plugin = this.pluginDataService.GetPlugin(pluginId, version); if (plugin == null) { throw new DexterException("Unable to find the specified plugin"); } string pluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\Extensions\Plugins", plugin.Title, @"\Assemblies"); if (!Directory.Exists(pluginPath)) { throw new DirectoryNotFoundException(string.Format("Unable to find the specified path '{0}'.", pluginPath)); } string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.TopDirectoryOnly); if (files.Length < 1) { this.logger.WarnFormat("Unable to find the assemblies for the plugin '{0}'", plugin.Title); return; } foreach (var file in files) { var pluginAssemblies = Assembly.LoadFrom(file); Type pluginType = pluginAssemblies.GetTypes().FirstOrDefault(t => !t.IsInterface && !t.IsAbstract && typeof(IPlugin).IsAssignableFrom(t)); if (pluginType == null) { logger.DebugFormat("The is not an IPlugin for the assemly '{0}' for the plugin '{1}'.", Path.GetFileName(file), plugin.Title); continue; } container.Register(pluginType, pluginType, LifeCycle.Singleton); var pluginInstance = (IPlugin)DexterContainer.Resolve(pluginType); if (!plugin.IsInstalled) { logger.DebugFormat("Calling Setup method for '{0}' for the plugin '{1}'.", pluginType, plugin.Title); pluginInstance.Setup(); plugin.IsInstalled = true; } logger.DebugFormat("Calling Initialize method for '{0}' for the plugin '{1}'.", pluginType, plugin.Title); pluginInstance.Initialize(); plugin.Enabled = true; } this.pluginDataService.UpdatePlugin(plugin); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Web.HttpApplication"/> class. /// </summary> public DexterApplication() { this.logger = LogManager.GetCurrentClassLogger(); DexterContainer.StartUp(); this.container = DexterContainer.Resolve <IDexterContainer>(); this.dexterCall = DexterContainer.Resolve <IDexterCall>(); this.routingService = DexterContainer.Resolve <IRoutingService>(); this.taskExecutor = DexterContainer.Resolve <ITaskExecutor>(); this.pluginService = DexterContainer.Resolve <IPluginService>(); this.pluginService.LoadAllEnabledPlugins(); base.BeginRequest += (o, args) => this.BeginRequest(); base.EndRequest += (o, args) => this.EndRequest(); this.Init(); }
private static Action CreateNewAction(Action call) { return(delegate { IDexterCall dexterCall = DexterContainer.Resolve <IDexterCall>(); dexterCall.StartSession(); try { call.Invoke(); dexterCall.Complete(true); } catch { dexterCall.Complete(false); throw; } }); }
public static MvcHtmlString TrackBackRdf(this HtmlHelper helper, PostDto item) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); BlogConfigurationDto c = DexterContainer.Resolve <IConfigurationService>().GetConfiguration(); if (!c.Tracking.EnableTrackBackReceive) { return(MvcHtmlString.Empty); } StringBuilder sb = new StringBuilder(); sb.Append("<!--"); sb.Append("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">"); sb.AppendLine(); sb.AppendFormat("<rdf:Description rdf:about=\"{0}\" dc:identifier=\"{0}\" dc:title=\"{1}\" trackback:ping=\"{2}\" />", u.Post.Permalink(item), item.Title, u.Post.TrackBack(item)); sb.AppendLine("</rdf:RDF>"); sb.AppendLine("-->"); return(MvcHtmlString.Create(sb.ToString())); }
private static Func <T> CreateNewFunc <T>(Func <T> call) { return(delegate { IDexterCall dexterCall = DexterContainer.Resolve <IDexterCall>(); dexterCall.StartSession(); try { T returnObject = call.Invoke(); dexterCall.Complete(true); return returnObject; } catch { dexterCall.Complete(false); throw; } }); }
public static MvcHtmlString CreateMenu(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); StringBuilder sb = new StringBuilder(); sb.Append("<ul class=\"container_12\">"); AddHome(sb, u, helper.ViewContext); AddPost(sb, u, helper.ViewContext); AddComments(sb, u, helper.ViewContext); //AddStats(sb, u, helper.ViewContext); AddSettigns(sb, u, helper.ViewContext); //Addbackup(sb, u, helper.ViewContext); AddUsers(sb, u, helper.ViewContext); sb.Append("</li>"); sb.Append("</ul>"); return(MvcHtmlString.Create(sb.ToString())); }
public TrackbackHelper() { urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); configurationService = DexterContainer.Resolve <IConfigurationService>(); logger = LogManager.GetCurrentClassLogger(); }
public override void InitHelpers() { base.InitHelpers(); this.urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); }
public void ResolveByType_WithNullType_ShouldThrowArgumenNullException() { Executing.This(() => DexterContainer.Resolve(null)).Should().Throw <ArgumentNullException>(); }
public static MvcHtmlString MetaWeblogRsd(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); return(new MvcHtmlString(string.Format("<link href=\"{0}\" rel=\"EditURI\" type=\"application/rsd+xml\" title=\"RSD\" />", u.Service.MetaWeblogRsd()))); }
public static MvcHtmlString PingBack(this HtmlHelper helper) { IUrlBuilder u = DexterContainer.Resolve <IUrlBuilder>(); return(new MvcHtmlString(string.Format("<link href=\"{0}\" rel=\"pingback\" />", u.Service.Pingback()))); }
static PingbackHelper() { urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); }
static PingHelper() { pingDataService = DexterContainer.Resolve <IPingDataService>(); configurationDataService = DexterContainer.Resolve <IConfigurationDataService>(); }
public PublishedBackgroundTask(ItemDto item) : this(item, DexterContainer.Resolve <IConfigurationDataService>()) { }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Web.Caching.OutputCacheProvider" /> class. /// </summary> public DexterOutputCacheProvider() { this.provider = DexterContainer.Resolve <ICacheProvider>(); }
/// <summary> /// Creates the helpers. /// </summary> protected void CreateHelpers() { this.urlBuilder = DexterContainer.Resolve <IUrlBuilder>(); }