本文整理汇总了C#中Dynamo.Nodes.List.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# List.SelectMany方法的具体用法?C# List.SelectMany怎么用?C# List.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.SelectMany方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllDependencies
private IEnumerable<PackageDependency> GetAllDependencies()
{
var pmExtension = dynamoViewModel.Model.GetPackageManagerExtension();
var pkgLoader = pmExtension.PackageLoader;
// all workspaces
var workspaces = new List<CustomNodeWorkspaceModel>();
foreach (var def in AllDependentFuncDefs())
{
CustomNodeWorkspaceModel ws;
if (dynamoViewModel.Model.CustomNodeManager.TryGetFunctionWorkspace(
def.FunctionId,
DynamoModel.IsTestMode,
out ws))
{
workspaces.Add(ws);
}
}
// get all of dependencies from custom nodes and additional files
var allFilePackages =
workspaces
.Select(x => x.FileName)
.Union(AdditionalFiles)
.Where(pkgLoader.IsUnderPackageControl)
.Select(pkgLoader.GetOwnerPackage)
.Where(x => x != null)
.Where(x => (x.Name != Name))
.Distinct()
.Select(x => new PackageDependency(x.Name, x.VersionName));
workspaces = new List<CustomNodeWorkspaceModel>();
foreach (var def in AllFuncDefs())
{
CustomNodeWorkspaceModel ws;
if (dynamoViewModel.Model.CustomNodeManager.TryGetFunctionWorkspace(
def.FunctionId,
DynamoModel.IsTestMode,
out ws))
{
workspaces.Add(ws);
}
}
// get all of the dependencies from types
var allTypePackages = workspaces
.SelectMany(x => x.Nodes)
.Select(x => x.GetType())
.Where(pkgLoader.IsUnderPackageControl)
.Select(pkgLoader.GetOwnerPackage)
.Where(x => x != null)
.Where(x => (x.Name != Name))
.Distinct()
.Select(x => new PackageDependency(x.Name, x.VersionName));
var dsFunctionPackages = workspaces
.SelectMany(x => x.Nodes)
.OfType<DSFunctionBase>()
.Select(x => x.Controller.Definition.Assembly)
.Where(pkgLoader.IsUnderPackageControl)
.Select(pkgLoader.GetOwnerPackage)
.Where(x => x != null)
.Where(x => (x.Name != Name))
.Distinct()
.Select(x => new PackageDependency(x.Name, x.VersionName));
return allFilePackages.Union(allTypePackages).Union(dsFunctionPackages);
}
示例2: InvokeAPIMethod
/// <summary>
/// Invoke an API method, using the node's lacing strategy to build lists of arguments
/// </summary>
/// <param name="node">The node.</param>
/// <param name="args">The incoming Values on the node.</param>
/// <param name="api_base_type">The API's base type whose method we will invoke.</param>
/// <param name="pi">An array of parameter info for the method.</param>
/// <param name="mi">The method info for the method.</param>
/// <param name="return_type">The expected return type from the method.</param>
/// <returns></returns>
public static Value InvokeAPIMethod(dynRevitTransactionNode node, FSharpList<Value> args, Type api_base_type, ParameterInfo[] pi, MethodBase mi, Type return_type)
{
//if any argument are a list, honor the lacing strategy
//compile a list of parameter lists to be used in our method invocation
List<List<object>> parameters = null;
switch (node.ArgumentLacing)
{
case LacingStrategy.Single:
parameters = GetSingleArguments(args, pi);
break;
case LacingStrategy.Shortest:
parameters = GetShortestArguments(args, pi);
break;
case LacingStrategy.Longest:
parameters = GetLongestArguments(args, pi);
break;
default:
parameters = GetSingleArguments(args, pi);
break;
}
var invocationTargetList = new List<object>();
if (api_base_type == typeof(Autodesk.Revit.Creation.Document) ||
api_base_type == typeof(Autodesk.Revit.Creation.FamilyItemFactory) ||
api_base_type == typeof(Autodesk.Revit.Creation.ItemFactoryBase))
{
if (dynRevitSettings.Doc.Document.IsFamilyDocument)
{
invocationTargetList.Add(dynRevitSettings.Doc.Document.FamilyCreate);
}
else
{
invocationTargetList.Add(dynRevitSettings.Doc.Document.Create);
}
}
else if (api_base_type == typeof(Autodesk.Revit.Creation.Application))
{
invocationTargetList.Add(dynRevitSettings.Revit.Application.Create);
}
else
{
if (!mi.IsStatic && !mi.IsConstructor)
{
if (args[0].IsList)
{
invocationTargetList.AddRange(((Value.List)args[0]).Item.Select(x => DynamoTypeConverter.ConvertInput(x, api_base_type)));
}
else
{
//the first input will always hold the instance
//whose methods you want to invoke
invocationTargetList.Add(DynamoTypeConverter.ConvertInput(args[0], api_base_type));
}
}
}
//object result = null;
List<object> results = null;
//if the method info is for a constructor, then
//call the constructor for each set of parameters
//if it's an instance method, then invoke the method for
//each instance passed in.
results = mi.IsConstructor ?
parameters.Select(x => ((ConstructorInfo) mi).Invoke(x.ToArray())).ToList() :
invocationTargetList.SelectMany(x => parameters.Select(y => mi.Invoke(x, y.ToArray())).ToList()).ToList();
dynRevitUtils.StoreElements(node, results);
return ConvertAllResults(results);
}