本文整理汇总了C#中Kirikiri.Tjs2.Variant.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.GetString方法的具体用法?C# Variant.GetString怎么用?C# Variant.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kirikiri.Tjs2.Variant
的用法示例。
在下文中一共展示了Variant.GetString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringProperty
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
private static void GetStringProperty(Variant result, Variant str, Variant member
)
{
// processes properties toward strings.
if (member.IsNumber() != true)
{
string name = member.GetString();
if (name == null)
{
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty);
}
if (name.Equals("length"))
{
// get string length
string s = str.AsString();
if (s == null)
{
result.Set(0);
}
else
{
// tTJSVariantString::GetLength can return zero if 'this' is NULL
result.Set(s.Length);
}
return;
}
else
{
if (name[0] >= '0' && name[0] <= '9')
{
string s = str.AsString();
int n = int.Parse(name);
int len = s.Length;
if (n == len)
{
result.Set(string.Empty);
return;
}
if (n < 0 || n > len)
{
throw new TJSException(Error.RangeError);
}
result.Set(Sharpen.Runtime.Substring(s, n, n + 1));
return;
}
}
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name);
}
else
{
// member.Type() == tvtInteger || member.Type() == tvtReal
string s = str.AsString();
int n = member.AsInteger();
int len = s.Length;
if (n == len)
{
result.Set(string.Empty);
return;
}
if (n < 0 || n > len)
{
throw new TJSException(Error.RangeError);
}
result.Set(Sharpen.Runtime.Substring(s, n, n + 1));
return;
}
}
示例2: SetOctetProperty
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
private static void SetOctetProperty(Variant param, Variant octet, Variant member
)
{
// processes properties toward octets.
if (member.IsNumber() != true)
{
string name = member.GetString();
if (name == null)
{
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty);
}
if (name.Equals("length"))
{
ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty);
}
else
{
if (name[0] >= '0' && name[0] <= '9')
{
ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty);
}
}
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name);
}
else
{
// member.Type() == tvtInteger || member.Type() == tvtReal
ThrowFrom_tjs_error(Error.E_ACCESSDENYED, string.Empty);
}
}
示例3: GetOctetProperty
/// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
private static void GetOctetProperty(Variant result, Variant octet, Variant member
)
{
// processes properties toward octets.
if (member.IsNumber() != true)
{
string name = member.GetString();
if (name == null)
{
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty);
}
if (name.Equals("length"))
{
// get string length
ByteBuffer o = octet.AsOctet();
if (o != null)
{
result.Set(o.Capacity());
}
else
{
result.Set(0);
}
return;
}
else
{
if (name[0] >= '0' && name[0] <= '9')
{
ByteBuffer o = octet.AsOctet();
int n = int.Parse(name);
int len = o != null ? o.Capacity() : 0;
if (n < 0 || n >= len)
{
throw new TJSException(Error.RangeError);
}
result.Set(o.Get(n));
return;
}
}
ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name);
}
else
{
// member.Type() == tvtInteger || member.Type() == tvtReal
ByteBuffer o = octet.AsOctet();
int n = member.AsInteger();
int len = o != null ? o.Capacity() : 0;
if (n < 0 || n >= len)
{
throw new TJSException(Error.RangeError);
}
result.Set(o.Get(n));
return;
}
}