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


C# IConfiguration.Resolve方法代码示例

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


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

示例1: DumpTree

        /// <returns>True if the tree was dumped, false if the root item was not included</returns>
        public virtual bool DumpTree(IItemData item, IConfiguration configuration = null)
        {
            using (new TransparentSyncDisabler())
            {
                if(configuration == null) configuration = GetConfigurationForItem(item);

                if (configuration == null) return false;

                var logger = configuration.Resolve<ILogger>();

                var predicate = configuration.Resolve<IPredicate>();
                var serializationStore = configuration.Resolve<ITargetDataStore>();
                var sourceStore = configuration.Resolve<ISourceDataStore>();

                var rootReference = serializationStore.GetByPathAndId(item.Path, item.Id, item.DatabaseName);
                if (rootReference != null)
                {
                    logger.Warn("[D] existing serialized items under {0}".FormatWith(rootReference.GetDisplayIdentifier()));
                    serializationStore.Remove(rootReference);
                }

                logger.Info("[U] Serializing included items under root {0}".FormatWith(item.GetDisplayIdentifier()));

                if (!predicate.Includes(item).IsIncluded) return false;

                DumpTreeInternal(item, predicate, serializationStore, sourceStore, logger);
            }
            return true;
        }
开发者ID:PetersonDave,项目名称:Unicorn,代码行数:30,代码来源:SerializationHelper.cs

示例2: AllRootPathsExist

        /// <summary>
        /// Verifies that all root paths defined in the predicate exist in Sitecore
        /// In other words, if you were to reserialize this configuration would there be something
        /// to serialize at all root locations?
        /// </summary>
        public static bool AllRootPathsExist(IConfiguration configuration)
        {
            var predicate = configuration.Resolve<PredicateRootPathResolver>();
            var sourceDataStore = configuration.Resolve<ISourceDataStore>();

            return predicate.GetRootPaths().All(include => RootPathExists(sourceDataStore, include));
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:12,代码来源:ControlPanelUtility.cs

示例3: UnicornConfigurationRolesEventHandler

		public UnicornConfigurationRolesEventHandler(IConfiguration configuration)
		{
			Assert.ArgumentNotNull(configuration, nameof(configuration));

			_predicate = configuration.Resolve<IRolePredicate>();
			_dataStore = configuration.Resolve<IRoleDataStore>();
		}
开发者ID:jnbuehler,项目名称:Unicorn,代码行数:7,代码来源:UnicornConfigurationRolesEventHandler.cs

示例4: DumpItem

        /// <returns>True if the item was dumped, false if it was not included</returns>
        public virtual bool DumpItem(IItemData item, IConfiguration configuration = null)
        {
            using (new TransparentSyncDisabler())
            {
                if(configuration == null) configuration = GetConfigurationForItem(item);

                if (configuration == null) return false;

                var predicate = configuration.Resolve<IPredicate>();
                var serializationStore = configuration.Resolve<ITargetDataStore>();

                return DumpItemInternal(item, predicate, serializationStore).IsIncluded;
            }
        }
开发者ID:PetersonDave,项目名称:Unicorn,代码行数:15,代码来源:SerializationHelper.cs

示例5: PostProcessItems

        protected virtual void PostProcessItems(Item[] items, IConfiguration configuration)
        {
            var syncConfiguration = configuration.Resolve<ISyncConfiguration>();

            if (syncConfiguration == null) return;

            var logger = configuration.Resolve<ILogger>();

            if (syncConfiguration.UpdateLinkDatabase)
                UpdateLinkDatabase(items, logger);

            if (syncConfiguration.UpdateSearchIndex)
                UpdateSearchIndexes(items, logger);
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:14,代码来源:SyncedItemPostProcessor.cs

示例6: GetHealthStatus

		private string GetHealthStatus(IConfiguration configuration)
		{
			var configurationHasAnySerializedItems = ControlPanelUtility.HasAnySerializedItems(configuration);

			var configurationHasValidRootParentPaths = ControlPanelUtility.AllRootParentPathsExist(configuration);

			var unicornDataProviderConfiguration = configuration.Resolve<IUnicornDataProviderConfiguration>();

			var configurationHasTransparentSync = unicornDataProviderConfiguration != null && unicornDataProviderConfiguration.EnableTransparentSync;

			var dependents = configuration.Resolve<ConfigurationDependencyResolver>().Dependencies;

			var dependentsData = string.Join(", ", dependents.Select(d => d.Configuration.Name));

			return $"{configuration.Name}|{configurationHasAnySerializedItems}|{configurationHasValidRootParentPaths}|{configurationHasTransparentSync}|{dependentsData}";
		}
开发者ID:jnbuehler,项目名称:Unicorn,代码行数:16,代码来源:ConfigurationHealthVerb.cs

示例7: MoveBootstrapToTargetDataStore

        public virtual bool MoveBootstrapToTargetDataStore(string directory, string targetDataStorePath, IConfiguration configuration)
        {
            var logger = configuration.Resolve<ILogger>();

            if (string.IsNullOrEmpty(directory))
            {
                logger.Error("Source directory not specified.");
                return false;
            }

            if (string.IsNullOrEmpty(targetDataStorePath))
            {
                logger.Error("targetStoreDataPath directory not specified (or resolved).");
                return false;
            }

            logger.Info(string.Empty);
            logger.Info($"Bootstrap folder \"{directory}\" being moved to \"{targetDataStorePath}\"");

            try
            {
                if (Directory.Exists(targetDataStorePath))
                    Directory.Delete(targetDataStorePath, true);
                MoveDirectory(directory, targetDataStorePath);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return false;
            }

            return true;
        }
开发者ID:cassidydotdk,项目名称:Unicorn.Bootstrap,代码行数:33,代码来源:Bootstrap.cs

示例8: ProcessFullSyncPackage

		private void ProcessFullSyncPackage(RemotingPackage package, IConfiguration configuration, ILogger logger)
		{
			package.Manifest.Strategy = RemotingStrategy.Full;
			using (new SecurityDisabler())
			{
				var predicate = configuration.Resolve<IPredicate>();

				var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems();

				foreach (var root in roots)
				{
					logger.Info("[U] Serializing included items under root {0}".FormatWith(root.DisplayIdentifier));
					Serialize(root, predicate, package.SerializationProvider, logger);
				}
			}
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:16,代码来源:RemotingService.cs

示例9: ConfigItem

			public ConfigItem(IConfiguration config, IEnumerable<IConfiguration> possibleConfigurations)
			{
				Config = config;
				Dependencies = config.Resolve<ConfigurationDependencyResolver>()
					.Dependencies
					.Select(dep => dep.Configuration)
					.Where(dep => possibleConfigurations.Any(conf => conf.Name.Equals(dep.Name)))
					.ToArray();
			}
开发者ID:GlennHaworth,项目名称:Unicorn,代码行数:9,代码来源:InterconfigurationDependencyResolver.cs

示例10: ProcessHistoryEnginePackage

		private static void ProcessHistoryEnginePackage(RemotingPackage package, IConfiguration configuration, DateTime ifModifiedSince)
		{
			// TODO: need to "coalesce" history so we are not replaying more events than we need to
			// e.g. create then move in one sync will cause the created item to not be present as a serialized item
			// in the package because it was moved so the create fails

			package.Manifest.Strategy = RemotingStrategy.Differential;

			using (new SecurityDisabler())
			{
				var serializationProvider = package.SerializationProvider;

				var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems();

				var historyDatabases = roots.Select(x => x.DatabaseName).Distinct().Select(Factory.GetDatabase).ToArray();

				foreach (var historyDatabase in historyDatabases)
				{
					var localHistory = GetMergedHistory(ifModifiedSince, historyDatabase);

					foreach (var historyEntry in localHistory)
					{
						if (historyEntry.Action == HistoryAction.Moved)
						{
							var item = historyDatabase.GetItem(historyEntry.ItemId);

							if (item == null) continue; // invalid history entry - item deleted

							var manifestEntry = RemotingPackageManifestEntry.FromEntry(historyEntry, historyDatabase.Name);

							manifestEntry.OldItemPath = historyEntry.ItemPath; // on a moved entry, the itempath is the pre-move path
							manifestEntry.ItemPath = item.Paths.Path; // the path from the Item is the post-move path

							package.Manifest.AddEntry(manifestEntry);
						}
						else if (historyEntry.Action == HistoryAction.Deleted)
						{
							package.Manifest.AddEntry(RemotingPackageManifestEntry.FromEntry(historyEntry, historyDatabase.Name));
						}
						else
						{
							var item = historyDatabase.GetItem(historyEntry.ItemId);

							if (item == null) continue; // invalid history entry - item deleted

							// serialize updated item to package directory
							serializationProvider.SerializeItem(new SitecoreSourceItem(item));

							package.Manifest.AddEntry(RemotingPackageManifestEntry.FromEntry(historyEntry, historyDatabase.Name));
						}
					}
				}

				package.Manifest.LastSynchronized = DateTime.UtcNow;
			}
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:56,代码来源:RemotingService.cs

示例11: HasAnySerializedItems

        /// <summary>
        /// Checks if any of the current predicate's root paths exist in the serialization provider
        /// </summary>
        public static bool HasAnySerializedItems(IConfiguration configuration)
        {
            var pathResolver = configuration.Resolve<PredicateRootPathResolver>();

            // if you have no root paths at all that's actually cool. You might just be serializing roles.
            // either way there are no missing root items to worry about, since there are no roots.
            if (pathResolver.GetRootPaths().Length == 0) return true;

            return pathResolver.GetRootSerializedItems().Length > 0;
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:13,代码来源:ControlPanelUtility.cs

示例12: SynchroniseTargetDataStore

        public virtual void SynchroniseTargetDataStore(IConfiguration configuration)
        {
            var logger = configuration.Resolve<ILogger>();
            var helper = configuration.Resolve<SerializationHelper>();

            try
            {
                logger.Info(string.Empty);
                logger.Info("Unicorn.Bootstrap is syncing " + configuration.Name);

                var pathResolver = configuration.Resolve<PredicateRootPathResolver>();

                var roots = pathResolver.GetRootSerializedItems();

                helper.SyncTree(configuration, null, roots);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
开发者ID:cassidydotdk,项目名称:Unicorn.Bootstrap,代码行数:21,代码来源:Bootstrap.cs

示例13: UnicornSyncCompletePipelineArgs

		public UnicornSyncCompletePipelineArgs(IConfiguration configuration, DateTime syncStartedTimestamp)
		{
			Assert.ArgumentNotNull(configuration, "configuration");

			var dataCollector = configuration.Resolve<ISyncCompleteDataCollector>();

			Assert.IsNotNull(dataCollector, "Configuration had no ISyncCompleteDataCollector registered!");

			Changes = dataCollector.GetChanges();
			Configuration = configuration;
			SyncStartedTimestamp = syncStartedTimestamp;
			ProcessedItemCount = dataCollector.ProcessedItemCount;
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:13,代码来源:UnicornSyncCompletePipelineArgs.cs

示例14: DumpItem

        /// <returns>True if the item was dumped, false if it was not included</returns>
        public virtual bool DumpItem(IItemData item, IConfiguration configuration = null)
        {
            using (new TransparentSyncDisabler())
            {
                if (configuration == null) configuration = GetConfigurationForItem(item);

                if (configuration == null) return false;

                var predicate = configuration.Resolve<IPredicate>();
                var serializationStore = configuration.Resolve<ITargetDataStore>();

                CacheManager.ClearAllCaches(); // BOOM! This clears all caches before we begin;
                                               // because for a TpSync configuration we could have TpSync items in the data cache which 'taint' the reserialize
                                               // from being purely database

                var result = DumpItemInternal(item, predicate, serializationStore).IsIncluded;

                CacheManager.ClearAllCaches(); // BOOM! And we clear everything again at the end, because now
                                               // for a TpSync configuration we might have DATABASE items in cache where we want TpSync.

                return result;
            }
        }
开发者ID:ramnkl,项目名称:Unicorn,代码行数:24,代码来源:SerializationHelper.cs

示例15: GetImplicitDependencies

        protected virtual IEnumerable<IConfigurationDependency> GetImplicitDependencies(IConfiguration configuration)
        {
            var configRootPaths = configuration.Resolve<IPredicate>().GetRootPaths();

            var nonIgnoredConfigurations = AllConfigurations
                .Where(config => configuration.IgnoredImplicitDependencies
                    .All(ignoredDep => !IsWildcardMatch(config.Name, ignoredDep)
                ));

            foreach (var config in nonIgnoredConfigurations)
            {
                if (config.Name.Equals(configuration.Name, StringComparison.OrdinalIgnoreCase)) continue; // don't depend on yourself :)

                var candidateParentPaths = config.Resolve<IPredicate>().GetRootPaths();

                bool match = false;

                foreach (var candidateParent in candidateParentPaths)
                {
                    foreach (var configRoot in configRootPaths)
                    {
                        // mismatching dbs = don't care about path
                        if (!configRoot.DatabaseName.Equals(candidateParent.DatabaseName)) continue;

                        var configRootPath = $"{configRoot.Path.TrimEnd('/')}/";
                        var candidateParentPath = $"{candidateParent.Path.TrimEnd('/')}/";
                        if (configRootPath.StartsWith(candidateParentPath) && !configRootPath.Equals(candidateParentPath, StringComparison.Ordinal))
                        {
                            match = true;
                            break;
                        }
                    }

                    if (match) break;
                }

                if (match) yield return new ImplicitConfigurationDependency(config);
            }
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:39,代码来源:ConfigurationDependencyResolver.cs


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