internal override bool TryDeleteValue(CodeContext /*!*/ context, object instance, PythonType owner) { Assert.NotNull(context, owner); throw ReadOnlyException(DynamicHelpers.GetPythonTypeFromType(Info.DeclaringType)); }
public void __set__(CodeContext context, object instance, object value) { TrySetValue(context, instance, DynamicHelpers.GetPythonType(instance), value); }
public string /*!*/ __repr__(CodeContext /*!*/ context) { return(String.Format("<method '{0}' of '{1}' objects>", Template.Name, DynamicHelpers.GetPythonTypeFromType(DeclaringType).Name)); }
internal override bool TrySetValue(CodeContext context, object instance, PythonType owner, object value) { if (instance == null) { return(false); } if (!(instance is IPythonObject sdo)) { throw PythonOps.TypeError("__class__ assignment: only for user defined types"); } if (!(value is PythonType dt)) { throw PythonOps.TypeError("__class__ must be set to new-style class, not '{0}' object", DynamicHelpers.GetPythonType(value).Name); } if (dt.UnderlyingSystemType != DynamicHelpers.GetPythonType(instance).UnderlyingSystemType) { throw PythonOps.TypeErrorForIncompatibleObjectLayout("__class__ assignment", DynamicHelpers.GetPythonType(instance), dt.UnderlyingSystemType); } sdo.SetPythonType(dt); return(true); }
public static ReflectedEvent.BoundEvent MakeBoundEvent(ReflectedEvent eventObj, object instance, Type type) { return(new ReflectedEvent.BoundEvent(eventObj, instance, DynamicHelpers.GetPythonTypeFromType(type))); }
public string /*!*/ __repr__(CodeContext /*!*/ context) { return(string.Format("<property# {0} on {1}>", __name__, DynamicHelpers.GetPythonTypeFromType(DeclaringType).Name)); }
public void __set__(CodeContext context, object instance, object value) { // TODO: Throw? currently we have a test that verifies we never throw when this is called directly. TrySetValue(context, instance, DynamicHelpers.GetPythonType(instance), value); }