本文整理汇总了C#中Node类的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPing
public void SendPing()
{
engine.Add(node);
engine.TimeOut = TimeSpan.FromMilliseconds(75);
ManualResetEvent handle = new ManualResetEvent(false);
engine.MessageLoop.QuerySent += delegate(object o, SendQueryEventArgs e) {
if (!e.TimedOut && e.Query is Ping)
handle.Set();
if (!e.TimedOut || !(e.Query is Ping))
return;
PingResponse response = new PingResponse(node.Id, e.Query.TransactionId);
listener.RaiseMessageReceived(response, e.EndPoint);
};
Assert.AreEqual(NodeState.Unknown, node.State, "#1");
DateTime lastSeen = node.LastSeen;
Assert.IsTrue(handle.WaitOne(1000, false), "#1a");
Node nnnn = node;
node = engine.RoutingTable.FindNode(nnnn.Id);
Assert.IsTrue (lastSeen < node.LastSeen, "#2");
Assert.AreEqual(NodeState.Good, node.State, "#3");
}
示例2: Comment
public Comment(Node hostNode)
{
HostNode = hostNode;
var scrollViewer = new ScrollViewer
{
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
Height = 70,
CanContentScroll = true
};
var textBlock = new TextBlock
{
Background = Brushes.Transparent,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(5),
FontSize = 12
};
Child = scrollViewer;
CornerRadius = new CornerRadius(5);
scrollViewer.Content = textBlock;
var bindingTextToTextBlock = new Binding("Text")
{
Source = this,
Mode = BindingMode.OneWay
};
textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);
hostNode.SpaceCanvas.Children.Add(this);
}
示例3: OnMailBox
public override void OnMailBox(Node from, string address, object letter)
{
for (var i = 0; i < lineCount-1; i++) {
GetComponent<Label> (i).Text = GetComponent<Label> (i + 1).Text;
}
GetComponent<Label> (lineCount - 1).Text = (string)letter;
}
示例4: magix_viewport_load_viewport
public static void magix_viewport_load_viewport(object sender, ActiveEventArgs e)
{
Node ip = Ip(e.Params);
if (ShouldInspect(ip))
{
AppendInspectFromResource(
ip["inspect"],
"Magix.tiedown",
"Magix.tiedown.hyperlisp.inspect.hl",
"[magix.viewport.load-viewport-dox].value");
return;
}
Node node = new Node();
node["file"].Value = "plugin:magix.file.load-from-resource";
node["file"]["assembly"].Value = "Magix.tiedown";
node["file"]["resource-name"].Value = "Magix.tiedown.hyperlisp.load-viewport.hl";
RaiseActiveEvent(
"magix.execute.execute-script",
node);
Control ctrl = ModuleControllerLoader.Instance.LoadActiveModule(node["params"]["viewport"].Get<string>());
e.Params["viewport"].Value = ctrl;
}
示例5: Bullet
public Bullet(Node parent, string name)
: base(parent, name)
{
Render = new ImageRender(this, "Render");
Render.SetTexture(GetRoot<State>().GetService<AssetCollector>().GetAsset<Texture2D>("bullet"));
Render.Layer = .1f;
Render.Scale = new Vector2(.1f);
Render.Color = Color.White;
Render.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);
//Make our collision rectangles the size of the rendered sprite.
Body.Bounds = Render.Bounds;
Body.Origin = new Vector2(Render.Texture.Width / 2f, Render.Texture.Height / 2f);
Shape = new Circle(this, "Shape", Body.Width / 2);
Shape.Offset = new Vector2(Body.Width / 2, Body.Height / 2);
Shape.LinkDependency(Circle.DEPENDENCY_BODY, Body);
Collision.Group.AddMask(1);
Collision.Pair.AddMask(2);
Collision.Immovable = true;
Collision.CollideEvent += collision => Recycle();
Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
Shape.LinkDependency(Circle.DEPENDENCY_COLLISION, Collision);
DeathTimer = new Timer(this, "DeathTimer");
DeathTimer.Milliseconds = 2000;
DeathTimer.LastEvent += Recycle;
DeathTimer.LastEvent += DeathTimer.Stop;
}
示例6: Tilemap
public Tilemap(Node parent, string name, Texture2D tileTexture, Point size, Point tileSize)
: base(parent, name)
{
Body = new Body(this, "Body");
Render = new TilemapRender(this, "TilemapRender", tileTexture, size, tileSize);
Render.LinkDependency(TilemapRender.DEPENDENCY_BODY, Body);
}
示例7: SaveAllConncectedComponents
private static void SaveAllConncectedComponents(Node<int> node,
HashSet<int> visitedNodes, List<string> connectedComponents)
{
string graphs = string.Empty;
Stack<Node<int>> nodesStack = new Stack<Node<int>>();
nodesStack.Push(node);
while (nodesStack.Count > 0)
{
Node<int> currentNode = nodesStack.Pop();
visitedNodes.Add(currentNode.Value);
graphs += " -> " + currentNode.Value;
foreach (var child in currentNode.Children)
{
if (!visitedNodes.Contains(child.Value))
{
visitedNodes.Add(child.Value);
nodesStack.Push(child);
}
}
}
connectedComponents.Add(graphs.Substring(4));
}
示例8: ElectricityCalcul
static void ElectricityCalcul(Node actual, ref int VoltageColector, int Intensity, bool previous, Node From)
{
if (VoltageColector <= 0 || previous == false || actual._activatedByPlayer == false || Intensity == 0)
{
actual._activated = false;
}
else
{
if (VoltageColector < actual.getCost())
{
actual._activated = false;
}
else
{
actual._activated = true;
actual._intensity = Intensity;
VoltageColector = VoltageColector - actual.getCost();
}
}
int localVoltage = VoltageColector;
actual._peerOut.ForEach(delegate(Node other)
{
if (other != From)
ElectricityCalcul(other, ref localVoltage, (int)actual.energyDiv(), actual._activated, actual);
});
VoltageColector = localVoltage;
}
示例9: NodeViewModel
public NodeViewModel(Node node, Vector location, IControlTypesResolver controlTypesResolver)
{
Node = node;
Title = node.Title;
Location = new CanvasPoint(location);
ControlTypesResolver = controlTypesResolver;
foreach (var pin in node.InputPins)
{
AddInputPin(pin);
}
foreach (var pin in node.OutputPins)
{
AddOutputPin(pin);
}
node.Processed += OnNodeProcessed;
node.PinsChanged += OnNodePinsChanged;
_disposable = Disposable.Create(() =>
{
node.PinsChanged -= OnNodePinsChanged;
node.Processed -= OnNodeProcessed;
});
}
示例10: ConstructAmbiguousEntity
/// <summary>
/// Validates and constructs generic entities out of an ambiguous generic definition entity.
/// </summary>
private IEntity ConstructAmbiguousEntity(Node constructionNode, Ambiguous ambiguousDefinition, IType[] typeArguments)
{
var checker = new GenericConstructionChecker(typeArguments, constructionNode);
var matches = new List<IEntity>(ambiguousDefinition.Entities);
bool reportErrors = false;
foreach (Predicate<IEntity> check in checker.Checks)
{
matches = matches.Collect(check);
if (matches.Count == 0)
{
Errors.Add(checker.Errors[0]); // only report first error, assuming the rest are superfluous
return TypeSystemServices.ErrorEntity;
}
if (reportErrors)
checker.ReportErrors(Errors);
checker.DiscardErrors();
// We only want full error reporting once we get down to a single candidate
if (matches.Count == 1)
reportErrors = true;
}
IEntity[] constructedMatches = Array.ConvertAll<IEntity, IEntity>(matches.ToArray(), def => MakeGenericEntity(def, typeArguments));
return Entities.EntityFromList(constructedMatches);
}
示例11: CreateControls
private void CreateControls(Node node)
{
foreach(Node idx in node)
{
string caption = idx["Caption"].Get<string>();
string value = idx["Value"].Get<string>();
string type = idx["Type"].Get<string>();
int position = idx["Position"].Get<int>();
Panel pnl = new Panel();
pnl.CssClass = "bordered-panel";
Label cpt = new Label();
cpt.CssClass = "label-caption";
cpt.Text = caption;
pnl.Controls.Add(cpt);
Label val = new Label();
val.CssClass = "label-value";
val.Text = value;
pnl.Controls.Add(val);
// Rooting...
wrpPnl.Controls.Add(pnl);
}
}
示例12: MoshParser
public MoshParser(ILexer lexer)
{
m_startRuleToken = new Token { TokenType = TokenType.NEW_RULE };
m_tree = new Node<string>();
m_lexer = lexer;
m_consumed = new Stack<Token>();
m_err = new Queue<Error>();
// Setup rule pre-calling conditions
m_rulePreHook = name =>
{
if (m_tree.Value == null)
{
m_tree.Value = name;
return m_tree;
}
var tempNode = m_tree;
var newTopNode = m_tree.AddChild(name);
m_tree = newTopNode;
return tempNode;
};
// Setup rule post-calling conditions
m_rulePostHook = node => m_tree = node;
}
示例13: Setup
public void Setup()
{
listener = new TestListener();
node = new Node(NodeId.Create(), new IPEndPoint(IPAddress.Any, 0));
engine = new DhtEngine(listener);
//engine.Add(node);
}
示例14: SolverValidator
public SolverValidator(Solver solver, NodeCollection nodes, Node root, IPositionLookupTable<Node> transpositionTable)
{
this.solver = solver;
this.nodes = nodes;
this.root = root;
this.transpositionTable = transpositionTable;
}
示例15: CircularDependency_ThrowsCircularDependencyException_Test
public void CircularDependency_ThrowsCircularDependencyException_Test()
{
var a = new Node<object>("a");
var b = new Node<object>("b");
var c = new Node<object>("c");
var d = new Node<object>("d");
var e = new Node<object>("e");
a.Edges.Add(b); // a depends on b
a.Edges.Add(d); // a depends on d
b.Edges.Add(c); // b depends on c
b.Edges.Add(e); // b depends on e
c.Edges.Add(d); // c depends on d
c.Edges.Add(e); // c depends on e
d.Edges.Add(b); // d depends on b
var resolved = new List<Node<object>>();
CircularDependencyException<object> exception = null;
try
{
a.ResolveDependencies();
}
catch (CircularDependencyException<object> ex)
{
exception = ex;
}
Assert.NotNull(exception);
Assert.Equal(d, exception.A);
Assert.Equal(b, exception.B);
}