• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ContentType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Create

        public static RequestInfo Create(
            RequestMethod method, string target, string uriTemplate, Dictionary<string, object> parameters,
            string userAgent, Dictionary<string, string> headers, ContentType requestContentType,
            ContentType responseContentType, TimeSpan cacheDuration,
            int timeout, int retryCount,
            Uri uri, string requestBody, IRequestFactory requestFactory)
        {
            var result = new RequestInfo
                             {
                                 Target = target,
                                 UriTemplate = uriTemplate,
                                 AllowedRetries = retryCount,
                                 Uri = uri,
                                 Method = method,
                                 UserAgent = userAgent,
                                 _headers = new Dictionary<string, string>(headers ?? new Dictionary<string, string>()),
                                 RequestBody = requestBody,
                                 Parameters = new Dictionary<string, object>(parameters ?? new Dictionary<string, object>()),
                                 CacheDuration = cacheDuration,
                                 RequestContentType = requestContentType,
                                 ResponseContentType = responseContentType,
                                 Timeout = timeout
                             };

            return result;
        }
开发者ID:bitpusher,项目名称:Salient.ReliableHttpClient,代码行数:26,代码来源:RequestInfo.cs


示例17: ContentTypeOfXmlFileDependsOnRootElement

		public void ContentTypeOfXmlFileDependsOnRootElement(string tag,
			ContentType expectedContentType)
		{
			string xmlData = CreateXmlDataFromTag(tag);
			ContentType contentTypeFromXmlRoot = GetContentTypeOfXmlData(xmlData);
			Assert.AreEqual(expectedContentType, contentTypeFromXmlRoot);
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:ContentTypeIdentifierTests.cs


示例18: CreateFields

		private static void CreateFields(ClientContext ctx, ContentType orderCT) {
			#region Customer
			FieldCreationInformation customer = new FieldCreationInformation(FieldType.Lookup);
			customer.DisplayName = "Customer";
			customer.InternalName = "Customer";
			customer.Group = "ODA1";
			customer.Id = Constants.GUID.OrderCT.CUSTOMER.ToGuid();

			ctx.Web.AddFieldToContentType(orderCT, ctx.Web.CreateField<FieldUrl>(customer, false));
			#endregion
			#region Product
			TaxonomyFieldCreationInformation product = new TaxonomyFieldCreationInformation();

			product.DisplayName = "Product";
			product.InternalName = "Product_2";
			product.Group = "ODA1";
			product.TaxonomyItem = GetProductTermSet(ctx);
			
			product.Id = Constants.GUID.OrderCT.PRODUCT.ToGuid();
			var meh = ctx.Web.CreateTaxonomyField(product);
			ctx.ExecuteQuery();
			ctx.Web.WireUpTaxonomyField(meh, product.TaxonomyItem as TermSet);
			ctx.Web.AddFieldToContentType(orderCT, meh );
			#endregion
			#region Price
			FieldCreationInformation price = new FieldCreationInformation(FieldType.Currency);
			price.DisplayName = "Price";
			price.InternalName = "Price";
			price.Group = "ODA1";
			price.Id = Constants.GUID.OrderCT.PRICE.ToGuid();

			FieldUrl addedPrice = ctx.Web.CreateField<FieldUrl>(price, false);
			ctx.Web.AddFieldToContentType(orderCT, addedPrice);
			#endregion
		}
开发者ID:Luviz,项目名称:OfficeDev1.MAssinment,代码行数:35,代码来源:OrderCT.cs


示例19: GetContentType

        public static string GetContentType(ContentType contentType)
        {
            if (ContentTypes.ContainsKey(contentType))
                return ContentTypes[contentType];

            return null;
        }
开发者ID:TheHunter,项目名称:HunterCouch,代码行数:7,代码来源:CouchConstant.cs


示例20: AddKeyWordProperty

		private TextType AddKeyWordProperty(TextType propType, string name, string value, ContentType property)
		{
			if (propType == null)
			{
				propType = new TextType(property);
				m_docText.AddTextType(propType);
			}

			TextNode newNode = new TextNode();
			newNode.AddParent(propType);
			propType.AddChild(newNode);

			newNode.AddInfo(new NodeInfo()
			{
				name = "Name",
				type = DataType.String,
				value = name
			});

			newNode.AddInfo(new NodeInfo()
			{
				name = "Value",
				type = DataType.String,
				value = value
			});

			return propType;
		}
开发者ID:killbug2004,项目名称:WSProf,代码行数:28,代码来源:DiscoveryResult.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Context类代码示例发布时间:2022-05-24
下一篇:
C# ContentSection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap