GetField() public méthode

public GetField ( String name, BindingFlags bindingAttr ) : FieldInfo
name String
bindingAttr BindingFlags
Résultat System.Reflection.FieldInfo
Exemple #1
0
 public virtual FieldInfo GetLocalField(String name)
 {
     return(storage.GetField(name, BindingFlags.Instance |
                             BindingFlags.Static |
                             BindingFlags.Public |
                             BindingFlags.DeclaredOnly));
 }
Exemple #2
0
        private static void DirectSetObjectProperty(object obj, string rhs, object value)
        {
            ArrayObject  ary       = obj as ArrayObject;
            StringObject str       = obj as StringObject;
            ScriptObject js_obj    = obj as ScriptObject;
            bool         is_js_obj = js_obj != null;

            if (is_js_obj)
            {
                InvalidateCacheEntry(js_obj, rhs);
            }

            // Numeric index?
            uint index;

            if (IsArrayIndex(rhs, out index))
            {
                if (ary != null)
                {
                    Hashtable elems     = ary.elems;
                    bool      had_value = elems.ContainsKey(index);
                    elems [index] = value;
                    if (!had_value)
                    {
                        AdjustArrayLength(ary, index);
                    }
                    return;
                }
                else if (str != null)
                {
                    return;
                }
            }
            if (!TrySetNativeProperty(obj, rhs, value) && is_js_obj)
            {
                FieldInfo field = js_obj.GetField(rhs);
                if (field == null)
                {
                    field = js_obj.AddField(rhs);
                }
                field.SetValue(rhs, value);
            }
        }
        internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext) : base(context)
        {
            this.body          = body;
            this.type          = type;
            this.handler       = handler;
            this.finally_block = finally_block;
            ScriptObject parent = base.Globals.ScopeStack.Peek();

            while (parent is WithObject)
            {
                parent = parent.GetParent();
            }
            this.handler_scope = null;
            this.field         = null;
            if (identifier != null)
            {
                this.fieldName = identifier.ToString();
                this.field     = parent.GetField(this.fieldName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                if (this.field != null)
                {
                    if ((((type == null) && (this.field is JSVariableField)) && (this.field.IsStatic && (((JSVariableField)this.field).type == null))) && (!this.field.IsLiteral && !this.field.IsInitOnly))
                    {
                        return;
                    }
                    if (((IActivationObject)parent).GetLocalField(this.fieldName) != null)
                    {
                        identifier.context.HandleError(JSError.DuplicateName, false);
                    }
                }
                this.handler_scope = new BlockScope(parent);
                this.handler_scope.catchHanderScope = true;
                JSVariableField field = this.handler_scope.AddNewField(identifier.ToString(), Microsoft.JScript.Missing.Value, FieldAttributes.Public);
                this.field            = field;
                field.originalContext = identifier.context;
                if (identifier.context.document.debugOn && (this.field is JSLocalField))
                {
                    this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field);
                }
            }
            this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt;
            this.tryEndContext = tryEndContext;
        }
        internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext)
            : base(context)
        {
            this.body          = body;
            this.type          = type;
            this.handler       = handler;
            this.finally_block = finally_block;
            ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek();

            while (current_scope is WithObject) //Can only happen at run time and only if there is an eval
            {
                current_scope = current_scope.GetParent();
            }
            this.handler_scope = null;
            this.field         = null;
            if (identifier != null)
            {
                this.fieldName = identifier.ToString();
                this.field     = current_scope.GetField(this.fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
                if (this.field != null)
                {
                    if (type == null && (field is JSVariableField && field.IsStatic && ((JSVariableField)field).type == null) && !field.IsLiteral && !field.IsInitOnly)
                    {
                        return; //preserve legacy semantics by using the existing variable
                    }
                    if (((IActivationObject)current_scope).GetLocalField(this.fieldName) != null)
                    {
                        identifier.context.HandleError(JSError.DuplicateName, false);
                    }
                }
                this.handler_scope = new BlockScope(current_scope);
                this.handler_scope.catchHanderScope = true;
                JSVariableField f = this.handler_scope.AddNewField(identifier.ToString(), Missing.Value, FieldAttributes.Public); // must be a local
                this.field = f; f.originalContext = identifier.context;
                if (identifier.context.document.debugOn && this.field is JSLocalField)
                {
                    this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field);
                }
            }
            this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt;
            this.tryEndContext = tryEndContext;
        }