示例#1
0
 public void Delete(SourceCache <NeuronDto, int> cache, NeuronDto dto)
 {
     // TODO: update data source
     // TODO: warn user
     // TODO: if dto has a parent then user is deleting a relationship only, otherwise a neuron is being deleted
     cache.Remove(dto);
 }
示例#2
0
        // DEL: create dummy data
        private static IEnumerable <NeuronDto> CreateChildren(NeuronDto parentDto = null)
        {
            var random = new Random();

            return(Enumerable.Range(1, random.Next(1, 10))
                   .Select(i =>
            {
                return NeuronService.CreateNeuron($"Neuron {i}", i % 2 == 0 ? ChildType.Postsynaptic : ChildType.Presynaptic, parentDto);
            }));
        }
示例#3
0
 internal static NeuronDto CreateNeuron(string name, ChildType type, NeuronDto parentDto = null)
 {
     return(new NeuronDto(
                Guid.NewGuid().GetHashCode(),
                parentDto == null ? 0 : parentDto.Id,
                Guid.NewGuid().ToString(),
                parentDto == null ? string.Empty : parentDto.NeuronId,
                name,
                type
                ));
 }
示例#4
0
        public void AddPresynaptic(SourceCache <NeuronDto, int> cache, NeuronDto neuronDto)
        {
            var presyn = new NeuronDto(
                Guid.NewGuid().GetHashCode(),
                neuronDto.Id,
                Guid.NewGuid().ToString(),
                neuronDto.ParentNeuronId,
                "New Presynaptic",
                ChildType.Presynaptic
                );

            cache.AddOrUpdate(presyn);
        }
示例#5
0
        public void ChangeData(SourceCache <NeuronDto, int> cache, NeuronDto dto, string value)
        {
            // TODO: update data source
            // TODO: retrieve updated value and replace value in children
            var newValue = new NeuronDto(
                dto.Id,
                dto.ParentId,
                dto.NeuronId,
                dto.ParentNeuronId,
                value,
                dto.Type
                );

            cache.AddOrUpdate(newValue);
        }
示例#6
0
        public void Reload(SourceCache <NeuronDto, int> cache, NeuronDto neuronDto = null)
        {
            IEnumerable <NeuronDto> children = null;

            if (neuronDto == null || !cache.Items.Any(i => i.ParentId == neuronDto.Id))
            {
                children = NeuronService.CreateChildren(neuronDto);
            }
            else
            {
                children = cache.Items.Where(i => i.ParentId == neuronDto.Id);
                cache.Remove(children);
                // TODO: set children to data from cortex graph
            }

            cache.AddOrUpdate(children);
        }
示例#7
0
 public void Add(SourceCache <NeuronDto, int> cache, NeuronDto neuronDto)
 {
     // TODO: Update data source
     cache.AddOrUpdate(neuronDto);
 }