本文整理汇总了C#中INode.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# INode.GetHashCode方法的具体用法?C# INode.GetHashCode怎么用?C# INode.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.GetHashCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodeID
public AdoStoreNodeID GetNodeID(INode n)
{
AdoStoreNodeID id = new AdoStoreNodeID(n);
if (this._cache.TryGetValue(n.GetHashCode(), out id))
{
return id;
}
else
{
return new AdoStoreNodeID(n);
}
}
示例2: GetIndexNameForObject
protected override string GetIndexNameForObject(INode obj)
{
return @"index\o\" + this.GetHash(obj.GetHashCode().ToString());
}
示例3: GetNextNodeID
/// <summary>
/// Gets the next available Database Node ID if the Node is not in the Database or the existing Database Node ID
/// </summary>
/// <param name="n">Node to get an ID for</param>
/// <param name="createRequired">Whether the Manager needs to create a Node Record in the Database</param>
/// <returns></returns>
protected virtual int GetNextNodeID(INode n, out bool createRequired)
{
int id = -1;
createRequired = false;
try
{
Monitor.Enter(this._nodeIDs);
if (this._nextNodeID == -1)
{
this.LoadNodeIDMap();
}
if (this._nodeIDs.ContainsKey(n.GetHashCode()))
{
id = this._nodeIDs[n.GetHashCode()];
//Use the Node Collection to record Nodes we've requested IDs for
//This allows us to take advantage of the Node Collections ability to detect
//when Node Hash Codes collide and then we can use this in the next step to
//do a Database lookup if necessary
if (!this._nodeCollection.Contains(n))
{
this._nodeCollection.Add(n);
}
if (id == -1 || n.Collides)
{
//There are multiple Nodes with this Hash Code
//Lookup from Database
String getNodeID = "SELECT nodeID FROM NODES WHERE nodeType=" + (int)n.NodeType + " AND nodeValue=N'" + this.EscapeString(n.ToString()) + "'";
Object nodeID = this.ExecuteScalar(getNodeID);
if (nodeID != null)
{
return Int32.Parse(nodeID.ToString());
}
else
{
id = ++this._nextNodeID;
createRequired = true;
}
}
}
else
{
id = ++this._nextNodeID;
this._nodeIDs.Add(n.GetHashCode(), id);
createRequired = true;
}
}
finally
{
Monitor.Exit(this._nodeIDs);
}
if (id != -1)
{
return id;
}
else
{
throw new RdfStorageException("Error obtaining a Node ID");
}
}
示例4: CompareDocumentPosition
/// <summary>
/// Compares the position of the current node against another node in any other document.
/// </summary>
/// <param name="otherNode">The node that's being compared against.</param>
/// <returns>The relationship that otherNode has with node, given in a bitmask.</returns>
public virtual DocumentPositions CompareDocumentPosition(INode otherNode)
{
if (this == otherNode)
return DocumentPositions.Same;
if (_owner != otherNode.Owner)
return DocumentPositions.Disconnected | DocumentPositions.ImplementationSpecific | (otherNode.GetHashCode() > GetHashCode() ? DocumentPositions.Following : DocumentPositions.Preceding);
else if (Contains(otherNode))
return DocumentPositions.ContainedBy | DocumentPositions.Following;
else if (otherNode.Contains(this))
return DocumentPositions.Contains | DocumentPositions.Preceding;
return CompareRelativePositionInNodeList(_owner.ChildNodes, this, otherNode);
}
示例5: GetIndexNameForPredicate
protected override string GetIndexNameForPredicate(INode pred)
{
return @"index\p\" + this.GetHash(pred.GetHashCode().ToString());
}
示例6: StartSubgraph
/// <summary>
/// Creates a new sub-graph to the VCG graph
/// </summary>
/// <param name="node">The node starting the new sub-graph</param>
/// <param name="label">The label to use for the node</param>
/// <param name="attributes">An enumerable of attribute strings</param>
/// <param name="textColor">The color of the text</param>
/// <param name="subgraphColor">The color of the subgraph node</param>
/// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
public void StartSubgraph(INode node, string label, IEnumerable<String> attributes, GrColor textColor,
GrColor subgraphColor)
{
Indent();
sw.Write("graph:{{title:\"n{0}\"", node.GetHashCode());
if(label != null) sw.Write(" label:\"{0}\" status:clustered", label);
if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
if(subgraphColor != textColor) sw.Write(" color:" + GetColor(subgraphColor));
if(attributes != null)
{
sw.Write(" info1: \"");
bool first = true;
indent++;
foreach(String attr in attributes)
{
if(first) first = false;
else
{
sw.WriteLine();
Indent();
}
sw.Write(EncodeString(attr));
}
indent--;
sw.Write('\"');
}
sw.WriteLine();
indent++;
}
示例7: DumpEdge
/// <summary>
/// Dump an edge to the VCG graph
/// </summary>
/// <param name="srcNode">The source node of the edge</param>
/// <param name="tgtNode">The target node of the edge</param>
/// <param name="label">The label of the edge, may be null</param>
/// <param name="attributes">An enumerable of attribute strings</param>
/// <param name="textColor">The color of the text</param>
/// <param name="edgeColor">The color of the edge</param>
/// <param name="lineStyle">The linestyle of the edge</param>
/// <param name="thickness">The thickness of the edge (1-5)</param>
///
/// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
///
public void DumpEdge(INode srcNode, INode tgtNode, String label, IEnumerable<String> attributes,
GrColor textColor, GrColor edgeColor, GrLineStyle lineStyle, int thickness)
{
Indent();
sw.Write("edge:{{sourcename:\"n{0}\" targetname:\"n{1}\"", srcNode.GetHashCode(), tgtNode.GetHashCode());
String attrStr = "";
if(attributes != null && attributes.GetEnumerator().MoveNext())
{
StringBuilder attrStrBuilder = new StringBuilder("\nAttributes:");
bool first = true;
// indent++;
foreach(String attr in attributes)
{
if(first) first = false;
else
{
attrStrBuilder.Append('\n');
}
attrStrBuilder.Append(EncodeString(attr));
}
// indent--;
// sw.Write('\"');
attrStr = attrStrBuilder.ToString();
}
if(label != null) sw.Write(" label:\"" + label + attrStr + "\"");
if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
if(edgeColor != GrColor.Default) sw.Write(" color:" + GetColor(edgeColor));
if(lineStyle != GrLineStyle.Default) sw.Write(" linestyle:" + GetLineStyle(lineStyle));
if(thickness != 1) sw.Write(" thickness:" + thickness);
sw.WriteLine('}');
}
示例8: DumpNode
/// <summary>
/// Dump a node to the VCG graph.
/// </summary>
/// <param name="node">The node to be dumped.</param>
/// <param name="label">The label to use for the node.</param>
/// <param name="attributes">An enumerable of attribute strings.</param>
/// <param name="textColor">The color of the text.</param>
/// <param name="nodeColor">The color of the node border.</param>
/// <param name="borderColor">The color of the node.</param>
/// <param name="nodeShape">The shape of the node.</param>
///
/// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
///
public void DumpNode(INode node, String label, IEnumerable<String> attributes, GrColor textColor,
GrColor nodeColor, GrColor borderColor, GrNodeShape nodeShape)
{
Indent();
sw.Write("node:{{title:\"n{0}\"", node.GetHashCode());
if(label != null) sw.Write(" label:\"{0}\"", label);
if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
if(nodeColor != GrColor.White) sw.Write(" color:" + GetColor(nodeColor));
if(borderColor != textColor) sw.Write(" bordercolor:" + GetColor(borderColor));
if(nodeShape != GrNodeShape.Default) sw.Write(" shape:" + GetNodeShape(nodeShape));
if(attributes != null)
{
sw.Write(" info1: \"");
bool first = true;
indent++;
foreach(String attr in attributes)
{
if(first) first = false;
else
{
sw.WriteLine();
Indent();
}
sw.Write(EncodeString(attr));
}
indent--;
sw.Write('\"');
}
sw.WriteLine('}');
}
示例9: DetachEvent
internal void DetachEvent (INode node, string eve, EventHandler handler) {
string key = String.Intern (node.GetHashCode() + ":" + eve);
#if debug
Console.Error.WriteLine ("Event Detached: " + key);
#endif
DomEvents.RemoveHandler (key, handler);
}
示例10: SaveNode
/// <summary>
/// Gets the Node ID for a Node in the Database creating a new Database record if necessary
/// </summary>
/// <param name="n">Node to Save</param>
/// <returns></returns>
public override string SaveNode(INode n)
{
bool create;
int id = this.GetNextNodeID(n, out create);
if (create)
{
//Doesn't exist so Insert a Node Record
String createNode = "INSERT INTO NODES (nodeID, nodeType, nodeValue, nodeHash) VALUES (" + id + ", " + (int)n.NodeType + ", N'" + this.EscapeString(n.ToString()) + "', " + n.GetHashCode() + ")";
try
{
this.ExecuteNonQuery(createNode);
}
catch (SqlException sqlEx)
{
this.Close(true, true);
throw new RdfStorageException("Unable to create a Node Record in the Database", sqlEx);
}
}
return id.ToString();
}