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


C# Database.GetDataProviders方法代码示例

本文整理汇总了C#中Database.GetDataProviders方法的典型用法代码示例。如果您正苦于以下问题:C# Database.GetDataProviders方法的具体用法?C# Database.GetDataProviders怎么用?C# Database.GetDataProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


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

示例1: TransferPath

 public static void TransferPath(string itemPath, Database sourceDatabase, Database targetDatabase, Action<string> callback)
 {
     var item = sourceDatabase.GetItem(itemPath);
     var dataProvider = targetDatabase.GetDataProviders().First() as DataProviderWrapper;
     TransferAncestors(item.Parent, dataProvider, callback);
     TransferItemAndDescendants(item, dataProvider, callback);
 }
开发者ID:dsolovay,项目名称:SitecoreData,代码行数:7,代码来源:TransferUtil.cs

示例2: CreateTestProvider

		// TODO

		private UnicornDataProvider CreateTestProvider(Database db, ITargetDataStore targetDataStore = null, ISourceDataStore sourceDataStore = null, IPredicate predicate = null, IFieldFilter filter = null, IUnicornDataProviderLogger logger = null, bool enableTransparentSync = false)
		{
			if (predicate == null)
			{
				predicate = CreateInclusiveTestPredicate();
			}

			if (filter == null)
			{
				filter = Substitute.For<IFieldFilter>();
				filter.Includes(Arg.Any<Guid>()).Returns(true);
			}

			targetDataStore = targetDataStore ?? Substitute.For<ITargetDataStore>();
			sourceDataStore = sourceDataStore ?? Substitute.For<ISourceDataStore>();

			var dp = new UnicornDataProvider(targetDataStore, 
				sourceDataStore, 
				predicate, 
				filter, 
				logger ?? Substitute.For<IUnicornDataProviderLogger>(), 
				new DefaultUnicornDataProviderConfiguration(enableTransparentSync), 
				new PredicateRootPathResolver(predicate, targetDataStore, sourceDataStore, Substitute.For<ILogger>()));
			
			dp.ParentDataProvider = db.GetDataProviders().First();

			return dp;
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:30,代码来源:UnicornDataProviderTests.cs

示例3: GetSqlProvider

        /// <summary>
        /// Gets the base SQL provider that will store physical items
        /// </summary>
        /// <param name="db"></param>
        /// <returns></returns>
        private DataProvider GetSqlProvider(Database db)
        {
            var providers = db.GetDataProviders();
            var provider = providers.FirstOrDefault(x => x is SqlDataProvider);

            if (provider == null)
            {
                Sitecore.Diagnostics.Log.Error("Failed to find SqlDataProvider", this);
                throw new RequiredObjectIsNullException("Failed to find SqlDataProvider");
            }

            return provider;
        }
开发者ID:bplasmeijer,项目名称:Glass.Mapper,代码行数:18,代码来源:GlassDataProvider.cs

示例4: Initialise

        /// <summary>
        /// Setups the specified context.
        /// </summary>
        /// <param name="db">The db.</param>
        public  void Initialise(Database db)
        {
            var manager = new DataManager(db);
            var context = new CallContext(manager, db.GetDataProviders().Count());
            
            lock (_setupLock)
            {
                try
                {
                    if (_setupComplete) return;

                    global::Sitecore.Diagnostics.Log.Info("Started CodeFirst setup", this);

                    var sqlProvider = GetSqlProvider(db);

                    var glassFolder = GetGlassTemplateFolder(sqlProvider, context);

                    if (Context.Contexts.Keys.Any(x => x == ContextName))
                    {

                        var glsContext = Context.Contexts[ContextName];
                        _typeConfigurations = glsContext.TypeConfigurations
                                                         .Where(x => x.Value is SitecoreTypeConfiguration)
                                                         .ToDictionary(x => x.Key,
                                                                       x => x.Value as SitecoreTypeConfiguration);

                        foreach (var cls in _typeConfigurations.Where(x => x.Value.CodeFirst))
                        {
                            var templateDefinition = sqlProvider.GetItemDefinition(cls.Value.TemplateId, context);

                            if (templateDefinition == ItemDefinition.Empty || templateDefinition == null)
                            {
                                var containingFolder = GetTemplateFolder(cls.Key.Namespace, glassFolder, sqlProvider, context);
                                templateDefinition = CreateTemplateItem(db, cls.Value, cls.Key, sqlProvider, containingFolder, context);
                            }

                            BaseTemplateChecks(templateDefinition, sqlProvider, context, cls.Value);

                            //initialize sections and children
                            foreach (ID sectionId in this.GetChildIDsTemplate(cls.Value, templateDefinition, context))
                            {
                                this.GetChildIDsSection(SectionTable.First(s => s.SectionId == sectionId), context);
                            }
                        }

                        if (global::Sitecore.Configuration.Settings.GetBoolSetting(
                            "AutomaticallyRemoveDeletedTemplates",
                            true))
                            RemoveDeletedClasses(glassFolder, sqlProvider, context);

                        global::Sitecore.Diagnostics.Log.Info("Finished CodeFirst setup", this);
                    }
                    
                    ClearCaches(db);
                   
                }
                finally 
                {
                    _setupComplete = true;
                }

            }
        }
开发者ID:bplasmeijer,项目名称:Glass.Mapper,代码行数:67,代码来源:GlassDataProvider.cs

示例5: Initialise

        /// <summary>
        /// Setups the specified context.
        /// </summary>
        /// <param name="db">The db.</param>
        public void Initialise(Database db)
        {
            if (_setupComplete || _setupProcessing)
                return;

            lock (_setupLock)
            {
                try
                {
                    if (_setupComplete || _setupProcessing)
                        return;

                    Sitecore.Diagnostics.Log.Info("Started CodeFirst setup " + db.Name, this);
                    _setupProcessing = true;
                    var manager = new DataManager(db);
                    var context = new CallContext(manager, db.GetDataProviders().Count());

                    var sqlProvider = GetSqlProvider(db);
                    var glassFolder = GetGlassTemplateFolder(sqlProvider, context);

                    if (CurrentContext != null)
                    {
                        foreach (var cls in TypeConfigurations.Where(x => x.Value.CodeFirst))
                        {
                            var templateDefinition = sqlProvider.GetItemDefinition(cls.Value.TemplateId, context);

                            if (templateDefinition == ItemDefinition.Empty || templateDefinition == null)
                            {
                                var containingFolder = GetTemplateFolder(cls.Key.Namespace, glassFolder, sqlProvider, context);
                                templateDefinition = CreateTemplateItem(db, cls.Value, cls.Key, sqlProvider, containingFolder, context);
                            }

                            BaseTemplateChecks(templateDefinition, cls.Value, db);

                            //initialize sections and children
                            foreach (ID sectionId in GetChildIDsTemplate(cls.Value, templateDefinition, context, sqlProvider))
                            {
                                GetChildIDsSection(SectionTable.First(s => s.SectionId == sectionId), context, sqlProvider);
                            }
                        }

                        if (Settings.GetBoolSetting("AutomaticallyRemoveDeletedTemplates", true))
                            RemoveDeletedClasses(glassFolder, sqlProvider, context);

                        ClearCaches(db);
                    }

                    Sitecore.Diagnostics.Log.Info("Finished CodeFirst setup " + db.Name, this);
                }
                catch (Exception ex)
                {
                    Sitecore.Diagnostics.Log.Error("CodeFirst error " + ex.Message, ex, this);
                    throw;
                }
                finally
                {
                    _setupComplete = true;
                }
            }
        }
开发者ID:neilduncan,项目名称:Glass.Mapper,代码行数:64,代码来源:GlassDataProvider.cs

示例6: Initialise

        /// <summary>
        /// Setups the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public  void Initialise(Database db)
        {
            var manager = new DataManager(db);
            var context = new CallContext(manager, db.GetDataProviders().Count());
            
            lock (_setupLock)
            {
                try
                {
                    if (_setupComplete) return;

                    global::Sitecore.Diagnostics.Log.Info("Started CodeFirst setup", this);

                    var providers = db.GetDataProviders();
                    var provider = providers.FirstOrDefault(x => !(x is GlassDataProvider));

                    var templateFolder = provider.GetItemDefinition(TemplateFolderId, context);

                    var glassFolder = provider.GetItemDefinition(GlassFolderId, context);

                    if (glassFolder == ItemDefinition.Empty || glassFolder == null)
                    {
                        provider.CreateItem(GlassFolderId, "GlassTemplates", FolderTemplateId, templateFolder, context);
                    }

                    if (Context.Contexts.Keys.Any(x => x == ContextName))
                    {

                        var glsContext = Context.Contexts[ContextName];
                        _typeConfigurations = glsContext.TypeConfigurations
                                                         .Where(x => x.Value is SitecoreTypeConfiguration)
                                                         .ToDictionary(x => x.Key,
                                                                       x => x.Value as SitecoreTypeConfiguration);

                        foreach (var cls in _typeConfigurations.Where(x => x.Value.CodeFirst))
                        {
                            var clsTemplate = provider.GetItemDefinition(cls.Value.TemplateId, context);

                            if (clsTemplate == ItemDefinition.Empty || clsTemplate == null)
                            {

                                //setup folders
                                IEnumerable<string> namespaces = cls.Key.Namespace.Split('.');
                                namespaces = namespaces.SkipWhile(x => x != "Templates").Skip(1);

                                ItemDefinition containing = glassFolder;
                                foreach (var ns in namespaces)
                                {
                                    var children = provider.GetChildIDs(containing, context);

                                    ItemDefinition found = null;
                                    foreach (ID child in children)
                                    {
                                        if (!ID.IsNullOrEmpty(child))
                                        {
                                            var childDef = provider.GetItemDefinition(child, context);
                                            if (childDef.Name == ns)
                                                found = childDef;
                                        }
                                    }

                                    if (found == null)
                                    {
                                        ID newId = ID.NewID;
                                        provider.CreateItem(newId, ns, FolderTemplateId, containing, context);
                                        found = provider.GetItemDefinition(newId, context);
                                    }
                                    containing = found;

                                }

                                //create the template in Sitecore
                                string templateName = cls.Value.TemplateName;

                                if (string.IsNullOrEmpty(templateName))
                                    templateName = cls.Key.Name;

                                provider.CreateItem(cls.Value.TemplateId, templateName, TemplateTemplateId, containing,
                                                    context);
                                clsTemplate = provider.GetItemDefinition(cls.Value.TemplateId, context);
                                //Assign the base template
                                var templateItem = Factory.GetDatabase("master").GetItem(clsTemplate.ID);

                                using (new SecurityDisabler())
                                {
                                    templateItem.Editing.BeginEdit();
                                    templateItem["__Base template"] = "{1930BBEB-7805-471A-A3BE-4858AC7CF696}";
                                    templateItem.Editing.EndEdit();
                                }
                            }

                            BaseTemplateChecks(clsTemplate, provider, context, cls.Value);

                            //initialize sections and children
                            foreach (ID sectionId in this.GetChildIDsTemplate(cls.Value, clsTemplate, context))
                            {
//.........这里部分代码省略.........
开发者ID:jelleovermars,项目名称:Glass.Mapper,代码行数:101,代码来源:GlassDataProvider.cs

示例7: GetSqlProvider

 /// <summary>
 /// Gets the base SQL provider that will store physical items
 /// </summary>
 /// <param name="db"></param>
 /// <returns></returns>
 private DataProvider GetSqlProvider(Database db)
 {
     var providers = db.GetDataProviders();
     return providers.FirstOrDefault(x => x is SqlDataProvider);
 }
开发者ID:wavveen,项目名称:BoC.Sitecore.CodefirstRenderings,代码行数:10,代码来源:CodeFirstRenderingsDataProvider.cs


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