Last change
on this file since 13067 was
12762,
checked in by aballeit, 9 years ago
|
#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)
|
File size:
920 bytes
|
Rev | Line | |
---|
[12762] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | namespace SharpVectors.Runtime.Utils
|
---|
| 5 | {
|
---|
| 6 | internal static class TryCast
|
---|
| 7 | {
|
---|
| 8 | public static bool Cast<B, D>(B baseObject, out D derivedObject)
|
---|
| 9 | where D : class
|
---|
| 10 | {
|
---|
| 11 | if (baseObject == null)
|
---|
| 12 | {
|
---|
| 13 | derivedObject = null;
|
---|
| 14 | return false;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | derivedObject = baseObject as D;
|
---|
| 18 |
|
---|
| 19 | return (derivedObject != null);
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | internal static class DynamicCast
|
---|
| 24 | {
|
---|
| 25 | public static bool Cast<B, D>(B baseObject, out D derivedObject)
|
---|
| 26 | where D : class, B
|
---|
| 27 | {
|
---|
| 28 | if (baseObject == null)
|
---|
| 29 | {
|
---|
| 30 | derivedObject = null;
|
---|
| 31 | return false;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | derivedObject = baseObject as D;
|
---|
| 35 |
|
---|
| 36 | return (derivedObject != null);
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.