C# Class IronPython.Runtime.Types.ReflectedField

Inheritance: PythonTypeSlot, ICodeFormattable
Mostrar archivo Open project: jschementi/iron Class Usage Examples

Private Properties

Property Type Description
DoSet void
IsSetDescriptor bool
MakeGetExpression void
ShouldSetOrDelete bool
TryDeleteValue bool
TryGetValue bool
TrySetValue bool
TrySetValueWorker bool
__delete__ void

Public Methods

Method Description
GetValue ( Microsoft.Scripting.CodeContext context, object instance ) : object

Convenience function for users to call directly

ReflectedField ( FieldInfo info ) : System.Linq.Expressions
ReflectedField ( FieldInfo info, NameType nameType ) : System.Linq.Expressions
SetValue ( Microsoft.Scripting.CodeContext context, object instance, object value ) : void

This function can be used to set a field on a value type without emitting a warning. Otherwise it is provided only to have symmetry with properties which have GetValue/SetValue for supporting explicitly implemented interfaces. Setting fields on value types usually warns because it can silently fail to update the value you expect. For example consider this example where Point is a value type with the public fields X and Y: arr = System.Array.CreateInstance(Point, 10) arr[0].X = 42 print arr[0].X prints 0. This is because reading the value from the array creates a copy of the value. Setting the value then mutates the copy and the array does not get updated. The same problem exists when accessing members of a class.

__repr__ ( Microsoft.Scripting.CodeContext context ) : string
__set__ ( Microsoft.Scripting.CodeContext context, object instance, object value ) : void

Private Methods

Method Description
DoSet ( Microsoft.Scripting.CodeContext context, object instance, object val, bool suppressWarning ) : void
IsSetDescriptor ( Microsoft.Scripting.CodeContext context, IronPython.Runtime.Types.PythonType owner ) : bool
MakeGetExpression ( PythonBinder binder, Expression codeContext, DynamicMetaObject instance, DynamicMetaObject owner, ConditionalBuilder builder ) : void
ShouldSetOrDelete ( IronPython.Runtime.Types.PythonType type ) : bool
TryDeleteValue ( Microsoft.Scripting.CodeContext context, object instance, IronPython.Runtime.Types.PythonType owner ) : bool
TryGetValue ( Microsoft.Scripting.CodeContext context, object instance, IronPython.Runtime.Types.PythonType owner, object &value ) : bool
TrySetValue ( Microsoft.Scripting.CodeContext context, object instance, IronPython.Runtime.Types.PythonType owner, object value ) : bool
TrySetValueWorker ( Microsoft.Scripting.CodeContext context, object instance, IronPython.Runtime.Types.PythonType owner, object value, bool suppressWarning ) : bool
__delete__ ( object instance ) : void

Method Details

GetValue() public method

Convenience function for users to call directly
public GetValue ( Microsoft.Scripting.CodeContext context, object instance ) : object
context Microsoft.Scripting.CodeContext
instance object
return object

ReflectedField() public method

public ReflectedField ( FieldInfo info ) : System.Linq.Expressions
info System.Reflection.FieldInfo
return System.Linq.Expressions

ReflectedField() public method

public ReflectedField ( FieldInfo info, NameType nameType ) : System.Linq.Expressions
info System.Reflection.FieldInfo
nameType NameType
return System.Linq.Expressions

SetValue() public method

This function can be used to set a field on a value type without emitting a warning. Otherwise it is provided only to have symmetry with properties which have GetValue/SetValue for supporting explicitly implemented interfaces. Setting fields on value types usually warns because it can silently fail to update the value you expect. For example consider this example where Point is a value type with the public fields X and Y: arr = System.Array.CreateInstance(Point, 10) arr[0].X = 42 print arr[0].X prints 0. This is because reading the value from the array creates a copy of the value. Setting the value then mutates the copy and the array does not get updated. The same problem exists when accessing members of a class.
public SetValue ( Microsoft.Scripting.CodeContext context, object instance, object value ) : void
context Microsoft.Scripting.CodeContext
instance object
value object
return void

__repr__() public method

public __repr__ ( Microsoft.Scripting.CodeContext context ) : string
context Microsoft.Scripting.CodeContext
return string

__set__() public method

public __set__ ( Microsoft.Scripting.CodeContext context, object instance, object value ) : void
context Microsoft.Scripting.CodeContext
instance object
value object
return void