Exemplo n.º 1
0
        internal bool SetStaticPropertyOrField(string id, HybInstance value, AccessLevel accessLevel)
        {
            SSPropertyInfo property = GetProperty(id);

            if (property != null)
            {
                if (property.AccessModifier.IsAcceesible(accessLevel) == false)
                {
                    throw new SemanticViolationException($"Invalid access: {id}");
                }
                property.SetMethod.Invoke(null, new HybInstance[] { value });
                return(true);
            }

            SSFieldInfo field = GetField(id);

            if (field != null)
            {
                if (field.AccessModifier.IsAcceesible(accessLevel) == false)
                {
                    throw new SemanticViolationException($"Invalid access: {id}");
                }
                field.SetValue(null, value);
                return(true);
            }

            return(false);
        }