public override void Execute(SharedObjects shared) { var list = new ListValue(); string alarmTypes = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); if (!KACWrapper.APIReady) { ReturnValue = list; throw new KOSUnavailableAddonException("listAlarms()", "Kerbal Alarm Clock"); } //Get the list of alarms from the KAC Object KACWrapper.KACAPI.KACAlarmList alarms = KACWrapper.KAC.Alarms; foreach (KACWrapper.KACAPI.KACAlarm alarm in alarms) { // if its not my alarm or a general alarm, ignore it if (!string.IsNullOrEmpty(alarm.VesselID) && alarm.VesselID != shared.Vessel.id.ToString()) { continue; } if (alarmTypes.ToUpperInvariant() == "ALL" || alarm.AlarmTime.ToString() == alarmTypes) list.Add(new KACAlarmWrapper(alarm)); } ReturnValue = list; }
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); }
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; }
public void CopyIsACopy() { var list = new ListValue(); var zedObject = new object(); InvokeDelegate(list, "ADD", zedObject); var firstObject = new object(); InvokeDelegate(list, "ADD", firstObject); var secondObject = new object(); InvokeDelegate(list, "ADD", secondObject); var thirdObject = new object(); InvokeDelegate(list, "ADD", thirdObject); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(4,length); var copy = InvokeDelegate(list, "COPY") as ListValue; Assert.AreNotSame(list, copy); var copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(4,copyLength); InvokeDelegate(copy, "CLEAR"); copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(0,copyLength); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(4,length); }
public void CanGetIndex() { var list = new ListValue(); var zedObject = ScalarIntValue.Zero; InvokeDelegate(list, "ADD", zedObject); var firstObject = ScalarIntValue.One; InvokeDelegate(list, "ADD", firstObject); var secondObject = ScalarIntValue.Two; InvokeDelegate(list, "ADD", secondObject); var thirdObject = new ScalarIntValue(4); InvokeDelegate(list, "ADD", thirdObject); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(new ScalarIntValue(4),length); Assert.AreSame(zedObject, list[0]); Assert.AreSame(firstObject, list[1]); Assert.AreSame(secondObject, list[2]); Assert.AreSame(thirdObject, list[3]); Assert.AreNotSame(list[0], list[1]); Assert.AreNotSame(list[0], list[2]); Assert.AreNotSame(list[0], list[3]); Assert.AreNotSame(list[1], list[2]); Assert.AreNotSame(list[1], list[3]); Assert.AreNotSame(list[2], list[3]); }
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; }
public void Dispose() { updateHandler.RemoveObserver(this); voice.Frequency = 0f; song = null; voice = null; maker = null; }
public static ListValue PartsToList(IEnumerable<global::Part> parts) { var toReturn = new ListValue(); foreach (var part in parts) { toReturn.Add(new PartValue(part)); } return toReturn; }
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; }
public void CanAddItem() { var list = new ListValue(); Assert.IsNotNull(list); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(ScalarIntValue.Zero, length); InvokeDelegate(list, "ADD", ScalarIntValue.Zero); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(ScalarIntValue.One, length); }
public void CanAddItem() { var list = new ListValue(); Assert.IsNotNull(list); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(0,length); InvokeDelegate(list, "ADD", new object()); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(1,length); }
public void CanClear() { var list = new ListValue(); InvokeDelegate(list, "ADD", ScalarIntValue.Zero); InvokeDelegate(list, "ADD", ScalarIntValue.Zero); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(ScalarIntValue.Two,length); InvokeDelegate(list, "CLEAR"); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(ScalarIntValue.Zero,length); }
public void CanClear() { var list = new ListValue(); InvokeDelegate(list, "ADD", new object()); InvokeDelegate(list, "ADD", new object()); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(2,length); InvokeDelegate(list, "CLEAR"); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(0,length); }
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; }
public void addItem(string text, string value) { try { if(!this._list.ContainsKey(text)) { ListValue d = new ListValue(); d.text = text; d.value = value; this._list.Add(text, d); this._list2.Add(value, d); this.Items.Add(text); } } catch { } }
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; }
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; }
public void CanGetListIndex() { var list = new ListValue(); list.Add("bar"); cpu.PushStack(list); const int INDEX = 0; cpu.PushStack(INDEX); var opcode = new OpcodeGetIndex(); opcode.Execute(cpu); Assert.AreEqual(1, list.Count); Assert.AreEqual("bar", cpu.PopStack()); }
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); }
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; }
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")); }
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()); }
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; }
public void CanSetListIndex() { var list = new ListValue(); list.Add(new StringValue("bar")); cpu.PushStack(list); const int INDEX = 0; cpu.PushStack(INDEX); const string VALUE = "foo"; cpu.PushStack(VALUE); var opcode = new OpcodeSetIndex(); opcode.Execute(cpu); Assert.AreEqual(1, list.Count()); Assert.AreNotEqual(new StringValue("bar"), list[0]); Assert.AreEqual(new StringValue("foo"), list[0]); }
public void DoesNotContainInvalidToString() { var list = new ListValue { "First In List", "Second In List", "Last In List" }; var lexicon = new Lexicon<object, object> { {"list", list}, {"not list", 2} }; var result = (string)InvokeDelegate(lexicon, "DUMP"); Assert.IsFalse(result.Contains("System")); Assert.IsFalse(result.Contains("string[]")); }
public void CanSetListIndexWithDouble() { var list = new ListValue(); list.Add("bar"); cpu.PushStack(list); const double INDEX = 0.0d; cpu.PushStack(INDEX); const string VALUE = "foo"; cpu.PushStack(VALUE); var opcode = new OpcodeSetIndex(); opcode.Execute(cpu); Assert.AreEqual(1, list.Count); Assert.AreNotEqual("bar", list[0]); Assert.AreEqual("foo", list[0]); }
public void DoesNotContainInvalidToString() { var list = new ListValue { new StringValue("First In List"), new StringValue("Second In List"), new StringValue("Last In List") }; var lexicon = new Lexicon { {new StringValue("list"), list}, {new StringValue("not list"), new ScalarIntValue(2)} }; var result = (StringValue)InvokeDelegate(lexicon, "DUMP"); Assert.IsFalse(result.Contains("System")); Assert.IsFalse(result.Contains("string[]")); }
public void CanDeepPrintListInLexicon() { var list = new ListValue { "First In List", "Second In List", "Last In List" }; var lexicon = new Lexicon<object, object> { {"list", list}, {"not list", 2} }; var result = (string)InvokeDelegate(lexicon, "DUMP"); Assert.IsTrue(result.Contains("LEXICON of 2 items")); Assert.IsTrue(result.Contains(" [\"list\"]= LIST of 3 items")); Assert.IsTrue(result.Contains("Last In List")); }
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; }
public void CanPrintListInLexicon() { var list = new ListValue { new StringValue("First In List"), new StringValue("Second In List"), new StringValue("Last In List") }; var lexicon = new Lexicon { {new StringValue("list"), list}, {new StringValue("not list"), new ScalarIntValue(2)} }; var result = (StringValue)InvokeDelegate(lexicon, "DUMP"); Assert.IsTrue(result.Contains("LEXICON of 2 items")); Assert.IsTrue(result.Contains("[\"list\"] = LIST of 3 items")); Assert.IsTrue(result.Contains("Last In List")); }
internal static StatementResult CreateSingleColumnResultSet(V1.Type type, string col, params object[] values) { ResultSet rs = new ResultSet { Metadata = new ResultSetMetadata { RowType = new StructType() }, }; rs.Metadata.RowType.Fields.Add(new StructType.Types.Field { Name = col, Type = type, }); foreach (object val in values) { ListValue row = new ListValue(); row.Values.Add(SpannerConverter.ToProtobufValue(type, val)); rs.Rows.Add(row); } return(CreateQuery(rs)); }
public void CanSetListIndexWithFloat() { var list = new ListValue(); list.Add(new StringValue("bar")); cpu.PushArgumentStack(list); const float INDEX = 0.0f; cpu.PushArgumentStack(INDEX); const string VALUE = "foo"; cpu.PushArgumentStack(VALUE); var opcode = new OpcodeSetIndex(); opcode.Execute(cpu); Assert.AreEqual(1, list.Count()); Assert.AreNotEqual(new StringValue("bar"), list[0]); Assert.AreEqual(new StringValue("foo"), list[0]); }
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)); }
public void CopyIsACopy() { var list = new ListValue(); var zedObject = new object(); InvokeDelegate(list, "ADD", zedObject); var firstObject = new object(); InvokeDelegate(list, "ADD", firstObject); var secondObject = new object(); InvokeDelegate(list, "ADD", secondObject); var thirdObject = new object(); InvokeDelegate(list, "ADD", thirdObject); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(4, length); var copy = InvokeDelegate(list, "COPY") as ListValue; Assert.AreNotSame(list, copy); var copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(4, copyLength); InvokeDelegate(copy, "CLEAR"); copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(0, copyLength); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(4, length); }
public override void Execute(SharedObjects shared) { string listType = shared.Cpu.PopValue().ToString(); var list = new ListValue(); switch (listType) { case "bodies": foreach (var body in FlightGlobals.fetch.bodies) { list.Add(new BodyTarget(body, shared)); } break; case "targets": foreach (var vessel in FlightGlobals.Vessels) { if (vessel == shared.Vessel) { continue; } list.Add(new VesselTarget(vessel, shared)); } break; case "resources": case "parts": case "engines": case "sensors": case "elements": case "dockingports": list = shared.Vessel.PartList(listType, shared); break; } shared.Cpu.PushStack(list); }
/// <summary> /// Protect the sheet. /// </summary> /// <param name="Worksheet"></param> /// <param name="pageM"></param> /// <param name="sheetProtection"></param> /// <param name="pRanges"></param> /// <param name="lockedColumns"></param> private void ProtectSheet(Worksheet Worksheet, out PageMargins pageM, out SheetProtection sheetProtection, out ProtectedRanges pRanges, string[] editableColumns, DataTable dt) { pageM = Worksheet.GetFirstChild <PageMargins>(); sheetProtection = new SheetProtection(); sheetProtection.Sheet = true; sheetProtection.Objects = true; sheetProtection.Scenarios = true; // Set the password. sheetProtection.Password = new HexBinaryValue() { Value = "CC1A" }; pRanges = new ProtectedRanges(); if (editableColumns.Length > 0) { int i = 0; foreach (string columnName in editableColumns) { i++; ProtectedRange pRange = new ProtectedRange(); ListValue <StringValue> lValue = new ListValue <StringValue>(); // Get Excel Column Number. string columnindex = GetExcelColumnNumber(columnName, dt); lValue.InnerText = columnindex + "1:" + columnindex + (dt.Rows.Count + 1).ToString(); // Assign the editable columns. pRange.SequenceOfReferences = lValue; pRange.Name = "Editable_" + i.ToString(); pRanges.Append(pRange); } } }
internal static bool IsRepromptRequest(WebhookRequest request) { bool isRepromptRequest = false; ListValue inputs = request.OriginalDetectIntentRequest.Payload?.Fields?["inputs"]?.ListValue; if (inputs != null) { bool isIntentFound = false; int valCount = 0; while (!isIntentFound && valCount < inputs.Values.Count) { Value val = inputs.Values[valCount]; if (val.StructValue != null) { if (val.StructValue.Fields["intent"] != null) { string intentName = val.StructValue.Fields["intent"].StringValue; isIntentFound = true; if (intentName.Equals(INTENT_NOINPUT, StringComparison.OrdinalIgnoreCase)) { isRepromptRequest = true; } } } valCount++; } } return(isRepromptRequest); }
public void CopyIsACopy() { var list = new ListValue(); var zedObject = ScalarIntValue.Zero; InvokeDelegate(list, "ADD", zedObject); var firstObject = ScalarIntValue.One; InvokeDelegate(list, "ADD", firstObject); var secondObject = ScalarIntValue.Two; InvokeDelegate(list, "ADD", secondObject); var thirdObject = new ScalarIntValue(4); InvokeDelegate(list, "ADD", thirdObject); var length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(new ScalarIntValue(4), length); var copy = InvokeDelegate(list, "COPY") as ListValue; Assert.AreNotSame(list, copy); var copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(new ScalarIntValue(4), copyLength); InvokeDelegate(copy, "CLEAR"); copyLength = InvokeDelegate(copy, "LENGTH"); Assert.AreEqual(ScalarIntValue.Zero, copyLength); length = InvokeDelegate(list, "LENGTH"); Assert.AreEqual(new ScalarIntValue(4), length); }
/// <summary> /// Provides the value associated to this Expression /// </summary> /// <param name="context">The context on which the value must be found</param> /// <param name="explain">The explanation to fill, if any</param> /// <returns></returns> protected internal override IValue GetValue(InterpretationContext context, ExplanationPart explain) { IValue retVal = null; ListValue value = ListExpression.GetValue(context, explain) as ListValue; if (value != null) { int token = PrepareIteration(context); context.LocalScope.SetVariable(AccumulatorVariable); AccumulatorVariable.Value = InitialValue.GetValue(context, explain); foreach (IValue v in value.Val) { if (v != EfsSystem.Instance.EmptyValue) { // All elements should always be != from EmptyValue ElementFound = true; IteratorVariable.Value = v; if (ConditionSatisfied(context, explain)) { MatchingElementFound = true; AccumulatorVariable.Value = IteratorExpression.GetValue(context, explain); } } NextIteration(); } EndIteration(context, explain, token); retVal = AccumulatorVariable.Value; } else { AddError("Cannot evaluate list value " + ListExpression, RuleChecksEnum.ExecutionFailed); } return(retVal); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToPackAndUnpackList() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToPackAndUnpackList() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackListHeader(ALICE.labels().length()); IList <string> expected = new List <string>(); TextArray labels = ALICE.labels(); for (int i = 0; i < labels.Length(); i++) { string labelName = labels.StringValue(i); packer.Pack(labelName); expected.Add(labelName); } AnyValue unpacked = unpacked(output.Bytes()); // Then assertThat(unpacked, instanceOf(typeof(ListValue))); ListValue unpackedList = ( ListValue )unpacked; assertThat(unpackedList, equalTo(ValueUtils.asListValue(expected))); }
public override void Evaluate() { var name = new Term(RegexMatch.Groups[2].Value); var type = new Term(RegexMatch.Groups[1].Value); var list = new ListValue(); switch (type.Text.ToUpper()) { case "BODIES": foreach (var body in FlightGlobals.fetch.bodies) { list.Add(new BodyTarget(body, Vessel)); } break; case "TARGETS": foreach (var vessel in FlightGlobals.Vessels) { if (vessel == Vessel) { continue; } list.Add(new VesselTarget(vessel, ParentContext)); } break; } if (list.Empty()) { list = Vessel.PartList(type.Text); } FindOrCreateVariable(name.Text).Value = list; State = ExecutionState.DONE; }
private string PerformLAdd(LAddCommand command) { if (_storage.TryGetValue(command.Key, out var value)) { if (value is ListValue lv) { if (lv.Value.Contains(command.Value)) { return($"List associated with key {command.Key} already have element {command.Value} "); } lv.Value.Add(command.Value); return($"{command.Value} has been added to list associated with key {command.Key}"); } return($"Type associated with key {command.Key} is not a hash-value type"); } var newValue = new ListValue { Value = { command.Value } }; _storage[command.Key] = newValue; return($"{command.Value} has been added to list associated with key {command.Key}"); }
/// <summary> /// Build a list of all the KSP things (fields, events, actions) that /// this class will support as a suffix on this instance. /// </summary> /// <returns>list of all the suffixes except the hardcoded ones in GetSuffix()</returns> private ListValue AllThings() { const string FORMATTER = "({0}) {1}, is {2}"; var all = new ListValue(); // We appear to have not implemented a concatenator or range add for // our ListValue type. Thus the for-loops below: ListValue fields = AllFields(FORMATTER); ListValue events = AllEvents(FORMATTER); ListValue actions = AllActions(FORMATTER); foreach (Structure field in fields) { all.Add(field); } foreach (Structure kspevent in events) { all.Add(kspevent); } foreach (Structure action in actions) { all.Add(action); } return all; }
/// <summary> /// Sets the model for this tree view /// </summary> /// <param name="model"></param> public void SetModel(IValue model) { DisplayedModel = model; List <IValue> objectModel = new List <IValue>(); ListValue listValue = model as ListValue; if (listValue != null) { foreach (IValue value in listValue.Val) { if (value != EfsSystem.Instance.EmptyValue) { objectModel.Add(value); } } } else { objectModel.Add(model); } structureTreeListView.SetObjects(objectModel); }
//This method gets the value/type info for the method parameters of all frames without creating an mi debugger varialbe for them. For use in the callstack window //NOTE: eval is not called public async Task <List <ArgumentList> > GetParameterInfoOnly(AD7Thread thread, bool values, bool types, uint low, uint high) { var frames = await MICommandFactory.StackListArguments(values || types?PrintValues.SimpleValues : PrintValues.NoValues, thread.Id, low, high); List <ArgumentList> parameters = new List <ArgumentList>(); foreach (var f in frames) { int level = f.FindInt("level"); ListValue argList = null; f.TryFind <ListValue>("args", out argList); List <SimpleVariableInformation> args = new List <SimpleVariableInformation>(); if (argList != null) { if (argList is ValueListValue) // a tuple for each arg { foreach (var arg in ((ValueListValue)argList).Content) { args.Add(new SimpleVariableInformation(arg.FindString("name"), /*isParam*/ true, arg.TryFindString("value"), arg.TryFindString("type"))); } } else { // simple arg name list string[] names = ((ResultListValue)argList).FindAllStrings("name"); foreach (var n in names) { args.Add(new SimpleVariableInformation(n, /*isParam*/ true, null, null)); } } } parameters.Add(new ArgumentList(level, args)); } return(parameters); }
private void InitializeSuffixes() { AddSuffix("ADDLABEL", new OptionalArgsSuffix <Label>(AddLabel, new Structure[] { new StringValue("") })); AddSuffix("ADDTEXTFIELD", new OptionalArgsSuffix <TextField>(AddTextField, new Structure [] { new StringValue("") })); AddSuffix("ADDBUTTON", new OptionalArgsSuffix <Button>(AddButton, new Structure [] { new StringValue("") })); AddSuffix("ADDRADIOBUTTON", new OptionalArgsSuffix <Button>(AddRadioButton, new Structure [] { new StringValue(""), new BooleanValue(false) })); AddSuffix("ADDCHECKBOX", new OptionalArgsSuffix <Button>(AddCheckbox, new Structure [] { new StringValue(""), new BooleanValue(false) })); AddSuffix("ADDPOPUPMENU", new Suffix <PopupMenu>(AddPopupMenu)); AddSuffix("ADDHSLIDER", new OptionalArgsSuffix <Slider>(AddHSlider, new Structure [] { new ScalarDoubleValue(0), new ScalarDoubleValue(0), new ScalarDoubleValue(1) })); AddSuffix("ADDVSLIDER", new OptionalArgsSuffix <Slider>(AddVSlider, new Structure [] { new ScalarDoubleValue(0), new ScalarDoubleValue(0), new ScalarDoubleValue(1) })); AddSuffix("ADDHBOX", new Suffix <Box>(AddHBox)); AddSuffix("ADDVBOX", new Suffix <Box>(AddVBox)); AddSuffix("ADDHLAYOUT", new Suffix <Box>(AddHLayout)); AddSuffix("ADDVLAYOUT", new Suffix <Box>(AddVLayout)); AddSuffix("ADDSCROLLBOX", new Suffix <ScrollBox>(AddScrollBox)); AddSuffix("ADDSTACK", new Suffix <Box>(AddStack)); AddSuffix("ADDSPACING", new OptionalArgsSuffix <Spacing>(AddSpace, new Structure [] { new ScalarIntValue(-1) })); AddSuffix("ADDTIPDISPLAY", new OptionalArgsSuffix <Label>(AddTipDisplay, new Structure[] { new StringValue("") })); AddSuffix("WIDGETS", new Suffix <ListValue>(() => ListValue.CreateList(Widgets))); AddSuffix("RADIOVALUE", new Suffix <StringValue>(() => new StringValue(GetRadioValue()))); AddSuffix("ONRADIOCHANGE", new SetSuffix <UserDelegate>(() => CallbackGetter(UserOnRadioChange), value => UserOnRadioChange = CallbackSetter(value))); AddSuffix("SHOWONLY", new OneArgsSuffix <Widget>(value => ShowOnly(value))); AddSuffix("CLEAR", new NoArgsVoidSuffix(Clear)); }
public ComparableListValueDefinitionType(ListValue defaultListValue) { _defaultListValue = defaultListValue; }
public static ListValue Construct(IEnumerable <PartModule> modules, SharedObjects shared) { var list = modules.Select(mod => Construct(mod, shared)).ToList(); return(ListValue.CreateList(list)); }
private static IList <IDictionary <String, String> > ListValueToDictionaryList(ListValue listValue) { IList <Object> objs = (IList <Object>)listValue.GetStorableData(); return(objs.Where(val => val is IDictionary <String, IValue>).Select(val => ValueDictToStringDict((IDictionary <String, IValue>)val)).ToList()); }
public static ListValue Construct(IEnumerable <global::Part> parts, SharedObjects shared) { var partList = parts.Select(part => Construct(part, shared)).ToList(); return(ListValue.CreateList(partList)); }
public void CanCreate() { var list = new ListValue(); Assert.IsNotNull(list); }
public ScriptOffsetInfo(ListValue l, TypeValue t, int i) { list = l; type = t; index = i; }
public ScriptOffsetInfo() { list = ListValue.Null; type = TypeValue.None; index = -1; }
internal Definition(LanguageDictionary dic, string def, string source) { TheDefinition = def; this.source = new ListValue <string>(source, dic.Sources); }
internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction) { OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length]; switch (unionValueRestriction.UnionId) { // ST_AnimationDgmBuildType case 25: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>(); break; // ST_AnimationChartBuildType case 27: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>(); break; // ST_AdjCoordinate case 45: simpleValues[0] = new Int64Value(); simpleValues[1] = new StringValue(); break; // ST_AdjAngle case 46: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_LayoutShapeType case 145: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.ShapeTypeValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>(); break; // ST_ParameterVal case 183: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>(); simpleValues[10] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>(); simpleValues[11] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>(); simpleValues[12] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>(); simpleValues[13] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>(); simpleValues[14] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>(); simpleValues[15] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>(); simpleValues[16] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>(); simpleValues[17] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>(); simpleValues[18] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>(); simpleValues[19] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>(); simpleValues[20] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>(); simpleValues[21] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>(); simpleValues[22] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>(); simpleValues[23] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>(); simpleValues[24] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>(); simpleValues[25] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>(); simpleValues[26] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>(); simpleValues[27] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>(); simpleValues[28] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>(); simpleValues[29] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>(); simpleValues[30] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>(); simpleValues[31] = new Int32Value(); simpleValues[32] = new DoubleValue(); simpleValues[33] = new BooleanValue(); simpleValues[34] = new StringValue(); simpleValues[35] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>(); break; // ST_ModelId case 184: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_FunctionValue case 207: simpleValues[0] = new Int32Value(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>(); break; // ST_FunctionArgument case 209: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>(); break; // ST_NonZeroDecimalNumber case 368: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_MarkupId case 375: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_HexColor case 404: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>(); simpleValues[1] = new HexBinaryValue(); break; // ST_DecimalNumberOrPercent case 507: simpleValues[0] = new StringValue(); simpleValues[1] = new Int32Value(); break; // ST_SignedHpsMeasure_O14 case 525: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_HpsMeasure_O14 case 528: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_SignedTwipsMeasure_O14 case 531: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_TwipsMeasure_O14 case 534: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_TransitionEightDirectionType case 544: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); break; // ST_TLTimeAnimateValueTime case 561: simpleValues[0] = new Int32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O12 case 603: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O14 case 604: simpleValues[0] = new StringValue(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_PublishDate case 689: simpleValues[0] = new DateTimeValue(); simpleValues[1] = new DateTimeValue(); simpleValues[2] = new StringValue(); break; // ST_ChannelDataPoint case 697: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); break; // ST_ChannelPropertyName case 701: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_BrushPropertyName case 704: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_ChannelName case 707: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelNameValues>(); simpleValues[1] = new StringValue(); break; // ST_Units case 719: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>(); simpleValues[10] = new StringValue(); break; // ST_BrushPropertyValue case 732: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.PenTipShapeValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.RasterOperationValues>(); simpleValues[4] = new StringValue(); break; // ST_Ref case 746: simpleValues[0] = new StringValue(); simpleValues[1] = new UInt32Value(); break; // ST_CtxNodeType case 747: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>(); simpleValues[1] = new StringValue(); break; // ST_SemanticType case 750: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>(); simpleValues[1] = new UInt32Value(); break; // ST_PointsOrInt case 753: simpleValues[0] = new ListValue <StringValue>(); simpleValues[1] = new Int32Value(); break; default: Debug.Assert(false); break; } Debug.Assert(simpleValues.Length > 0); return(simpleValues); }
private StringValue Observe(StringValue body, ListValue instrumentPlusObserveType, ScalarValue exposure) { string url = ""; string filename = body + "_" + instrumentPlusObserveType[0] + "_" + instrumentPlusObserveType[1] + ".txt"; string opts = ""; var lines = File.ReadAllLines("config.txt", Encoding.UTF8); foreach (string line in lines) { string[] parameters = line.Split('|'); if (parameters[0] == "url") { url = parameters[1]; } if (parameters[0] == "params") { opts = parameters[1]; } } if (File.Exists(filename)) { var configPsg = File.ReadAllText(filename); var planetsMap = new Dictionary <string, string> { ["PS4892b"] = "PS4892b", ["PS4892c"] = "TauCetif", ["PS4892d"] = "Teegardenb", ["PS4892e"] = "TRAPPIST1b", ["PS4892f"] = "TRAPPIST1c", ["PS4892g"] = "TRAPPIST1e", ["PS4892h"] = "TRAPPIST1f", ["PS4892i"] = "TRAPPIST1d", ["PS4892j"] = "TRAPPIST1g", ["PS4892k"] = "TRAPPIST1h", }; List <CelestialBody> bodies = FlightGlobals.Bodies; Boolean bodyExist = false; CelestialBody targetBody = bodies[0]; foreach (var currentBody in bodies) { if (currentBody.GetName() == planetsMap[body]) { bodyExist = true; targetBody = currentBody; } } if (bodyExist) { Vector3 heading = targetBody.GetTransform().position - FlightGlobals.ActiveVessel.GetTransform().position; double distance = Math.Round(heading.magnitude / 1000.0); double distanceAu = distance / 149600000000; if (distance < 100000000) { configPsg = configPsg.Replace("${DISTANCE}", distance.ToString()); configPsg = configPsg.Replace("${ALTITUDEUNIT}", "km"); } else { configPsg = configPsg.Replace("${DISTANCE}", distanceAu.ToString()); configPsg = configPsg.Replace("${ALTITUDEUNIT}", "AU"); } configPsg = configPsg.Replace("${EXPOSURE}", exposure.ToString()); configPsg = configPsg.Replace("\r\n", "\n"); File.WriteAllText("psg_config_debug.txt", configPsg); var request = WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { string req = opts + WebUtility.UrlEncode(configPsg); streamWriter.Write(req); } _logger.Log($"posting to url: {url}"); _logger.Log($"post body:\n{WebUtility.UrlEncode(configPsg)}"); var httpResponse = request.GetResponse() as HttpWebResponse; using (Stream responseStream = httpResponse.GetResponseStream()) using (var reader = new StreamReader(responseStream, Encoding.UTF8)) { _logger.Log("got response from PSG"); _logger.Log($"PSG response size: {responseStream.Length}"); var payloadRows = 0; var output = new List <(string, string)>(); while (!reader.EndOfStream) { var currentRow = reader.ReadLine(); if (currentRow.StartsWith(@"#", StringComparison.InvariantCulture)) { continue; } payloadRows++; var values = currentRow.Split(' '); output.Add((values[0], values[2])); } _logger.Log($"PSG response payload size: {payloadRows} rows"); if (payloadRows == 0) { _logger.LogError("No response from PSG"); return("No response from PSG"); } var csvOutput = new StringBuilder(); var psgOutput = new StringBuilder(); foreach (var(first, second) in output) { csvOutput.AppendLine($"{first};{second}"); psgOutput.AppendLine($"{first} {second}"); } var currentTime = DateTime.Now; var outFile = $"psg_out_{currentTime:O}"; outFile = Regex.Replace(outFile, @"\+|:", "_"); var csvFilename = $"{outFile}.csv"; var psgFilename = $"{outFile}.txt"; _logger.Log($"writing PSG response to '{csvFilename}'"); File.WriteAllText(csvFilename, csvOutput.ToString()); _logger.Log($"writing PSG response to '{psgFilename}'"); File.WriteAllText(psgFilename, psgOutput.ToString()); } return("Observe complete"); } else { return("Celestial body does not exist"); } } else { return("Config file does not exist"); } //return "No result"; }
protected override IEnumerable <IValue> getItems(Context context) { ListValue list = (ListValue)getValue(context); return(list.GetEnumerable(context)); }
private static IList <string> ListValueToStringList(ListValue listValue) { IList <Object> objs = (IList <Object>)listValue.GetStorableData(); return(objs.Select(val => val.ToString()).ToList()); }
public override IValue interpret(Context context) { ListValue value = (ListValue)getValue(context); return(value.ToSetValue()); }