本文整理汇总了C#中Pair类的典型用法代码示例。如果您正苦于以下问题:C# Pair类的具体用法?C# Pair怎么用?C# Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于命名空间,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pair1_Unit_Constructor1_Optimal
public void Pair1_Unit_Constructor1_Optimal()
{
String expected = default(String);
Pair<String> target = new Pair<String>();
Assert.AreEqual(expected, target.First);
Assert.AreEqual(expected, target.Second);
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("We will now do some Pair Arithmetic!");
PairArithmeticClient pairClient = new PairArithmeticClient();
Pair p1 = new Pair { First = 15, Second = 22 };
Pair p2 = new Pair { First = 7, Second = 13 };
Console.WriteLine(string.Format("\r\nPair 1 is {{{0}, {1}}}", p1.First, p1.Second));
Console.WriteLine(string.Format("Pair 2 is {{{0}, {1}}}", p2.First, p2.Second));
Pair result = pairClient.Add(p1, p2);
Console.WriteLine(string.Format("\r\nP1 + P2 is {{{0}, {1}}}", result.First, result.Second));
result = pairClient.Subtract(p1, p2);
Console.WriteLine(string.Format("\r\nP1 - P2 is {{{0}, {1}}}", result.First, result.Second));
result = pairClient.ScalarMultiply(p1, 3);
Console.WriteLine(string.Format("\r\nP1 * 3 is {{{0}, {1}}}", result.First, result.Second));
PoliteClient politeClient = new PoliteClient();
Console.WriteLine("");
Console.WriteLine(politeClient.SayHello("Rob"));
Console.WriteLine("\r\nDone\r\nPress any key to exit...");
Console.ReadKey();
}
示例3: ObjectCreator
public ObjectCreator(Manifest manifest, FileSystem.FileSystem modFiles)
{
typeCache = new Cache<string, Type>(FindType);
ctorCache = new Cache<Type, ConstructorInfo>(GetCtor);
// Allow mods to load types from the core Game assembly, and any additional assemblies they specify.
var assemblyList = new List<Assembly>() { typeof(Game).Assembly };
foreach (var path in manifest.Assemblies)
{
var data = modFiles.Open(path).ReadAllBytes();
// .NET doesn't provide any way of querying the metadata of an assembly without either:
// (a) loading duplicate data into the application domain, breaking the world.
// (b) crashing if the assembly has already been loaded.
// We can't check the internal name of the assembly, so we'll work off the data instead
var hash = CryptoUtil.SHA1Hash(data);
Assembly assembly;
if (!ResolvedAssemblies.TryGetValue(hash, out assembly))
{
assembly = Assembly.Load(data);
ResolvedAssemblies.Add(hash, assembly);
}
assemblyList.Add(assembly);
}
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => Pair.New(asm, ns))).ToArray();
AppDomain.CurrentDomain.AssemblyResolve -= ResolveAssembly;
}
示例4: AcceptorBase
internal AcceptorBase(FuncDecl symbol, Expr guard, ExprSet[] lookahead)
{
this.symbol = symbol;
this.guard = guard;
this.lookahead = lookahead;
this.lhs = new Pair<FuncDecl, Sequence<ExprSet>>(symbol, new Sequence<ExprSet>(lookahead));
}
示例5: IsInRectangle
/// <summary>
/// Check if a point is within a given rectangle.
/// </summary>
/// <param name="pos">Position (in either world or screen coordinates)</param>
/// <param name="x">Rectangle X position</param>
/// <param name="y">Rectangle Y position</param>
/// <param name="width">Rectangle width</param>
/// <param name="height">Rectangle height</param>
/// <returns>True if the point is in the given rectangle</returns>
public static bool IsInRectangle(Pair<int> pos, int x, int y, int width, int height)
{
return (pos.x >= x &&
pos.x <= x + width &&
pos.y >= y &&
pos.y <= y + height);
}
示例6: ConstructLambdaFromLet
// Take a bag of LET components and write the equivalent LAMBDA
// expression. Handles named LET.
private static Datum ConstructLambdaFromLet(LetComps comps)
{
// Unzip!
List<Datum> names = new List<Datum>();
List<Datum> vals = new List<Datum>();
foreach (Pair p in comps.bindings)
{
names.Add(p.First);
vals.Add(p.Second);
}
Datum formals = Primitives.List(names);
Datum bodyFunc = new Pair(new Symbol("lambda"),
new Pair(formals, comps.body));
Datum transform;
if (comps.self == null)
{
// Unnamed LET.
transform = new Pair(bodyFunc, Primitives.List(vals));
}
else
{
// Named LET.
transform =
new Pair(Datum.List(new Symbol("let"),
Datum.List(Datum.List(comps.self,
null)),
Datum.List(new Symbol("set!"),
comps.self,
bodyFunc),
comps.self),
Primitives.List(vals));
}
Shell.Trace("LET transform produced ", transform);
return transform;
}
示例7: Item
public Item(int value)
{
Value = value;
NonSerializedValue = value;
TransientValue = value;
Pair = new Pair("p1", value);
}
示例8: process
public void process(Message message, SessionID sessionID)
{
Message echo = (Message)message;
PossResend possResend = new PossResend(false);
if (message.getHeader().isSetField(possResend))
message.getHeader().getField(possResend);
ClOrdID clOrdID = new ClOrdID();
message.getField(clOrdID);
Pair pair = new Pair(clOrdID, sessionID);
if (possResend.getValue() == true)
{
if (orderIDs.Contains(pair))
return;
}
if(!orderIDs.Contains(pair))
orderIDs.Add(pair, pair);
try
{
Session.sendToTarget(echo, sessionID);
}
catch (SessionNotFound) { }
}
示例9: PasswordCommand
void PasswordCommand(ISender sender, ArgumentList args)
{
Player player = sender as Player;
Protection temp = new Protection ();
Pair<Action, Protection> pair = new Pair<Action, Protection> (Action.NOTHING, null);
if (args.Count != 1) {
player.SendMessage ("Usage: /cpassword <password>", 255, 255, 0, 0);
return;
}
string Extra = args[0];
temp = new Protection ();
temp.Owner = player.Name;
temp.Type = Protection.PASSWORD_PROTECTION;
temp.Data = SHA1.Hash (Extra);
char[] pass = Extra.ToCharArray ();
for (int index = 0; index < pass.Length; index++) {
pass [index] = '*';
}
pair.First = Action.CREATE;
pair.Second = temp;
player.SendMessage ("Password: " + new string (pass), 255, 255, 0, 0);
player.SendMessage ("Open the chest to protect it!", 255, 0, 255, 0);
// cache the action if it's not null!
if (pair.First != Action.NOTHING) {
ResetActions (player);
Cache.Actions.Add (player.Name, pair);
}
}
示例10: Heap
public Heap(Pair[] _points)
{
this.points = _points;
int pointsCount = _points.Length;
int leafsCount = pointsCount;
leafsCount = leafsCount - 1;
leafsCount = leafsCount | (leafsCount >> 1);
leafsCount = leafsCount | (leafsCount >> 2);
leafsCount = leafsCount | (leafsCount >> 4);
leafsCount = leafsCount | (leafsCount >> 8);
leafsCount = leafsCount | (leafsCount >> 16);
leafsCount = leafsCount | (leafsCount >> 32);
leafsCount = leafsCount + 1;
this.count = 2 * leafsCount - 1;
this.heap = new int[this.count];
for (int i = 0; i < pointsCount; i++) {
this.heap[this.count - 1 - i] = i;
}
for (int i = count - 1 - pointsCount; i >= 0; i--) {
this.heap[i] = int.MinValue;
}
BuildHeap();
}
示例11: Proxy
void Proxy(object user)
{
Pair p = new Pair();
p.inst = Interlocked.Increment(ref inst);
p.sl = (Socket)user;
p.sr = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
lock (lck) Console.WriteLine("{0} Connect now", p.Id);
p.sr.Connect(e2);
lock (lck) Console.WriteLine("{0} Connected", p.Id);
Thread tlr = new Thread(Dolr);
tlr.Start(p);
Thread trl = new Thread(Dorl);
trl.Start(p);
tlr.Join();
trl.Join();
lock (lck) Console.WriteLine("{0} Shutdown now", p.Id);
p.sr.Shutdown(SocketShutdown.Both);
p.sl.Shutdown(SocketShutdown.Both);
lock (lck) Console.WriteLine("{0} Close now", p.Id);
p.sr.Close();
p.sl.Close();
lock (lck) Console.WriteLine("{0} Finished", p.Id);
}
示例12: Bootstrap
/// <summary>
/// Bootstraps to the given peer addresses. I.e., looking for near nodes.
/// </summary>
/// <param name="peerAddresses">The node to which bootstrap should be performed to.</param>
/// <param name="routingBuilder">All relevant information for the routing process.</param>
/// <param name="cc">The channel creator.</param>
/// <returns>A task object that is set to complete if the route has been found.</returns>
public Task<Pair<TcsRouting, TcsRouting>> Bootstrap(ICollection<PeerAddress> peerAddresses,
RoutingBuilder routingBuilder, ChannelCreator cc)
{
// search close peers
Logger.Debug("Bootstrap to {0}.", Convenient.ToString(peerAddresses));
var tcsDone = new TaskCompletionSource<Pair<TcsRouting, TcsRouting>>();
// first, we find close peers to us
routingBuilder.IsBootstrap = true;
var tcsRouting0 = Routing(peerAddresses, routingBuilder, Message.Message.MessageType.Request1, cc);
// we need to know other peers as well
// this is important if this peer is passive and only replies on requests from other peers
tcsRouting0.Task.ContinueWith(taskRouting0 =>
{
if (!taskRouting0.IsFaulted)
{
// setting this to null causes to search for a random number
routingBuilder.LocationKey = null;
var tcsRouting1 = Routing(peerAddresses, routingBuilder, Message.Message.MessageType.Request1, cc);
tcsRouting1.Task.ContinueWith(taskRouting1 =>
{
var pair = new Pair<TcsRouting, TcsRouting>(tcsRouting0, tcsRouting1);
tcsDone.SetResult(pair);
});
}
else
{
tcsDone.SetException(taskRouting0.TryGetException());
}
});
return tcsDone.Task;
}
示例13: RoundWin
void RoundWin(Pair<int, float> winInfo)
{
// init values
targetCol = gameMan.pColor[winInfo.First];
winDuration = winInfo.Second / winSpeedFactor;
winTimer = 0;
}
示例14: Team8x4ViewModel
/// <summary>
/// Initializes a new instance of the Team8x4ViewModel class.
/// </summary>
public Team8x4ViewModel()
{
Pair1 = new Pair();
Pair2 = new Pair();
Pair3 = new Pair();
Pair4 = new Pair();
}
示例15: Main
static void Main(string[] args)
{
// Question 1
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
if (asm.GetName().Name == "tp3")
{
foreach (Type ty in asm.GetTypes())
{
Console.WriteLine(" Classe : " + ty);
foreach (MethodInfo mi in ty.GetMethods())
{
Console.WriteLine(" Methode : " + mi);
foreach (ParameterInfo pi in mi.GetParameters())
Console.WriteLine("Parametre : " + pi.GetType());
}
}
}
}
// Question 2
Console.WriteLine();
Pair<int, char> p = new Pair<int, char>(5, 'c');
Console.WriteLine("Paire:" + p.El1 + " " + p.El2);
// Question 3
HashTableReflection tab = new HashTableReflection();
Console.ReadLine();
}