Exemplo n.º 1
0
// SetProp sets the property name of the component c with the value v.
// SetProp panics if the component does not have such property or
// if the types do not match.
func (job *Job) SetProp(c fwk.Component, name string, value interface{}) {
	job.setProp(c, name, value)
	job.stmts = append(job.stmts, Stmt{
		Type: StmtSetProp,
		Data: C{
			Type: c.Type(),
			Name: c.Name(),
			Props: P{
				name: value,
			},
		},
	})
}
Exemplo n.º 2
0
func (job *Job) setProp(c fwk.Component, name string, value interface{}) {
	if !job.app.HasProp(c, name) {
		err := fwk.Errorf("component [%s:%s] has no property named %q\n",
			c.Type(),
			c.Name(),
			name,
		)
		job.Errorf(err.Error())
		panic(err)
	}

	err := job.app.SetProp(c, name, value)
	if err != nil {
		job.Errorf(
			"could not set property name=%q value=%#v on component [%s]: %v\n",
			name, value,
			c.Name(),
			err,
		)
		panic(err)
	}
}