本文整理汇总了C#中FSharpList.Count方法的典型用法代码示例。如果您正苦于以下问题:C# FSharpList.Count方法的具体用法?C# FSharpList.Count怎么用?C# FSharpList.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSharpList
的用法示例。
在下文中一共展示了FSharpList.Count方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildParameterList
/// <summary>
/// Builds a parameter list given a list of arguments and a list of parameter info
/// </summary>
/// <param name="args">A list of Values which will be distributed to the output lists</param>
/// <param name="pi">An array of parameter info for the method</param>
/// <param name="end">The end count</param>
/// <param name="parameters">A parameters List to add to.</param>
private static void BuildParameterList(FSharpList<Value> args, ParameterInfo[] pi, int end, List<List<object>> parameters)
{
//for a static method, the number of parameters
//will equal the number of arguments on the node
if (args.Count() == pi.Count())
{
//ARGUMENT LOOP
for (int j = 0; j < end; j++)
{
//create a list to hold each set of arguments
var currParams = new List<object>();
//PARAMETER LOOP
for (int i = 0; i < pi.Count(); i++)
{
var arg = args[i];
//if the value is a list, add the jth item converted
//or the last item if i exceeds the count of the list
if (arg.IsList)
{
var lst = (Value.List) arg;
var argItem = (j < lst.Item.Count() ? lst.Item[j]: lst.Item.Last());
currParams.Add(DynamoTypeConverter.ConvertInput(argItem, pi[i].ParameterType));
}
else
//if the value is not a list,
//just add the value
currParams.Add(DynamoTypeConverter.ConvertInput(arg, pi[i].ParameterType));
}
parameters.Add(currParams);
}
}
//for instance methods, the first argument will be the
//item or list of items which will be the target of invocation
//in this case, skip parsing the first argument
else
{
//ARGUMENT LOOP
for (int j = 0; j < end; j++)
{
//create a list to hold each set of arguments
var currParams = new List<object>();
//PARAMETER LOOP
for (int i = 0; i < pi.Count(); i++)
{
var arg = args[i + 1];
//if the value is a list, add the jth item converted
//or the last item if i exceeds the count of the list
if (arg.IsList)
{
//var argItem = ((Value.List)arg).Item.Count() < end ? args.Last() : args[j];
var lst = (Value.List)arg;
var argItem = (j < lst.Item.Count() ? lst.Item[j] : lst.Item.Last());
currParams.Add(DynamoTypeConverter.ConvertInput(argItem, pi[i].ParameterType));
}
else
//if the value is not a list,
//just add the value
currParams.Add(DynamoTypeConverter.ConvertInput(arg, pi[i].ParameterType));
}
parameters.Add(currParams);
}
}
}
示例2: ResetSystem
private void ResetSystem(FSharpList<Value> points, FSharpList<Value> curves)
{
if (points == null || curves == null)
return;
//particleSystem.Clear();
particleSystem = null;
particleSystem = new ParticleSystem();
_fixPtCount = points.Count();
particleSystem.setConverged(false);
particleSystem.setGravity(_g);
particleSystem.setThreshold(_threshold);
CreateSpringsFromCurves(curves, points);
DispatchOnUIThread(new Action(dynSettings.Controller.RequestClearDrawables));
_reset = false;
}
示例3: __eval_internal
protected internal virtual void __eval_internal(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
var argList = new List<string>();
if (args.Count() > 0)
{
argList = args.Select(x => x.ToString()).ToList<string>();
}
var outPutsList = new List<string>();
if(outPuts.Count() > 0)
{
outPutsList = outPuts.Keys.Select(x=>x.NickName).ToList<string>();
}
Debug.WriteLine(string.Format("__eval_internal : {0} : {1}",
string.Join(",", argList),
string.Join(",", outPutsList)));
Evaluate(args, outPuts);
}
示例4: Evaluate
public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
//THE OLD WAY
//outPuts[OutPortData[0]] = Evaluate(args);
//THE NEW WAY
//if this element maintains a collcection of references
//then clear the collection
if (this is IClearable)
(this as IClearable).ClearReferences();
List<FSharpList<Value>> argSets = new List<FSharpList<Value>>();
//create a zip of the incoming args and the port data
//to be used for type comparison
var portComparison = args.Zip(InPortData, (first, second) => new Tuple<Type, Type>(first.GetType(), second.PortType));
//if any value is a list whose expectation is a single
//do an auto map
//TODO: figure out a better way to do this than using a lot
//of specific excludes
if (args.Count() > 0 &&
portComparison.Any(x => x.Item1 == typeof(Value.List) &&
x.Item2 != typeof(Value.List)) &&
!(this.ArgumentLacing == LacingStrategy.Disabled))
{
//if the argument is of the expected type, then
//leave it alone otherwise, wrap it in a list
int j = 0;
foreach (var arg in args)
{
//incoming value is list and expecting single
if (portComparison.ElementAt(j).Item1 == typeof(Value.List) &&
portComparison.ElementAt(j).Item2 != typeof(Value.List))
{
//leave as list
argSets.Add(((Value.List)arg).Item);
}
//incoming value is list and expecting list
else
{
//wrap in list
argSets.Add(Utils.MakeFSharpList(arg));
}
j++;
}
IEnumerable<IEnumerable<Value>> lacedArgs = null;
switch (this.ArgumentLacing)
{
case LacingStrategy.First:
lacedArgs = argSets.SingleSet();
break;
case LacingStrategy.Shortest:
lacedArgs = argSets.ShortestSet();
break;
case LacingStrategy.Longest:
lacedArgs = argSets.LongestSet();
break;
case LacingStrategy.CrossProduct:
lacedArgs = argSets.CartesianProduct();
break;
}
//setup an empty list to hold results
FSharpList<Value> result = FSharpList<Value>.Empty;
//run the evaluate method for each set of
//arguments in the cartesian result. do these
//in reverse order so our cons comes out the right
//way around
for (int i = lacedArgs.Count() - 1; i >= 0; i--)
{
var evalResult = Evaluate(Utils.MakeFSharpList(lacedArgs.ElementAt(i).ToArray()));
result = FSharpList<Value>.Cons(evalResult, result);
runCount++;
}
outPuts[OutPortData[0]] = Value.NewList(result);
}
else
{
outPuts[OutPortData[0]] = Evaluate(args);
runCount++;
}
}
示例5: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
_points = ((Value.List)args[0]).Item;//point list
_curves = ((Value.List)args[1]).Item;//spring list
_d = ((Value.Number)args[2]).Item;//dampening
_s = ((Value.Number)args[3]).Item;//spring constant
_r = ((Value.Number)args[4]).Item;//rest length
_use_rl = Convert.ToBoolean(((Value.Number)args[5]).Item);//use rest length
_rlf = ((Value.Number)args[6]).Item;//rest length factor
_m = ((Value.Number)args[7]).Item;//nodal mass
_g = ((Value.Number)args[8]).Item;//gravity z component
_threshold = ((Value.Number) args[9]).Item; //convergence threshold
//if we are in the evaluate, this has been
//marked dirty and we should set it to unconverged
//in case one of the inputs has changed.
particleSystem.setConverged(false);
particleSystem.setGravity(_g);
particleSystem.setThreshold(_threshold);
//if the particle system has a different layout, then
//clear it instead of updating
if(particleSystem.numberOfParticles() == 0 ||
_fixPtCount != _points.Count() ||
_curves.Count() != particleSystem.numberOfSprings() ||
_reset)
{
ResetSystem(_points, _curves);
}
else
{
UpdateSystem();
}
FSharpList<Value> forces = FSharpList<Value>.Empty;
for (int i = 0; i < particleSystem.numberOfSprings(); i++)
{
forces = FSharpList<Value>.Cons(Value.NewNumber(particleSystem.getSpring(i).getResidualForce()), forces);
}
forces.Reverse();
FSharpList<Value> results = FSharpList<Value>.Empty;
results = FSharpList<Value>.Cons(Value.NewList(forces), results);
results = FSharpList<Value>.Cons(Value.NewContainer(particleSystem), results);
//return Value.NewContainer(particleSystem);
return Value.NewList(results);
}
示例6: Evaluate
public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
var element = (Element)((Value.Container) args[0]).Item;
var results = FSharpList<Value>.Empty;
for(int i=args.Count()-1; i>0; i--)
{
var paramName = ((Value.String) args[i]).Item;
var param = element.get_Parameter(paramName);
if (param != null)
{
var pd = OutPortData[i - 1];
switch (param.StorageType)
{
case StorageType.Double:
switch (param.Definition.ParameterType)
{
case ParameterType.Length:
outPuts[pd] = Value.NewContainer(Units.Length.FromFeet(param.AsDouble(), dynSettings.Controller.UnitsManager));
break;
case ParameterType.Area:
outPuts[pd] = Value.NewContainer(Units.Area.FromSquareFeet(param.AsDouble(), dynSettings.Controller.UnitsManager));
break;
case ParameterType.Volume:
outPuts[pd] = Value.NewContainer(Units.Volume.FromCubicFeet(param.AsDouble(), dynSettings.Controller.UnitsManager));
break;
default:
outPuts[pd] = Value.NewNumber(param.AsDouble());
break;
}
break;
case StorageType.ElementId:
outPuts[pd] = FScheme.Value.NewContainer(param.AsElementId());
break;
case StorageType.Integer:
outPuts[pd] = FScheme.Value.NewNumber(param.AsInteger());
break;
case StorageType.String:
if (string.IsNullOrEmpty(param.AsString()))
{
outPuts[pd] = FScheme.Value.NewString(string.Empty);
}
else
{
outPuts[pd] = FScheme.Value.NewString(param.AsString());
}
break;
default:
if (string.IsNullOrEmpty(param.AsValueString()))
{
outPuts[pd] = FScheme.Value.NewString(string.Empty);
}
else
{
outPuts[pd] = FScheme.Value.NewString(param.AsValueString());
}
break;
}
}
}
}
示例7: Evaluate
public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
//if this element maintains a collcection of references
//then clear the collection
if(this is IClearable)
(this as IClearable).ClearReferences();
List<FSharpList<Value>> argSets = new List<FSharpList<Value>>();
//create a zip of the incoming args and the port data
//to be used for type comparison
var portComparison = args.Zip(InPortData,
(first, second) => new Tuple<Type, Type>(first.GetType(), second.PortType));
var listOfListComparison = args.Zip(InPortData, (first, second) => new Tuple<bool, Type>(Utils.IsListOfLists(first), second.PortType));
//there are more than zero arguments
//and there is either an argument which does not match its expections
//OR an argument which requires a list and gets a list of lists
//AND argument lacing is not disabled
if (args.Count() > 0 &&
(portComparison.Any(x => x.Item1 == typeof(Value.List) && x.Item2 != typeof(Value.List)) ||
listOfListComparison.Any(x => x.Item1 == true && x.Item2 == typeof(Value.List))) &&
this.ArgumentLacing != LacingStrategy.Disabled)
{
//if the argument is of the expected type, then
//leave it alone otherwise, wrap it in a list
int j = 0;
foreach (var arg in args)
{
//incoming value is list and expecting single
if (portComparison.ElementAt(j).Item1 == typeof (Value.List) &&
portComparison.ElementAt(j).Item2 != typeof (Value.List))
{
//leave as list
argSets.Add(((Value.List)arg).Item);
}
//incoming value is list and expecting list
else
{
//check if we have a list of lists, if so, then don't wrap
if (Utils.IsListOfLists(arg))
//leave as list
argSets.Add(((Value.List)arg).Item);
else
//wrap in list
argSets.Add(Utils.MakeFSharpList(arg));
}
j++;
}
IEnumerable<IEnumerable<Value>> lacedArgs = null;
switch (this.ArgumentLacing)
{
case LacingStrategy.First:
lacedArgs = argSets.SingleSet();
break;
case LacingStrategy.Shortest:
lacedArgs = argSets.ShortestSet();
break;
case LacingStrategy.Longest:
lacedArgs = argSets.LongestSet();
break;
case LacingStrategy.CrossProduct:
lacedArgs = argSets.CartesianProduct();
break;
}
//setup an empty list to hold results
FSharpList<Value> result = FSharpList<Value>.Empty;
//run the evaluate method for each set of
//arguments in the cartesian result. do these
//in reverse order so our cons comes out the right
//way around
for (int i = lacedArgs.Count() - 1; i >= 0; i--)
{
var evalResult = Evaluate(Utils.MakeFSharpList(lacedArgs.ElementAt(i).ToArray()));
result = FSharpList<Value>.Cons(evalResult, result);
}
outPuts[OutPortData[0]] = Value.NewList(result);
}
else
{
outPuts[OutPortData[0]] = Evaluate(args);
}
ValidateConnections();
if (dynSettings.Controller.UIDispatcher != null && this is IDrawable)
{
dynSettings.Controller.UIDispatcher.Invoke(new Action(() => (this as IDrawable).Draw()));
}
}
示例8: Evaluate
public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
_points = ((Value.List)args[0]).Item;//point list
_curves = ((Value.List)args[1]).Item;//spring list
_d = ((Value.Number)args[2]).Item;//dampening
_s = ((Value.Number)args[3]).Item;//spring constant
_r = ((Value.Number)args[4]).Item;//rest length
_useRl = Convert.ToBoolean(((Value.Number)args[5]).Item);//use rest length
_rlf = ((Value.Number)args[6]).Item;//rest length factor
_m = ((Value.Number)args[7]).Item;//nodal mass
_g = ((Value.Number)args[8]).Item;//gravity z component
_threshold = ((Value.Number) args[9]).Item; //convergence threshold
//if we are in the evaluate, this has been
//marked dirty and we should set it to unconverged
//in case one of the inputs has changed.
ParticleSystem.setConverged(false);
ParticleSystem.setGravity(_g);
ParticleSystem.setThreshold(_threshold);
//if the particle system has a different layout, then
//clear it instead of updating
if(ParticleSystem.numberOfParticles() == 0 ||
_fixPtCount != _points.Count() ||
_curves.Count() != ParticleSystem.numberOfSprings() ||
_reset)
{
ResetSystem(_points, _curves);
}
else
{
UpdateSystem();
}
outPuts[_psPort] = Value.NewContainer(ParticleSystem);
outPuts[_forcesPort] = Value.NewList(Utils.SequenceToFSharpList(
ParticleSystem.Springs.Select(s => Value.NewNumber(s.getResidualForce()))));
}
示例9: Evaluate
public override void Evaluate(FSharpList<Value> args, Dictionary<PortData, Value> outPuts)
{
var element = (Element)((Value.Container) args[0]).Item;
var results = FSharpList<Value>.Empty;
for(int i=args.Count()-1; i>0; i--)
{
var paramName = ((Value.String) args[i]).Item;
var param = element.get_Parameter(paramName);
if (param != null)
{
var pd = OutPortData[i - 1];
switch (param.StorageType)
{
case StorageType.Double:
outPuts[pd] = FScheme.Value.NewNumber(param.AsDouble());
break;
case StorageType.ElementId:
outPuts[pd] = FScheme.Value.NewContainer(param.AsElementId());
break;
case StorageType.Integer:
outPuts[pd] = FScheme.Value.NewNumber(param.AsInteger());
break;
case StorageType.String:
if (string.IsNullOrEmpty(param.AsString()))
{
outPuts[pd] = FScheme.Value.NewString(string.Empty);
}
else
{
outPuts[pd] = FScheme.Value.NewString(param.AsString());
}
break;
default:
if (string.IsNullOrEmpty(param.AsValueString()))
{
outPuts[pd] = FScheme.Value.NewString(string.Empty);
}
else
{
outPuts[pd] = FScheme.Value.NewString(param.AsValueString());
}
break;
}
}
}
}