using System;
class TestClass
{
private int value;
public int SetValue() { return this.value; }
public void SetValue(int value) { this.value = value; }
}
class MainClass
{
TestClass test;
static int Main(string[] argv)
{
return 0;
}
}
Десктоп? AvaloniaUi?- WPF, Windows.Forms
Мобильная? Uno? Xamarin.Forms?- Xamarin.Forms, Xamarin.Native(Android/IOS)
Веб-сервисы?- Asp.Net Core, Asp.Net, Web.Forms
Task task = null;
private async void button_Click(object sender, RoutedEventArgs e)
{
if(this.task != null)
{
return;
}
this.task = Task.Run(() => GO());
await this.task;
this.task = null;
}
void GO()
{
string email = "null", password = "null";
Dispatcher.Invoke(() => { email = Email.Text; password = Password.Password; });
using (EFContext _context = new EFContext())
{
var res = _context.User.FirstOrDefault(x => x.Email == email && x.Password == password);
if (res != null)
{
Dispatcher.Invoke(() =>
{
MainWindow w = new MainWindow(res.Id);
w.Show();
this.Close();
});
}
else
{
Dispatcher.Invoke(() => IncorrectData.Visibility = Visibility.Visible);
}
}
}
public interface IBotBehaviour
{
void Process();
}
public interface IBot
{
void SetBehaviour(IBotBehaviour behaviour);
}
public class IdleBehaviour : IBotBehaviour
{
public void Process()
{
// wait 1s
}
}
public class FollowBehaviour : IBotBehaviour
{
public FollowBehaviour(Position myPosition, Position targetPosition)
{
}
public void Process()
{
// move my pos to target pos
}
}
// new BotTest().SetBehaviour(new FollowBehaviour(myPosition, targetPosition))
public class BotTest : IBot
{
protected IBotBehaviour currentBehaviour;
public void SetBehaviour(IBotBehaviour behaviour)
{
this.currentBehaviour = behaviour;
}
// call currentBehaviour.Process() in game cycle
}
new BotTest().SetBehaviour(new FollowBehaviour(myPosition, targetPosition))
public interface IBotState
{
}
public interface IBotBehaviour
{
void Process();
void Setup(IBotState state);
}
public interface IBotBehaviour<TState>
where TState : IBotState
{
void Setup(TState state);
}
public interface IBot
{
void SetBehaviour(IBotBehaviour behaviour);
}
public class IdleBehaviour : IBotBehaviour
{
public void Process()
{
// wait 1s
}
public void Setup(IBotState state)
{
}
}
public class FollowState : IBotState
{
public Position myPosition;
public Position targetPosition;
}
public class FollowBehaviour : IBotBehaviour<FollowState>
{
Position myPosition;
Position targetPosition;
public void Process()
{
// move my pos to target pos
}
public void Setup(IBotState state)
{
this.Setup((FollowState)state);
}
public void Setup(FollowState state)
{
this.myPosition = state.myPosition;
this.targetPosition = state.targetPosition;
}
}
public class BotTest : IBot
{
protected IBotBehaviour currentBehaviour;
public void SetBehaviour(IBotBehaviour behaviour)
{
currentBehaviour = behaviour;
}
// call currentBehaviour.Process() in game cycle
}
public class UserManager<TUser> : IDisposable
where TUser : class
{
public void Dispose()
{
throw new NotImplementedException();
}
}
public class UserManagerWrapper<TUser> : UserManager<TUser>
where TUser : class
{
}