Beispiel #1
0
        public override object GetAttr(ICallerContext context, object self, SymbolId name)
        {
            object ret;

            if (TryGetAttr(context, self, name, out ret))
            {
                return(ret);
            }
            throw Ops.AttributeErrorForMissingAttribute(ToString(), name);
        }
Beispiel #2
0
        internal void SetAttr(ICallerContext context, SymbolId name, object value)
        {
            Initialize(context);

            if (HaveInterfaces)
            {
                foreach (DynamicType type in interfaces)
                {
                    try {
                        type.SetAttr(context, obj, name, value);
                        return;
                    } catch {
                    }
                }
                throw Ops.AttributeErrorForMissingAttribute(ComType.MakeDynamicType().__name__.ToString(), name);
            }
            else
            {
                try {
                    Obj.GetType().InvokeMember(
                        (string)SymbolTable.IdToString(name),
                        System.Reflection.BindingFlags.SetProperty |
                        System.Reflection.BindingFlags.SetField,
                        Type.DefaultBinder,
                        Obj,
                        new object[1] {
                        value
                    }
                        );
                } catch (Exception e) {
                    if (e.InnerException != null)
                    {
                        throw ExceptionConverter.UpdateForRethrow(e.InnerException);
                    }
                    throw;
                }
            }
        }