本文整理汇总了C#中Kirikiri.Tjs2.Variant.AsObject方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.AsObject方法的具体用法?C# Variant.AsObject怎么用?C# Variant.AsObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kirikiri.Tjs2.Variant
的用法示例。
在下文中一共展示了Variant.AsObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VariantToJavaObject
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
public static object VariantToJavaObject(Variant param, Type type)
{
if (type.IsPrimitive)
{
// プリミティブタイプの场合
if (type.Equals(typeof(int)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger());
}
else
{
if (type.Equals(typeof(double)))
{
return (param.AsDouble());
}
else
{
if (type.Equals(typeof(bool)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger() != 0 ? true : false);
}
else
{
if (type.Equals(typeof(float)))
{
return ((float)param.AsDouble());
}
else
{
if (type.Equals(typeof(long)))
{
return Sharpen.Extensions.ValueOf(param.AsInteger());
}
else
{
if (type.Equals(typeof(char)))
{
return ((char)param.AsInteger());
}
else
{
if (type.Equals(typeof(byte)))
{
return (unchecked((byte)param.AsInteger()));
}
else
{
if (type.Equals(typeof(short)))
{
return ((short)param.AsInteger());
}
else
{
// may be Void.TYPE
return null;
}
}
}
}
}
}
}
}
}
else
{
if (type.Equals(typeof(string)))
{
return param.AsString();
}
else
{
if (type.Equals(typeof(ByteBuffer)))
{
return param.AsOctet();
}
else
{
if (type.Equals(typeof(Variant)))
{
return param;
}
else
{
if (type.Equals(typeof(VariantClosure)))
{
return param.AsObjectClosure();
}
else
{
if (type.Equals(typeof(Dispatch2)))
{
return param.AsObject();
}
else
{
if (type.Equals(param.ToJavaObject().GetType()))
{
return param.ToJavaObject();
//.........这里部分代码省略.........
示例2: Callback
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
public virtual bool Callback(string name, int flags, Variant value)
{
if ((flags & Interface.HIDDENMEMBER) != 0)
{
return true;
}
if (value.IsObject())
{
// object
Dispatch2 dsp = value.AsObject();
// determin dsp's object type
Variant val;
if (dsp != null)
{
if (dsp.GetNativeInstance(DictionaryClass.ClassID) != null)
{
// dictionary
bool objrec = false;
int count = mStack.Count;
for (int i = 0; i < count; i++)
{
Dispatch2 v = mStack[i];
if (v == dsp)
{
// object recursion detected
objrec = true;
break;
}
}
val = new Variant();
if (objrec)
{
val.SetObject(null);
}
else
{
// becomes null
Dispatch2 newobj = TJS.CreateDictionaryObject();
val.SetObject(newobj, newobj);
DictionaryNI newni;
if ((newni = (DictionaryNI)newobj.GetNativeInstance(DictionaryClass.ClassID)) !=
null)
{
newni.AssignStructure(dsp, mStack);
}
}
}
else
{
if (dsp.GetNativeInstance(ArrayClass.ClassID) != null)
{
// array
bool objrec = false;
int count = mStack.Count;
for (int i = 0; i < count; i++)
{
Dispatch2 v = mStack[i];
if (v == dsp)
{
// object recursion detected
objrec = true;
break;
}
}
val = new Variant();
if (objrec)
{
val.SetObject(null);
}
else
{
// becomes null
Dispatch2 newobj = TJS.CreateArrayObject();
val.SetObject(newobj, newobj);
ArrayNI newni;
if ((newni = (ArrayNI)newobj.GetNativeInstance(ArrayClass.ClassID)) != null)
{
newni.AssignStructure(dsp, mStack);
}
}
}
else
{
val = value;
}
}
}
else
{
// other object types
val = value;
}
mDest.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, val, mDest);
}
else
{
// other types
mDest.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, value, mDest);
//.........这里部分代码省略.........