SGScript.IObjectBase.sgsSetPropertyByName C# (CSharp) Method

sgsSetPropertyByName() public method

public sgsSetPropertyByName ( Variable key, Context ctx, bool isprop, int valueOnStack ) : bool
key Variable
ctx Context
isprop bool
valueOnStack int
return bool
        public bool sgsSetPropertyByName( Variable key, Context ctx, bool isprop, int valueOnStack )
        {
            SGSClassInfo cinfo = GetClassInfo();
            SGSPropInfo propinfo;
            if( !cinfo.props.TryGetValue( key, out propinfo ) || !propinfo.canWrite )
            {
                if( backingStore != null )
                    return backingStore.SetSubItem( key, ctx.StackItem( valueOnStack ), isprop );
                return false;
            }
            if( propinfo.parseVarMethod == null )
                throw new SGSException( RC.ENOTFND, string.Format(
                    "Property cannot be set - no Context.ParseVar method exists that supports this type ({0})", propinfo.propType ) );

            object[] args = new object[]{ null, ctx.StackItem( valueOnStack ) };
            propinfo.parseVarMethod.Invoke( ctx, args );
            if( propinfo.info is FieldInfo )
                (propinfo.info as FieldInfo).SetValue( this, args[0] );
            else // PropertyInfo
                (propinfo.info as PropertyInfo).SetValue( this, args[0], null );
            return true;
        }

Same methods

IObjectBase::sgsSetPropertyByName ( Variable key, Variable val, bool isprop ) : bool