Beispiel #1
0
        private static IEnumerable <string> GetAllValidNodeTypes(ISimRepository simRepository)
        {
            var result = new List <string>();

            // From Core
            System.Reflection.Assembly core = System.Reflection.Assembly.GetAssembly(typeof(Relation));
            result.AddRange(core.GetTypes()
                            .Where(a => a.Name.Equals("Node", StringComparison.OrdinalIgnoreCase))
                            .Select(a => a.Name));

            // From Repository
            result.AddRange(simRepository
                            .GetAll(a => a is DynamicRelation)
                            .Select(a => (a as DynamicRelation).Name));

            return(result);
        }
Beispiel #2
0
        public void Execute()
        {
            if (!CanExecute())
            {
                throw new OperationCanceledException($"{GetType().Name} cannot be excuted");
            }

            JsonSerializer serializer = new JsonSerializer();
            var            path       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                     $@"SIM\Json\{nameSpace}.json");
            TextWriter             writer   = new StreamWriter(path);
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            };
            var text = JsonConvert.SerializeObject(repository.GetAll(), settings);

            writer.Write(text);
            writer.Close();
        }
Beispiel #3
0
 /// <summary>
 /// Collection of applicable outwards relations on the Node
 /// </summary>
 /// <param name="repository"></param>
 /// <returns></returns>
 public IReadOnlyCollection <Relation> OutwardsRelations(ISimRepository repository)
 {
     return(repository.GetAll(a => a is Relation && ((a as Relation).Origin == this))
            .Select(a => a as Relation)
            .ToList().AsReadOnly());
 }
Beispiel #4
0
 static void Main(string[] args)
 {
     repository = new Neo4jRepository();
     var x = repository.GetAll(a => a is Node);
 }
Beispiel #5
0
 private void PrintRelations()
 {
     var all = repository.GetAll(a => a is DynamicRelation);
 }
Beispiel #6
0
 public CodeFactory(ISimRepository repository) : this(repository.GetAll().Select(c => c as DynamicObject))
 {
 }