Exemplo n.º 1
0
        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            _disposed = true;

            ListPath?.Dispose();

            foreach (DataModelConditionPart child in Children)
            {
                child.Dispose();
            }

            base.Dispose(disposing);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Updates the list the predicate is evaluated on
        /// </summary>
        /// <param name="path">The path pointing to the list inside the list</param>
        public void UpdateList(DataModelPath?path)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("DataModelConditionList");
            }

            if (path != null && !path.IsValid)
            {
                throw new ArtemisCoreException("Cannot update list to an invalid path");
            }

            ListPath?.Dispose();
            ListPath = path != null ? new DataModelPath(path) : null;
            SubscribeToListPath();

            // Remove the old root group that was tied to the old data model
            while (Children.Any())
            {
                RemoveChild(Children[0]);
            }

            if (ListPath != null)
            {
                Type listType = ListPath.GetPropertyType() !;
                ListType        = listType.GetGenericEnumerableType();
                IsPrimitiveList = ListType == null || ListType.IsPrimitive || ListType.IsEnum || ListType == typeof(string);

                // Create a new root group
                AddChild(new DataModelConditionGroup(this));
            }
            else
            {
                ListType = null;
            }
        }