SGScript.Variable.SetSubItem C# (CSharp) Method

SetSubItem() public method

public SetSubItem ( Variable key, Variable val, bool isprop ) : bool
key Variable
val Variable
isprop bool
return bool
        public bool SetSubItem( Variable key, Variable val, bool isprop )
        {
            return ctx.SetIndex( this, key, val, isprop );
        }

Same methods

Variable::SetSubItem ( string key, Variable val, bool isprop ) : bool

Usage Example

Esempio n. 1
0
        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);
        }