public static bool SitecoreVersion([NotNull] this IItemSelectionContext itemSelectionContext, [NotNull] System.Version minVersion, [NotNull] System.Version maxVersion, bool trueIfEmptyVersion = true) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); Assert.ArgumentNotNull(minVersion, nameof(minVersion)); Assert.ArgumentNotNull(maxVersion, nameof(maxVersion)); if (!itemSelectionContext.Items.Any()) { return(false); } if (!IsSameSite(itemSelectionContext)) { return(false); } var version = itemSelectionContext.Items.First().ItemUri.Site.SitecoreVersion; if (version == Sites.SitecoreVersion.EmptyVersion) { return(trueIfEmptyVersion); } if (version < minVersion || version > maxVersion) { return(false); } return(true); }
private string GetItemId([NotNull] IItemSelectionContext context, [NotNull] string defaultValue) { Debug.ArgumentNotNull(context, nameof(context)); Debug.ArgumentNotNull(defaultValue, nameof(defaultValue)); var itemId = ItemId.Empty; if (!string.IsNullOrEmpty(defaultValue)) { Guid guid; if (Guid.TryParse(defaultValue, out guid)) { itemId = new ItemId(guid); } } var databaseUri = context.Items.First().ItemUri.DatabaseUri; var itemUri = new ItemUri(databaseUri, itemId); var dialog = new SelectItemDialog(); dialog.Initialize(Resources.Browse, itemUri); if (AppHost.Shell.ShowDialog(dialog) != true) { return(defaultValue); } return(dialog.SelectedItemUri.ItemId.ToString()); }
protected List <IItem> GetItems([NotNull] IItemSelectionContext context) { Debug.ArgumentNotNull(context, nameof(context)); var items = new List <IItem>(); foreach (var item in context.Items) { items.Add(item); } return(items); }
public static Site GetSite([NotNull] this IItemSelectionContext itemSelectionContext) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); if (!itemSelectionContext.Items.Any()) { return(Site.Empty); } if (!IsSameDatabase(itemSelectionContext)) { return(Site.Empty); } return(itemSelectionContext.Items.First().ItemUri.Site); }
public static System.Version SitecoreVersion([NotNull] this IItemSelectionContext itemSelectionContext) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); if (!itemSelectionContext.Items.Any()) { return(Sites.SitecoreVersion.EmptyVersion); } if (!IsSameSite(itemSelectionContext)) { return(Sites.SitecoreVersion.EmptyVersion); } return(itemSelectionContext.Items.First().ItemUri.Site.SitecoreVersion); }
public override bool CanExecute(object parameter) { var context = parameter as IItemSelectionContext; if (context == null) { return(false); } if (!context.Items.Any()) { return(false); } string databaseName = null; string siteName = null; foreach (var item in context.Items) { if (databaseName == null) { databaseName = item.ItemUri.DatabaseName.Name; siteName = item.ItemUri.Site.Name; } else if (databaseName != item.ItemUri.DatabaseName.Name) { return(false); } else if (siteName != item.ItemUri.Site.Name) { return(false); } } if (!context.Items.All(i => i.ItemUri.Site.DataService.CanExecuteAsync("Workflows.ExecuteWorkflowCommand"))) { return(false); } Context = context; return(true); }
public static bool IsSameSite([NotNull] this IItemSelectionContext itemSelectionContext) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); Site site = null; foreach (var item in itemSelectionContext.Items) { if (site == null) { site = item.ItemUri.Site; } else if (item.ItemUri.Site != site) { return(false); } } return(true); }
public static bool IsSameDatabase([NotNull] this IItemSelectionContext itemSelectionContext) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); DatabaseUri databaseUri = null; foreach (var item in itemSelectionContext.Items) { if (databaseUri == null) { databaseUri = item.ItemUri.DatabaseUri; } else if (item.ItemUri.DatabaseUri != databaseUri) { return(false); } } return(true); }
public static string GetItemIdList([NotNull] this IItemSelectionContext itemSelectionContext) { Assert.ArgumentNotNull(itemSelectionContext, nameof(itemSelectionContext)); var sb = new StringBuilder(); var first = true; foreach (var item in itemSelectionContext.Items) { if (!first) { sb.Append(','); } first = false; sb.Append(item.ItemUri.ItemId); } return(sb.ToString()); }
public override bool CanExecute(object parameter) { var context = parameter as IItemSelectionContext; if (context == null) { return(false); } if (!context.Items.Any()) { return(false); } if (context.Items.Any(i => i is LibraryItemTreeViewItem)) { return(false); } Context = context; return(true); }
public override void ContextMenuClosed() { Context = null; }