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

Add project files.

This commit is contained in:
Ahmed Zamil
2017-09-15 23:40:03 +03:00
parent 4c95cb1cc6
commit 7ae722ab51
99 changed files with 14687 additions and 0 deletions

92
Test/MyObject.cs Normal file
View File

@ -0,0 +1,92 @@
using Esiur.Data;
using Esiur.Engine;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
class MyObject : IResource
{
public Instance Instance { get; set; }
public event DestroyedEvent OnDestroy;
[ResourceEvent]
public event ResourceEventHanlder LevelUp;
[ResourceEvent]
public event ResourceEventHanlder LevelDown;
public void Destroy()
{
}
public MyObject()
{
Info = new Structure();
Info["size"] = 200;
Info["age"] = 30;
Info["name"] = "Zamil";
Name = "Ahmed";
Level = 5;
}
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
{
return new AsyncReply<bool>();
}
[ResourceFunction]
public int Add(int value)
{
Level += value;
LevelUp?.Invoke(null, "going up", value);
return Level;
}
[ResourceFunction]
public int Subtract(int value)
{
Level -= value;
LevelDown?.Invoke(null, "going down", value);
return Level;
}
[ResourceProperty]
public Structure Info
{
get;
set;
}
[ResourceProperty]
public string Name
{
get;
set;
}
[ResourceProperty]
public MyObject Me
{
get
{
return this;
}
}
int level;
[ResourceProperty]
public int Level
{
get { return level; }
set
{
level = value;
Instance?.Modified();
}
}
}
}