本文整理汇总了C#中Context.Request方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Request方法的具体用法?C# Context.Request怎么用?C# Context.Request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.Request方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnitTest
//
void UnitTest ()
{
Context theContext = new Context();
theContext.SetState( new ConcreteStateA( theContext ));
theContext.Request( 5 );
theContext.Request( 15 );
theContext.Request( 25 );
theContext.Request( 35 );
}
示例2: Main
public static void Main( string[] args )
{
// Setup context in a state
Context c = new Context( new ConcreteStateA() );
c.Show();
// Issue request, which toggles state
c.Request();
c.Show();
// Issue request, which toggles state
c.Request();
c.Show();
}
示例3: Demo
/// <summary>
/// Entry point into console application.
/// </summary>
static void Demo()
{
// Setup context in a state
Context c = new Context(new ConcreteStateA());
// Issue requests, which toggles state
c.Request();
c.Request();
c.State = new ConcreteStateB();
c.Request();
c.Request();
// Wait for user
Console.ReadKey();
}
示例4: Execute
public void Execute(Demo4Input input)
{
using (var context = new Context())
using (var socket = context.Request())
{
socket.Connect("tcp://localhost:5559");
SendRequests(socket, input.NodeNumberFlag);
}
}
示例5: Main
static void Main(string[] args)
{
//#region Book User Level
//User user = new User("Hyman");
//user.BuyBook(2000);
//user.BuyBook(2000);
//user.BuyBook(2000);
//user.BuyBook(2000);
//Console.Read();
//#endregion
#region State patter structure
Context context = new Context();
context.Request();
context.Request();
context.Request();
context.Request();
Console.Read();
#endregion
}
示例6: Demo
// The user interface
static void Demo()
{
// context.s are States
// Decide on a starting state and hold onto the Context thus established
Context context = new Context();
context.State = new RestingState();
char command = ' ';
Console.WriteLine("Welcome to \"The State Game\"!");
Console.WriteLine("You are standing here looking relaxed!");
while (command != 'e')
{
Console.WriteLine("\nWhat would you like to do now?");
Console.Write(" Move Attack Stop Run Panic CalmDown Exit the game: ==>");
string choice;
do
{
choice = Console.ReadLine();
}
while (choice == null);
command = choice[0];
context.Request(command);
}
}
示例7: Main
public static void Main()
{
Context context = new Context();
context.State = new NormalState();
Random r = new Random(37);
for (int i = 0; i <= 25; i++) {
int command = r.Next(3);
Console.Write(context.Request(command) + " ");
}
Console.WriteLine();
}