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)));
        }
        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 void RegisterByGenericsByAssemblyByLifeCycleEnum_WithNullAssembly_ShouldThrowArgumentNullException()
 {
     Executing.This(() =>
                    DexterContainer.Register <DexterContainerTest>(null, LifeCycle.Singleton))
     .Should()
     .Throw <ArgumentNullException>();
 }
        public void Release_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Release(this);
            this.mockContainer.Verify(x => x.Release(this), Times.Once());
        }
        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 void ResolveAll_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.ResolveAll <DexterContainerTest>();

            this.mockContainer.Verify(x => x.ResolveAll <DexterContainerTest>(), Times.Once());
        }
        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 ResolveByTypeAndKey_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Resolve(typeof(DexterContainerTest));

            this.mockContainer.Verify(x => x.Resolve(typeof(DexterContainerTest)), Times.Once());
        }
        public void Configure_ShouldCallConfigureFromMockEngine()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Configure("myConfig");

            this.mockContainer.Verify(x => x.Configure("myConfig"), Times.Once());
        }
        public void RegisterComponentsByBaseClass_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.RegisterComponentsByBaseClass <DexterContainerTest>(this.GetType().Assembly, LifeCycle.Singleton);

            this.mockContainer.Verify(x => x.RegisterComponentsByBaseClass <DexterContainerTest>(this.GetType().Assembly, LifeCycle.Singleton));
        }
        public void HasComponentByKey_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.HasComponent(typeof(DexterContainer));

            this.mockContainer.Verify(x => x.HasComponent(typeof(DexterContainer)), 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 RegisterByGenericsByKeyAndLifeCycleEnum_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Register <DexterContainerTest, DexterContainerTest>(LifeCycle.Singleton);

            this.mockContainer.Verify(x => x.Register <DexterContainerTest, DexterContainerTest>(LifeCycle.Singleton), Times.Once());
        }
        public void ResolveAllByType_WithValidData_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.ResolveAll(typeof(DexterContainerTest));

            this.mockContainer.Verify(x => x.ResolveAll(typeof(DexterContainerTest)));
        }
        public void ResolveByGenerics_ShouldInvokeMockMethod()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Resolve <DexterContainerTest>();

            this.mockContainer.Verify(x => x.Resolve <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);
        }
Beispiel #18
0
        /// <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();
        }
Beispiel #19
0
        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()));
        }
Beispiel #21
0
        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()));
        }
Beispiel #23
0
        public override void InitHelpers()
        {
            base.InitHelpers();

            this.urlBuilder = DexterContainer.Resolve <IUrlBuilder>();
        }
 public void RegisterByKeyAndTypeAndTypeAndLifeCycleEnum_WithNullImplementedType_ShouldThrowArgumentNullException()
 {
     Executing.This(() => DexterContainer.Register(typeof(DexterContainerTest), null, LifeCycle.Singleton)).Should().Throw <ArgumentNullException>();
 }
 static PingHelper()
 {
     pingDataService          = DexterContainer.Resolve <IPingDataService>();
     configurationDataService = DexterContainer.Resolve <IConfigurationDataService>();
 }
Beispiel #26
0
 static PingbackHelper()
 {
     urlBuilder = DexterContainer.Resolve <IUrlBuilder>();
 }
 public void RegisterComponentsByBaseClass_WithNullAssembly_ShouldThrowArgumentNullException()
 {
     Executing.This(() => DexterContainer.RegisterComponentsByBaseClass <DexterContainerTest>(null, LifeCycle.Singleton)).Should().Throw <ArgumentNullException>();
 }
        public void SetCurrent_ShouldChangeTheCurrentContainer()
        {
            DexterContainer.SetCurrent(this.mockContainer.Object);

            DexterContainer.Engine.Should().Be.EqualTo(this.mockContainer.Object);
        }
 public void ResolveByType_WithNullType_ShouldThrowArgumenNullException()
 {
     Executing.This(() => DexterContainer.Resolve(null)).Should().Throw <ArgumentNullException>();
 }
 public void Release_WithNullInstance_ShouldThrowArgumentNullExceprtion()
 {
     Executing.This(() => DexterContainer.Release(null)).Should().Throw <ArgumentNullException>();
 }