Exemplo n.º 1
0
 /// <summary>Adds an allowed zone to the definition's list of allwed zones.</summary>
 /// <param name="zone">The zone name to add.</param>
 public void AddAllowedZone(string zone)
 {
     if (!AllowedZoneNames.Contains(zone))
     {
         AllowedZoneNames.Add(zone);
     }
 }
Exemplo n.º 2
0
        public ItemDefinition Clone()
        {
            var id = new ItemDefinition(ItemType);

            id.AllowedChildFilters  = AllowedChildFilters.ToList();
            id.AllowedIn            = AllowedIn;
            id.AllowedParentFilters = AllowedParentFilters.ToList();
            id.AllowedZoneNames     = AllowedZoneNames.ToList();
            id.AuthorizedRoles      = AuthorizedRoles != null?AuthorizedRoles.ToList() : AuthorizedRoles;

            id.AvailableZones    = AvailableZones.ToList();
            id.Containers        = Containers.ToList();
            id.Description       = Description;
            id.Discriminator     = Discriminator;
            id.Displayables      = Displayables.ToList();
            id.Editables         = Editables.ToList();
            id.Enabled           = Enabled;
            id.IconUrl           = IconUrl;
            id.Installer         = Installer;
            id.IsDefined         = IsDefined;
            id.EditableModifiers = EditableModifiers.ToList();
            id.ContentModifiers  = ContentModifiers.ToList();
            id.NumberOfItems     = 0;
            id.RelatedTo         = RelatedTo;
            id.SortOrder         = SortOrder;
            id.Template          = Template;
            id.Title             = Title;
            id.ToolTip           = ToolTip;
            //id.ReloadRoot();
            return(id);
        }
Exemplo n.º 3
0
        /// <summary>Find out if this item is allowed in a zone.</summary>
        /// <param name="zoneName">The zone name to check.</param>
        /// <returns>True if the item is allowed in the zone.</returns>
        public bool IsAllowedInZone(string zoneName)
        {
            if (!IsDefined || !Enabled)
            {
                return(false);
            }

            if (AllowedIn == AllowedZones.All)
            {
                return(true);
            }
            if (AllowedIn == AllowedZones.AllNamed && !string.IsNullOrEmpty(zoneName))
            {
                return(true);
            }

            if (AllowedZoneNames == null)
            {
                return(true);
            }

            if (string.IsNullOrEmpty(zoneName) && AllowedZoneNames.Count == 0 && AllowedIn != AllowedZones.AllNamed)
            {
                return(true);
            }

            if (AllowedIn == AllowedZones.None)
            {
                return(false);
            }

            return(AllowedZoneNames.Contains(zoneName));
        }
Exemplo n.º 4
0
        public ItemDefinition Clone()
        {
            var id = new ItemDefinition(ItemType);

            id.AllowedChildFilters  = AllowedChildFilters.ToList();
            id.AllowedIn            = AllowedIn;
            id.AllowedParentFilters = AllowedParentFilters.ToList();
            id.Attributes           = Attributes.ToList();
            id.AllowedZoneNames     = AllowedZoneNames.ToList();
            id.AuthorizedRoles      = AuthorizedRoles != null?AuthorizedRoles.ToArray() : AuthorizedRoles;

            id.AvailableZones      = AvailableZones.ToList();
            id.Containers          = new ContentList <IEditableContainer>(Containers.Select(ec => ec.TryClone()));
            id.ContentTransformers = ContentTransformers.ToList();
            id.Description         = Description;
            id.Discriminator       = Discriminator;
            id.Displayables        = new ContentList <IDisplayable>(Displayables.Select(d => d.TryClone()));
            id.Editables           = new ContentList <IEditable>(Editables.Select(e => e.TryClone()));
            id.Enabled             = Enabled;
            id.EditableModifiers   = EditableModifiers.ToList();
            id.IconUrl             = IconUrl;
            id.Installer           = Installer;
            id.IsDefined           = IsDefined;
            id.NumberOfItems       = 0;
            id.Metadata            = Metadata.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            id.AdditionalFlags     = AdditionalFlags.ToList();
            id.RemovedFlags        = RemovedFlags.ToList();
            id.Properties          = Properties.ToDictionary(p => p.Key, p => p.Value.Clone());
            id.RelatedTo           = RelatedTo;
            id.SortOrder           = SortOrder;
            id.TemplateKey         = TemplateKey;
            id.Title   = Title;
            id.ToolTip = ToolTip;
            return(id);
        }