internal void InternalInitClass()
        {
            var info = RedReflection.GetTypeInfo(GetType());

            foreach (var propertyInfo in info.PropertyInfos)
            {
                if (string.IsNullOrEmpty(propertyInfo.RedName))
                {
                    continue;
                }

                var propTypeInfo = RedReflection.GetTypeInfo(propertyInfo.Type);
                if (propertyInfo.Type.IsValueType || propTypeInfo.IsValueType)
                {
                    if (propertyInfo.Flags.Equals(Flags.Empty))
                    {
                        SetDictValue(propertyInfo.RedName, (IRedType)System.Activator.CreateInstance(propertyInfo.Type));
                    }
                    else
                    {
                        var flags = propertyInfo.Flags;
                        SetDictValue(propertyInfo.RedName, (IRedType)System.Activator.CreateInstance(propertyInfo.Type, flags.MoveNext() ? flags.Current : 0));
                    }
                }
            }
        }
Beispiel #2
0
        public CArrayBase(int size)
        {
            _internalList = new List <T>(new T[size]);

            var propTypeInfo = RedReflection.GetTypeInfo(typeof(T));

            if (propTypeInfo.IsValueType)
            {
                for (var i = 0; i < Count; i++)
                {
                    this[i] = System.Activator.CreateInstance <T>();
                }
            }
        }