本文整理汇总了C#中DType类的典型用法代码示例。如果您正苦于以下问题:C# DType类的具体用法?C# DType怎么用?C# DType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DType类属于命名空间,在下文中一共展示了DType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DTypeToType
public static Type DTypeToType(DType type)
{
Type temp = null;
if (!fundamentalTypes.TryGetValue(type, out temp))
temp = null;
return temp;
}
示例2: DigitsArray
static DigitsArray()
{
unchecked
{
AllBits = (DType)~((DType)0);
HiBitSet = (DType)(((DType)1) << (DataSizeBits) - 1);
}
}
示例3: ReadValue
//helper method, should not be used generally
public object ReadValue (DType dtype)
{
switch (dtype)
{
case DType.Byte:
return ReadByte ();
case DType.Boolean:
return ReadBoolean ();
case DType.Int16:
return ReadInt16 ();
case DType.UInt16:
return ReadUInt16 ();
case DType.Int32:
return ReadInt32 ();
case DType.UInt32:
return ReadUInt32 ();
case DType.Int64:
return ReadInt64 ();
case DType.UInt64:
return ReadUInt64 ();
#if !DISABLE_SINGLE
case DType.Single:
return ReadSingle ();
#endif
case DType.Double:
return ReadDouble ();
case DType.String:
return ReadString ();
case DType.ObjectPath:
return ReadObjectPath ();
case DType.Signature:
return ReadSignature ();
case DType.Variant:
return ReadVariant ();
default:
throw new Exception ("Unhandled D-Bus type: " + dtype);
}
}
示例4: SetType
public DVar[] Fields = new DVar[12]; //This is explicityly left unprotected to reduce access overhead
public DType SetType(DType type)
{
if (!DType.IsParentOf(type))
throw new Exception(string.Format("Type {0} is not a parent of tyoe {1} and so cannot be extended", DType, type));
DType = type;
var maxFieldIndex = DType.FieldIndex;
if (maxFieldIndex >= Fields.Length)
{
var newFields = new DVar[Fields.Length + 10];
Array.Copy(Fields, newFields, Fields.Length);
Fields = newFields;
}
return type;
}
示例5: PropertyInvokeDialog
public PropertyInvokeDialog(Window parent, Bus bus, string busName, ObjectPath path, IElement element)
: base(element.Name, parent, DialogFlags.DestroyWithParent | DialogFlags.Modal)
{
this.Build ();
this.parent = parent;
this.setAlign.HideAll ();
this.WidthRequest = 250;
this.HeightRequest = 150;
this.propertyName.Text = element.Name;
this.propertyType = Mapper.DTypeFromString (element.Data.ReturnType);
try {
this.caller = new PropertyCaller (bus, busName, path, element.Parent.Name, element.Name, element.Data);
} catch (Exception e) {
Logging.Error ("Error while creating the invocation proxy", e, parent);
buttonExecute.Sensitive = false;
}
}
示例6: GetAlignment
public static int GetAlignment(DType dtype)
{
switch (dtype) {
case DType.Byte:
return 1;
case DType.Boolean:
return 4;
case DType.Int16:
case DType.UInt16:
return 2;
case DType.Int32:
case DType.UInt32:
return 4;
case DType.Int64:
case DType.UInt64:
return 8;
#if !DISABLE_SINGLE
case DType.Single: //Not yet supported!
return 4;
#endif
case DType.Double:
return 8;
case DType.String:
return 4;
case DType.ObjectPath:
return 4;
case DType.Signature:
return 1;
case DType.Array:
return 4;
case DType.Struct:
case DType.StructBegin:
return 8;
case DType.Variant:
return 1;
case DType.DictEntry:
case DType.DictEntryBegin:
return 8;
case DType.Invalid:
default:
throw new Exception ("Cannot determine alignment of " + dtype);
}
}
示例7: GetAlignment
public static int GetAlignment (DType dtype)
{
switch (dtype) {
case DType.Byte:
return 1;
case DType.Boolean:
return 4;
case DType.Int16:
case DType.UInt16:
return 2;
case DType.Int32:
case DType.UInt32:
return 4;
case DType.Int64:
case DType.UInt64:
return 8;
#if !DISABLE_SINGLE
case DType.Single: //Not yet supported!
return 4;
#endif
case DType.Double:
return 8;
case DType.String:
return 4;
case DType.ObjectPath:
return 4;
case DType.Signature:
return 1;
case DType.Array:
return 4;
case DType.StructBegin:
return 8;
case DType.Variant:
return 1;
case DType.DictEntryBegin:
return 8;
case DType.UnixFileDescriptor:
return 4;//note that this refers to the length of the INDEX to the FD, not the FD itself
case DType.Invalid:
default:
throw new Exception ("Cannot determine alignment of " + dtype);
}
}
示例8: Signature
internal Signature(DType[] value)
{
if (value == null)
throw new ArgumentNullException ("value");
if (value.Length == 0) {
this.data = Empty.data;
return;
}
if (value.Length == 1) {
this.data = DataForDType (value[0]);
return;
}
this.data = new byte[value.Length];
for (int i = 0 ; i != value.Length ; i++)
this.data[i] = (byte)value[i];
}
示例9: Convert
public static object Convert(DType type, string value)
{
switch (type) {
case DType.Boolean:
return bool.Parse (value);
case DType.Byte:
return byte.Parse (value);
case DType.Int16:
return short.Parse (value);
case DType.Int32:
return int.Parse (value);
case DType.Int64:
return long.Parse (value);
case DType.UInt32:
return uint.Parse (value);
case DType.UInt64:
return ulong.Parse (value);
case DType.UInt16:
return ushort.Parse (value);
default:
return value;
}
}
示例10: SingleDivide
private static void SingleDivide(BigInteger leftSide, BigInteger rightSide, out BigInteger quotient, out BigInteger remainder)
{
if (rightSide.IsZero)
{
throw new DivideByZeroException();
}
DigitsArray remainderDigits = new DigitsArray(leftSide.m_digits);
remainderDigits.ResetDataUsed();
int pos = remainderDigits.DataUsed - 1;
ulong divisor = (ulong)rightSide.m_digits[0];
ulong dividend = (ulong)remainderDigits[pos];
DType[] result = new DType[leftSide.m_digits.Count];
leftSide.m_digits.CopyTo(result, 0, result.Length);
int resultPos = 0;
if (dividend >= divisor)
{
result[resultPos++] = (DType)(dividend / divisor);
remainderDigits[pos] = (DType)(dividend % divisor);
}
pos--;
while (pos >= 0)
{
dividend = ((ulong)(remainderDigits[pos + 1]) << DigitsArray.DataSizeBits) + (ulong)remainderDigits[pos];
result[resultPos++] = (DType)(dividend / divisor);
remainderDigits[pos + 1] = 0;
remainderDigits[pos--] = (DType)(dividend % divisor);
}
remainder = new BigInteger(remainderDigits);
DigitsArray quotientDigits = new DigitsArray(resultPos + 1, resultPos);
int j = 0;
for (int i = quotientDigits.DataUsed - 1; i >= 0; i--, j++)
{
quotientDigits[j] = result[i];
}
quotient = new BigInteger(quotientDigits);
}
示例11: MultiDivide
private static void MultiDivide(BigInteger leftSide, BigInteger rightSide, out BigInteger quotient, out BigInteger remainder)
{
if (rightSide.IsZero)
{
throw new DivideByZeroException();
}
DType val = rightSide.m_digits[rightSide.m_digits.DataUsed - 1];
int d = 0;
for (uint mask = DigitsArray.HiBitSet; mask != 0 && (val & mask) == 0; mask >>= 1)
{
d++;
}
int remainderLen = leftSide.m_digits.DataUsed + 1;
DType[] remainderDat = new DType[remainderLen];
leftSide.m_digits.CopyTo(remainderDat, 0, leftSide.m_digits.DataUsed);
DigitsArray.ShiftLeft(remainderDat, d);
rightSide = rightSide << d;
ulong firstDivisor = rightSide.m_digits[rightSide.m_digits.DataUsed - 1];
ulong secondDivisor = (rightSide.m_digits.DataUsed < 2 ? (DType)0 : rightSide.m_digits[rightSide.m_digits.DataUsed - 2]);
int divisorLen = rightSide.m_digits.DataUsed + 1;
DigitsArray dividendPart = new DigitsArray(divisorLen, divisorLen);
DType[] result = new DType[leftSide.m_digits.Count + 1];
int resultPos = 0;
ulong carryBit = (ulong)0x1 << DigitsArray.DataSizeBits; // 0x100000000
for (int j = remainderLen - rightSide.m_digits.DataUsed, pos = remainderLen - 1; j > 0; j--, pos--)
{
ulong dividend = ((ulong)remainderDat[pos] << DigitsArray.DataSizeBits) + (ulong)remainderDat[pos - 1];
ulong qHat = (dividend / firstDivisor);
ulong rHat = (dividend % firstDivisor);
while (pos >= 2)
{
if (qHat == carryBit || (qHat * secondDivisor) > ((rHat << DigitsArray.DataSizeBits) + remainderDat[pos - 2]))
{
qHat--;
rHat += firstDivisor;
if (rHat < carryBit)
{
continue;
}
}
break;
}
for (int h = 0; h < divisorLen; h++)
{
dividendPart[divisorLen - h - 1] = remainderDat[pos - h];
}
BigInteger dTemp = new BigInteger(dividendPart);
BigInteger rTemp = rightSide * (long)qHat;
while (rTemp > dTemp)
{
qHat--;
rTemp -= rightSide;
}
rTemp = dTemp - rTemp;
for (int h = 0; h < divisorLen; h++)
{
remainderDat[pos - h] = rTemp.m_digits[rightSide.m_digits.DataUsed - h];
}
result[resultPos++] = (DType)qHat;
}
Array.Reverse(result, 0, resultPos);
quotient = new BigInteger(new DigitsArray(result));
int n = DigitsArray.ShiftRight(remainderDat, d);
DigitsArray rDA = new DigitsArray(n, n);
rDA.CopyFrom(remainderDat, 0, 0, rDA.DataUsed);
remainder = new BigInteger(rDA);
}
示例12: CopyTo
internal void CopyTo(DType[] array, int offset, int length)
{
Array.Copy(m_data, 0, array, offset, length);
}
示例13: CopyFrom
internal void CopyFrom(DType[] source, int sourceOffset, int offset, int length)
{
Array.Copy(source, sourceOffset, m_data, 0, length);
}
示例14: ReportAbstractNotImplemented
internal override void ReportAbstractNotImplemented(ErrorSink/*!*/ errors, DType/*!*/ declaringType, PhpType/*!*/ referringType)
{
errors.Add(Errors.AbstractPropertyNotImplemented, referringType.Declaration.SourceUnit,
referringType.Declaration.Position, referringType.FullName, declaringType.MakeFullGenericName(), this.FullName);
ReportError(errors, Errors.RelatedLocation);
}
示例15: GetAttributeUsageCount
public override int GetAttributeUsageCount(DType/*!*/ type, AST.CustomAttribute.TargetSelectors selector)
{
return attributes.Count(type, selector);
}