当前位置: 首页>>代码示例>>C#>>正文


C# ContentType类代码示例

本文整理汇总了C#中ContentType的典型用法代码示例。如果您正苦于以下问题:C# ContentType类的具体用法?C# ContentType怎么用?C# ContentType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContentType类属于命名空间,在下文中一共展示了ContentType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadAsync

        public async Task<IDictionary<long, Program>> LoadAsync(ContentType contentType, CancellationToken cancellationToken)
        {
            var playlists = Playlists;

            foreach (var playlist in playlists)
            {
                try
                {
                    var parser = new M3U8Parser();

                    if (null != _playlistWebReader)
                        _playlistWebReader.Dispose();

                    _playlistWebReader = _webReaderManager.CreateReader(playlist, ContentKind.Playlist, contentType: contentType);

                    var actualPlaylist = await parser.ParseAsync(_playlistWebReader, _retryManager, playlist, cancellationToken)
                        .ConfigureAwait(false);

                    return await LoadAsync(_playlistWebReader, parser, contentType, cancellationToken).ConfigureAwait(false);
                }
                catch (StatusCodeWebException e)
                {
                    // This one didn't work, so try the next playlist url.
                    Debug.WriteLine("HlsProgramManager.LoadAsync: " + e.Message);
                }
            }

            return NoPrograms;
        }
开发者ID:henricj,项目名称:phonesm,代码行数:29,代码来源:HlsProgramManager.cs

示例2: LoadSubProgram

        protected virtual async Task<ISubProgram> LoadSubProgram(IProgramManager programManager, ContentType contentType, CancellationToken cancellationToken)
        {
            ISubProgram subProgram;

            try
            {
                var programs = await programManager.LoadAsync(contentType, cancellationToken).ConfigureAwait(false);

                var program = programs.Values.FirstOrDefault();

                if (null == program)
                {
                    Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): program not found");
                    throw new FileNotFoundException("Unable to load program");
                }

                subProgram = SelectSubProgram(program.SubPrograms);

                if (null == subProgram)
                {
                    Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): no sub programs found");
                    throw new FileNotFoundException("Unable to load program stream");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: " + ex.Message);
                throw;
            }

            return subProgram;
        }
开发者ID:henricj,项目名称:phonesm,代码行数:32,代码来源:HlsPlaylistSegmentManagerPolicy.cs

示例3: AttachedAlbumData

 public AttachedAlbumData(ContentType type, Uri linkUrl,
     AlbumData album, AttachedImageData[] pictures, Uri plusBaseUrl)
     : base(type, linkUrl)
 {
     Album = album;
     Pictures = pictures;
 }
开发者ID:namoshika,项目名称:SnkLib.Web.GooglePlus,代码行数:7,代码来源:AttachedAlbumData.cs

示例4: CanFormatResponse

        public bool CanFormatResponse(ContentType acceptHeaderElement, bool matchCharset, out ContentType contentType)
        {
            if (acceptHeaderElement == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("acceptHeaderElement");
            }

            // Scrub the content type so that it is only mediaType and the charset
            string charset = acceptHeaderElement.CharSet;
            contentType = new ContentType(acceptHeaderElement.MediaType);
            contentType.CharSet = this.DefaultContentType.CharSet;
            string contentTypeStr = contentType.ToString();
            
            if (matchCharset &&
                !string.IsNullOrEmpty(charset) &&
                !string.Equals(charset, this.DefaultContentType.CharSet, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (this.contentTypeMapper != null &&
                this.contentTypeMapper.GetMessageFormatForContentType(contentType.MediaType) == this.ContentFormat)
            {
                return true;
            }

            if (this.Encoder.IsContentTypeSupported(contentTypeStr) && 
                (charset == null || contentType.CharSet == this.DefaultContentType.CharSet))
            {
                return true;
            }
            contentType = null;
            return false;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:34,代码来源:MultiplexingFormatMapping.cs

示例5: DataStreamContext

 public DataStreamContext(MemoryStream data, ContentType contentType)
 {
     this.contentType = contentType;
     this.baseUri = string.Format("data:{0};base64,", this.contentType);
     this.data = data;
     this.isBase64 = true;
 }
开发者ID:Carbonfrost,项目名称:ff-foundations-runtime,代码行数:7,代码来源:DataStreamContext.cs

示例6: XlsxMacrosheetXmlPartFilter

 public XlsxMacrosheetXmlPartFilter(CommonNamespaces commonNamespaces, Dictionary<string, string> StringContentLookup, Dictionary<string, WorkSheet> WorksheetLookup, Dictionary<string, CellFormatData> CellFormats, ContentType[] contentTypesToDetect, ref XlsxProcessingDictionaries processingDictionaries, ref PredefinedObjectsProcessingHelper predefinedObjectsHelper, PartInfo rel)
     : base(commonNamespaces, rel.Target, StringContentLookup, WorksheetLookup, CellFormats, contentTypesToDetect, ref processingDictionaries, ref predefinedObjectsHelper)
 {
     m_id = rel.Id;
     m_target = rel.Target;
     m_type = rel.GetContentType();
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:XlsxMacrosheetXmlPartFilter.cs

示例7: GetStreamEntries

    /// <summary>
    /// Get a list of entries for a specific stream.
    /// </summary>
    /// <remarks>streams-endpoint (https://developer.feedly.com/v3/streams/#get-the-content-of-a-stream)</remarks>
    /// <param name="id">A feedId, a categoryId, a tagId or a system category id.</param>
    /// <param name="type">The type of the <paramref name="id"/>.</param>
    /// <param name="count">Number of entry ids to return. Default is 20, max is 10000.</param>
    /// <param name="sorting">Newest or oldest. Default is newest.</param>
    /// <param name="unreadOnly">if <c>true</c>, return unread entries only.</param>
    /// <param name="newerThan">Date from where to search on.</param>
    /// <param name="continuation">A continuation id is used to page through the entries.</param>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <returns></returns>
    public async Task<FeedlyStreamEntriesResponse> GetStreamEntries(
      string id,
      ContentType type,
      int? count = null,
      FeedSorting sorting = FeedSorting.Newest,
      bool? unreadOnly = null,
      DateTime? newerThan = null,
      string continuation = null,
      CancellationToken cancellationToken = default(CancellationToken))
    {
      Dictionary<string, string> parameters = new Dictionary<string, string>();
      parameters["streamId"] = ValueToResource(type, id);
      parameters["ranked"] = sorting.ToString().ToLower();
      if (count.HasValue)
      {
        parameters["count"] = count.Value.ToString();
      }
      if (unreadOnly.HasValue)
      {
        parameters["unreadOnly"] = unreadOnly.Value.ToString();
      }
      if (newerThan.HasValue)
      {
        DateTime date = ((DateTime)newerThan.Value).ToUniversalTime();
        DateTime epoc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
        parameters["newerThan"] = Math.Truncate(date.Subtract(epoc).TotalMilliseconds).ToString();
      }
      if (!String.IsNullOrEmpty(continuation))
      {
        parameters["continuation"] = continuation;
      }

      return await Client.Request<FeedlyStreamEntriesResponse>(HttpMethod.Get, "v3/streams/contents", parameters, false, (type == ContentType.Category || type == ContentType.Tag), cancellationToken);
    }
开发者ID:jvanrhyn,项目名称:FeedlySharp,代码行数:47,代码来源:Streams.cs

示例8: GetEncoding

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="contentType"></param>
        /// <returns></returns>
        public static Encoding GetEncoding(this byte[] message, string contentType)
        {
            var charSet = new ContentType(contentType).CharSet.ToLower();
            switch (charSet)
            {
                case "utf-8":
                    return new UTF8Encoding();

                case "utf-16":
                    if (message[0] == 0xff && message[1] == 0xfe)
                    {
                        return new UnicodeEncoding(false, true);
                    }
                    if (message[0] == 0xfe && message[1] == 0xff)
                    {
                        return new UnicodeEncoding(true, true);
                    }

                    throw new InvalidOperationException("No byte order mark detected. Byte order mark required when charset=utf-16");

                case "utf-16le":
                    return new UnicodeEncoding(false, false);

                case "utf-16be":
                    return new UnicodeEncoding(true, false);

                default:                  
                    throw new InvalidOperationException("Unrecognised charset: " + charSet);
            }
        }
开发者ID:RustyF,项目名称:EnergyTrading-Core,代码行数:36,代码来源:ChannelsExtensions.cs

示例9: LoadSettings

 public void LoadSettings(ContentType type)
 {
     this.folders = new ContentRootFolderCollection(type);
     this.contentType = type;
     foreach (ContentRootFolder flder in contentType == ContentType.Movie ? Settings.MovieFolders : Settings.TvFolders)
         folders.Add(new ContentRootFolder(flder));
 }
开发者ID:Garreye,项目名称:meticumedia,代码行数:7,代码来源:RootFolderControl.xaml.cs

示例10: AddContentTypeToList

        /// <summary>
        /// Add content type to list
        /// </summary>
        /// <param name="list"></param>
        /// <param name="contentType"></param>
        /// <param name="defaultContent"></param>
        public static void AddContentTypeToList(this List list, ContentType contentType, bool defaultContent = false)
        {
            list.ContentTypesEnabled = true;
            list.Update();
            list.Context.ExecuteQuery();
            ContentTypeCollection contentTypes = list.ContentTypes;
            list.Context.Load(contentTypes);
            list.Context.ExecuteQuery();

            foreach (ContentType ct in contentTypes)
            {
                if (ct.Name.ToLowerInvariant() == contentType.Name.ToString().ToLowerInvariant())
                {
                    // Already there, abort
                    return;
                }
            }

            contentTypes.AddExistingContentType(contentType);
            list.Context.ExecuteQuery();
            //set the default content type
            if (defaultContent)
            {
                SetDefaultContentTypeToList(list, contentType);
            }
        }
开发者ID:usmanfast,项目名称:PnP,代码行数:32,代码来源:FieldAndContentTypeExtensions.cs

示例11: GetLast

 public IQueryable<MediaContent> GetLast(ContentType type, int count = GlobalConstants.HomeLastContentCount)
 {
     return this.contents.GetAll()
         .Where(c => c.ContentType == type)
         .OrderByDescending(c => c.CreatedOn)
         .Take(count);
 }
开发者ID:Borayvor,项目名称:ASP.NET-MVC-CourseProject,代码行数:7,代码来源:MediaContentFetcherService.cs

示例12: Selectable

        public Selectable(string text, string urlOrPadding, ContentType contentType)
        {
            switch (contentType)
            {
                case ContentType.Html:
                    {
                        HtmlDocument document = new HtmlDocument();
                        document.OptionAutoCloseOnEnd = true;
                        document.LoadHtml(text);

                        if (!string.IsNullOrEmpty(urlOrPadding))
                        {
                            FixAllRelativeHrefs(document, urlOrPadding);
                        }

                        Elements = new List<dynamic> { document.DocumentNode.OuterHtml };
                        break;
                    }
                case ContentType.Json:
                    {
                        string json = string.IsNullOrEmpty(urlOrPadding) ? text : RemovePadding(text, urlOrPadding);
                        Elements = new List<dynamic> { json };
                        break;
                    }
            }
        }
开发者ID:GamesDesignArt,项目名称:DotnetSpider,代码行数:26,代码来源:Selectable.cs

示例13: ContentRootFolder

 /// <summary>
 /// Default constructor
 /// </summary>
 public ContentRootFolder(ContentType type)
 {
     this.ContentType = type;
     childFolders.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(childFolders_CollectionChanged);
     this.Id = idCnt++;
     this.Temporary = false;
 }
开发者ID:Garreye,项目名称:meticumedia,代码行数:10,代码来源:ContentRootFolder.cs

示例14: View

 public void View(string contentName, ContentType type)
 {
     if (viewers.ContainsKey(type))
         viewers[type].PreviewContent(contentName);
     else
         ShowNoPreviewText(contentName);
 }
开发者ID:remy22,项目名称:DeltaEngine,代码行数:7,代码来源:ContentViewer.cs

示例15: BuildContentTypeClass

        public virtual CodeCompileUnit BuildContentTypeClass(ContentType contentType)
        {
            var unit = new CodeCompileUnit();

            // Add global namespace used for Imports
            _globalNameSpace = AddGlobalNamespace(unit);

            // Add main type namespace
            var mainNamespace = AddMainNamespace(unit, contentType);

            // Add main type declaration
            var typeDeclaration = AddTypeDeclaration(mainNamespace, contentType);

            // Add main type attributes
            AddContentTypeAttribute(contentType, typeDeclaration);
            AddAccessAttribute(contentType, typeDeclaration);

            // Add properties
            foreach (var propertyDefinition in contentType.PropertyDefinitions)
            {
                AddPropertyDeclaration(propertyDefinition, typeDeclaration);
            }

            AddDefaultValuesMethod(contentType, typeDeclaration);

            return unit;
        }
开发者ID:nordseth,项目名称:ComposerMigration,代码行数:27,代码来源:ContentTypeCodeBuilder.cs


注:本文中的ContentType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。