Ejemplo n.º 1
0
    private void GetEmbeddableName()
    {
        var         p          = new Plugins();
        var         items      = p.GetEmbeddablePlugins();
        IEmbeddable embeddable = ((List <IEmbeddable>)items).Find(i => i.EmbeddableID == EmbeddableID);

        litEmbeddableName.Text = embeddable.EmbeddableName;
    }
Ejemplo n.º 2
0
 private bool IsEmbedded(ISiteObject Value)
 {
     if (Value is IEmbeddable)
     {
         IEmbeddable embedded = Value as IEmbeddable;
         return(embedded.IsEmbedded);
     }
     return(false);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Respond to the specified <see cref="DiscordMessage"/> with the<see cref="DiscordEmbed"/> provided by the specified object that implements <see cref="IEmbeddable"/>
 /// </summary>
 /// <param name="message">The <see cref="DiscordMessage"/> to respond to. If this is null, nothing will happen. </param>
 /// <param name="embeddableObject">The <see cref="IEmbeddable"/> that provides a <see cref="DiscordEmbed"/> to respond with.</param>
 /// <returns></returns>
 public static async Task <DiscordMessage> RespondToAsync(DiscordMessage message, IEmbeddable embeddableObject)
 {
     if (message != null)
     {
         return(await message.RespondAsync(embed : embeddableObject.ToEmbed()));
     }
     return(null);
 }
Ejemplo n.º 4
0
        public IEmbeddableItemListViewModel(SiteDb siteDb, IEmbeddable embeddedobject)
        {
            string baseurl = siteDb.WebSite.BaseUrl();

            if (embeddedobject == null)
            {
                throw new ArgumentNullException("embedded object");
            }

            Id = embeddedobject.Id;

            if (embeddedobject.IsEmbedded)
            {
                Name = StringHelper.GetSummary(embeddedobject.Body);
                var info = ObjectService.GetObjectInfo(siteDb, embeddedobject as SiteObject);
                FullUrl   = info.Url;
                RouteName = Name;
            }
            else
            {
                var route = siteDb.Routes.GetByObjectId(embeddedobject.Id);
                if (route != null)
                {
                    //  Name = route.Name;
                    FullUrl   = Kooboo.Lib.Helper.UrlHelper.Combine(baseurl, route.Name);
                    RouteName = route.Name;
                    RouteId   = route.Id;
                }

                this.Name = embeddedobject.Name;
                if (string.IsNullOrEmpty(this.Name))
                {
                    if (route != null)
                    {
                        this.Name = route.Name;
                    }
                }
                if (string.IsNullOrEmpty(this.Name))
                {
                    this.Name = StringHelper.GetSummary(embeddedobject.Body);
                }
            }

            LastModified = embeddedobject.LastModified;


            List <UsedByRelation> usedby = null;

            if (embeddedobject.ConstType == ConstObjectType.Style)
            {
                usedby = siteDb.Styles.GetUsedBy(embeddedobject.Id);
            }
            else if (embeddedobject.ConstType == ConstObjectType.Script)
            {
                usedby = siteDb.Scripts.GetUsedBy(embeddedobject.Id);
            }
            else if (embeddedobject.ConstType == ConstObjectType.Form)
            {
                usedby = siteDb.Forms.GetUsedBy(embeddedobject.Id);
            }
            else if (embeddedobject.ConstType == ConstObjectType.Code)
            {
                usedby = siteDb.Code.GetUsedBy(embeddedobject.Id);
            }

            References = Sites.Helper.RelationHelper.Sum(usedby);
        }