Stetic.TypedPropertyDescriptor.SetValue C# (CSharp) Method

SetValue() public method

public SetValue ( object obj, object value ) : void
obj object
value object
return void
        public override void SetValue(object obj, object value)
        {
            ObjectWrapper ww = ObjectWrapper.Lookup (obj);
            IDisposable t = ww != null && !ww.Loading? ww.UndoManager.AtomicChange : null;
            try {
                if (isWrapperProperty)
                    obj = ww;
                if (memberInfo != null)
                    obj = memberInfo.GetValue (obj, null);
                propertyInfo.SetValue (obj, value, null);
            } catch (Exception ex) {
                throw new InvalidOperationException ("Could not set value for property " + klass.Name + "." + Name + " to object '" + obj + "'", ex);
            } finally {
                if (t != null)
                    t.Dispose ();
            }
        }

Usage Example

Esempio n. 1
0
 static void SetProperties(TypedClassDescriptor klass, Gtk.Widget widget, string[] propNames, GLib.Value[] propVals)
 {
     for (int n = 0; n < propNames.Length; n++)
     {
         foreach (ItemGroup grp in klass.ItemGroups)
         {
             foreach (ItemDescriptor it in grp)
             {
                 if (it is TypedPropertyDescriptor)
                 {
                     TypedPropertyDescriptor prop = (TypedPropertyDescriptor)it;
                     if (prop.GladeName == propNames[n])
                     {
                         prop.SetValue(widget, propVals[n].Val);
                     }
                 }
             }
         }
     }
 }