本文整理汇总了C#中this.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# this.Convert方法的具体用法?C# this.Convert怎么用?C# this.Convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.Convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToScaledSmoothedCanny
public static Image<Gray, byte> ToScaledSmoothedCanny(this Image<Bgr,byte> image)
{
Image<Gray, Byte> grayFrame = image.Convert<Gray, Byte>();
Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown();
Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp();
Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(new Gray(100), new Gray(60));
return cannyFrame;
}
示例2: Convert
/// <summary>
/// Extends Convert so that buffer offset of 0 and call to Array.Length are not needed.
/// <example>
/// decoder.Convert(bytes, chars, charIndex, charCount, flush, bytesUsed, charsUsed, completed);
/// </example>
/// </summary>
public static void Convert(this Decoder decoder, Byte[] bytes, Char[] chars, Int32 charIndex, Int32 charCount, Boolean flush, out Int32 bytesUsed, out Int32 charsUsed, out Boolean completed)
{
if(decoder == null) throw new ArgumentNullException("decoder");
if(bytes == null) throw new ArgumentNullException("bytes");
decoder.Convert(bytes, 0, bytes.Length, chars, charIndex, charCount, flush, out bytesUsed, out charsUsed, out completed);
}
示例3: Convert
/// <summary>
/// Extends Convert so that buffer offset of 0 and call to Array.Length are not needed.
/// <example>
/// encoder.Convert(chars, bytes, byteIndex, byteCount, flush, charsUsed, bytesUsed, completed);
/// </example>
/// </summary>
public static void Convert(this Encoder encoder, Char[] chars, Byte[] bytes, Int32 byteIndex, Int32 byteCount, Boolean flush, out Int32 charsUsed, out Int32 bytesUsed, out Boolean completed)
{
if(encoder == null) throw new ArgumentNullException("encoder");
if(chars == null) throw new ArgumentNullException("chars");
encoder.Convert(chars, 0, chars.Length, bytes, byteIndex, byteCount, flush, out charsUsed, out bytesUsed, out completed);
}
示例4: ConvertSafe
/// <summary>
/// Converts a value and handles typical bugs of Toolkit and official IValueConverters.
/// </summary>
/// <param name="vc"></param>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public static object ConvertSafe(this IValueConverter vc, object value, Type targetType, object parameter, CultureInfo culture)
{
// WP7 Toolkit's time converters have a bug where dates of different time zones are not properly
// converted, and also crash the app. This fixes it.
// See https://github.com/WFoundation/WF.Player.WinPhone/issues/23
if (value is DateTime)
{
DateTime dtValue = (DateTime)value;
// Lets the converter try converting the raw value.
try
{
vc.Convert(dtValue, targetType, parameter, culture);
}
catch (NotSupportedException)
{
// Fix the value date time by converting it to local time.
DateTime fixedValue = dtValue.ToLocalTime();
// The conversion should be fine now.
try
{
return vc.Convert(fixedValue, targetType, parameter, culture);
}
catch (NotSupportedException)
{
// Despite all precautions, if the conversion still doesn't work, this probably means that
// the date is still considered to be "in the future". Let's assume it's not too far from the present...
try
{
return vc.Convert(DateTime.Now, targetType, parameter, culture);
}
catch (Exception)
{
// Great despair, and nothing much to be done...
return null;
}
}
}
}
// Let the wrapper converter handle other values.
return vc.Convert(value, targetType, parameter, culture);
}
示例5: FromPersistence
/// <summary>
/// Converts persistence objects to immutable statistics objects
/// </summary>
/// <param name="dataArray">The persistence data objects.</param>
/// <returns>array of statistics objects</returns>
public static ExecutionStatistics[] FromPersistence(this ExecutionData[] dataArray)
{
return dataArray.Convert(
d => new ExecutionStatistics(
d.Name,
d.OpenCount,
d.CloseCount,
d.Counters,
d.RunningTime));
}
示例6: ColorLevel
public static Image<Bgr, Byte> ColorLevel(this Image<Gray, Byte> src, ConnectLevel conn)
{
var dst = src.Convert<Bgr, Byte>();
var color = new Bgr(0, 0, 255);
foreach (var domain in conn.Domains) {
foreach (var p in domain.Points) {
dst[p.Y, p.X] = color;
}
}
return dst;
}
示例7: ToPersistence
/// <summary>
/// Converts immutable statistics objects to the persistence objects
/// </summary>
/// <param name="statisticsArray">The immutable statistics objects.</param>
/// <returns>array of persistence objects</returns>
public static ExecutionData[] ToPersistence(this ExecutionStatistics[] statisticsArray)
{
return statisticsArray.Convert(es => new ExecutionData
{
CloseCount = es.CloseCount,
Counters = es.Counters,
Name = es.Name,
OpenCount = es.OpenCount,
RunningTime = es.RunningTime
});
}
示例8: ToListViewGroupData
public static ListViewGroupedModel<ConsignDetail> ToListViewGroupData(this ConsignDto dto)
{
var lst = dto.Convert();
var a = lst.ToLookup(l => l.Group)
.Select(l => new ListViewGroup<ConsignDetail>(l) {
Title = l.Key,
ShortTitle = l.Key,
});
return new ListViewGroupedModel<ConsignDetail>() {
Groups = new ObservableCollection<ListViewGroup<ConsignDetail>>(a)
};
}
示例9: Enumerable
public static IEnsuring Enumerable(this IBooleanCondition<Type> condition)
{
var concreteCondition = condition.Convert<ConditionTree<Type>>();
var isEnumerable = concreteCondition.Value.IsEnumerable();
if (!concreteCondition.IsNegated)
{
if (!isEnumerable)
{
if (concreteCondition.IsArgument)
{
var defaultException = new ArgumentException("The type is not enumerable.", concreteCondition.ArgumentName);
ConditionalException
.Throw(defaultException, concreteCondition.Exception);
}
ConditionalException
.Throw(new TypeIsNotEnumerableException(), concreteCondition.Exception);
}
}
else
{
if (isEnumerable)
{
if (concreteCondition.IsArgument)
{
var defaultException = new ArgumentException("The type is enumerable.", concreteCondition.ArgumentName);
ConditionalException
.Throw(defaultException, concreteCondition.Exception);
}
ConditionalException
.Throw(new TypeIsEnumerableException(), concreteCondition.Exception);
}
}
return EnsuringWrapper.Create();
}
示例10: ToCairo
public static global::Cairo.Color ToCairo(this IColor me)
{
Color.Bgra bgra = me.Convert<Color.Bgra>();
return new global::Cairo.Color(bgra.Red / 255.0, bgra.Green / 255.0, bgra.Blue / 255.0, bgra.Alpha / 255.0);
}
示例11: ToNanos
/// <summary>
/// Convert the specified time duration in the given unit to the
/// nanoseconds units.
/// </summary>
public static double ToNanos(this TimeUnit @from, long duration) {
return @from.Convert(duration, TimeUnit.Nanoseconds);
}
示例12: Convert
public static object Convert(this IStepArgumentTypeConverter converter, object value, Type typeToConvertTo, CultureInfo cultureInfo)
{
return converter.Convert(value, new RuntimeBindingType(typeToConvertTo), cultureInfo);
}
示例13: AddColor
public static Pen AddColor(this Pen pen, Color addColor, float percent)
{
return pen.Convert(pen.Color.AddColor(addColor, percent));
}
示例14: ToBlueGrayScale
public static Pen ToBlueGrayScale(this Pen pen)
{
return pen.Convert(pen.Color.ToBlueGrayScale());
}
示例15: Call
public static object Call(this IValueConverter converter, object value)
{
return converter.Convert(value, null, null, null);
}