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

TryResolveConstant() приватный Метод

private TryResolveConstant ( RubyContext callerContext, RubyGlobalScope autoloadScope, string name, IronRuby.Runtime.ConstantStorage &value ) : bool
callerContext RubyContext
autoloadScope IronRuby.Runtime.RubyGlobalScope
name string
value IronRuby.Runtime.ConstantStorage
Результат bool
        internal bool TryResolveConstant(RubyContext/*!*/ callerContext, RubyGlobalScope autoloadScope, string/*!*/ name, out ConstantStorage value) {
            return callerContext != Context ?
                TryResolveConstant(autoloadScope, name, out value) :
                TryResolveConstantNoLock(autoloadScope, name, out value);
        }

Same methods

RubyModule::TryResolveConstant ( RubyGlobalScope autoloadScope, string name, IronRuby.Runtime.ConstantStorage &value ) : bool

Usage Example

Пример #1
0
        internal static RubyClass/*!*/ DefineClass(Scope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name, object superClassObject) {
            Assert.NotNull(owner);
            RubyClass superClass = ToSuperClass(owner.Context, superClassObject);

            object existing;
            if (ReferenceEquals(owner, owner.Context.ObjectClass)
                ? owner.TryResolveConstant(autoloadScope, name, out existing)
                : owner.TryGetConstant(autoloadScope, name, out existing)) {
                
                RubyClass cls = existing as RubyClass;
                if (cls == null || !cls.IsClass) {
                    throw RubyExceptions.CreateTypeError(String.Format("{0} is not a class", name));
                }

                if (superClassObject != null && !ReferenceEquals(cls.SuperClass, superClass)) {
                    throw RubyExceptions.CreateTypeError(String.Format("superclass mismatch for class {0}", name));
                }
                return cls;
            } else {
                return owner.Context.DefineClass(owner, name, superClass);
            }
        }
All Usage Examples Of IronRuby.Builtins.RubyModule::TryResolveConstant
RubyModule