Example #1
0
        public static IManagedProperty Find(this ManagedPropertyList list, string property, bool ignoreCase)
        {
            if (ignoreCase)
            {
                for (int i = 0, c = list.Count; i < c; i++)
                {
                    var item = list[i];
                    if (item.Name.EqualsIgnoreCase(property))
                    {
                        return(item);
                    }
                }
                return(null);
            }

            return(list.Find(property));
        }
        /// <summary>
        /// 获取当前可用的属性列表,包括编译时属性、动态运行时属性。
        /// </summary>
        /// <returns></returns>
        public ManagedPropertyList GetAvailableProperties()
        {
            if (_availableCache == null)
            {
                if (_runtimeProperties == null) { this.ResetRuntimeProperties(); }

                _availableCache = new ManagedPropertyList();
                _availableCache.AddRange(
                    _compiledProperties.Concat(_runtimeProperties)
                    );
            }

            return _availableCache;
        }
        private void ResetRuntimeProperties()
        {
            _runtimeProperties = new ManagedPropertyList();

            this.EnumerateHierarchyContainers(item =>
            {
                _runtimeProperties.AddRange(item.GetRuntimeProperties());
            });

            ChangeWithHierarchy();
        }
        private void NotifyRuntimeChanged()
        {
            this._runtimeProperties = null;
            this._availableCache = null;

            var handler = this.RuntimePropertiesChanged;
            if (handler != null) handler(this, EventArgs.Empty);
        }
        internal void InitCompiledProperties()
        {
            this.EnumerateHierarchyContainers(item =>
            {
                _compiledProperties.AddRange(item.GetCompiledProperties());
            });

            _nonReadOnlyCompiledProperties = new ManagedPropertyList();
            _nonReadOnlyCompiledProperties.AddRange(
                _compiledProperties.Where(p => !p.IsReadOnly)
                );

            //如果最后一个还没有被初始化,则包含继承属性的整个属性列表都需要重新设置 TypeIndex
            var list = _nonReadOnlyCompiledProperties;
            if (list.Count > 0 && list[list.Count - 1].TypeCompiledIndex == -1)
            {
                for (int i = 0, c = list.Count; i < c; i++)
                {
                    var item = list[i] as IManagedPropertyInternal;
                    if (!item.IsReadOnly) { item.TypeCompiledIndex = i; }
                }
            }
        }