2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

Updated to support IIP v3.3

This commit is contained in:
2019-05-24 05:38:53 +03:00
parent d215e48761
commit 08e95bd4dc
106 changed files with 6643 additions and 1179 deletions

View File

@ -4,6 +4,7 @@ using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Test
{
@ -16,7 +17,7 @@ namespace Test
public event ResourceEventHanlder LevelUp;
[ResourceEvent]
public event ResourceEventHanlder LevelDown;
public void Destroy()
{
@ -26,8 +27,8 @@ namespace Test
Info = new Structure();
Info["size"] = 200;
Info["age"] = 28;
Info["name"] = "Zamil";
Name = "Ahmed";
Info["name"] = "Esiur";
Name = "Esiur Project";
Level = 5;
}
@ -52,6 +53,46 @@ namespace Test
return Level;
}
[ResourceFunction]
public IEnumerable<string> Enum(int count)
{
var msg = new string[] { "Have you throught what if a function has multiple returns ?", "So you can return chunks of IO operation that not yet finished.", "Also, what about the progress ?", "This is an example of both.", "Use it anyway you like" };
for (var i = 0; i < count; i++)
{
Thread.Sleep(2000);
yield return msg[(int)(i % msg.Length)];
}
}
[ResourceFunction]
public AsyncReply<string> Stream(int count)
{
var reply = new AsyncReply<string>();
var msg = new object[] { "Have you throught what if a function has multiple returns ?", "So you can return chunks of IO operation that not yet finished.", "Also, what about the progress ?", "This is an example of both.", "Use it anyway you like" };
Timer timer = null;
var msgCounter = 0;
timer = new Timer((x) =>
{
reply.TriggerProgress(AsyncReply.ProgressType.Execution, count, 22);
if (count % 2 == 0 && msgCounter < msg.Length)
reply.TriggerChunk(msg[msgCounter++]);
count--;
if (count <= 0)
{
timer.Dispose();
reply.Trigger("Done");
}
}, null, 10, 3000);
return reply;
}
[ResourceProperty]
public Structure Info
{