internal bool GetStaticPropertyOrField(string id, out HybInstance value, AccessLevel accessLevel)
        {
            SSPropertyInfo property = GetProperty(id);

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

            SSFieldInfo field = GetField(id);

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

            value = null;
            return(false);
        }
Exemple #2
0
 public bool TryGetField(string id, out SSFieldInfo field)
 {
     field = null;
     if (HasField(id) == false)
     {
         return(false);
     }
     field = Fields[id];
     return(true);
 }
        public SSFieldInfo GetField(string id)
        {
            SSFieldInfo field = null;

            if (_Fields == null)
            {
                _Fields = new Dictionary <string, SSFieldInfo>();
            }
            if (_Fields.ContainsKey(id))
            {
                field = _Fields[id];
            }
            else
            {
                field = _GetField(id);
                if (field != null)
                {
                    _Fields[id] = field;
                }
            }

            return(field);
        }
Exemple #4
0
 public void AddField(SSFieldInfo field)
 {
     Fields.Add(field.Id, field);
 }