本文整理汇总了C#中ListValue.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ListValue.Add方法的具体用法?C# ListValue.Add怎么用?C# ListValue.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListValue
的用法示例。
在下文中一共展示了ListValue.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServoGroups
private ListValue GetServoGroups()
{
var list = new ListValue();
if (!IRWrapper.APIReady)
{
throw new KOSUnavailableAddonException("IR:GROUPS", "Infernal Robotics");
}
var controlGroups = IRWrapper.IRController.ServoGroups;
if (controlGroups == null)
{
//Control Groups are somehow null, just return the empty list
return list;
}
foreach (IRWrapper.IControlGroup cg in controlGroups)
{
if (cg.Vessel == null || cg.Vessel == shared.Vessel)
list.Add(new IRControlGroupWrapper(cg, shared));
}
return list;
}
示例2: GetAllServos
private ListValue GetAllServos()
{
var list = new ListValue();
if (!IRWrapper.APIReady)
{
throw new KOSUnavailableAddonException("IR:ALLSERVOS", "Infernal Robotics");
}
var controlGroups = IRWrapper.IRController.ServoGroups;
if (controlGroups == null)
{
//Control Groups are somehow null, just return the empty list
return list;
}
foreach (IRWrapper.IControlGroup cg in controlGroups)
{
if (cg.Servos == null || (cg.Vessel!=null && cg.Vessel != shared.Vessel))
continue;
foreach (IRWrapper.IServo s in cg.Servos)
{
list.Add (new IRServoWrapper (s, shared));
}
}
return list;
}
示例3: GetSuffix
public override object GetSuffix(string suffixName)
{
switch (suffixName)
{
case "NAME":
return Part.name;
case "STAGE":
return Part.inverseStage;
case "UID":
return Part.uid;
case "RESOURCES":
var resources = new ListValue();
foreach (PartResource resource in Part.Resources)
{
resources.Add(new ResourceValue(resource));
}
return resources;
case "MODULES":
var modules = new ListValue();
foreach (var module in Part.Modules)
{
modules.Add(module.GetType());
}
return modules;
case "TARGETABLE":
return Part.Modules.OfType<ITargetable>().Any();
case "SHIP":
return new VesselTarget(Part.vessel);
}
return base.GetSuffix(suffixName);
}
示例4: CanSerializeLists
public void CanSerializeLists()
{
var list = new ListValue();
var nested = new ListValue();
list.Add(new StringValue("item1"));
list.Add(new ScalarIntValue(2));
list.Add(nested);
nested.Add(new StringValue("nested1"));
ListValue deserialized = Deserialize(Serialize(list)) as ListValue;
Assert.AreEqual(new StringValue("item1"), deserialized[0]);
Assert.AreEqual(new ScalarIntValue(2), deserialized[1]);
Assert.IsTrue(deserialized[2] is ListValue);
}
示例5: CanShallowPrintListInLexicon
public void CanShallowPrintListInLexicon()
{
var list = new ListValue();
list.Add("First In List");
list.Add("Second In List");
list.Add("Last In List");
var lexicon = new Lexicon<object, object>();
lexicon.Add("list", list);
lexicon.Add("not list", 2);
var result = lexicon.ToString();
Assert.IsTrue(result.Contains("LEXICON of 2 items"));
Assert.IsTrue(result.Contains(" [\"list\"]= LIST of 3 items"));
Assert.IsFalse(result.Contains("Last In List"));
}
示例6: PartsToList
public static ListValue PartsToList(IEnumerable<global::Part> parts)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
toReturn.Add(new PartValue(part));
}
return toReturn;
}
示例7: CanGetDoubleIndex
public void CanGetDoubleIndex()
{
var list = new ListValue();
list.Add(new StringValue("bar"));
list.Add(new StringValue("foo"));
list.Add(new StringValue("fizz"));
cpu.PushStack(list);
const double INDEX = 2.5;
cpu.PushStack(INDEX);
var opcode = new OpcodeGetIndex();
opcode.Execute(cpu);
Assert.AreEqual(3, list.Count());
Assert.AreEqual(new StringValue("fizz"), cpu.PopStack());
}
示例8: CanGetCorrectListIndex
public void CanGetCorrectListIndex()
{
var list = new ListValue();
list.Add("bar");
list.Add("foo");
list.Add("fizz");
cpu.PushStack(list);
const int INDEX = 1;
cpu.PushStack(INDEX);
var opcode = new OpcodeGetIndex();
opcode.Execute(cpu);
Assert.AreEqual(3, list.Count);
Assert.AreEqual("foo", cpu.PopStack());
}
示例9: BuildPatchList
private object BuildPatchList()
{
var list = new ListValue();
var orbit = orbitRef;
while (orbit.nextPatch != null && list.Count >= PATCHES_LIMIT)
{
list.Add(new OrbitInfo(orbit, vesselRef));
}
return list;
}
示例10: PartsToList
public static new ListValue PartsToList(IEnumerable<global::Part> parts)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
foreach (PartModule module in part.Modules)
{
var engineModule = module as ModuleEngines;
if (engineModule != null)
{
toReturn.Add(new EngineValue(part, engineModule));
}
var engineModuleFx = module as ModuleEnginesFX;
if (engineModuleFx != null)
{
toReturn.Add(new EngineValue(part, engineModuleFx));
}
}
}
return toReturn;
}
示例11: PartsToList
public static ListValue PartsToList(IEnumerable<global::Part> parts, SharedObjects sharedObj)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
foreach (PartModule module in part.Modules)
{
var sensor = module as ModuleEnviroSensor;
if (sensor == null) continue;
toReturn.Add(new SensorValue(part, sensor, sharedObj));
}
}
return toReturn;
}
示例12: PartsToList
public static ListValue PartsToList(IEnumerable<global::Part> parts, SharedObjects sharedObj)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
foreach (PartModule module in part.Modules)
{
var engines = module as ModuleEngines;
if (engines != null)
{
toReturn.Add(new EngineValue(part, new ModuleEngineAdapter(engines), sharedObj));
}
}
}
return toReturn;
}
示例13: PartsToList
public static ListValue PartsToList(IEnumerable<global::Part> parts, SharedObjects sharedObj)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
foreach (PartModule module in part.Modules)
{
var dockingNode = module as ModuleDockingNode;
if (dockingNode != null)
{
toReturn.Add(new DockingPortValue(dockingNode, sharedObj));
}
}
}
return toReturn;
}
示例14: PartsToList
public static new ListValue PartsToList(IEnumerable<global::Part> parts)
{
var toReturn = new ListValue();
foreach (var part in parts)
{
foreach (PartModule module in part.Modules)
{
UnityEngine.Debug.Log("Module Found: "+ module);
var dockingNode = module as ModuleDockingNode;
if (dockingNode != null)
{
toReturn.Add(new DockingPortValue(dockingNode));
}
}
}
return toReturn;
}
示例15: GetAlarms
private ListValue GetAlarms()
{
var list = new ListValue();
if (!KACWrapper.APIReady)
{
return list;
}
//Get the list of alarms from the KAC Object
KACWrapper.KACAPI.KACAlarmList alarms = KACWrapper.KAC.Alarms;
foreach (KACWrapper.KACAPI.KACAlarm alarm in alarms)
{
list.Add(new KACAlarmWrapper(alarm));
}
return list;
}