本文整理汇总了C#中IGraphNode类的典型用法代码示例。如果您正苦于以下问题:C# IGraphNode类的具体用法?C# IGraphNode怎么用?C# IGraphNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGraphNode类属于命名空间,在下文中一共展示了IGraphNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindImmediateDependent
private IDictionary<LibraryDescription, ISet<LibraryDescription>> FindImmediateDependent(IGraphNode<LibraryDescription> root)
{
var result = new Dictionary<LibraryDescription, ISet<LibraryDescription>>();
root.DepthFirstPreOrderWalk(
visitNode: (node, ancestors) =>
{
ISet<LibraryDescription> slot;
if (!result.TryGetValue(node.Item, out slot))
{
slot = new HashSet<LibraryDescription>();
result.Add(node.Item, slot);
}
// first item in the path is the immediate parent
if (ancestors.Any())
{
slot.Add(ancestors.First().Item);
}
return true;
});
// removing the root package
result.Remove(root.Item);
return result;
}
开发者ID:noahfalk,项目名称:dnx,代码行数:28,代码来源:LibraryDependencyFlatRenderer.cs
示例2: PrintHierarchyInternal
private static void PrintHierarchyInternal(IGraphNode node, int indentation, StringBuilder builder)
{
PrintIndentation(indentation, builder);
builder.Append(node.Guid + " ");
PrintIndentation(indentation, builder);
builder.Append(node.Name ?? "<untitled>");
builder.Append(": [");
builder.Append(node.Content.GetType().Name);
builder.Append("] = ");
if (node.Content.IsReference)
{
if (node.Content.Value != null)
{
builder.Append(node.Content.Value.ToString().Replace(Environment.NewLine, " "));
builder.Append(" > ");
}
builder.Append("Reference -> ");
builder.Append(node.Content.Reference);
}
else if (node.Content.Value == null)
{
builder.Append("(null)");
}
else
{
builder.Append(node.Content.Value.ToString().Replace(Environment.NewLine, " "));
}
builder.AppendLine();
foreach (var child in node.Children)
{
PrintHierarchyInternal(child, indentation + 4, builder);
}
}
开发者ID:FERRERDEV,项目名称:xenko,代码行数:33,代码来源:DebugExtensions.cs
示例3: QuantumConsistencyException
/// <summary>
/// Initializes a new instance of the QuantumConsistencyException class.
/// </summary>
/// <param name="expected">A string representing the expected result.</param>
/// <param name="observed">A string representing the observed result.</param>
/// <param name="node">The node that is related to this error.</param>
public QuantumConsistencyException(string expected, string observed, IGraphNode node)
: base(GetMessage(expected, observed))
{
Expected = expected ?? "(NullMessage)";
Observed = observed ?? "(NullMessage)";
Node = node;
}
开发者ID:FERRERDEV,项目名称:xenko,代码行数:13,代码来源:QuantumConsistencyException.cs
示例4: TestCollectionObjectContentNode
/// <summary>
/// Tests the validity of a node that is an object that is a collection
/// </summary>
/// <param name="node">The node to validate.</param>
/// <param name="obj">The value represented by this node.</param>
/// <param name="isReference">Indicate whether the node is expected to contain an enumerable reference to the collection items.</param>
public static void TestCollectionObjectContentNode(IGraphNode node, object obj, bool isReference)
{
if (node == null) throw new ArgumentNullException(nameof(node));
if (obj == null) throw new ArgumentNullException(nameof(obj));
// Check that the content is of the expected type.
Assert.IsInstanceOf<ObjectContent>(node.Content);
// Check that the content is properly referencing its node.
Assert.AreEqual(node, node.Content.OwnerNode);
// A node with an ObjectContent should have the same name that the type of its content.
Assert.AreEqual(obj.GetType().Name, node.Name);
// A node with an ObjectContent should be a root node.
Assert.IsNull(node.Parent);
// A node with an ObjectContent should have the related object as value of its content.
Assert.AreEqual(obj, node.Content.Retrieve());
if (isReference)
{
// A node with an ObjectContent representing a collection of reference types should contain an enumerable reference.
Assert.AreEqual(true, node.Content.IsReference);
Assert.IsInstanceOf<ReferenceEnumerable>(node.Content.Reference);
}
else
{
// A node with an ObjectContent representing a collection of primitive or struct types should not contain a refernce.
Assert.AreEqual(false, node.Content.IsReference);
}
// A node with an ObjectContent representing a collection should not have any child.
Assert.AreEqual(0, node.Children.Count);
}
开发者ID:cg123,项目名称:xenko,代码行数:35,代码来源:Helper.cs
示例5: ObservableModelNode
/// <summary>
/// Initializes a new instance of the <see cref="ObservableModelNode"/> class.
/// </summary>
/// <param name="ownerViewModel">The <see cref="ObservableViewModel"/> that owns the new <see cref="ObservableModelNode"/>.</param>
/// <param name="baseName">The base name of this node. Can be null if <see cref="index"/> is not. If so a name will be automatically generated from the index.</param>
/// <param name="isPrimitive">Indicate whether this node should be considered as a primitive node.</param>
/// <param name="modelNode">The model node bound to the new <see cref="ObservableModelNode"/>.</param>
/// <param name="graphNodePath">The <see cref="GraphNodePath"/> corresponding to the given <see cref="modelNode"/>.</param>
/// <param name="index">The index of this content in the model node, when this node represent an item of a collection. <c>null</c> must be passed otherwise</param>
protected ObservableModelNode(ObservableViewModel ownerViewModel, string baseName, bool isPrimitive, IGraphNode modelNode, GraphNodePath graphNodePath, object index = null)
: base(ownerViewModel, baseName, index)
{
if (modelNode == null) throw new ArgumentNullException(nameof(modelNode));
if (baseName == null && index == null)
throw new ArgumentException("baseName and index can't be both null.");
this.isPrimitive = isPrimitive;
SourceNode = modelNode;
// By default we will always combine items of list of primitive items.
CombineMode = index != null && isPrimitive ? CombineMode.AlwaysCombine : CombineMode.CombineOnlyForAll;
SourceNodePath = graphNodePath;
// Override display name if available
var memberDescriptor = GetMemberDescriptor() as MemberDescriptorBase;
if (memberDescriptor != null)
{
if (index == null)
{
var displayAttribute = TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute<DisplayAttribute>(memberDescriptor.MemberInfo);
if (!string.IsNullOrEmpty(displayAttribute?.Name))
{
DisplayName = displayAttribute.Name;
}
IsReadOnly = !memberDescriptor.HasSet;
}
}
}
开发者ID:psowinski,项目名称:xenko,代码行数:37,代码来源:ObservableModelNode.cs
示例6: IsCyclic
/// <summary>
/// Returns true if graph node is cyclic.
/// </summary>
/// <param name="node">Graph node.</param>
/// <param name="path">Path from a graph node to this <paramref name="graph node"/>.</param>
/// <param name="acyclicNodes">Nodes from which a cycle does not exist.</param>
/// <returns>Returns true if graph node is cyclic.</returns>
private static bool IsCyclic(IGraphNode node, ISet<string> path, ISet<string> acyclicNodes)
{
node.ThrowIfArgumentNull(nameof(node));
node.Id.ThrowIfArgumentNull(nameof(node.Id));
node.Neighbors.ThrowIfArgumentNull(nameof(node.Neighbors));
if (acyclicNodes.Contains(node.Id))
{
return false;
}
if (path.Contains(node.Id))
{
return true;
}
path.Add(node.Id);
foreach (var neighbor in node.Neighbors)
{
if (IsCyclic(neighbor, path, acyclicNodes))
{
return true;
}
}
path.Remove(node.Id);
acyclicNodes.Add(node.Id);
return false;
}
开发者ID:rmandvikar,项目名称:csharp-extensions,代码行数:32,代码来源:GraphExtension.cs
示例7: FindTargetReference
protected override ObjectReference FindTargetReference(IGraphNode sourceNode, IGraphNode targetNode, ObjectReference sourceReference)
{
if (sourceReference.Index.IsEmpty)
return targetNode.Content.Reference as ObjectReference;
// Special case for objects that are identifiable: the object must be linked to the base only if it has the same id
if (sourceReference.ObjectValue != null)
{
if (sourceReference.Index.IsEmpty)
{
return targetNode.Content.Reference.AsObject;
}
var sourceAssetNode = (AssetNode)sourceNode;
if (sourceAssetNode.IsNonIdentifiableCollectionContent)
return null;
// Enumerable reference: we look for an object with the same id
var targetReference = targetNode.Content.Reference.AsEnumerable;
var sourceIds = CollectionItemIdHelper.GetCollectionItemIds(sourceNode.Content.Retrieve());
var targetIds = CollectionItemIdHelper.GetCollectionItemIds(targetNode.Content.Retrieve());
var itemId = sourceIds[sourceReference.Index.Value];
var targetKey = targetIds.GetKey(itemId);
return targetReference.FirstOrDefault(x => Equals(x.Index.Value, targetKey));
}
// Not identifiable - default applies
return base.FindTargetReference(sourceNode, targetNode, sourceReference);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:29,代码来源:AssetToBaseNodeLinker.cs
示例8: GetAllChildNodes
private static IEnumerable<IGraphNode> GetAllChildNodes(IGraphNode graphNode)
{
var processedNodes = new HashSet<IGraphNode>();
var nodeStack = new Stack<IGraphNode>();
nodeStack.Push(graphNode);
while (nodeStack.Count > 0)
{
var node = nodeStack.Pop();
processedNodes.Add(node);
// We don't want to include the initial node
if (node != graphNode)
yield return node;
// Add child nodes
node.Children.ForEach(x => nodeStack.Push(x));
// Add object reference target node
var objectReference = node.Content.Reference as ObjectReference;
if (objectReference?.TargetNode != null)
nodeStack.Push(objectReference.TargetNode);
// Add enumerable reference target nodes
var enumerableReference = node.Content.Reference as ReferenceEnumerable;
enumerableReference?.Select(x => x.TargetNode).NotNull().ForEach(x => nodeStack.Push(x));
}
}
开发者ID:FERRERDEV,项目名称:xenko,代码行数:27,代码来源:GraphNodeChangeListener.cs
示例9: GraphNodeToObject
public object GraphNodeToObject(IGraphNode node, Type type)
{
var seq = (ISequenceGraphNode) node;
Type elemType = null;
if (type.IsArray)
elemType = type.GetElementType();
else if (TypeTools.IsAssignableToGenericType(type, typeof(IList<>)))
elemType = TypeTools.GetGenericArguments(type)[0];
var elements = seq.Select(n => n?.RebuildObject(elemType));
if (type.IsArray)
{
var a = Array.CreateInstance(elemType, seq.Length);
int i = 0;
foreach (var e in elements)
a.SetValue(e, i++);
return a;
}
var instance = (IList)Activator.CreateInstance(type);
foreach (var e in elements)
instance.Add(e);
return instance;
}
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:26,代码来源:ListSerializationSurrogate.cs
示例10: GetRenderContent
public IEnumerable<string> GetRenderContent(IGraphNode<LibraryDescription> root)
{
var dict = FindImmediateDependent(root);
var libraries = dict.Keys.OrderBy(description => description.Identity.Name);
var results = new List<string>();
var gacOrFrameworkReferences = libraries.Where(library => library.Identity.IsGacOrFrameworkReference);
if (gacOrFrameworkReferences.Any())
{
results.Add("Framework references:");
RenderLibraries(gacOrFrameworkReferences, dict, results);
results.Add(string.Empty);
}
var otherReferences = libraries.Where(library => !library.Identity.IsGacOrFrameworkReference);
var referencesGroups = otherReferences.GroupBy(reference => reference.Type);
foreach (var group in referencesGroups)
{
results.Add(string.Format("{0} references:", group.Key));
RenderLibraries(group, dict, results);
results.Add(string.Empty);
}
return results;
}
开发者ID:noahfalk,项目名称:dnx,代码行数:26,代码来源:LibraryDependencyFlatRenderer.cs
示例11: UnregisterNode
protected virtual void UnregisterNode(IGraphNode node)
{
node.Content.PrepareChange += ContentPrepareChange;
node.Content.FinalizeChange += ContentFinalizeChange;
node.Content.Changing -= ContentChanging;
node.Content.Changed -= ContentChanged;
}
开发者ID:subajat1,项目名称:xenko,代码行数:7,代码来源:GraphNodeChangeListener.cs
示例12: GraphNodeToObject
public object GraphNodeToObject(IGraphNode node, Type objectType)
{
var n = node as IStringGraphNode;
if (n != null)
return Name.BuildName(n.Value);
return Name.BuildName(((IPrimitiveGraphNode)node).Value);
}
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:7,代码来源:Formatters.cs
示例13: Walk
public void Walk(IGraphNode<LibraryDescription> root)
{
_assemblyFilePaths = new HashSet<string>(StringComparer.Ordinal);
_dependencyAssemblySources = new Dictionary<string, HashSet<string>>(StringComparer.Ordinal);
_dependencyPackageSources = new Dictionary<string, HashSet<string>>(StringComparer.Ordinal);
var libraries = new HashSet<LibraryDescription>();
root.DepthFirstPreOrderWalk(visitNode: (node, _) => VisitLibrary(node, _, libraries));
_reports.Information.WriteLine("\n[Target framework {0} ({1})]\n",
_framework.ToString(), VersionUtility.GetShortFrameworkName(_framework));
foreach (var assemblyFilePath in _assemblyFilePaths.OrderBy(assemblyName => assemblyName))
{
_reports.Information.WriteLine(assemblyFilePath);
if (_showDetails)
{
var assemblyName = Path.GetFileNameWithoutExtension(assemblyFilePath);
HashSet<string> packagesSources;
if (_dependencyPackageSources.TryGetValue(assemblyName, out packagesSources) && packagesSources.Any())
{
_reports.Information.WriteLine(" by package: {0}", string.Join(", ", packagesSources));
}
HashSet<string> assemblySources;
if (_dependencyAssemblySources.TryGetValue(assemblyName, out assemblySources) && assemblySources.Any())
{
_reports.Information.WriteLine(" by assembly: {0}", string.Join(", ", assemblySources));
}
}
}
}
开发者ID:henghu-bai,项目名称:dnx,代码行数:33,代码来源:AssemblyWalker.cs
示例14: Render
public void Render(IGraphNode<LibraryDependency> root)
{
// tuples of <Library Name, Requested Version, Actual Version>
var results = new HashSet<Tuple<string, string, string>>();
root.DepthFirstPreOrderWalk(
(node, ancestors) =>
{
var dependency = node.Item;
if (IsLibraryMismatch(dependency))
{
results.Add(Tuple.Create(
dependency.Library.Identity.Name,
dependency.LibraryRange.VersionRange?.MinVersion.ToString(),
dependency.Library.Identity.Version?.ToString()));
}
return true;
});
if (results.Any())
{
var format = GetFormat(results, padding: 2);
RenderTitle(format);
RenderMismatches(format, results);
}
}
开发者ID:leloulight,项目名称:dnx,代码行数:28,代码来源:MismatchedDependencyRenderer.cs
示例15: Walk
public ISet<string> Walk(IGraphNode<Library> root)
{
var assemblies = new HashSet<string>();
var libraries = new HashSet<Library>();
root.DepthFirstPreOrderWalk(visitNode: (node, _) => VisitLibrary(node, _, libraries, assemblies));
return assemblies;
}
开发者ID:nagyistoce,项目名称:dnx,代码行数:8,代码来源:AssemblyWalker.cs
示例16: VisitNode
protected override void VisitNode(IGraphNode node, GraphNodePath currentPath)
{
var targetNode = linker.FindTarget(node);
// Override the target node, in case FindTarget returned a different one.
VisitedLinks[node] = targetNode;
linker.LinkNodes(node, targetNode);
base.VisitNode(node, currentPath);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:GraphNodeLinker.cs
示例17: Render
public void Render(IGraphNode<Library> root)
{
var dict = FindImmediateDependent(root);
foreach (var key in dict.Keys.OrderBy(library => library.Name))
{
_output.WriteLine(key.ToString().White().Bold());
_output.WriteLine(" -> {0}", string.Join(", ", dict[key].Select(lib => lib.ToString()).OrderBy(s => s)));
}
}
开发者ID:nagyistoce,项目名称:dnx,代码行数:9,代码来源:LibraryDependencyFlatRenderer.cs
示例18: GraphNodeChangeListener
/// <summary>
/// Initializes a new instance of the <see cref="GraphNodeChangeListener"/> class.
/// </summary>
/// <param name="rootNode">The root node for which to track referenced node changes.</param>
public GraphNodeChangeListener(IGraphNode rootNode)
{
this.rootNode = rootNode;
foreach (var node in GetAllChildNodes(rootNode))
{
node.Content.Changing += ContentChanging;
node.Content.Changed += ContentChanged;
}
}
开发者ID:FERRERDEV,项目名称:xenko,代码行数:13,代码来源:GraphNodeChangeListener.cs
示例19: ObservableViewModel
/// <summary>
/// Initializes a new instance of the <see cref="ObservableViewModel"/> class.
/// </summary>
/// <param name="serviceProvider">A service provider that can provide a <see cref="IDispatcherService"/> and an <see cref="ObservableViewModelService"/> to use for this view model.</param>
/// <param name="nodeContainer">A <see cref="NodeContainer"/> to use to build view model nodes.</param>
/// <param name="modelNode">The root model node of the view model to generate.</param>
/// <param name="dirtiables">The list of <see cref="IDirtiable"/> objects linked to this view model.</param>
public ObservableViewModel(IViewModelServiceProvider serviceProvider, NodeContainer nodeContainer, IGraphNode modelNode, IEnumerable<IDirtiable> dirtiables)
: this(serviceProvider, nodeContainer, dirtiables.SafeArgument("dirtiables").ToList())
{
if (modelNode == null) throw new ArgumentNullException(nameof(modelNode));
var node = ObservableViewModelService.ObservableNodeFactory(this, "Root", modelNode.Content.IsPrimitive, modelNode, new GraphNodePath(modelNode), modelNode.Content.Type, null);
node.Initialize();
RootNode = node;
node.CheckConsistency();
}
开发者ID:FERRERDEV,项目名称:xenko,代码行数:16,代码来源:ObservableViewModel.cs
示例20: ShouldReconcileItem
protected override bool ShouldReconcileItem(MemberContent member, IGraphNode targetNode, object localValue, object baseValue, bool isReference)
{
// Always reconcile referenced parts
if (isReference && IsReferencedPart(member, targetNode))
{
return true;
}
return base.ShouldReconcileItem(member, targetNode, localValue, baseValue, isReference);
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:9,代码来源:AssetCompositePropertyGraph.cs
注:本文中的IGraphNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论