예제 #1
0
        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);
        }
예제 #2
0
파일: Class.cs 프로젝트: ru-ace/SlowSharp
 public bool TryGetProperty(string id, out SSPropertyInfo property)
 {
     property = null;
     if (HasProperty(id) == false)
     {
         return(false);
     }
     property = Properties[id];
     return(true);
 }
예제 #3
0
        public SSPropertyInfo GetProperty(string id)
        {
            SSPropertyInfo property = null;

            if (_Properties == null)
            {
                _Properties = new Dictionary <string, SSPropertyInfo>();
            }
            if (_Properties.ContainsKey(id))
            {
                property = _Properties[id];
            }
            else
            {
                property = _GetProperty(id);
                if (property != null)
                {
                    _Properties[id] = property;
                }
            }

            return(property);
        }