本文整理汇总了C#中Dynamo.Nodes.List.Add方法的典型用法代码示例。如果您正苦于以下问题:C# List.Add方法的具体用法?C# List.Add怎么用?C# List.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collect
/// <summary>
/// Get all of the dependencies from a workspace
/// </summary>
/// <param name="workspace">The workspace to read the dependencies from</param>
/// <param name="customNodeManager">A custom node manager to look up dependencies</param>
/// <returns>A WorkspaceDependencies object containing the workspace and its CustomNodeWorkspaceModel dependencies</returns>
public static WorkspaceDependencies Collect(HomeWorkspaceModel workspace, ICustomNodeManager customNodeManager)
{
if (workspace == null) throw new ArgumentNullException("workspace");
if (customNodeManager == null) throw new ArgumentNullException("customNodeManager");
// collect all dependencies
var dependencies = new HashSet<CustomNodeDefinition>();
foreach (var node in workspace.Nodes.OfType<Function>())
{
dependencies.Add(node.Definition);
foreach (var dep in node.Definition.Dependencies)
{
dependencies.Add(dep);
}
}
var customNodeWorkspaces = new List<ICustomNodeWorkspaceModel>();
foreach (var dependency in dependencies)
{
ICustomNodeWorkspaceModel customNodeWs;
var workspaceExists = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs);
if (!workspaceExists)
{
throw new InvalidOperationException(String.Format(Resources.CustomNodeDefinitionNotFoundErrorMessage, dependency.FunctionName));
}
if (!customNodeWorkspaces.Contains(customNodeWs))
{
customNodeWorkspaces.Add(customNodeWs);
}
}
return new WorkspaceDependencies(workspace, customNodeWorkspaces);
}
示例2: PresetModel
/// <summary>
/// create a new presetsState, this will serialize all the referenced nodes by calling their serialize method,
/// the resulting XML elements will be used to save this state when the presetModel is saved on workspace save
/// </summary>
/// <param name="name">name for the state, must not be null </param>
/// <param name="description">description of the state, can be null</param>
/// <param name="inputsToSave">set of nodeModels, must not be null</param>
/// <param name="id">an id GUID, can be empty GUID</param>
public PresetModel(string name, string description, IEnumerable<NodeModel> inputsToSave):base()
{
if (String.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}
if (inputsToSave == null || inputsToSave.Count() < 1)
{
throw new ArgumentNullException("inputsToSave");
}
Name = name;
Description = description;
nodes = inputsToSave.ToList();
var tempdoc = new XmlDocument();
serializedNodes = new List<XmlElement>();
foreach (var node in Nodes)
{
serializedNodes.Add(node.Serialize(tempdoc, SaveContext.Preset));
}
}
示例3: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
CurveLoop firstLoop = (CurveLoop)((Value.Container)args[0]).Item;
CurveLoop secondLoop = (CurveLoop)((Value.Container)args[1]).Item;
List<VertexPair> vertPairs = null;
if (dynRevitSettings.Revit.Application.VersionName.Contains("2013"))
{
vertPairs = new List<VertexPair>();
int i = 0;
int nCurves1 = firstLoop.Count();
int nCurves2 = secondLoop.Count();
for (; i < nCurves1 && i < nCurves2; i++)
{
vertPairs.Add(new VertexPair(i, i));
}
}
var result = GeometryCreationUtilities.CreateBlendGeometry(firstLoop, secondLoop, vertPairs);
solids.Add(result);
return Value.NewContainer(result);
}
示例4: GetCarbonNeutralPotential
public static Dictionary<string, object> GetCarbonNeutralPotential(RunResultSummary Results)
{
// Populate Carbon Neutral Potential data
List<object> CO2Emission = new List<Object>();
CO2Emission.Add(Results.CarbonNeutralPotential.Units);
CO2Emission.Add((double)Results.CarbonNeutralPotential.RunEmissions.Value);
List<object> RenewablePotential = new List<object>();
RenewablePotential.Add(Results.CarbonNeutralPotential.Units);
RenewablePotential.Add((double)Results.CarbonNeutralPotential.OnsiteRenewablePotentialEmissions.Value);
List<object> NVentilationPotential = new List<object>();
NVentilationPotential.Add(Results.CarbonNeutralPotential.Units);
NVentilationPotential.Add(Results.CarbonNeutralPotential.NaturalVentilationPotentialEmissions.Value);
List<object> BiofuelUse = new List<object>();
BiofuelUse.Add(Results.CarbonNeutralPotential.Units);
BiofuelUse.Add((double)Results.CarbonNeutralPotential.OnsiteBiofuelUseEmissions.Value);
List<object> NetCO2Emission = new List<object>();
NetCO2Emission.Add(Results.CarbonNeutralPotential.Units);
NetCO2Emission.Add((double)Results.CarbonNeutralPotential.NetCO2Emissions.Value);
List<object> LargeSUV = new List<object>();
LargeSUV.Add(Results.CarbonNeutralPotential.NetLargeSUVEquivalent.Units);
LargeSUV.Add((double)Results.CarbonNeutralPotential.NetLargeSUVEquivalent.Value);
// Populate Outputs
return new Dictionary<string, object>
{
{"Run CO2 Emission",CO2Emission},
{"Onsite Renewable Potential", RenewablePotential},
{"Natural Ventilation Potential",NVentilationPotential},
{"Onsite Biofuel Use",BiofuelUse},
{"Net CO2 Emission",NetCO2Emission},
{"Net Large SUV Equivalent", LargeSUV}
};
}
示例5: PreUpdateModel
private void PreUpdateModel(object dataItem)
{
// Attempt get to the data-bound model (if there's any).
NodeModel nodeModel = dataItem as NodeModel;
NoteModel noteModel = dataItem as NoteModel;
if (null == nodeModel && (null == noteModel))
{
NodeViewModel nodeViewModel = dataItem as NodeViewModel;
if (null != nodeViewModel)
nodeModel = nodeViewModel.NodeModel;
else
{
// TODO(Ben): We temporary do not handle NoteModel here
// because NoteView actively update the data-bound "Text"
// property as user types, so when this method is called,
// it will be too late to record the states before the
// text change happened.
//
// NoteViewModel noteViewModel = dataItem as NoteViewModel;
// if (null != noteViewModel)
// noteModel = noteViewModel.Model;
}
}
// If we do get a node/note, record it for undo.
if (null != nodeModel || (null != noteModel))
{
List<ModelBase> models = new List<ModelBase>();
if (null != nodeModel) models.Add(nodeModel);
if (null != noteModel) models.Add(noteModel);
DynamoModel dynamo = dynSettings.Controller.DynamoModel;
dynamo.CurrentWorkspace.RecordModelsForModification(models);
dynSettings.Controller.DynamoViewModel.UndoCommand.RaiseCanExecuteChanged();
dynSettings.Controller.DynamoViewModel.RedoCommand.RaiseCanExecuteChanged();
}
}
示例6: GetStatementVariables
/// <summary>
/// Call this method to get a list of lists of variables defined in
/// the given set of Statement objects. This method is typically used
/// in conjunction with DoesStatementRequireOutputPort method.
/// </summary>
/// <param name="statements">A list of Statement objects whose defined
/// variables are to be retrieved. This list can be empty but it cannot
/// be null.</param>
/// <param name="onlyTopLevel">Set this parameter to false to retrieve
/// all variables defined in nested Statement objects.</param>
/// <returns>Returns a list of lists of variables defined by the given
/// set of Statement objects.</returns>
///
public static IEnumerable<IEnumerable<string>> GetStatementVariables(
IEnumerable<Statement> statements, bool onlyTopLevel)
{
if (statements == null)
throw new ArgumentNullException("statements");
var definedVariables = new List<List<string>>();
foreach (var statement in statements)
{
definedVariables.Add(Statement.GetDefinedVariableNames(
statement, onlyTopLevel));
}
return definedVariables;
}
示例7: RectangularSectionSinglyReinforced
internal RectangularSectionSinglyReinforced(double b, double h, double A_s, double c_cntr,
ConcreteMaterial ConcreteMaterial, RebarMaterial LongitudinalRebarMaterial, bool hasTies=false)
{
CrossSectionRectangularShape shape = new CrossSectionRectangularShape(ConcreteMaterial.Concrete, null, b, h);
base.ConcreteMaterial = ConcreteMaterial; //duplicate save of concrete material into base Dynamo class
List<wosadAci.RebarPoint> LongitudinalBars = new List<wosadAci.RebarPoint>();
wosadAci.Rebar thisBar = new wosadAci.Rebar(A_s, LongitudinalRebarMaterial.Material);
wosadAci.RebarPoint point = new wosadAci.RebarPoint(thisBar, new wosadAci.RebarCoordinate() { X = 0, Y = -h / 2.0 + c_cntr });
LongitudinalBars.Add(point);
wosadAci.IConcreteFlexuralMember fs = new wosadAci14.ConcreteSectionFlexure(shape, LongitudinalBars, new CalcLog());
this.FlexuralSection = fs;
}
示例8: Evaluate
public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
{
Element thisElement = (Element)((FScheme.Value.Container)args[0]).Item;
instanceGeometryObjects = new List<GeometryObject>();
var result = FSharpList<FScheme.Value>.Empty;
Autodesk.Revit.DB.Options geoOptionsOne = new Autodesk.Revit.DB.Options();
geoOptionsOne.ComputeReferences = true;
GeometryObject geomObj = thisElement.get_Geometry(geoOptionsOne);
GeometryElement geomElement = geomObj as GeometryElement;
if ((thisElement is GenericForm) && (geomElement.Count() < 1))
{
GenericForm gF = (GenericForm)thisElement;
if (!gF.Combinations.IsEmpty)
{
Autodesk.Revit.DB.Options geoOptionsTwo = new Autodesk.Revit.DB.Options();
geoOptionsTwo.IncludeNonVisibleObjects = true;
geoOptionsTwo.ComputeReferences = true;
geomObj = thisElement.get_Geometry(geoOptionsTwo);
geomElement = geomObj as GeometryElement;
}
}
foreach (GeometryObject geob in geomElement)
{
GeometryInstance ginsta = geob as GeometryInstance;
if (ginsta != null)
{
GeometryElement instanceGeom = ginsta.GetInstanceGeometry();
instanceGeometryObjects.Add(instanceGeom);
foreach (GeometryObject geobInst in instanceGeom)
{
result = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(geobInst), result);
}
}
else
{
result = FSharpList<FScheme.Value>.Cons(FScheme.Value.NewContainer(geob), result);
}
}
return FScheme.Value.NewList(result);
}
示例9: 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))));
}
示例10: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
var input = args[0];
var xi = ((Value.Number)args[1]).Item;// Number
var x0 = ((Value.Number)args[2]).Item;// Starting Coord
var xs = (SpacingRuleLayout)((Value.Container)args[3]).Item; // Spacing
Autodesk.Revit.DB.DividedPath divPath;
var refList = new List<Reference>();
refList.Clear();
var c = (CurveElement)((Value.Container)input).Item;
FSharpList<Value> result = FSharpList<Value>.Empty;
Curve crvRef = c.GeometryCurve;
refList.Add(crvRef.Reference);
if (this.Elements.Any())
{
if (dynUtils.TryGetElement(this.Elements[0], out divPath))
{
SetSpacing(divPath, xi, xs);
}
else
{
divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
SetSpacing(divPath, xi, xs);
this.Elements[0] = divPath.Id;
}
}
else
{
divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
SetSpacing(divPath, xi, xs);
this.Elements.Add(divPath.Id);
}
refList.Clear();
return Value.NewContainer(divPath);
}
示例11: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
CurveLoop firstLoop = (CurveLoop)((Value.Container)args[0]).Item;
CurveLoop secondLoop = (CurveLoop)((Value.Container)args[1]).Item;
List<VertexPair> vertPairs = new List<VertexPair>();
int i = 0;
foreach (Curve c in firstLoop)
{
vertPairs.Add(new VertexPair(i, i));
i++;
}
var result = GeometryCreationUtilities.CreateBlendGeometry(firstLoop, secondLoop, vertPairs);
solids.Add(result);
return Value.NewContainer(result);
}
示例12: RunMutationTests
internal void RunMutationTests()
{
String logTarget = dynamoViewModel.Model.Logger.LogPath + "MutationLog.log";
StreamWriter writer = new StreamWriter(logTarget);
writer.WriteLine("MutateTest Internal activate");
System.Diagnostics.Debug.WriteLine("MutateTest Internal activate");
new Thread(() =>
{
try
{
Assembly assembly = Assembly.GetExecutingAssembly();
var mutators = new List<AbstractMutator>();
foreach (Type type in assembly.GetTypes())
{
var attribute = Attribute.GetCustomAttribute(type, typeof(MutationTestAttribute));
if (attribute != null)
{
object[] args = new object[] { dynamoViewModel };
var classInstance = Activator.CreateInstance(type, args);
mutators.Add((AbstractMutator)classInstance);
}
}
foreach (var mutator in mutators)
InvokeTest(mutator, writer);
}
finally
{
dynamoViewModel.Model.Logger.Log("Fuzz testing finished.");
writer.Flush();
writer.Close();
writer.Dispose();
}
}).Start();
}
示例13: GenerateInputPortData
/// <summary>
/// Call this method to generate a list of PortData from given set of
/// unbound identifiers. This method ensures that the generated ports
/// are only having names that do not exceed a preconfigured length.
/// </summary>
/// <param name="unboundIdents">A list of unbound identifiers for which
/// input port data is to be generated. This list can be empty but it
/// cannot be null.</param>
/// <returns>Returns a list of input port data generated based on the
/// input unbound identifier list.</returns>
///
public static IEnumerable<PortData> GenerateInputPortData(
IEnumerable<string> unboundIdents)
{
if (unboundIdents == null)
throw new ArgumentNullException("unboundIdents");
int maxLength = Configurations.CBNMaxPortNameLength;
List<PortData> inputPorts = new List<PortData>();
foreach (string name in unboundIdents)
{
string portName = name;
if (portName.Length > maxLength)
portName = portName.Remove(maxLength - 3) + "...";
inputPorts.Add(new PortData(portName, name));
}
return inputPorts;
}
示例14: BuildAstForPartialMultiOutput
/// <summary>
/// Produces AST for a partial function application of a multi-output function.
/// </summary>
/// <param name="model">NodeModel to produce AST for.</param>
/// <param name="rhs">AST representing the partial application. This will need to be used to assign all output port identifiers.</param>
/// <param name="resultAst">Result accumulator: add all new output AST to this list.</param>
protected virtual void BuildAstForPartialMultiOutput(
NodeModel model, AssociativeNode rhs, List<AssociativeNode> resultAst)
{
var missingAmt =
Enumerable.Range(0, model.InPortData.Count).Count(x => !model.HasInput(x));
var tmp =
AstFactory.BuildIdentifier("__partial_" + model.GUID.ToString().Replace('-', '_'));
resultAst.Add(AstFactory.BuildAssignment(tmp, rhs));
resultAst.AddRange(
(Definition.ReturnKeys ?? Enumerable.Empty<string>()).Select(
AstFactory.BuildStringNode)
.Select(
(rtnKey, index) =>
AstFactory.BuildAssignment(
model.GetAstIdentifierForOutputIndex(index),
AstFactory.BuildFunctionObject(
"__ComposeBuffered",
3,
new[] { 0, 1 },
new List<AssociativeNode>
{
AstFactory.BuildExprList(
new List<AssociativeNode>
{
AstFactory.BuildFunctionObject(
"__GetOutput",
2,
new[] { 1 },
new List<AssociativeNode>
{
AstFactory.BuildNullNode(),
rtnKey
}),
tmp
}),
AstFactory.BuildIntNode(missingAmt),
AstFactory.BuildNullNode()
}))));
}
示例15: mi_Click
void mi_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (AllElements.Count == 0)
return;
//select the elements
dynRevitSettings.Doc.Selection.Elements.Clear();
var existingElements = new List<Element>();
foreach (var id in AllElements)
{
Element el;
if (dynUtils.TryGetElement(id, typeof (Element), out el))
{
existingElements.Add(el);
}
}
existingElements.ForEach(x => dynRevitSettings.Doc.Selection.Elements.Add(x));
//show the elements
dynRevitSettings.Doc.ShowElements(existingElements.Select(x => x.Id).ToList());
}