本文整理汇总了C#中MediaType类的典型用法代码示例。如果您正苦于以下问题:C# MediaType类的具体用法?C# MediaType怎么用?C# MediaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaType类属于命名空间,在下文中一共展示了MediaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDraft
/// <summary>
/// Gets the draft data for the media entity with the given id.
/// </summary>
/// <param name="id">The id</param>
/// <param name="type">The media type</param>
/// <returns>The draft media data, null if the data wasn't found</returns>
public virtual byte[] GetDraft(Guid id, MediaType type = MediaType.Media) {
var path = GetPath(id, true, type);
if (File.Exists(path))
return File.ReadAllBytes(path);
return null;
}
示例2: Put
/// <summary>
/// Stores the given data for the media entity with the given id.
/// </summary>
/// <param name="id">The id</param>
/// <param name="data">The media data</param>
/// <param name="type">The media type</param>
public void Put(Guid id, byte[] data, MediaType type = MediaType.Media) {
var blob = GetBlock(type, id, false) ;
using (var stream = new MemoryStream(data)) {
blob.UploadFromStream(stream) ;
}
}
示例3: ChannelChangedEventArgs
/// <summary>
///
/// </summary>
/// <param name="channelName"></param>
/// <param name="channelUri"></param>
/// <param name="trackTitle"></param>
public ChannelChangedEventArgs(MediaType mediaType, string channelName, Uri channelUri, string trackTitle)
{
_mediaType = mediaType;
_trackName = trackTitle;
_channelUri = channelUri;
_channelName = channelName;
}
示例4: Get
/// <summary>
/// Gets the data for the cached image with the given dimensions. In case of
/// a cache miss null is returned.
/// </summary>
/// <param name="id">The id</param>
/// <param name="width">The width of the image</param>
/// <param name="height">The optional height of the image</param>
/// <param name="type">The media type</param>
/// <returns>The binary data, null in case of a cache miss</returns>
public virtual byte[] Get(Guid id, int width, int? height, MediaType type = MediaType.Media) {
var path = GetPath(id, false, width, height, type) ;
if (File.Exists(path))
return File.ReadAllBytes(path) ;
return null ;
}
示例5: GivenARequest
public void GivenARequest(string verb, string uri, byte[] content, MediaType contentType)
{
var destinationUri = new Uri("http://127.0.0.1:" + this.port + uri);
WebRequest request = WebRequest.Create(destinationUri);
request.Timeout = int.MaxValue;
request.Method = verb;
request.ContentLength = content != null ? content.Length : 0;
if (request.ContentLength > 0)
{
request.ContentType = contentType.ToString();
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(content, 0, content.Length);
}
}
try
{
this.theResponse = request.GetResponse() as HttpWebResponse;
}
catch (WebException exception)
{
this.theResponse = exception.Response as HttpWebResponse;
}
}
示例6: ForMediaType
public ICodecWithMediaTypeDefinition ForMediaType(MediaType mediaType)
{
var model = new MediaTypeModel { MediaType = mediaType };
this.codecRegistration.MediaTypes.Add(model);
return new CodecMediaTypeDefinition(this, model);
}
示例7: MyMsrpSession
public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
: base(sipStack)
{
this.mCallback = new MyMsrpCallback(this);
base.mMediaType = mediaType;
base.remotePartyUri = remoteUri;
if (session == null)
{
base.outgoing = true;
#if WINDOWS_PHONE
mSession = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMsrpSessionNew(sipStack.WrappedStack, mCallback);
#else
mSession = new MsrpSession(sipStack.WrappedStack, mCallback);
#endif
}
else
{
base.outgoing = false;
mSession = session;
mSession.setCallback(mCallback);
}
// commons
base.init();
// SigComp
base.SigCompId = sipStack.SigCompId;
mSession.addHeader("Subject", "FIXME");
}
示例8: GetHttpEntity
public static HttpEntity GetHttpEntity(InMemoryRequest postRequest, string data, MediaType MediaType)
{
var bytes = Encoding.UTF8.GetBytes(data);
var httpEntity = new HttpEntity(postRequest.Entity.Headers, new MemoryStream(bytes)) { ContentLength = bytes.Length };
httpEntity.ContentType = MediaType;
return httpEntity;
}
示例9: PersonalMessage
public PersonalMessage(string personalmsg, MediaType mediatype, string[] currentmediacontent)
{
Message = personalmsg;
mediaType = mediatype;
content = currentmediacontent;
Format = "{0}";
}
示例10: AtomLink
/// <summary>
/// Represents an <see cref="AtomLink"/> instance initialized with the given <see cref="Uri"/>,
/// title, <see cref="Relationship"/> and <see cref="Type"/>.
/// </summary>
/// <param name="href">The <see cref="Uri"/> of the link.</param>
/// <param name="rel">The <see cref="Relationship"/> of the link.</param>
/// <param name="type">The <see cref="Type"/> of the link.</param>
/// <param name="title">The <see cref="Title"/> of the link.</param>
public AtomLink(Uri href, Relationship rel, MediaType type, string title)
{
this.HRef = href;
this.Title = title;
this.Rel = rel;
this.Type = type;
}
示例11: DownloadList
public DownloadList(MediaType mediaType, ListDownloadStatusEventHandler onDownloadStatusChange = null, int poolSize = 3)
{
MediaType = mediaType;
OnListDownloadStatusChange = onDownloadStatusChange;
_ignoreDownloaded = false;
_poolSize = poolSize;
}
示例12: Serialize
private static string Serialize(MediaType mediaType, object value)
{
Stream stream = null;
try
{
stream = new MemoryStream();
new JsonFormat().Serialize(mediaType, value, stream);
stream.Position = 0;
using (StreamReader reader = new StreamReader(stream))
{
stream = null;
return reader.ReadToEnd();
}
}
finally
{
if (stream != null)
{
stream.Dispose();
}
}
}
示例13: MPAInfo
public MPAInfo(MPAHeader hdr, UInt64 duration)
{
ai_ = new AudioInfo();
ai_.bitRate = MPAHeaderParser.bitrate(hdr);
ai_.bitsPerSample = 16;
ai_.channels = (UInt16)(hdr.channelMode < 3 ? 2 : 1);
ai_.sampleRate = MPAHeaderParser.samplingRate(hdr);
ai_.layer = (UInt16)(4 - hdr.layer);
ai_.vbr = false; //todo
duration_ = duration;
switch (hdr.version)
{
case 3:
{
mt_ = MediaType.MPEG10; break;
}
case 2:
{
mt_ = MediaType.MPEG20; break;
}
case 0:
{
mt_ = MediaType.MPEG25; break;
}
}
}
示例14: Get
/// <summary>
/// Gets the data for the media entity with the given id.
/// </summary>
/// <param name="id">The id</param>
/// <param name="type">The media type</param>
/// <returns>The media data, null if the data wasn't found</returns>
public byte[] Get(Guid id, MediaType type = MediaType.Media) {
var path = GetPath(id, false, type) ;
if (File.Exists(path))
return File.ReadAllBytes(path) ;
return null ;
}
示例15: ParseMediaType
//These methods should only be used when an exact match was found
private bool ParseMediaType(string input, out MediaType value)
{
input = input.CutToTag("title", true);
input = input.CutToLast('(', CutDirection.Left, true);
input = input.CutToFirst(')', CutDirection.Right, true);
value = MediaType.Movie;
return true;
//if (!input.Contains(" "))
//{
// value = ResultType.None;
// return true;
//}
//input = input.CutToLast(' ', CutDirection.Right, true);
//switch (input.ToString())
//{
// case "Video Game":
// value = ResultType.VideoGame;
// return true;
// case "Video":
// value = ResultType.Video;
// return true;
// case "TV":
// value = ResultType.TV;
// return true;
// case "TV series":
// value = ResultType.TVseries;
// return true;
// default:
// value = ResultType.None;
// return false;
//}
}