protected override string GetDialogText(SaveArgs args)
		{
			foreach (var item in args.Items)
			{
				Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

				Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

				var existingSitecoreItem = new ItemData(existingItem);

				if (_configurations.Any(configuration =>
				{
					if (!configuration.Resolve<IUnicornDataProviderConfiguration>().EnableTransparentSync &&
						configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded &&
						configuration.Resolve<IEvaluator>().ShouldPerformConflictCheck(existingItem))
						return true;

					return false;
				}))
				{
					return GetMessage(existingSitecoreItem);
				}
			}

			return null;
		}
        public void EvaluateNewSerializedItem_LogsCreatedItem(Db db, DbItem dbItem)
        {
            db.Add(dbItem);
            var item = db.GetItem(dbItem.ID);

            var logger = Substitute.For<ISerializedAsMasterEvaluatorLogger>();
            var evaluator = CreateTestEvaluator(logger);
            var itemData = new ItemData(item);

            evaluator.EvaluateNewSerializedItem(itemData);

            logger.Received().DeserializedNewItem(itemData);
        }
        public void EvaluateNewSerializedItem_DeserializesItem(Db db, DbItem dbItem)
        {
            db.Add(dbItem);
            var item = db.GetItem(dbItem.ID);

            var deserializer = Substitute.For<IDeserializer>();
            var evaluator = CreateTestEvaluator(deserializer: deserializer);
            var itemData = new ItemData(item);

            evaluator.EvaluateNewSerializedItem(itemData);

            deserializer.Received().Deserialize(itemData);
        }
Exemplo n.º 4
0
		protected override void Dump(Item item)
		{
			Assert.ArgumentNotNull(item, "item");

			var itemData = new ItemData(item);

			var result = _helper.DumpItem(itemData);

			if (!result)
			{
				base.Dump(item);
			}
		}
        public bool TryGetItemData(string id, out IItemData itemData)
        {
            itemData = null;

            Item item = GetItem(id);

            if (item == null)
            {
                return(false);
            }

            itemData = new Rainbow.Storage.Sc.ItemData(item);
            return(true);
        }
        public static string GetYaml(this Item item)
        {
            using (var stream = new MemoryStream())
            {
                ItemData data = new ItemData(item);
                Formatter.WriteSerializedItem(data, stream);
                stream.Seek(0, SeekOrigin.Begin);

                using (var reader = new StreamReader(stream))
                {
                    return reader.ReadToEnd();
                }
            }
        }
Exemplo n.º 7
0
        public virtual void Process(GetContentEditorWarningsArgs args)
        {
            Item item = args.Item;
            if (item == null) return;

            var existingSitecoreItem = new ItemData(item);

            if (_configurations.Any(configuration => configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded))
            {
                GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                warning.Title = RenderTitle(item);
                warning.Text = RenderWarning(item);
            }
        }
Exemplo n.º 8
0
        protected override string GetDialogText(SaveArgs args)
        {
            foreach (var item in args.Items)
            {
                Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                var existingSitecoreItem = new ItemData(existingItem);

                if (_configurations.Any(configuration => configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded))
                {
                    return GetMessage(existingSitecoreItem);
                }
            }

            return null;
        }
Exemplo n.º 9
0
		public virtual void Process(GetContentEditorWarningsArgs args)
		{
			Item item = args.Item;
			if (item == null) return;

			var existingSitecoreItem = new ItemData(item);

			var configuration = _configurations.FirstOrDefault(config => config.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded);
			if (configuration != null)
			{
				var evaluator = configuration.Resolve<IEvaluator>();

				var warningObject = evaluator.EvaluateEditorWarning(item);

				if (warningObject != null)
				{
					GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
					warning.Title = warningObject.Title;
					warning.Text = warningObject.Message;
				}
			}
		}