Example #1
0
        private static ISet<Block> GetAll(Block initial, Func<Block, IEnumerable<Block>> getNexts)
        {
            var toProcess = new Queue<Block>();
            var alreadyProcesses = new HashSet<Block>();
            getNexts(initial).ToList().ForEach(b => toProcess.Enqueue(b));
            while (toProcess.Count != 0)
            {
                var current = toProcess.Dequeue();
                if (alreadyProcesses.Contains(current))
                {
                    continue;
                }

                alreadyProcesses.Add(current);

                getNexts(current).ToList().ForEach(b => toProcess.Enqueue(b));
            }

            return alreadyProcesses.ToImmutableHashSet();
        }
        //public async Task ReceiveMessageAsync(IEntityDescriptor source, 
        //                                IMessage message,
        //                                IMethodEntityGrain destinationGrain)
        //{        
        //    //await destinationGrain.ProcessMessaggeAsync(source, message,this);
        //}


        /// <summary>
        ///  
        /// </summary>
        /// <returns></returns>
		public ImmutableHashSet<IEntity> GetAllEntites()
		{
			var result = new HashSet<IEntity>();
			var solutionGrain = SolutionGrainFactory.GetGrain("Solution");
			var methodDescriptors = solutionGrain.GetMethodDescriptors().Result;

			foreach (var methodDescriptor in methodDescriptors)
			{
				var orleansEnitityDesc = new OrleansEntityDescriptor(methodDescriptor);
				IMethodEntityGrain entity = (IMethodEntityGrain)GetEntityAsync(orleansEnitityDesc).Result;
				result.Add(entity);
			}

			return result.ToImmutableHashSet<IEntity>();
		}
        public ImmutableHashSet<IEntityDescriptor> GetAllEntitiesDescriptors()
        {
            var result = new HashSet<IEntityDescriptor>();
			var solutionGrain = SolutionGrainFactory.GetGrain("Solution");
			var methodDescriptors = solutionGrain.GetMethodDescriptors().Result;

			foreach (var methodDescriptor in methodDescriptors)
            {
                var orleansEnitityDesc = new OrleansEntityDescriptor(methodDescriptor);
                result.Add(orleansEnitityDesc);
            }

            return result.ToImmutableHashSet<IEntityDescriptor>();
        }