本文整理汇总了C#中Dynamo.Utilities.CustomNodeInfo类的典型用法代码示例。如果您正苦于以下问题:C# CustomNodeInfo类的具体用法?C# CustomNodeInfo怎么用?C# CustomNodeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CustomNodeInfo类属于Dynamo.Utilities命名空间,在下文中一共展示了CustomNodeInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanRefactorCustomNodeName
public void CanRefactorCustomNodeName()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "TheCat";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
_search.Add(dummyInfo1);
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
var newNodeName = "TheTurtle";
var newInfo = new CustomNodeInfo(guid1, newNodeName, catName, descr, path);
_search.Refactor(newInfo);
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
// search for new name
_search.SearchAndUpdateResultsSync(newNodeName);
// results are correct
Assert.AreEqual(1, _search.SearchResults.Count);
var res1 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
var node1 = res1 as CustomNodeSearchElement;
Assert.AreEqual(node1.Guid, guid1);
// search for old name
_search.SearchAndUpdateResultsSync(nodeName);
// results are correct
Assert.AreEqual(0, _search.SearchResults.Count);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:35,代码来源:Search.cs
示例2: CanRefactorCustomNodeDescription
public void CanRefactorCustomNodeDescription()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "Cool description, man";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
_search.Add(dummyInfo1);
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
// search for name
_search.SearchAndUpdateResultsSync(nodeName);
// results are correct
Assert.AreEqual(1, _search.SearchResults.Count);
var res1 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
var node1 = res1 as CustomNodeSearchElement;
Assert.AreEqual(node1.Guid, guid1);
Assert.AreEqual(node1.Description, descr);
// refactor description
const string newDescription = "Tickle me elmo";
var newInfo = new CustomNodeInfo(guid1, nodeName, catName, newDescription, path);
_search.Refactor(newInfo);
// num elements is unchanged
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
// search for name
_search.SearchAndUpdateResultsSync(nodeName);
// description is updated
Assert.AreEqual(1, _search.SearchResults.Count);
var res2 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res2);
var node2 = res2 as CustomNodeSearchElement;
Assert.AreEqual( guid1, node2.Guid );
Assert.AreEqual( newDescription, node2.Description);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:44,代码来源:Search.cs
示例3: CanRefactorCustomNodeWhilePreservingDuplicates
public void CanRefactorCustomNodeWhilePreservingDuplicates()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "TheCat";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
var guid2 = Guid.NewGuid();
var dummyInfo2 = new CustomNodeInfo(guid2, nodeName, catName, descr, path);
_search.Add(dummyInfo1);
_search.Add(dummyInfo2);
Assert.AreEqual(2, _search.SearchDictionary.NumElements);
// refactor one of the nodes with newNodeName
var newNodeName = "TheTurtle";
var newInfo = new CustomNodeInfo(guid1, newNodeName, catName, descr, path);
_search.Refactor(newInfo);
// num elements is unchanged
Assert.AreEqual(2, _search.SearchDictionary.NumElements);
// search for new name
_search.SearchAndUpdateResultsSync(newNodeName);
// results are correct - only one result
Assert.AreEqual(1, _search.SearchResults.Count);
var res1 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
var node1 = res1 as CustomNodeSearchElement;
Assert.AreEqual(node1.Guid, guid1);
// search for old name
_search.SearchAndUpdateResultsSync(nodeName);
// results are correct - the first nodes are returned
Assert.AreEqual(1, _search.SearchResults.Count);
var res2 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res2);
var node2 = res2 as CustomNodeSearchElement;
Assert.AreEqual(node2.Guid, guid2);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:44,代码来源:Search.cs
示例4: TryGetNodeInfo
/// <summary>
/// Attempts to retrieve information for the given custom node name. If there are multiple
/// custom nodes matching the given name, this method will return any one of them.
/// </summary>
/// <param name="name">Name of a custom node.</param>
/// <param name="info"></param>
/// <returns></returns>
public bool TryGetNodeInfo(string name, out CustomNodeInfo info)
{
info = NodeInfos.Values.FirstOrDefault(x => x.Name == name);
return info != null;
}
开发者ID:qingemeng,项目名称:Dynamo,代码行数:12,代码来源:CustomNodeManager.cs
示例5: RegisterCustomNodeWorkspace
private void RegisterCustomNodeWorkspace(
CustomNodeWorkspaceModel newWorkspace, CustomNodeInfo info, CustomNodeDefinition definition)
{
loadedWorkspaceModels[newWorkspace.CustomNodeId] = newWorkspace;
SetFunctionDefinition(definition);
OnDefinitionUpdated(definition);
newWorkspace.DefinitionUpdated += () =>
{
var newDef = newWorkspace.CustomNodeDefinition;
SetFunctionDefinition(newDef);
OnDefinitionUpdated(newDef);
};
SetNodeInfo(info);
newWorkspace.InfoChanged += () =>
{
var newInfo = newWorkspace.CustomNodeInfo;
SetNodeInfo(newInfo);
OnInfoUpdated(newInfo);
};
newWorkspace.FunctionIdChanged += oldGuid =>
{
loadedWorkspaceModels.Remove(oldGuid);
loadedCustomNodes.Remove(oldGuid);
loadOrder.Remove(oldGuid);
loadedWorkspaceModels[newWorkspace.CustomNodeId] = newWorkspace;
};
}
开发者ID:qingemeng,项目名称:Dynamo,代码行数:30,代码来源:CustomNodeManager.cs
示例6: SetNodeInfo
/// <summary>
/// Stores the path and function definition without initializing a node. Overwrites
/// the existing NodeInfo if necessary
/// </summary>
private void SetNodeInfo(CustomNodeInfo newInfo)
{
var guids = NodeInfos.Where(x =>
{
return !string.IsNullOrEmpty(x.Value.Path) &&
string.Compare(x.Value.Path, newInfo.Path, StringComparison.OrdinalIgnoreCase) == 0;
}).Select(x => x.Key).ToList();
foreach (var guid in guids)
{
NodeInfos.Remove(guid);
}
NodeInfos[newInfo.FunctionId] = newInfo;
OnInfoUpdated(newInfo);
}
开发者ID:qingemeng,项目名称:Dynamo,代码行数:20,代码来源:CustomNodeManager.cs
示例7: CreateCustomNodeInstance
/// <summary>
/// Creates a new Custom Node Instance.
/// </summary>
/// <param name="id">Identifier referring to a custom node definition.</param>
/// <param name="nickname">
/// Nickname for the custom node to be instantiated, used for error recovery if
/// the given id could not be found.
/// </param>
/// <param name="isTestMode">
/// Flag specifying whether or not this should operate in "test mode".
/// </param>
public Function CreateCustomNodeInstance(
Guid id, string nickname = null, bool isTestMode = false)
{
CustomNodeWorkspaceModel workspace;
CustomNodeDefinition def;
CustomNodeInfo info;
// Try to get the definition, initializing the custom node if necessary
if (TryGetFunctionDefinition(id, isTestMode, out def))
{
// Got the definition, proceed as planned.
info = NodeInfos[id];
}
else
{
// Couldn't get the workspace with the given ID, try a nickname lookup instead.
if (nickname != null && TryGetNodeInfo(nickname, out info))
return CreateCustomNodeInstance(info.FunctionId, nickname, isTestMode);
// Couldn't find the workspace at all, prepare for a late initialization.
Log(
Properties.Resources.UnableToCreateCustomNodeID + id + "\"",
WarningLevel.Moderate);
info = new CustomNodeInfo(id, nickname ?? "", "", "", "");
}
if (def == null)
{
def = CustomNodeDefinition.MakeProxy(id, info.Name);
}
var node = new Function(def, info.Name, info.Description, info.Category);
if (loadedWorkspaceModels.TryGetValue(id, out workspace))
RegisterCustomNodeInstanceForUpdates(node, workspace);
else
RegisterCustomNodeInstanceForLateInitialization(node, id, nickname, isTestMode);
return node;
}
开发者ID:qingemeng,项目名称:Dynamo,代码行数:49,代码来源:CustomNodeManager.cs
示例8: SetNodeInfo
/// <summary>
/// Stores the path and function definition without initializing a node. Overwrites
/// the existing NodeInfo if necessary
/// </summary>
/// <param name="guid">The unique id for the node.</param>
/// <param name="path">The path for the node.</param>
public void SetNodeInfo(CustomNodeInfo newInfo)
{
var nodeInfo = GetNodeInfo(newInfo.Guid);
if (nodeInfo == null)
{
NodeInfos.Add(newInfo.Guid, newInfo);
}
else
{
NodeInfos[newInfo.Guid] = newInfo;
}
}
开发者ID:RobertiF,项目名称:Dynamo,代码行数:18,代码来源:CustomNodeManager.cs
示例9: CustomNodeSaveAsAddsNewCustomNodeToSearchAndItCanBeRefactoredWhilePreservingOriginalFromExistingDyf2
public void CustomNodeSaveAsAddsNewCustomNodeToSearchAndItCanBeRefactoredWhilePreservingOriginalFromExistingDyf2()
{
// open custom node
// SaveAs
// two nodes are returned in search on custom node name, difer
var model = Controller.DynamoModel;
var examplePath = Path.Combine(GetTestDirectory(), @"core\custom_node_saving", "Constant2.dyf");
Controller.DynamoViewModel.OpenCommand.Execute(examplePath);
var nodeWorkspace =
model.Workspaces.FirstOrDefault(x => x is CustomNodeWorkspaceModel) as CustomNodeWorkspaceModel;
Assert.IsNotNull(nodeWorkspace);
var oldId = nodeWorkspace.CustomNodeDefinition.FunctionId;
var newPath = this.GetNewFileNameOnTempPath("dyf");
var originalNumElements = Controller.SearchViewModel.SearchDictionary.NumElements;
// save as
nodeWorkspace.SaveAs(newPath); // introduces new function id
var newId = nodeWorkspace.CustomNodeDefinition.FunctionId;
// refactor oldId with new name
var nodeName = "Constant2 Alt";
var catName = "TheCat";
var descr = "TheCat";
var dummyInfo1 = new CustomNodeInfo(newId, nodeName, catName, descr, "");
Controller.CustomNodeManager.Refactor(dummyInfo1);
// num elements is unchanged by refactor
Assert.AreEqual(originalNumElements + 1, Controller.SearchViewModel.SearchDictionary.NumElements);
// search common base name
Controller.SearchViewModel.SearchAndUpdateResultsSync("Constant2");
// results are correct
Assert.AreEqual(2, Controller.SearchViewModel.SearchResults.Count);
var res1 = Controller.SearchViewModel.SearchResults[0];
var res2 = Controller.SearchViewModel.SearchResults[1];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res2);
var node1 = res1 as CustomNodeSearchElement;
var node2 = res2 as CustomNodeSearchElement;
Assert.IsTrue((node1.Guid == oldId && node2.Guid == newId) ||
(node1.Guid == newId && node2.Guid == oldId));
}
开发者ID:khoaho,项目名称:Dynamo,代码行数:53,代码来源:WorkspaceSaving.cs
示例10: SetNodeInfo
/// <summary>
/// Stores the path and function definition without initializing a node
/// </summary>
/// <param name="guid">The unique id for the node.</param>
/// <param name="path">The path for the node.</param>
public void SetNodeInfo(CustomNodeInfo info)
{
this.SetNodeName(info.Guid, info.Name);
this.SetNodeCategory(info.Guid, info.Category);
this.SetNodeDescription(info.Guid, info.Description);
this.SetNodePath(info.Guid, info.Path);
}
开发者ID:kentvv,项目名称:Dynamo,代码行数:12,代码来源:CustomNodeManager.cs
示例11: SaveFunction
/// <summary>
/// Save a function. This includes writing to a file and compiling the
/// function and saving it to the FSchemeEnvironment
/// </summary>
/// <param name="definition">The definition to save</param>
/// <param name="bool">Whether to write the function to file.</param>
/// <returns>Whether the operation was successful</returns>
public void SaveFunction(FunctionDefinition definition, bool writeDefinition = true, bool addToSearch = false, bool compileFunction = true)
{
if (definition == null)
return;
// Get the internal nodes for the function
var functionWorkspace = definition.Workspace as FuncWorkspace;
// If asked to, write the definition to file
if (writeDefinition)
{
string path = "";
if (String.IsNullOrEmpty(definition.Workspace.FilePath))
{
var pluginsPath = this.Controller.CustomNodeManager.GetDefaultSearchPath();
if (!Directory.Exists(pluginsPath))
Directory.CreateDirectory(pluginsPath);
path = Path.Combine(pluginsPath, dynSettings.FormatFileName(functionWorkspace.Name) + ".dyf");
}
else
{
path = definition.Workspace.FilePath;
}
try
{
dynWorkspaceModel.SaveWorkspace(path, functionWorkspace);
if (addToSearch)
{
Controller.SearchViewModel.Add(functionWorkspace.Name, functionWorkspace.Category, functionWorkspace.Description, definition.FunctionId);
}
var customNodeInfo = new CustomNodeInfo(definition.FunctionId, functionWorkspace.Name, functionWorkspace.Category,
functionWorkspace.Description, path);
Controller.CustomNodeManager.SetNodeInfo(customNodeInfo);
#region Compile Function and update all nodes
IEnumerable<string> inputNames = new List<string>();
IEnumerable<string> outputNames = new List<string>();
dynSettings.Controller.FSchemeEnvironment.DefineSymbol(definition.FunctionId.ToString(), CustomNodeManager.CompileFunction(definition, ref inputNames, ref outputNames));
//Update existing function nodes which point to this function to match its changes
foreach (dynNodeModel el in AllNodes)
{
if (el is dynFunction)
{
var node = (dynFunction)el;
if (node.Definition != definition)
continue;
node.SetInputs(inputNames);
node.SetOutputs(outputNames);
el.RegisterAllPorts();
}
}
//Call OnSave for all saved elements
foreach (dynNodeModel el in functionWorkspace.Nodes)
el.onSave();
#endregion
}
catch (Exception e)
{
Log("Error saving:" + e.GetType());
Log(e);
}
}
}
开发者ID:kentvv,项目名称:Dynamo,代码行数:83,代码来源:DynamoViewModel.cs
示例12: CanRemoveSingleCustomNodeByIdWhereThereAreDuplicatesWithDifferentIds
public void CanRemoveSingleCustomNodeByIdWhereThereAreDuplicatesWithDifferentIds()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "TheCat";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var guid2 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
var dummyInfo2 = new CustomNodeInfo(guid2, nodeName, catName, descr, path);
_search.Add(dummyInfo1);
_search.Add(dummyInfo2);
Assert.AreEqual(2, _search.SearchDictionary.NumElements);
_search.RemoveNodeAndEmptyParentCategory(guid2);
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
_search.SearchAndUpdateResultsSync(nodeName);
Assert.AreEqual(1, _search.SearchResults.Count);
var res1 = _search.SearchResults[0];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
var node1 = res1 as CustomNodeSearchElement;
Assert.AreEqual(node1.Guid, guid1);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:29,代码来源:Search.cs
示例13: CanAddDuplicateCustomNodeWithDifferentGuidsAndGetBothInResults
public void CanAddDuplicateCustomNodeWithDifferentGuidsAndGetBothInResults()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "TheCat";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var guid2 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
var dummyInfo2 = new CustomNodeInfo(guid2, nodeName, catName, descr, path);
_search.Add(dummyInfo1);
_search.Add(dummyInfo2);
Assert.AreEqual(2, _search.SearchDictionary.NumElements);
_search.SearchAndUpdateResultsSync(nodeName);
Assert.AreEqual(2, _search.SearchResults.Count);
var res1 = _search.SearchResults[0];
var res2 = _search.SearchResults[1];
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res2);
var node1 = res1 as CustomNodeSearchElement;
var node2 = res2 as CustomNodeSearchElement;
Assert.AreEqual(node1.Guid, guid1);
Assert.AreEqual(node2.Guid, guid2);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:33,代码来源:Search.cs
示例14: CanRemoveNodeAndCategoryByFunctionId
public void CanRemoveNodeAndCategoryByFunctionId()
{
var nodeName = "TheNoodle";
var catName = "TheCat";
var descr = "TheCat";
var path = @"C:\turtle\graphics.dyn";
var guid1 = Guid.NewGuid();
var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);
// add custom node
_search.Add(dummyInfo1);
// confirm it's in the dictionary
Assert.AreEqual(1, _search.SearchDictionary.NumElements);
// remove custom node
_search.RemoveNodeAndEmptyParentCategory(guid1);
// it's gone
Assert.AreEqual(0, _search.SearchDictionary.NumElements);
_search.SearchAndUpdateResultsSync(nodeName);
Assert.AreEqual(0, _search.SearchResults.Count);
}
开发者ID:algobasket,项目名称:Dynamo,代码行数:24,代码来源:Search.cs
示例15: GetOwnerPackage
public Package GetOwnerPackage(CustomNodeInfo def)
{
return GetOwnerPackage(def.Path);
}
开发者ID:RevitLution,项目名称:Dynamo,代码行数:4,代码来源:PackageLoader.cs
示例16: Add
public bool Add(CustomNodeInfo nodeInfo)
{
var nodeEle = new CustomNodeSearchElement(nodeInfo);
if (SearchDictionary.Contains(nodeEle))
{
return this.Refactor(nodeInfo);
}
SearchDictionary.Add(nodeEle, nodeEle.Name);
SearchDictionary.Add(nodeEle, nodeInfo.Category + "." + nodeEle.Name);
TryAddCategoryAndItem(nodeInfo.Category, nodeEle);
return true;
}
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:16,代码来源:SearchViewModel.cs
示例17: AssertAddAndRemoveCustomNode
/// <summary>
/// Helper method for custom node adding and removing
/// </summary>
public void AssertAddAndRemoveCustomNode(SearchViewModel search, string nodeName, string catName, string descr = "Bla",
string path = "Bla")
{
var dummyInfo = new CustomNodeInfo(Guid.NewGuid(), nodeName, catName, descr, path);
search.Add(dummyInfo);
search.SearchAndUpdateResultsSync(nodeName);
Assert.AreNotEqual(0, search.SearchResults.Count);
Assert.AreEqual(search.SearchResults[0].Name, nodeName);
Assert.IsTrue(search.ContainsCategory(catName));
search.RemoveNodeAndEmptyParentCategory(nodeName);
search.SearchAndUpdateResultsSync(nodeName);
Assert.AreEqual(0, search.SearchResults.Count);
Assert.IsFalse(search.ContainsCategory(catName));
}
开发者ID:heegwon,项目名称:Dynamo,代码行数:22,代码来源:SearchTests.cs
示例18: Refactor
public bool Refactor(CustomNodeInfo nodeInfo)
{
this.RemoveNodeAndEmptyParentCategory(nodeInfo.Guid);
return this.Add(nodeInfo);
}
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:5,代码来源:SearchViewModel.cs
示例19: AddFileToPath
/// <summary>
/// Import a dyf file for eventual initialization.
/// </summary>
/// <returns>null if we failed to get data from the path, otherwise the CustomNodeInfo object for the </returns>
public CustomNodeInfo AddFileToPath(string file)
{
Guid guid;
string name;
string category;
string description;
if (!GetHeaderFromPath(file, out guid, out name, out category, out description))
{
return null;
}
// the node has already been loaded
// from somewhere else
if (Contains(guid))
{
var nodeInfo = GetNodeInfo(guid);
if (nodeInfo != null)
{
return nodeInfo;
}
}
var info = new CustomNodeInfo(guid, name, category, description, file);
SetNodeInfo(info);
return info;
}
开发者ID:RobertiF,项目名称:Dynamo,代码行数:30,代码来源:CustomNodeManager.cs
示例20: SetNodeInfo
/// <summary>
/// Stores the path and function definition without initializing a node. Overwrites
/// the existing NodeInfo if necessary
/// </summary>
private void SetNodeInfo(CustomNodeInfo newInfo)
{
NodeInfos[newInfo.FunctionId] = newInfo;
OnInfoUpdated(newInfo);
}
开发者ID:junmendoza,项目名称:Dynamo,代码行数:9,代码来源:CustomNodeManager.cs
注:本文中的Dynamo.Utilities.CustomNodeInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论