IronRuby.Builtins.RubyModule.SetConstantChecked C# (CSharp) Метод

SetConstantChecked() публичный Метод

Sets constant of this module. Returns true if the constant is already defined in the module and it is not an autoloaded constant.
Thread safe.
public SetConstantChecked ( string name, object value ) : bool
name string
value object
Результат bool
        public bool SetConstantChecked(string/*!*/ name, object value) {
            using (Context.ClassHierarchyLocker()) {
                ConstantStorage existing;
                var result = TryLookupConstantNoLock(false, false, null, name, out existing);
                SetConstantNoLock(name, value);
                return result == ConstantLookupResult.Found;
            }
        }
        

Usage Example

Пример #1
0
        public static void SetConstant(RubyModule/*!*/ owner, string/*!*/ name, object value) {
            Assert.NotNull(owner, name);

            if (owner.SetConstantChecked(name, value)) {
                owner.Context.ReportWarning(String.Format("already initialized constant {0}", name));
            }

            // Initializes anonymous module's name:
            RubyModule module = value as RubyModule;
            if (module != null && module.Name == null) {
                module.Name = owner.MakeNestedModuleName(name);
            }
        }
RubyModule