C# Class IronPython.Runtime.Types.ReflectedField

Inheritance: PythonTypeSlot, ICodeFormattable
Afficher le fichier Open project: jschementi/iron Class Usage Examples

Private Properties

Свойство Type Description
DoSet void
IsSetDescriptor bool
MakeGetExpression void
ShouldSetOrDelete bool
TryDeleteValue bool
TryGetValue bool
TrySetValue bool
TrySetValueWorker bool
__delete__ void

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

ReflectedField() public méthode

public ReflectedField ( FieldInfo info ) : System.Linq.Expressions
info System.Reflection.FieldInfo
Résultat System.Linq.Expressions

ReflectedField() public méthode

public ReflectedField ( FieldInfo info, NameType nameType ) : System.Linq.Expressions
info System.Reflection.FieldInfo
nameType NameType
Résultat System.Linq.Expressions

SetValue() public méthode

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
Résultat void

__repr__() public méthode

public __repr__ ( Microsoft.Scripting.CodeContext context ) : string
context Microsoft.Scripting.CodeContext
Résultat string

__set__() public méthode

public __set__ ( Microsoft.Scripting.CodeContext context, object instance, object value ) : void
context Microsoft.Scripting.CodeContext
instance object
value object
Résultat void