本文整理汇总了C#中DataFormat类的典型用法代码示例。如果您正苦于以下问题:C# DataFormat类的具体用法?C# DataFormat怎么用?C# DataFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataFormat类属于命名空间,在下文中一共展示了DataFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RawTexture
public RawTexture()
{
Width = 0;
Height = 0;
Data = new byte[0];
Format = DataFormat.Invalid;
}
示例2: OEmbed
public ActionResult OEmbed(string url, int maxwidth = 570, int maxheight = 400, DataFormat format = DataFormat.Json)
{
if (string.IsNullOrEmpty(url))
return HttpStatusCodeResult(HttpStatusCode.BadRequest, "URL not specified");
var route = new RouteInfo(new Uri(url), AppConfig.HostAddress).RouteData;
var controller = route.Values["controller"].ToString().ToLowerInvariant();
if (controller != "song" && controller != "s") {
return HttpStatusCodeResult(HttpStatusCode.BadRequest, "Only song embeds are supported");
}
int id;
if (controller == "s") {
var match = Regex.Match(route.Values["action"].ToString(), @"(\d+)");
id = int.Parse(match.Groups[1].Value);
}
else {
id = int.Parse(route.Values["id"].ToString());
}
var song = Services.Songs.GetSong(id);
var html = string.Format("<iframe src=\"{0}\" width=\"{1}\" height=\"{2}\"></iframe>",
VocaUriBuilder.CreateAbsolute(Url.Action("EmbedSong", new {songId = id})), maxwidth, maxheight);
return Object(new SongOEmbedResponse(song, maxwidth, maxheight, html), format);
}
示例3: Serialization
Serialization(DataFormat dataFormat, string streamName)
{
Dbg.Assert(!string.IsNullOrEmpty(streamName), "stream needs a name");
format = dataFormat;
this.streamName = streamName;
}
示例4: GetWireType
private WireType GetWireType(TypeCode code, DataFormat format, ref Type type, out int modelKey)
{
modelKey = -1;
if (type.IsEnum) return WireType.None;
switch (code)
{
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Boolean:
case TypeCode.SByte:
case TypeCode.Byte:
case TypeCode.Char:
return WireType.Variant;
case TypeCode.Double:
return WireType.Fixed64;
case TypeCode.Single:
return WireType.Fixed32;
case TypeCode.String:
case TypeCode.DateTime:
case TypeCode.Decimal:
return WireType.String;
}
if (type == typeof(byte[]) || type == typeof(TimeSpan)
|| type == typeof(Guid) || type == typeof(Uri)) return WireType.String;
if ((modelKey = GetKey(ref type)) >= 0)
{
return WireType.String;
}
return WireType.None;
}
示例5: ByPV
public ActionResult ByPV(PVService service, string pvId, ContentLanguagePreference? lang, string callback,
DataFormat format = DataFormat.Auto)
{
var song = Service.GetSongWithPV(s => new SongForApiContract(s, lang ?? ContentLanguagePreference.Default), service, pvId);
return Object(song, format, callback);
}
示例6: ByPVBase
public ActionResult ByPVBase(PVService service, string pvId, string callback,
DataFormat format = DataFormat.Auto)
{
var song = Service.GetSongWithPV(s => new EntryBaseContract(s), service, pvId);
return Object(song, format, callback);
}
示例7: Run
public static string Run(string data, DataFormat inputFormat, DataFormat outputFormat, Operation operation)
{
if (string.IsNullOrEmpty(data)) return string.Empty;
var bytes = GetBytes(data, inputFormat);
var result = Process(bytes, operation);
return GetString(result, outputFormat);
}
示例8: RESTfulInvocationHandler
/// <summary>
/// 实例化RESTfulInvocationHandler
/// </summary>
/// <param name="attribute"></param>
/// <param name="token"></param>
/// <param name="foramt"></param>
public RESTfulInvocationHandler(string url, PublishKindAttribute attribute, Token token, DataFormat foramt, int timeout)
{
this.format = foramt;
this.attribute = attribute;
this.token = token;
this.url = url;
this.timeout = timeout;
}
示例9: UploadActivityAsync
/// <summary>
/// Uploads an activity.
/// </summary>
/// <param name="file">The path to the activity file on your local hard disk.</param>
/// <param name="dataFormat">The format of the file.</param>
/// <param name="activityType">The type of the activity.</param>
/// <returns>The status of the upload.</returns>
public async Task<UploadStatus> UploadActivityAsync(StorageFile file, DataFormat dataFormat, ActivityType activityType = ActivityType.Ride)
{
String format = String.Empty;
switch (dataFormat)
{
case DataFormat.Fit:
format = "fit";
break;
case DataFormat.FitGZipped:
format = "fit.gz";
break;
case DataFormat.Gpx:
format = "gpx";
break;
case DataFormat.GpxGZipped:
format = "gpx.gz";
break;
case DataFormat.Tcx:
format = "tcx";
break;
case DataFormat.TcxGZipped:
format = "tcx.gz";
break;
}
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", Authentication.AccessToken));
MultipartFormDataContent content = new MultipartFormDataContent();
byte[] fileBytes = null;
using (IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
{
fileBytes = new byte[stream.Size];
using (DataReader reader = new DataReader(stream))
{
await reader.LoadAsync((uint)stream.Size);
reader.ReadBytes(fileBytes);
}
}
var byteArrayContent = new ByteArrayContent(fileBytes);
content.Add(byteArrayContent, "file", file.Name);
HttpResponseMessage result = await client.PostAsync(
String.Format("https://www.strava.com/api/v3/uploads?data_type={0}&activity_type={1}",
format,
activityType.ToString().ToLower()),
content);
String json = await result.Content.ReadAsStringAsync();
return Unmarshaller<UploadStatus>.Unmarshal(json);
}
示例10: Index
public ActionResult Index(string query, DiscType discType = DiscType.Unknown,
int start = 0, bool getTotalCount = false, AlbumSortRule sort = AlbumSortRule.Name,
NameMatchMode nameMatchMode = NameMatchMode.Exact, DataFormat format = DataFormat.Auto)
{
var queryParams = new AlbumQueryParams(query, discType, start, maxResults, false, getTotalCount, nameMatchMode, sort);
var entries = Service.Find(a => new AlbumForApiContract(a, LoginManager.LanguagePreference), queryParams);
return Object(entries, format);
}
示例11: ByPVBase
public ActionResult ByPVBase(PVService? service, string pvId, string callback,
DataFormat format = DataFormat.Auto)
{
if (service == null)
return HttpStatusCodeResult(HttpStatusCode.BadRequest, "Service not specified or invalid");
var song = Service.GetSongWithPV(s => new EntryBaseContract(s), service.Value, pvId);
return Object(song, format, callback);
}
示例12: Tracks
public ActionResult Tracks(int id = invalidId, DataFormat format = DataFormat.Auto,
ContentLanguagePreference lang = ContentLanguagePreference.Default)
{
if (id == invalidId)
return NoId();
var tracks = Service.GetAlbum(id, a => a.Songs.Select(s => new SongInAlbumContract(s, lang)).ToArray());
return Object(tracks, format);
}
示例13: ConfigurationCell
/// <summary>
/// Creates a new <see cref="ConfigurationCell"/> from specified parameters.
/// </summary>
/// <param name="parent">The reference to parent <see cref="ConfigurationFrame"/> of this <see cref="ConfigurationCell"/>.</param>
/// <param name="idCode">The numeric ID code for this <see cref="ConfigurationCell"/>.</param>
/// <param name="isVirtual">Assigns flag that determines if this <see cref="ConfigurationCell"/> is virtual.</param>
public ConfigurationCell(ConfigurationFrame parent, ushort idCode, bool isVirtual)
: base(parent, idCode, int.MaxValue, int.MaxValue, int.MaxValue)
{
m_signalReferences = new Dictionary<SignalType, string[]>();
m_analogDataFormat = DataFormat.FloatingPoint;
m_frequencyDataFormat = DataFormat.FloatingPoint;
m_phasorDataFormat = DataFormat.FloatingPoint;
m_phasorCoordinateFormat = CoordinateFormat.Polar;
m_isVirtual = isVirtual;
}
示例14: IDX
// constructor for reading an IDX file
public IDX(Stream in_stream, bool in_writing=false)
{
_idx_stream = in_stream;
// verify we can actually use this stream
Debug.Assert(_idx_stream.CanRead && _idx_stream.CanSeek);
_writing = in_writing;
if (_writing)
{
// just verify stream is writeable
Debug.Assert(_idx_stream.CanWrite == true);
}
// get our endianness
_idx_endianness = (Endianness)(255 * ReadUInt8() + ReadUInt8());
Debug.Assert(_idx_endianness == Endianness.BigEndian || _idx_endianness == Endianness.LittleEndian);
// get data format
_data_format = (DataFormat)ReadUInt8();
// number of dimensions
byte dimensions = ReadUInt8();
Debug.Assert(dimensions > 0);
// get number of rows
_rows = ReadUInt32();
// calculate length of each row
_row_length = 1;
for (int k = 1; k < dimensions; k++)
{
_row_length *= ReadUInt32();
}
_row_length_bytes = _row_length;
switch (_data_format)
{
case DataFormat.UInt8:
case DataFormat.SInt8:
_row_length_bytes *= 1;
break;
case DataFormat.SInt16:
_row_length_bytes *= 2;
break;
case DataFormat.SInt32:
case DataFormat.Single:
_row_length_bytes *= 4;
break;
case DataFormat.Double:
_row_length_bytes *= 8;
break;
}
// get size of the header
_header_size = (uint)_idx_stream.Position;
}
示例15: ConfigurationCell
/// <summary>
/// Creates a new <see cref="ConfigurationCell"/> from specified parameters.
/// </summary>
/// <param name="parent">The reference to parent <see cref="ConfigurationFrame"/> of this <see cref="ConfigurationCell"/>.</param>
/// <param name="idCode">The numeric ID code for this <see cref="ConfigurationCell"/>.</param>
public ConfigurationCell(ConfigurationFrame parent, ushort idCode)
: base(parent, idCode, int.MaxValue, int.MaxValue, int.MaxValue)
{
// Create a cached signal reference dictionary for generated signal references
m_generatedSignalReferenceCache = new string[Enum.GetValues(typeof(SignalKind)).Length][];
m_analogDataFormat = DataFormat.FloatingPoint;
m_frequencyDataFormat = DataFormat.FloatingPoint;
m_phasorDataFormat = DataFormat.FloatingPoint;
m_phasorCoordinateFormat = CoordinateFormat.Polar;
}