public static ContentSourceInfo FindContentSourceForLiveClipboardFormat(LiveClipboardFormat format)
        {
            // see if the preferred content source is noted in the registry
            string contentSourceId = GetContentSourceIdForFormat(format);

            if (contentSourceId != null)
            {
                // if the content-source is still installed and active then return it
                ContentSourceInfo contentSourceInfo = ContentSourceManager.FindContentSource(contentSourceId);
                if (contentSourceInfo != null)
                {
                    return(contentSourceInfo);
                }
            }

            // didn't find a valid preconfigured entry, scan all sources to see if we've got one
            foreach (ContentSourceInfo contentSourceInfo in ContentSourceManager.ActiveContentSources)
            {
                foreach (LiveClipboardFormatHandler csFormatHandler in contentSourceInfo.LiveClipboardFormatHandlers)
                {
                    if (csFormatHandler.Format.Equals(format))
                    {
                        // note that this is now our default
                        SetContentSourceForFormat(format, contentSourceInfo.Id);

                        // return the source
                        return(contentSourceInfo);
                    }
                }
            }

            // no match found
            return(null);
        }
Example #2
0
        private bool InsertSmartContentFromEmbed(string embed)
        {
            ContentSourceInfo contentSource = ContentSourceManager.FindContentSource(typeof(VideoContentSource));

            if (contentSource != null)
            {
                SmartContentSource smartSource   = contentSource.Instance as SmartContentSource;
                VideoContentSource videoSource   = smartSource as VideoContentSource;
                IExtensionData     extensionData = _contentSourceSite.CreateExtensionData(Guid.NewGuid().ToString());
                ISmartContent      smartContent  = new SmartContent(extensionData);
                videoSource.CreateContentFromEmbed(embed, smartContent);
                // generate html and insert it
                string content = videoSource.GenerateEditorHtml(smartContent, _contentSourceSite);
                if (content != null)
                {
                    _contentSourceSite.InsertContent(VideoContentSource.ID, content, extensionData);
                    return(true);
                }
                else
                {
                    Trace.Fail("Video Source content generated from embed tag was empty");
                    return(false);
                }
            }
            Trace.Fail("Cannot find the video plugin");
            return(false);
        }