本文整理汇总了C#中Dynamo.Nodes.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAstForPartialMultiOutput
protected override void BuildAstForPartialMultiOutput(
NodeModel model, AssociativeNode rhs, List<AssociativeNode> resultAst)
{
base.BuildAstForPartialMultiOutput(model, rhs, resultAst);
var emptyList = AstFactory.BuildExprList(new List<AssociativeNode>());
var previewIdInit = AstFactory.BuildAssignment(model.AstIdentifierForPreview, emptyList);
resultAst.Add(previewIdInit);
resultAst.AddRange(
Definition.ReturnKeys.Select(
(rtnKey, idx) =>
AstFactory.BuildAssignment(
AstFactory.BuildIdentifier(
model.AstIdentifierForPreview.Name,
AstFactory.BuildStringNode(rtnKey)),
model.GetAstIdentifierForOutputIndex(idx))));
}
示例2: GetDefinedVariableNames
/// <summary>
/// Returns the names of all the variables defined in this code block.
/// </summary>
/// <returns>List containing all the names</returns>
public List<string> GetDefinedVariableNames()
{
var defVarNames = new List<string>();
// For unbound identifier, ideally if there is an input connect
// to it, it is defined variable. But here we have to be more
// aggresive. For copy/paste, the connectors haven't been
// created yet, so if a variable is defined in other CBN, even
// that variable is defined in this CBN, it is not included in
// the return value.
defVarNames.AddRange(inputIdentifiers);
// Then get all variabled on the LHS of the statements
foreach (Statement stmnt in codeStatements)
{
defVarNames.AddRange(Statement.GetDefinedVariableNames(stmnt, true));
}
return defVarNames;
}
示例3: DeleteModelImpl
void DeleteModelImpl(DeleteModelCommand command)
{
var modelsToDelete = new List<ModelBase>();
if (command.ModelGuid == Guid.Empty)
{
// When nothing is specified then it means all selected models.
modelsToDelete.AddRange(DynamoSelection.Instance.Selection.OfType<ModelBase>());
}
else
{
modelsToDelete.AddRange(command.ModelGuids.Select(guid => CurrentWorkspace.GetModelInternal(guid)));
}
DeleteModelInternal(modelsToDelete);
}
示例4: Paste
//.........这里部分代码省略.........
// Provide a small offset when pasting so duplicate pastes aren't directly on top of each other
CurrentWorkspace.IncrementPasteOffset();
var shiftX = workspaceX - minX + CurrentWorkspace.CurrentPasteOffset;
var shiftY = workspaceY - minY + CurrentWorkspace.CurrentPasteOffset;
foreach (var model in newNodeModels.Concat<ModelBase>(newNoteModels))
{
model.X = model.X + shiftX;
model.Y = model.Y + shiftY;
}
// Add the new NodeModel's to the Workspace
foreach (var newNode in newNodeModels)
{
CurrentWorkspace.AddAndRegisterNode(newNode, false);
createdModels.Add(newNode);
AddToSelection(newNode);
}
// TODO: is this required?
OnRequestLayoutUpdate(this, EventArgs.Empty);
// Add the new NoteModel's to the Workspace
foreach (var newNote in newNoteModels)
{
CurrentWorkspace.AddNote(newNote, false);
createdModels.Add(newNote);
AddToSelection(newNote);
}
ModelBase start;
ModelBase end;
var newConnectors =
from c in connectors
// If the guid is in nodeLookup, then we connect to the new pasted node. Otherwise we
// re-connect to the original.
let startNode =
modelLookup.TryGetValue(c.Start.Owner.GUID, out start)
? start as NodeModel
: CurrentWorkspace.Nodes.FirstOrDefault(x => x.GUID == c.Start.Owner.GUID)
let endNode =
modelLookup.TryGetValue(c.End.Owner.GUID, out end)
? end as NodeModel
: CurrentWorkspace.Nodes.FirstOrDefault(x => x.GUID == c.End.Owner.GUID)
// Don't make a connector if either end is null.
where startNode != null && endNode != null
select
ConnectorModel.Make(startNode, endNode, c.Start.Index, c.End.Index);
createdModels.AddRange(newConnectors);
//Grouping depends on the selected node models.
//so adding the group after nodes / notes are added to workspace.
//select only those nodes that are part of a group.
var newAnnotations = new List<AnnotationModel>();
foreach (var annotation in annotations)
{
var annotationNodeModel = new List<NodeModel>();
var annotationNoteModel = new List<NoteModel>();
//checked condition here that supports pasting of multiple groups
foreach (var models in annotation.SelectedModels)
{
ModelBase mbase;
modelLookup.TryGetValue(models.GUID, out mbase);
if (mbase is NodeModel)
{
annotationNodeModel.Add(mbase as NodeModel);
}
if (mbase is NoteModel)
{
annotationNoteModel.Add(mbase as NoteModel);
}
}
var annotationModel = new AnnotationModel(annotationNodeModel, annotationNoteModel)
{
GUID = Guid.NewGuid(),
AnnotationText = annotation.AnnotationText,
Background = annotation.Background,
FontSize = annotation.FontSize
};
newAnnotations.Add(annotationModel);
}
// Add the new Annotation's to the Workspace
foreach (var newAnnotation in newAnnotations)
{
CurrentWorkspace.AddAnnotation(newAnnotation);
createdModels.Add(newAnnotation);
AddToSelection(newAnnotation);
}
// Record models that are created as part of the command.
CurrentWorkspace.RecordCreatedModels(createdModels);
}
示例5: BuildAst
internal override IEnumerable<AssociativeNode> BuildAst(List<AssociativeNode> inputAstNodes)
{
//Do not build if the node is in error.
if (this.State == ElementState.Error)
{
return null;
}
var resultNodes = new List<AssociativeNode>();
// Define unbound variables if necessary
if (inputIdentifiers != null &&
inputAstNodes != null &&
inputIdentifiers.Count == inputAstNodes.Count)
{
var initStatments = inputIdentifiers.Zip(inputAstNodes,
(ident, rhs) =>
{
var identNode = AstFactory.BuildIdentifier(ident);
MapIdentifiers(identNode);
return AstFactory.BuildAssignment(identNode, rhs);
});
resultNodes.AddRange(initStatments);
}
foreach (var stmnt in codeStatements)
{
var astNode = ProtoCore.Utils.NodeUtils.Clone(stmnt.AstNode);
MapIdentifiers(astNode);
resultNodes.Add(astNode as ProtoCore.AST.AssociativeAST.AssociativeNode);
}
return resultNodes;
}
示例6: Compile
public FScheme.Expression Compile()
{
IEnumerable<string> inputNames = null;
IEnumerable<string> outputNames = null;
// Get the internal nodes for the function
WorkspaceModel functionWorkspace = this.WorkspaceModel;
#region Find outputs
// Find output elements for the node
List<Output> outputs = functionWorkspace.Nodes.OfType<Output>().ToList();
var topMost = new List<Tuple<int, NodeModel>>();
// if we found output nodes, add select their inputs
// these will serve as the function output
if (outputs.Any())
{
topMost.AddRange(
outputs.Where(x => x.HasInput(0)).Select(x => x.Inputs[0]));
outputNames = outputs.Select(x => x.Symbol);
}
else
{
// if there are no explicitly defined output nodes
// get the top most nodes and set THEM as the output
IEnumerable<NodeModel> topMostNodes = functionWorkspace.GetTopMostNodes();
NodeModel infinite = null;
var outNames = new List<string>();
foreach (NodeModel topNode in topMostNodes)
{
if (topNode is Function && (topNode as Function).Definition == this)
{
infinite = topNode;
continue;
}
foreach (int output in Enumerable.Range(0, topNode.OutPortData.Count))
{
if (!topNode.HasOutput(output))
{
topMost.Add(Tuple.Create(output, topNode));
outNames.Add(topNode.OutPortData[output].NickName);
}
}
}
if (infinite != null && outNames.Count == 0)
{
topMost.Add(Tuple.Create(0, infinite));
outNames.Add("∞");
}
outputNames = outNames;
}
#endregion
// color the node to define its connectivity
foreach (var ele in topMost)
{
ele.Item2.ValidateConnections();
}
//Find function entry point, and then compile
var variables = functionWorkspace.Nodes.OfType<Symbol>().ToList();
inputNames = variables.Select(x => x.InputSymbol);
//Update existing function nodes which point to this function to match its changes
dynSettings.Controller.DynamoModel.AllNodes
.OfType<Function>()
.Where(el => el.Definition != null && el.Definition.FunctionId == this.FunctionId)
.ToList()
.ForEach(node =>
{
node.SetInputs(inputNames);
node.SetOutputs(outputNames);
node.RegisterAllPorts();
});
//Call OnSave for all saved elements
functionWorkspace.Nodes.ToList().ForEach(x => x.onSave());
INode top;
var buildDict = new Dictionary<NodeModel, Dictionary<int, INode>>();
if (topMost.Count > 1)
{
InputNode node = new ExternalFunctionNode(FScheme.Value.NewList);
int i = 0;
foreach (var topNode in topMost)
{
string inputName = i.ToString(CultureInfo.InvariantCulture);
node.AddInput(inputName);
//.........这里部分代码省略.........
示例7: LoadAllTypesFromDynamoAssemblies
public List<Type> LoadAllTypesFromDynamoAssemblies()
{
var nodeTypes = new List<Type>();
var loadedAssemblyNames = new HashSet<string>();
var allLoadedAssembliesByPath = new Dictionary<string, Assembly>();
var allLoadedAssemblies = new Dictionary<string, Assembly>();
// cache the loaded assembly information
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (assembly.IsDynamic)
continue;
try
{
allLoadedAssembliesByPath[assembly.Location] = assembly;
allLoadedAssemblies[assembly.FullName] = assembly;
}
catch { }
}
// find all the dlls registered in all search paths
// and concatenate with all dlls in the current directory
var allDynamoAssemblyPaths =
DynamoPathManager.Instance.Nodes.SelectMany((path) =>
{
return (Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly));
}).ToList();
// add the core assembly to get things like code block nodes and watches.
allDynamoAssemblyPaths.Add(Path.Combine(DynamoPathManager.Instance.MainExecPath, "DynamoCore.dll"));
var resolver = new ResolveEventHandler(delegate(object sender, ResolveEventArgs args)
{
Assembly result;
allLoadedAssemblies.TryGetValue(args.Name, out result);
return result;
});
foreach (var assemblyPath in allDynamoAssemblyPaths)
{
var fn = Path.GetFileName(assemblyPath);
if (fn == null)
continue;
// if the assembly has already been loaded, then
// skip it, otherwise cache it.
if (loadedAssemblyNames.Contains(fn))
continue;
loadedAssemblyNames.Add(fn);
if (allLoadedAssembliesByPath.ContainsKey(assemblyPath))
{
List<Type> types = LoadNodesFromAssembly(allLoadedAssembliesByPath[assemblyPath]);
nodeTypes.AddRange(types);
}
else
{
try
{
var assembly = Assembly.LoadFrom(assemblyPath);
allLoadedAssemblies[assembly.GetName().Name] = assembly;
List<Type> types = LoadNodesFromAssembly(assembly);
nodeTypes.AddRange(types);
}
catch (Exception e)
{
DynamoViewModel.Model.Logger.Log(e);
}
}
}
return nodeTypes;
}
示例8: OnPreviewControlLoaded
private void OnPreviewControlLoaded(object sender, RoutedEventArgs e)
{
phaseInStoryboard = this.Resources["phaseInStoryboard"] as Storyboard;
phaseOutStoryboard = this.Resources["phaseOutStoryboard"] as Storyboard;
expandStoryboard = this.Resources["expandStoryboard"] as Storyboard;
condenseStoryboard = this.Resources["condenseStoryboard"] as Storyboard;
resizingStoryboard = this.Resources["resizingStoryboard"] as Storyboard;
var children = new List<Timeline>();
children.AddRange(phaseInStoryboard.Children);
children.AddRange(expandStoryboard.Children);
children.AddRange(condenseStoryboard.Children);
children.AddRange(resizingStoryboard.Children);
this.sizeAnimators = new Dictionary<string, DoubleAnimation>();
foreach (var child in children)
{
if (string.IsNullOrEmpty(child.Name))
continue;
switch (child.Name)
{
case Element.PhaseInWidthAnimator:
case Element.PhaseInHeightAnimator:
case Element.ExpandWidthAnimator:
case Element.ExpandHeightAnimator:
case Element.CondenseWidthAnimator:
case Element.CondenseHeightAnimator:
case Element.GridWidthAnimator:
case Element.GridHeightAnimator:
sizeAnimators.Add(child.Name, child as DoubleAnimation);
break;
}
}
if (this.sizeAnimators.Count != 8)
{
var message = "One or more DoubleAnimation timeline not found";
throw new InvalidOperationException(message);
}
// If there was a request queued before this control is loaded,
// then process the request as we now have the right width.
BeginNextTransition();
}
示例9: ParseSolid
private static void ParseSolid(GeometryObject obj, List<XYZ> pts)
{
var solid = obj as Solid;
foreach (Edge gEdge in solid.Edges)
{
Curve c = gEdge.AsCurve();
if (c is Line)
{
pts.Add(c.Evaluate(0, true));
pts.Add(c.Evaluate(1,true));
}
else
{
IList<XYZ> xyzArray = gEdge.Tessellate();
pts.AddRange(xyzArray);
}
}
}
示例10: GetUpstreamDrawableIds
/// <summary>
/// Gathers the Ids of the upstream drawable nodes.
/// </summary>
/// <param name="inputs">A dictionary describing the inputs on the node.</param>
/// <returns>A collection of strings.</returns>
private List<string> GetUpstreamDrawableIds(Dictionary<int, Tuple<int, NodeModel>> inputs)
{
var drawables = new List<string>();
foreach (KeyValuePair<int, Tuple<int, NodeModel>> pair in inputs)
{
if (pair.Value == null)
continue;
NodeModel node = pair.Value.Item2;
if(node.OldValue != null)
drawables.Add(node.GUID.ToString());
if (node.IsUpstreamVisible)
drawables.AddRange(GetUpstreamDrawableIds(node.Inputs));
}
return drawables;
}
示例11: BuildAst
//.........这里部分代码省略.........
RightNode = new IdentifierNode(Definition.Name)
};
rhs = staticProp;
break;
case FunctionType.InstanceProperty:
// Only handle getter here. Setter could be handled in CBN.
rhs = new NullNode();
if (inputAstNodes != null && inputAstNodes.Count >= 1)
{
var thisNode = inputAstNodes[0];
if (thisNode != null && !(thisNode is NullNode))
{
var insProp = new IdentifierListNode
{
LeftNode = inputAstNodes[0],
RightNode = new IdentifierNode(Definition.Name)
};
rhs = insProp;
}
}
break;
case FunctionType.InstanceMethod:
rhs = new NullNode();
if (inputAstNodes != null && inputAstNodes.Count >= 1)
{
var thisNode = inputAstNodes[0];
inputAstNodes.RemoveAt(0); // remove this pointer
if (thisNode != null && !(thisNode is NullNode))
{
var memberFunc = new IdentifierListNode
{
LeftNode = thisNode,
RightNode = AstFactory.BuildFunctionCall(function, inputAstNodes)
};
rhs = memberFunc;
}
}
break;
default:
if (HasUnconnectedInput())
{
var functionNode = new IdentifierNode(function);
rhs = CreateFunctionObject(functionNode, inputAstNodes);
}
else
{
rhs = AstFactory.BuildFunctionCall(function, inputAstNodes);
}
break;
}
resultAst.Add(AstFactory.BuildAssignment(AstIdentifierForPreview, rhs));
if (OutPortData.Count == 1)
{
var outputIdentiferNode = GetAstIdentifierForOutputIndex(0);
string outputIdentifier = outputIdentiferNode.ToString();
string thisIdentifier = AstIdentifierForPreview.ToString();
if (!string.Equals(outputIdentifier, thisIdentifier))
{
resultAst.Add(
AstFactory.BuildAssignment(outputIdentiferNode, AstIdentifierForPreview));
}
}
else
{
var undefinedOutputs = Definition.ReturnKeys == null || !Definition.ReturnKeys.Any();
resultAst.AddRange(
Enumerable.Range(0, OutPortData.Count)
.Select(
outputIdx =>
undefinedOutputs
? AstIdentifierForPreview
: new IdentifierNode(AstIdentifierForPreview)
{
ArrayDimensions =
new ArrayNode
{
Expr =
new StringNode
{
value =
Definition.ReturnKeys.ElementAt(
outputIdx)
}
}
}));
}
return resultAst;
}
示例12: GetColorsFromMirrorData
private static List<Color> GetColorsFromMirrorData(RuntimeMirror colorsMirror)
{
var colors = new List<Color>();
if (colorsMirror == null || colorsMirror.GetData() == null) return colors;
var data = colorsMirror.GetData();
if (data != null)
{
if (data.IsCollection)
{
colors.AddRange(data.GetElements().Select(e => e.Data).OfType<Color>());
}
else
{
var color = data.Data as Color;
if (color != null)
colors.Add(color);
}
}
return colors;
}
示例13: MergeMeshes
Mesh3D MergeMeshes(List<Mesh3D> meshes)
{
if (meshes.Count == 0)
return null;
Mesh3D fullMesh = new Mesh3D();
List<Point3D> positions = new List<Point3D>();
List<int> triangleIndices = new List<int>();
int offset = 0;
foreach (Mesh3D m in meshes)
{
positions.AddRange(m.Vertices);
foreach (int[] face in m.Faces)
{
triangleIndices.Add(face[0] + offset);
triangleIndices.Add(face[1] + offset);
triangleIndices.Add(face[2] + offset);
}
offset = positions.Count;
}
return new Mesh3D(positions, triangleIndices);
}
示例14: Send
/// <summary>
/// Sends workspace and its' dependencies to Flood.
/// </summary>
internal void Send(IEnumerable<IWorkspaceModel> workspaces)
{
if (String.IsNullOrWhiteSpace(serverUrl) || String.IsNullOrWhiteSpace(authenticationProvider.Username))
throw new Exception(Resource.ServerErrorMessage);
if (authenticationProvider == null)
throw new Exception(Resource.AuthenticationErrorMessage);
string fullServerAdress = serverUrl + ":" + port;
if (reachClient == null)
reachClient = new WorkspaceStorageClient(authenticationProvider, fullServerAdress);
HomeWorkspace = workspaces.OfType<HomeWorkspaceModel>().First();
var functionNodes = HomeWorkspace.Nodes.OfType<Function>();
List<CustomNodeDefinition> dependencies = new List<CustomNodeDefinition>();
foreach (var node in functionNodes)
{
dependencies.AddRange(node.Definition.Dependencies);
}
CustomNodeWorkspaces = new List<CustomNodeWorkspaceModel>();
foreach (var dependency in dependencies)
{
CustomNodeWorkspaceModel customNodeWs;
var isWorkspaceCreated = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs);
if (isWorkspaceCreated && !CustomNodeWorkspaces.Contains(customNodeWs))
CustomNodeWorkspaces.Add(customNodeWs);
}
var result = reachClient.Send(HomeWorkspace, CustomNodeWorkspaces);
}
示例15: GetAPIPropertyValue
/// <summary>
/// Get a property value from a member
/// </summary>
/// <param name="args">The incoming arguments</param>
/// <param name="api_base_type">The base type</param>
/// <param name="pi">The property info object for which you will return the value.</param>
/// <param name="return_type">The expected return type.</param>
/// <returns></returns>
public static Value GetAPIPropertyValue( FSharpList<Value> args,
Type api_base_type, PropertyInfo pi, Type return_type)
{
//var arg0 = (Autodesk.Revit.DB.HermiteFace)DynamoTypeConverter.ConvertInput(args[0], typeof(Autodesk.Revit.DB.HermiteFace));
//var result = arg0.Points;
var results = new List<object>();
//there should only be one argument
foreach (var arg in args)
{
if (arg.IsList)
{
FSharpList<Value> lst = FSharpList<Value>.Empty;
//the values here are the items whose properties
//you want to query. nothing fancy, just get the
//property for each of the items.
results.AddRange(((Value.List) arg).Item.
Select(v => DynamoTypeConverter.ConvertInput(v, api_base_type)).
Select(invocationTarget => pi.GetValue(invocationTarget, null)));
}
else
{
var invocationTarget = DynamoTypeConverter.ConvertInput(args[0], api_base_type);
results.Add(pi.GetValue(invocationTarget,null));
}
}
return ConvertAllResults(results);
}