本文整理汇总了C#中Ruby.Class.instance_variable_set方法的典型用法代码示例。如果您正苦于以下问题:C# Class.instance_variable_set方法的具体用法?C# Class.instance_variable_set怎么用?C# Class.instance_variable_set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ruby.Class
的用法示例。
在下文中一共展示了Class.instance_variable_set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cvar_set
internal static object cvar_set(Frame caller, Class klass, string cvar_name, object value, bool warn) //author: Brian, status: done
{
Class tmp = klass;
while (tmp != null)
{
if (tmp.attached != null)
{
if (tmp._type == Class.Type.Singleton && !(tmp.attached is Class))
{
Methods.rb_warn_m.singleton.Call1(klass, klass, null, null, new String("class variable access from toplevel singleton method"));
tmp = (Class)(tmp.super);
klass = tmp;
}
else
{
tmp = (Class)(tmp.attached);
}
}
if (tmp.instance_variable_defined(cvar_name))
{
if (tmp.Frozen)
throw TypeError.rb_error_frozen(caller, "class/module").raise(caller);
if (!tmp.Tainted && Eval.rb_safe_level() >= 4)
throw new SecurityError("Insecure: can't modify class variable").raise(caller);
if (warn && Eval.Test(Options.ruby_verbose.value) && klass != tmp)
Methods.rb_warn_m.singleton.Call1(klass, klass, null, null, new String("already initialized class variable " + cvar_name));
tmp.instance_variable_set(cvar_name, value);
if (Eval.Test(Options.ruby_verbose.value))
cvar_override_check(cvar_name, tmp);
return value;
}
tmp = tmp.super;
}
return klass.instance_variable_set(cvar_name, value);
}