Beispiel #1
0
 internal static ReflectedType MakeDynamicType()
 {
     if (comType != null)
     {
         return(comType);
     }
     lock (typeof(ComType)) {
         if (comType != null)
         {
             return(comType);
         }
         comType = new ComType();
         return(comType);
     }
 }
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;
                }
            }
        }