本文整理汇总了C#中RubyContext.IsObjectFrozen方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.IsObjectFrozen方法的具体用法?C# RubyContext.IsObjectFrozen怎么用?C# RubyContext.IsObjectFrozen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.IsObjectFrozen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeCopy
public static object InitializeCopy(RubyContext/*!*/ context, object self, object source) {
RubyClass selfClass = context.GetClassOf(self);
RubyClass sourceClass = context.GetClassOf(source);
if (sourceClass != selfClass) {
throw RubyExceptions.CreateTypeError("initialize_copy should take same class object");
}
if (context.IsObjectFrozen(self)) {
throw RubyExceptions.CreateTypeError(String.Format("can't modify frozen {0}", selfClass.Name));
}
return self;
}
示例2: UniqueSelf
public static IList UniqueSelf(RubyContext/*!*/ context, IList/*!*/ self) {
var seen = new Dictionary<object, bool>(context.EqualityComparer);
bool modified = false;
int i = 0;
while (i < self.Count) {
object key = self[i];
if (!seen.ContainsKey(key)) {
seen.Add(key, true);
i++;
} else {
if (context.IsObjectFrozen(self)) {
throw RubyExceptions.CreateTypeError("can't modify frozen array");
}
self.RemoveAt(i);
modified = true;
}
}
return modified ? self : null;
}
示例3: Frozen
public static bool Frozen(RubyContext/*!*/ context, object self) {
if (RubyUtils.IsRubyValueType(self)) {
return false; // can't freeze value types
}
return context.IsObjectFrozen(self);
}
示例4: RequiresNotFrozen
public static void RequiresNotFrozen(RubyContext/*!*/ context, object/*!*/ obj) {
if (context.IsObjectFrozen(obj)) {
throw RubyExceptions.CreateTypeError("can't modify frozen object");
}
}