本文整理汇总了C#中Variant.GetVariantType方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.GetVariantType方法的具体用法?C# Variant.GetVariantType怎么用?C# Variant.GetVariantType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variant
的用法示例。
在下文中一共展示了Variant.GetVariantType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSetProperty
protected override void OnSetProperty(string property, Variant value)
{
if (property == "MTU")
{
uint mtu = 0;
if (value.GetVariantType() == Variant.VariantType.BitStream)
{
var bs = (BitwiseStream)value;
bs.SeekBits(0, SeekOrigin.Begin);
ulong bits;
int len = bs.ReadBits(out bits, 32);
mtu = Endian.Little.GetUInt32(bits, len);
}
else if (value.GetVariantType() == Variant.VariantType.ByteString)
{
byte[] buf = (byte[])value;
int len = Math.Min(buf.Length * 8, 32);
mtu = Endian.Little.GetUInt32(buf, len);
}
else
{
throw new SoftException("Can't set MTU, 'value' is an unsupported type.");
}
if (MaxMTU >= mtu && mtu >= MinMTU)
{
try
{
using (var sock = OpenSocket(mtu))
{
Logger.Debug("Changed MTU of {0} to {1}.", Interface, mtu);
}
}
catch (Exception ex)
{
string err = "Failed to change MTU of '{0}' to {1}. {2}".Fmt(Interface, mtu, ex.Message);
Logger.Error(err);
var se = new SoftException(err, ex);
throw new SoftException(se);
}
}
}
}