public bool CanBeRemovedFromHead([NotNull] ID itemId) { Assert.ArgumentNotNull(itemId, nameof(itemId)); var dataManager = Database.DataManager; if (HeadProvider.GetItemDefinition(itemId, new CallContext(dataManager, 1)) == null) { return(false); } if (ReadOnlyProviders.All(x => x.GetItemDefinition(itemId) == null)) { return(false); } var itemDefinition = new ItemDefinition(itemId, string.Empty, ID.Undefined, ID.Undefined); foreach (VersionUri version in GetItemVersions(itemDefinition, new CallContext(dataManager, 1))) { var versionUri = new VersionUri(version.Language, version.Version); var actualFields = HeadProvider.GetItemFields(itemDefinition, versionUri, new CallContext(dataManager, 1)); var defaultFields = ReadOnlyProviders.FirstNotNull(x => x.GetItemFields(itemDefinition, versionUri)); if (actualFields?.Count != defaultFields?.Count) { return(false); } foreach (var i in actualFields.FieldValues.Keys.Cast <ID>()) { if ( !defaultFields.FieldValues.Contains(i) || actualFields[i] != defaultFields[i] || false) { return(false); } } foreach (var i in defaultFields.FieldValues.Keys.Cast <ID>()) { if ( !actualFields.FieldValues.Contains(i) || actualFields[i] != defaultFields[i] || false) { return(false); } } } return(true); }
/* Items.ItemData part of DataProvider */ public override FieldList GetItemFields(ItemDefinition itemDefinition, VersionUri versionUri, CallContext context) { #if DEBUG var timer = Stopwatch.StartNew(); #endif var itemFields = HeadProvider.GetItemFields(itemDefinition, versionUri, context) ?? ReadOnlyProviders.FirstNotNull(x => x.GetItemFields(itemDefinition, versionUri)); // do not print fields #if DEBUG this.Trace(null, timer, itemDefinition, versionUri, context); #endif return(itemFields); }