AjTalk.Language.BaseMetaClass.CreateClass C# (CSharp) Метод

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

public CreateClass ( string name, string varnames ) : IClass
name string
varnames string
Результат IClass
        public IClass CreateClass(string name, string varnames)
        {
            if (this.classInstance != null)
                throw new InvalidOperationException("Metaclass has an instance class");

            IBehavior super = null;

            if (this.SuperClass != null)
            {
                IMetaClass meta = this.SuperClass as IMetaClass;
                if (meta != null)
                    super = meta.ClassInstance;
            }

            BaseClass cls = new BaseClass(this, name, super, this.Machine, varnames);
            this.classInstance = cls;

            return cls;
        }

Usage Example

Пример #1
0
        public Machine(bool iscurrent)
        {
            if (iscurrent)
                this.SetCurrent();

            IMetaClass meta = new BaseMetaClass(null, null, this, string.Empty);
            this.nilclass = (BaseClass)meta.CreateClass("UndefinedObject", string.Empty);

            // TODO review, nil object never receives a message, see Send in Execution block
            this.nilclass.DefineInstanceMethod(new BehaviorDoesNotUnderstandMethod(this, this.nilclass));
            this.nilclass.DefineClassMethod(new BehaviorDoesNotUnderstandMethod(this, this.nilclass));
            this.nilclass.DefineInstanceMethod(new FunctionalMethod("ifNil:", this.nilclass, this.IfNil));
            this.nilclass.DefineInstanceMethod(new FunctionalMethod("ifNotNil:", this.nilclass, this.IfNotNil));
            this.nilclass.DefineInstanceMethod(new FunctionalMethod("isNil", this.nilclass, this.IsNil));
            this.nilclass.DefineInstanceMethod(new FunctionalMethod("isNotNil", this.nilclass, this.IsNotNil));

            // Native Behaviors
            var nativeObjectBehavior = new NativeObjectBehavior(meta, null, this);
            var enumerableBehavior = new EnumerableBehavior(meta, nativeObjectBehavior, this);
            var booleanBehavior = new BooleanBehavior(meta, nativeObjectBehavior, this);
            var listBehavior = new ListBehavior(meta, enumerableBehavior, this);
            var stringBehavior = new StringBehavior(meta, nativeObjectBehavior, this);

            this.RegisterNativeBehavior(typeof(IEnumerable), enumerableBehavior);
            this.RegisterNativeBehavior(typeof(bool), booleanBehavior);
            this.RegisterNativeBehavior(typeof(IList), listBehavior);
            this.RegisterNativeBehavior(typeof(Block), new BlockBehavior(meta, this.nilclass, this));
            this.RegisterNativeBehavior(typeof(string), stringBehavior);

            // Global Objects
            this.SetGlobalObject("UndefinedObject", this.nilclass);
            this.SetGlobalObject("Machine", this);
            this.SetGlobalObject("Smalltalk", this.environment);
        }
All Usage Examples Of AjTalk.Language.BaseMetaClass::CreateClass