当前位置: 首页>>代码示例>>C#>>正文


C# N2类代码示例

本文整理汇总了C#中N2的典型用法代码示例。如果您正苦于以下问题:C# N2类的具体用法?C# N2怎么用?C# N2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


N2类属于命名空间,在下文中一共展示了N2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplaceContent

		private void ReplaceContent(N2.Engine.IEngine factory)
		{
			var installer = factory.Resolve<N2.Edit.Installation.InstallationManager>();
			installer.Install();
			var root = installer.InsertExportFile(File.OpenRead(HttpContext.Current.Server.MapPath("~/App_Data/Demo.n2.xml.gz")), "Concrete_SampleData.gz");
			if (root.ID != factory.Host.DefaultSite.RootItemID)
				factory.Host.DefaultSite.RootItemID = root.ID;
			foreach (ContentItem item in root.Children)
			{
				if (item.ID == factory.Host.DefaultSite.StartPageID && item is StartPage)
				{
					CreateDemoPanel(factory, item);
					return;
				}
			}

			foreach (ContentItem item in root.Children)
			{
				if (item is StartPage)
				{
					CreateDemoPanel(factory, item);
					factory.Host.DefaultSite.StartPageID = item.ID;
					return;
				}
			}
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:26,代码来源:DemoInitializer.cs

示例2: UpdateEditor

        public override void UpdateEditor(N2.ContentItem item, Control editor)
        {
            if (item == null)
                throw new ArgumentNullException("item", "item is null.");
            if (editor == null)
                throw new ArgumentNullException("editor", "editor is null.");

            ListBox lb = (ListBox)editor;
            string currentlySelectedItemsString = (string)item[this.Name] ?? string.Empty;

            if (!string.IsNullOrEmpty(currentlySelectedItemsString))
            {
                string[] currentlySelectedItems = currentlySelectedItemsString.Split(ItemSeperator);
                if (currentlySelectedItems.Length > 0)
                {
                    foreach (string currentItem in currentlySelectedItems)
                    {
                        ListItem listItem = lb.Items.FindByValue(currentItem);

                        if (listItem != null)
                            listItem.Selected = true;
                    }
                }
            }
        }
开发者ID:jamestharpe,项目名称:HereSay,代码行数:25,代码来源:EditableListBoxAttribute.cs

示例3: Tracker

 public Tracker(Persistence.IPersister persister, Persistence.Finder.IItemFinder find, N2.Web.IUrlParser urlParser, N2.Web.IErrorHandler errorHandler)
 {
     this.persister = persister;
     this.find = find;
     this.urlParser = urlParser;
     this.errorHandler = errorHandler;
 }
开发者ID:spmason,项目名称:n2cms,代码行数:7,代码来源:Tracker.cs

示例4: CreateQuery

        protected virtual Lucene.Net.Search.Query CreateQuery(N2.Persistence.Search.Query query)
        {
            var q = "";
            if(!string.IsNullOrEmpty(query.Text))
                q = query.OnlyPages.HasValue
                     ? string.Format("+(Title:({0})^4 Text:({0}) PartsText:({0}))", query.Text)
                     : string.Format("+(Title:({0})^4 Text:({0}))", query.Text);

            if (query.Ancestor != null)
                q += string.Format(" +Trail:{0}*", Utility.GetTrail(query.Ancestor));
            if(query.OnlyPages.HasValue)
                q += string.Format(" +IsPage:{0}", query.OnlyPages.Value.ToString().ToLower());
            if (query.Roles != null)
                q += string.Format(" +Roles:(Everyone {0})", string.Join(" ", query.Roles.ToArray()));
            if (query.Types != null)
                q += string.Format(" +Types:({0})", string.Join(" ", query.Types.Select(t => t.Name).ToArray()));
            if (query.LanguageCode != null)
                q += string.Format(" +Language:({0})", query.LanguageCode);
            if (query.Exclution != null)
                q += string.Format(" -({0})", CreateQuery(query.Exclution));
            if (query.Intersection != null)
                q = string.Format("+({0}) +({1})", q, CreateQuery(query.Intersection));
            if (query.Union != null)
                q = string.Format("({0}) ({1})", q, CreateQuery(query.Union));

            Trace.WriteLine("CreateQuery: " + q);

            return accessor.GetQueryParser().Parse(q);
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:29,代码来源:LuceneSearcher.cs

示例5: AddDefinedEditors

        public override IDictionary<string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, N2.ContentItem item, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, Type containerTypeFilter, IEnumerable<string> editableNameFilter)
        {
            ItemDefinition cloned = null;

            // add a "wrap in container" checkbox to all parts that are within zones that are not wrapped in a container (BeforeMain, AfterMain).
            if (!definition.IsPage)
            {
                if (!(Defaults.IsContainerWrappable(item.ZoneName) ||
                      Defaults.IsContainerWrappable(System.Web.HttpContext.Current.Request["zoneName"])))
                {
                    cloned = definition.Clone();
                    var isWrappable = cloned.Editables.FirstOrDefault(x => x.Name == "UseContainer");
                    if (isWrappable != null)
                    {
                        cloned.Editables.Remove(isWrappable);
                    }
                }
            }

            if (item is IItemAdapter)
            {
                var result = (item as IItemAdapter).AddDefinedEditors(cloned ?? definition, container, user, containerTypeFilter, editableNameFilter);
                if (result != null)
                    return result;
            }
            return base.AddDefinedEditors(cloned ?? definition, item, container, user, containerTypeFilter, editableNameFilter);
        }
开发者ID:n2cms,项目名称:N2Bootstrap,代码行数:27,代码来源:ModelAdapter.cs

示例6: Persister_SitemapChangeNeeded

        static void Persister_SitemapChangeNeeded(object sender, N2.ItemEventArgs e)
        {
            DateTime published = e.AffectedItem.Published.GetValueOrDefault(DateTime.MaxValue);
            bool ignoreChange =
                published > DateTime.Now ||
                !e.AffectedItem.IsPage ||
                !AutoDefineOnType(e.AffectedItem.GetType());

            if (ignoreChange)
                return;

            IEnumerable<N2.ContentItem> sitemaps = Find.Items
                .Where
                // Add back when legacy compatibility is no longer an issue: .Type.Eq(typeof(SitemapXml))
                    .Type.NotEq(typeof(WebPage))
                //TODO: Remove all these Type.NotEq lines when we add back the .Type.Eq(typeof(SitemapXml)) line
                    .And.Type.NotEq(typeof(CustomContent))
                    .And.Type.NotEq(typeof(CustomCssContent))
                    .And.Type.NotEq(typeof(CustomHtmlContent))
                    .And.Type.NotEq(typeof(FeedPage))
                    .And.Type.NotEq(typeof(HomePage))
                    .And.Type.NotEq(typeof(LanguageHomePage))
                    .And.Type.NotEq(typeof(LanguageHomeRedirectPage))
                    .And.Type.NotEq(typeof(RedirectPage))
                    .And.IsPublished()
                .Select<N2.ContentItem>();
                //.Where(item => item.GetType().IsAssignableFrom(typeof(SitemapXml)))
                //.Cast<SitemapXml>();

            foreach (N2.ContentItem sitemap in sitemaps)
            {
                if(sitemap is SitemapXml)
                    ((SitemapXml)sitemap).Regenerate(Find.StartPage);
            }
        }
开发者ID:jamestharpe,项目名称:HereSay,代码行数:35,代码来源:SitemapDecorator.cs

示例7: Search

        public Result Search(N2.Persistence.Search.Query query)
        {
            if (!query.IsValid())
                return Result.Empty;

            var s = accessor.GetSearcher();
            try
            {
                var q = CreateQuery(query);
                var hits = s.Search(q, query.SkipHits + query.TakeHits);

                var result = new Result();
                result.Total = hits.totalHits;
                var resultHits = hits.scoreDocs.Skip(query.SkipHits).Take(query.TakeHits).Select(hit =>
                {
                    var doc = s.Doc(hit.doc);
                    int id = int.Parse(doc.Get("ID"));
                    ContentItem item = persister.Get(id);
                    return new Hit { Content = item, Score = hit.score };
                }).Where(h => h.Content != null).ToList();
                result.Hits = resultHits;
                result.Count = resultHits.Count;
                return result;
            }
            finally
            {
                //s.Close();
            }
        }
开发者ID:wrohrbach,项目名称:n2cms,代码行数:29,代码来源:LuceneSearcher.cs

示例8: GetItemsInZone

        public override ItemList GetItemsInZone(N2.ContentItem parentItem, string zoneName)
        {
            ItemList items = base.GetItemsInZone(parentItem, zoneName);
            if (zoneName.StartsWith("Sectional") && parentItem != null && parentItem.IsPage)
                items.AddRange(GetItemsInZone(parentItem.GetSafeParent(), zoneName));

            return items;
        }
开发者ID:Codeseer,项目名称:HereSay,代码行数:8,代码来源:SectionalZoneDecorator.cs

示例9: Initialize

        /// <summary>
        /// Implements <see cref="N2.Plugin.IPluginInitializer.Initialize"/> to register the 
        /// instance with N2 under its full type name.
        /// </summary>
        /// <param name="engine">Specifies the <see cref="N2.Engine.IEngine"/> instance to register
        /// the plug-in with.</param>
        public virtual void Initialize(N2.Engine.IEngine engine)
        {
            Type type = this.GetType();
            string fullName = type.FullName;
            engine.Container.AddComponent(fullName, type, type);

            Debug.WriteLine(fullName + " initialized.");
        }
开发者ID:Codeseer,项目名称:HereSay,代码行数:14,代码来源:PluginInitializer.cs

示例10: Regenerate

        protected internal void Regenerate(N2.ContentItem startingPoint)
        {
            if (startingPoint == null)
                throw new ArgumentNullException("startingPoint", "startingPoint is null.");

            this.SetDetail<string>(XmlKey, this.GenerateXml(startingPoint));
            N2.Context.Persister.Save(this);
        }
开发者ID:Codeseer,项目名称:HereSay,代码行数:8,代码来源:SitemapXml.cs

示例11: UpdateRootPage

 private static void UpdateRootPage(N2.Engine.IEngine engine, ContentItem imported, ContentItem startPage)
 {
     startPage.Title = imported.Title;
     startPage.Name = imported.Name;
     foreach (N2.Details.ContentDetail detail in imported.Details.Values)
         startPage[detail.Name] = detail.Value;
     engine.Persister.Save(startPage);
 }
开发者ID:spmason,项目名称:n2cms,代码行数:8,代码来源:DemoInitializer.cs

示例12: IsAllowed

 public N2.Definitions.AllowedDefinitionResult IsAllowed(N2.Definitions.AllowedDefinitionQuery query)
 {
     if (query.ChildDefinition.ItemType.IsAssignableFrom(typeof (BlogContainer)))
     {
         return AllowedDefinitionResult.Deny;
     }
     return AllowedDefinitionResult.DontCare;
 }
开发者ID:pauldotknopf,项目名称:N2Bootstrap.Blog,代码行数:8,代码来源:BlogContainerIntegrityAttribute.cs

示例13: Match

        public override bool Match(N2.ContentItem item)
        {
            if (existing.ContainsKey(item.ID))
                return false;

            existing.Add(item.ID, true);
            return true;
        }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:8,代码来源:DuplicateFilter.cs

示例14: Initialize

 public void Initialize(N2.Engine.IEngine engine)
 {
     // When using Dinamico check out /Dinamico/GlobalMvcStarter.cs which
     // configures these settings specifically for Dinamico
     RegisterControllerFactory(ControllerBuilder.Current, engine);
     RegisterRoutes(RouteTable.Routes, engine);
     RegisterViewEngines(ViewEngines.Engines);
     RegisterViewTemplates(engine);
 }
开发者ID:competentninja,项目名称:n2cms-website,代码行数:9,代码来源:CmsConfig.cs

示例15: Initialize

		public void Initialize(N2.Engine.IEngine engine)
		{
			//log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~/N2/Installation/log4net.config")));

			RegisterControllerFactory(ControllerBuilder.Current, engine);
			RegisterRoutes(RouteTable.Routes, engine);
			RegisterViewEngines(ViewEngines.Engines);
			RegisterViewTemplates(engine);
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:9,代码来源:GlobalMvcStarter.cs


注:本文中的N2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。