Example #1
0
 public static PathModel GetPaths(ListPath dtoItem)
 {
     var item = new PathModel
     {
         Action = dtoItem.action,
         Controller = dtoItem.controller,
         FileName = dtoItem.filename
     };
     return item;
 }
Example #2
0
        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            _disposed = true;

            ListPath?.Dispose();

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

            base.Dispose(disposing);
        }
Example #3
0
        /// <inheritdoc />
        public override bool Evaluate()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("DataModelConditionList");
            }

            if (ListPath == null || !ListPath.IsValid)
            {
                return(false);
            }

            return(EvaluateObject(ListPath.GetValue()));
        }
Example #4
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;
            }
        }