本文整理汇总了C#中IronRuby.Builtins.RubyModule.EnsureInitialized方法的典型用法代码示例。如果您正苦于以下问题:C# RubyModule.EnsureInitialized方法的具体用法?C# RubyModule.EnsureInitialized怎么用?C# RubyModule.EnsureInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.RubyModule
的用法示例。
在下文中一共展示了RubyModule.EnsureInitialized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeMembersFrom
internal void InitializeMembersFrom(RubyModule/*!*/ module) {
ContractUtils.RequiresNotNull(module, "module");
#if !SILVERLIGHT // missing Clone on Delegate
if (module.DeclaresGlobalConstants || module._clrConstants != null && _constants == null) {
#endif
EnsureInitialized();
module.EnsureInitialized();
#if !SILVERLIGHT
} else {
_state = module._state;
_initializer = (module._initializer != null) ? (Action<RubyModule>)module._initializer.Clone() : null;
}
#endif
if (module.DeclaresGlobalConstants) {
Debug.Assert(module._constants == null && module._clrConstants == null);
Debug.Assert(_constants != null);
_constants.Clear();
foreach (KeyValuePair<SymbolId, object> constant in _context.TopGlobalScope.Items) {
_constants.Add(SymbolTable.IdToString(constant.Key), constant.Value);
}
} else {
_constants = (module._constants != null) ? new Dictionary<string, object>(module._constants) : null;
// copy namespace members:
if (module._clrConstants != null) {
Debug.Assert(_constants != null);
foreach (KeyValuePair<SymbolId, object> constant in module._clrConstants.SymbolAttributes) {
_constants.Add(SymbolTable.IdToString(constant.Key), constant.Value);
}
}
}
_methods = (module._methods != null) ? new Dictionary<string, RubyMemberInfo>(module._methods) : null;
_classVariables = (module._classVariables != null) ? new Dictionary<string, object>(module._classVariables) : null;
_mixins = ArrayUtils.Copy(module._mixins);
// dependentModules - skip
// tracker - skip, .NET members not copied
Updated("InitializeFrom");
}
示例2: AddFullVersionTest
internal void AddFullVersionTest(RubyModule/*!*/ module, RubyContext/*!*/ context, Expression/*!*/ contextExpression) {
Assert.NotNull(module, context, contextExpression);
module.EnsureInitialized(); // Initialization changes the version number, so ensure that the module is initialized
// check for runtime (note that the module's runtime could be different from the call-site runtime):
AddRestriction(Ast.Equal(contextExpression, Ast.Constant(context)));
// check for version:
AddCondition(Ast.Equal(Ast.Property(Ast.Constant(module), RubyModule.VersionProperty), Ast.Constant(module.Version)));
}