Exemple #1
0
        private void Evaluate(String content, Boolean showOutput)
        {
            try
            {
                var result = _interactivity.Run(_engine, content);

                if (showOutput)
                {
                    var output = default(String);

                    if (result != null)
                    {
                        output = Stringify.This(result);
                    }

                    _interactivity.Info(output);
                    _engine.Scope["ans"] = result;
                }
            }
            catch (ParseException ex)
            {
                _interactivity.Display(ex.Error, content);
            }
            catch (Exception ex)
            {
                _interactivity.Error(ex.Message);
            }

            _interactivity.Write(Environment.NewLine);
        }
Exemple #2
0
        public String StringifyInstruction(RegisterUsage Usage, Stringify AsString, int Val)
        {
            switch (Usage)
            {
            case RegisterUsage.Stringify:
                return(AsString(this));

            case RegisterUsage.Register:
RegisterCase:
                return("R[" + Val + "]");

            case RegisterUsage.Constant:
ConstantCase:
                return(this.Constants.ByIdx(Val).GetString());

            case RegisterUsage.ConstantRegister:
                if (Val < 0x100)
                {
                    goto RegisterCase;
                }
                else
                {
                    Val -= 0x100;
                    goto ConstantCase;
                }

            case RegisterUsage.Numeric:
                return(Val.ToString());

            default:
                break;
            }
            return(null);
        }
Exemple #3
0
        public static void WaitForObjects()
        {
            var list = _trackers.SelectMany(kvp => kvp.Value.Entries.Select(e => (e, kvp.Key))).ToArray();

            _trackers.Clear();

            // snapshot a list of objects created so far
            // some of them might be from concurrent tests
            // var list = new List<WeakReference>(ObjectTracker.Default.Items.Select(x => new WeakReference(x)));
            try
            {
                Console.WriteLine($"Cleaning {list.Count()} objects...");
                WaitFor(() =>
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    return(list.All(x => x.e.WeakReference.Target == null));
                    // return ObjectTracker.Default.Count == 0;
                });
                Console.WriteLine("All objects are clear");
            }
            catch
            {
                var objs = list.Where(x => x.e.WeakReference.Target != null).ToArray();
                // var objs = ObjectTracker.Default.Items.Where(x => x != null).ToArray();
                Console.WriteLine($"Objects alive: {objs.Length} ======================");
                foreach (var item in objs)
                {
                    Console.WriteLine($"{item.Key}: {item.e.Type.Name}: {Stringify.ToString(item.e.WeakReference.Target, true)}");
                }
                throw;
            }
        }
Exemple #4
0
        private Object PerformWrite(Object value)
        {
            var str = Stringify.This(value);

            _interactivity.Write(str);
            return(null);
        }
Exemple #5
0
        void DisplayPhaseChangeMode()
        {
            ImGui.SliderAngle("PhaseAngle", ref _phaseAngleRadians);

            var manuvers = InterceptCalcs.OrbitPhasingManuvers(_currentKE, _sgp, _atDatetime, _phaseAngleRadians);


            double totalManuverDV = 0;

            foreach (var manuver in manuvers)
            {
                ImGui.Text(manuver.deltaV.Length() + "Δv");
                totalManuverDV += manuver.deltaV.Length();
                ImGui.Text("Seconds: " + manuver.timeInSeconds);
            }

            ImGui.Text("Total Δv");
            ImGui.SameLine();
            ImGui.Text("for all manuvers: " + Stringify.Velocity(totalManuverDV));



            if (ImGui.Button("Make it so"))
            {
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, _atDatetime, manuvers[0].deltaV);
                DateTime futureDate = _atDatetime + TimeSpan.FromSeconds(manuvers[1].timeInSeconds);
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, futureDate, manuvers[1].deltaV);
            }
        }
Exemple #6
0
        public bool validate()
        {
            int totalUsers = file_manager.CountLines(location);
            string usersinfile = file_manager.ReadData(location, -1);
            Stringify stringify = new Stringify();
            char[] delim = { Convert.ToChar(";") };
            char[] miled = { Convert.ToChar(",") };
            List<Username> usernames = new List<Username>();
            string[] users = stringify.getArray(usersinfile, delim);
            foreach (string user in users)
            {

                try
                {
                    string _username = stringify.getArray(user, miled)[1];
                    string _password = stringify.getArray(user, miled)[2];
                    usernames.Add(new Username { username = _username, password = _password });
                }
                catch (IndexOutOfRangeException)
                {

                }
            }
            return isUserExists(usernames);
        }
Exemple #7
0
        /// <summary>Saves the JSON to a string.</summary>
        public string ToString(Stringify format)
        {
            var sw = new StringWriter();

            Save(sw, format);
            return(sw.ToString());
        }
        internal override void Display()
        {
            if (IsActive == true && ImGui.Begin("Map Scale", ref IsActive, _flags))//Lets the user close the ruler
            {
                //displays the size in meters of the current screen area account for zoom and window dimensions
                var windowCornerInWorldCoordinate = _uiState.Camera.WorldCoordinate_m((int)_uiState.MainWinSize.X, (int)_uiState.MainWinSize.Y);
                ImGui.Text("Current screen is:");
                ImGui.Text(ECSLib.Stringify.Distance(((windowCornerInWorldCoordinate.X - _uiState.Camera.CameraWorldPosition_m.X) * 2)) + " wide.");
                ImGui.Text(ECSLib.Stringify.Distance((-(windowCornerInWorldCoordinate.Y - _uiState.Camera.CameraWorldPosition_m.Y) * 2)) + " tall.");
                //ImGui.Text((_uiState.Camera.WorldCoordinate_m((int)_uiState.Camera.ViewPortSize.X, (int)_uiState.Camera.ViewPortSize.Y).X - _uiState.Camera.CameraWorldPosition_m.X).ToString());
                var mpp = _uiState.Camera.WorldDistance_m(1);

                /* I can't math. why can't I math?
                 * var lightMetersPerS = 299792458;
                 * var lightsecondsPerMeter = 3.33564e-9;
                 * var lspp = lightsecondsPerMeter * mpp;
                 * var ppls = mpp / 299792458;
                 * ImGui.Text("Meters Per Pixel: " + mpp);
                 * ImGui.Text("Light Seconds Per Pixel: " + lspp);
                 * ImGui.Text("Pixels Per Light Second: " + ppls);
                 */
                //the measure button, when clicked class starts listening for first mouse click to start measuring stick, wherever the mouse goes after that is the other end of the measuring stick.
                if (ImGui.Button("Measure"))
                {
                    _measuring = true;
                }
                //if the first click hasnt been done but the Measure button has been clicked, then display tooltip indicating you are measuring.
                if (_measuring && !_firstClickDone)
                {
                    ImGui.SetTooltip("measuring...");
                }
                //if the first click has already been done, then start showing distance and draw line between first click and the latest mouse position
                else if (_firstClickDone)
                {
                    if (_zoomLevelAtFirstClick != _uiState.Camera.ZoomLevel)
                    {
                        _stopMeasuring();
                    }
                    else
                    {
                        ECSLib.Vector3 lastMousePos            = _uiState.Camera.MouseWorldCoordinate_m();
                        Vector2        lastMousePosInViewCoord = ImGui.GetMousePos();

                        SDL.SDL_SetRenderDrawColor(_uiState.rendererPtr, 255, 255, 255, 255);
                        SDL.SDL_RenderDrawLine(_uiState.rendererPtr, (int)_firstClickInViewCoord.X, (int)_firstClickInViewCoord.Y, (int)lastMousePosInViewCoord.X, (int)lastMousePosInViewCoord.Y);
                        double metricDistance = Math.Sqrt(Math.Pow(_firstClick.X - lastMousePos.X, 2) + Math.Pow(_firstClick.Y - lastMousePos.Y, 2));
                        double lightseconds   = metricDistance / 299792458;
                        string tooltipString  = Stringify.Distance(metricDistance) + "\r\n" + lightseconds + "ls";
                        ImGui.SetTooltip(tooltipString);
                    }
                }

                ImGui.End();
            }
            else
            {
                _stopMeasuring();
            }
        }
Exemple #9
0
 /// <summary>Saves the JSON to a stream.</summary>
 public void Save(Stream stream, Stringify format = Stringify.Plain)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     Save(new StreamWriter(stream), format);
 }
        public void StringifyNullIsUndefined()
        {
            var value     = default(Object);
            var result    = Stringify.This(value);
            var undefined = Stringify.Undefined();

            Assert.AreEqual(undefined, result);
        }
Exemple #11
0
        internal override void Display()
        {
            if (IsActive)
            {
                if (ImGui.Begin("Cargo", ref IsActive, _flags))
                {
                    if (_hasCargoAbilityLeft)
                    {
                        CargoListLeft.Display();
                        ImGui.SameLine();
                        ImGui.BeginChild("xfer", new System.Numerics.Vector2(100, 200));
                        ImGui.Text("Transfer");

                        if (SelectedCargoPannel != null && SelectedCargoPannel.selectedCargo != null)
                        {
                            if (UnselectedCargoPannel != null && UnselectedCargoPannel.CanStore(SelectedCargoPannel.selectedCargo.CargoTypeID))
                            {
                                if (ImGui.Button("x100"))
                                {
                                    MoveItems(100);
                                }
                                ImGui.SameLine();
                                if (ImGui.Button("x10"))
                                {
                                    MoveItems(10);
                                }
                                ImGui.SameLine();
                                if (ImGui.Button("x1"))
                                {
                                    MoveItems(1);
                                }
                                if (ImGui.Button("Action Order"))
                                {
                                    ActionXferOrder();
                                }
                            }
                            //else
                            //can't transfer due to target unable to store this type
                        }

                        ImGui.EndChild();
                        ImGui.SameLine();
                        if (_hasCargoAbilityRight)
                        {
                            CargoListRight.Display();
                            ImGui.Text("DeltaV Difference: " + Stringify.Velocity(_dvDifference_ms));
                            ImGui.Text("Max DeltaV Difference: " + Stringify.Velocity(_dvMaxRangeDiff_ms));
                            ImGui.Text("Transfer Rate Kg/h: " + _transferRate);
                        }
                        else
                        {
                            ImGui.Text("Select Entity For Transfer");
                        }
                    }
                }
                ImGui.End();
            }
        }
Exemple #12
0
        internal override void Display()
        {
            if (!IsActive)
            {
                return;
            }
            ImGui.SetNextWindowSize(new Vector2(600f, 400f), ImGuiCond.FirstUseEver);
            if (ImGui.Begin("Nav Control", ref IsActive, _flags))
            {
                BorderGroup.Begin("Mode");
                if (ImGui.Button("Manual Thrust"))
                {
                    _navMode = NavMode.Thrust;
                }
                if (ImGui.Button("Hohmann Transfer"))
                {
                    _navMode = NavMode.HohmannTransfer;
                }
                if (ImGui.Button("Phase Change"))
                {
                    _navMode = NavMode.PhaseChange;
                }
                if (ImGui.Button("High Δv Intercept"))
                {
                    _navMode = NavMode.HighDVIntercept;
                }
                if (ImGui.Button("Porkchop Plot"))
                {
                    _navMode = NavMode.PorkChopPlot;
                }
                BorderGroup.End();
                ImGui.NewLine();
                ImGui.Text("Availible Δv: " + Stringify.Velocity(_totalDV));
                switch (_navMode)
                {
                case NavMode.Thrust:
                {
                    DisplayThrustMode();
                    break;
                }

                case NavMode.PhaseChange:
                    DisplayPhaseChangeMode();
                    break;

                case NavMode.HohmannTransfer:
                    DisplayHohmannMode();
                    break;

                case NavMode.None:
                    break;

                default:
                    break;
                }
            }
        }
        public void StringifyDelegateIsFunction()
        {
            var del   = new Function(args => null);
            var value = default(Object);

            value = del;
            var result = Stringify.This(value);
            var func   = Stringify.This(del);

            Assert.AreEqual(func, result);
        }
        public void StringifyStringIsIdentity()
        {
            var str   = "Hallo";
            var value = default(Object);

            value = str;
            var result = Stringify.This(value);
            var self   = Stringify.This(str);

            Assert.AreEqual(self, result);
        }
        public void StringifyBooleanIsBoolean()
        {
            var bln   = true;
            var value = default(Object);

            value = bln;
            var result  = Stringify.This(value);
            var boolean = Stringify.This(bln);

            Assert.AreEqual(boolean, result);
        }
        public void StringifyDoubleIsNumber()
        {
            var dbl   = 2.0;
            var value = default(Object);

            value = dbl;
            var result = Stringify.This(value);
            var number = Stringify.This(dbl);

            Assert.AreEqual(number, result);
        }
        public void StringifyDoubleUsesInvariantCulture()
        {
            var dbl     = 2.8;
            var thread  = Thread.CurrentThread;
            var culture = thread.CurrentUICulture;

            thread.CurrentCulture = new CultureInfo("de-de");
            Assert.AreEqual("2,8", dbl.ToString());
            Assert.AreEqual("2.8", Stringify.This(dbl));
            thread.CurrentCulture = culture;
        }
Exemple #18
0
        private String Info(String topic, Object value)
        {
            var sb       = new StringBuilder();
            var type     = value.ToType();
            var typeName = $"{type["name"]}";

            sb.AppendFormat("Type of '{0}': ", topic);
            sb.AppendLine(typeName);
            sb.Append("Number value: ");
            sb.Append(Stringify.This(value.ToNumber()));
            sb.AppendLine();
            sb.Append("Boolean value: ");
            sb.Append(Stringify.This(value.ToBoolean()));
            sb.AppendLine();
            sb.Append("String value: ");
            sb.Append(Stringify.This(value));

            switch (typeName)
            {
            case "Number":
            case "Complex":
            case "String":
            case "Boolean":
            case "Function":
            case "Undefined":
                break;

            case "CMatrix":
                sb.AppendLine();
                sb.Append("Columns: ");
                sb.Append(((Complex[, ])value).GetLength(1));
                sb.AppendLine();
                sb.Append("Rows: ");
                sb.Append(((Complex[, ])value).GetLength(0));
                break;

            case "Matrix":
                sb.AppendLine();
                sb.Append("Columns: ");
                sb.Append(((Double[, ])value).GetLength(1));
                sb.AppendLine();
                sb.Append("Rows: ");
                sb.Append(((Double[, ])value).GetLength(0));
                break;

            case "Object":
                sb.AppendLine();
                sb.Append("Keys: ");
                sb.Append(String.Join(", ", ((IDictionary <String, Object>)value).Select(m => m.Key)));
                break;
            }

            return(sb.ToString());
        }
Exemple #19
0
        void DisplayHohmannMode()
        {
            double mySMA  = _currentKE.SemiMajorAxis;
            float  smaMin = 1;
            float  smaMax = (float)OrbitProcessor.GetSOI_m(Entity.GetSOIParentEntity(_orderEntity));

            if (ImGui.Combo("Target Object", ref _selectedSibling, _siblingNames, _siblingNames.Length))
            {
                Entity selectedSib = _siblingEntities[_selectedSibling];
                if (selectedSib.HasDataBlob <OrbitDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <OrbitDB>().SemiMajorAxis;
                }
                if (selectedSib.HasDataBlob <OrbitUpdateOftenDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <OrbitUpdateOftenDB>().SemiMajorAxis;
                }
                if (selectedSib.HasDataBlob <NewtonMoveDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <NewtonMoveDB>().GetElements().SemiMajorAxis;
                }
            }

            //TODO this should be radius from orbiting body not major axies.
            ImGui.SliderFloat("Target SemiMajorAxis", ref _targetSMA, smaMin, smaMax);
            var manuvers = InterceptCalcs.Hohmann2(_sgp, mySMA, _targetSMA);



            double totalManuverDV = 0;

            foreach (var manuver in manuvers)
            {
                ImGui.Text(manuver.deltaV.Length() + "Δv");
                totalManuverDV += manuver.deltaV.Length();
            }

            if (totalManuverDV > _totalDV)
            {
                ImGui.TextColored(new Vector4(0.9f, 0, 0, 1), "Total Δv for all manuvers: " + Stringify.Velocity(totalManuverDV));
            }
            else
            {
                ImGui.Text("Total Δv for all manuvers: " + Stringify.Velocity(totalManuverDV));
            }

            if (ImGui.Button("Make it so"))
            {
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, _atDatetime, manuvers[0].deltaV);
                DateTime futureDate = _atDatetime + TimeSpan.FromSeconds(manuvers[1].timeInSeconds);
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, futureDate, manuvers[1].deltaV);
            }
        }
        public static void DisplayValues(EMWaveForm waveForm, double magnatude)
        {
            var min   = waveForm.WavelengthMin_nm;
            var avg   = waveForm.WavelengthAverage_nm;
            var max   = waveForm.WavelengthMax_nm;
            var hight = magnatude;

            ImGui.Text(Stringify.DistanceSmall(min));
            ImGui.Text(Stringify.DistanceSmall(avg));
            ImGui.SameLine();
            ImGui.Text(Stringify.Power(hight));
            ImGui.Text(Stringify.DistanceSmall(max));
        }
Exemple #21
0
        public void Display()
        {
            var width = ImGui.GetWindowWidth() * 0.5f;

            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(240, 200), true, ImGuiWindowFlags.AlwaysAutoResize);
            foreach (var typeStore in _stores)
            {
                CargoTypeSD stype        = _staticData.CargoTypes[typeStore.Key];
                var         freeVolume   = typeStore.Value.FreeVolume;
                var         maxVolume    = typeStore.Value.MaxVolume;
                var         storedVolume = maxVolume - freeVolume;

                string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free";
                ImGui.PushID(_entityState.Entity.Guid.ToString());
                if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    ImGui.Columns(3);
                    ImGui.Text("Item");
                    ImGui.NextColumn();
                    ImGui.Text("Count");
                    ImGui.NextColumn();
                    ImGui.Text("Total Mass");
                    ImGui.NextColumn();
                    ImGui.Separator();
                    foreach (var cargoType in typeStore.Value.CurrentStoreInUnits)
                    {
                        ICargoable ctype         = typeStore.Value.Cargoables[cargoType.Key];
                        var        cname         = ctype.Name;
                        var        volumeStored  = cargoType.Value;
                        var        volumePerItem = ctype.VolumePerUnit;
                        var        massStored    = cargoType.Value * ctype.MassPerUnit;
                        var        itemsStored   = typeStore.Value.CurrentStoreInUnits[ctype.ID];
                        if (ImGui.Selectable(cname))
                        {
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Number(itemsStored));
                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Mass(massStored));
                        ImGui.SetTooltip(Stringify.Volume(volumeStored));
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
            }


            ImGui.EndChild();
        }
        public void StringifyDictionaryIsObject()
        {
            var dict = new Dictionary <String, Object>
            {
                { "Foo", "Bar" }
            };
            var value = default(Object);

            value = dict;
            var result = Stringify.This(value);
            var obj    = Stringify.This(dict);

            Assert.AreEqual(obj, result);
        }
Exemple #23
0
        private void RegenerateDescription(PlayMakerCodeGenerator compiler)
        {
            var parser = new PlayMakerParser(compiler.parserOptions);

            try {
                var fsm   = compiler.fsm as PlayMakerFSM;
                var model = parser.CreateModel(fsm);
                compiler.DebugDescription = Stringify.CreateDescription(model);
            }
            catch (System.Exception e) {
                Debug.LogErrorFormat("PlayMakerStringify, error parsing FSM: {0}", e.ToString());
                return;
            }
        }
Exemple #24
0
        static void Main(string[] args)
        {
            if (!args.Any())
            {
                MainClient();
                return;
            }

            RiverInit.RegAll();
            _timer = new Timer(Tick, null, 1000, 1000);

            // ObjectTracker.TypesToPrint.Add(typeof(Handler));

            var server1 = new SocksServer
            {
                Chain =
                {
                    // "ss://*****:*****@127.0.0.1:8338",
                },
            };

            server1.Run("socks://0.0.0.0:1080");

            /*
             *                      var server2 = new ShadowSocksServer
             *                      {
             *                              Chain =
             *                              {
             *                                      // "ss://*****:*****@127.0.0.1:8338",
             *                              },
             *                      };
             *                      server2.Run("ss://*****:*****@0.0.0.0:8338");
             */

            string q;

            do
            {
                q = Console.ReadLine();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.WaitForFullGCApproach();

                foreach (var item in ObjectTracker.Default.Get <Thread>())
                {
                    Console.WriteLine(Stringify.ToString(item, true));
                }
            } while (q != "q");
        }
        public void StringifyDoubleArrayIsMatrix()
        {
            var array = new Double[, ]
            {
                { 1, 2 },
                { 3, 4 }
            };
            var value = default(Object);

            value = array;
            var result = Stringify.This(value);
            var mat    = Stringify.This(array);

            Assert.AreEqual(mat, result);
        }
Exemple #26
0
 public void Info(Object result)
 {
     if (result == null)
     {
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.Write("Undefined");
         Console.ResetColor();
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.White;
         Console.Write(Stringify.This(result));
         Console.ResetColor();
     }
 }
Exemple #27
0
 /// <summary>Saves the JSON to a TextWriter.</summary>
 public void Save(TextWriter textWriter, Stringify format = Stringify.Plain)
 {
     if (textWriter == null)
     {
         throw new ArgumentNullException("textWriter");
     }
     if (format == Stringify.Hjson)
     {
         HjsonValue.Save(this, textWriter);
     }
     else
     {
         new JsonWriter(format == Stringify.Formatted).Save(this, textWriter, 0);
     }
     textWriter.Flush();
 }
Exemple #28
0
        static void GuiCostText(ComponentDesigner componentDesigner) //Prints a 2 col table with the costs of the part
        {
            //ImGui.BeginChild("Cost");
            if (componentDesigner != null) //If a part time is selected
            {
                ImGui.Columns(2);
                ImGui.BeginTabItem("Cost");

                ImGui.Text("Mass");
                ImGui.Text("Volume_km3");
                ImGui.Text("Crew Requred");
                ImGui.Text("Cost");
                ImGui.Text("Research Cost");
                ImGui.Text("Build Cost");
                ImGui.Text("Resource Costs");
                ImGui.NextColumn(); //Add all the cost names to col 1


                ImGui.Text(Stringify.Mass(componentDesigner.MassValue));
                ImGui.Text(Stringify.Volume(componentDesigner.VolumeM3Value));
                ImGui.Text(componentDesigner.CrewReqValue.ToString());
                ImGui.Text(componentDesigner.CreditCostValue.ToString());
                ImGui.Text(componentDesigner.ResearchCostValue.ToString() + " RP");
                ImGui.Text(componentDesigner.IndustryPointCostsValue.ToString() + " BP");
                ImGui.NextColumn(); //Add all the price values to col 2


                foreach (var kvp in componentDesigner.ResourceCostValues)
                {
                    var resource = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key);
                    if (resource == null)
                    {
                        resource = (ICargoable)_state.Faction.GetDataBlob <FactionInfoDB>().IndustryDesigns[kvp.Key];
                    }
                    var xpos = ImGui.GetCursorPosX();
                    ImGui.SetCursorPosX(xpos + 12);
                    ImGui.Text(resource.Name);
                    ImGui.NextColumn();
                    ImGui.Text(kvp.Value.ToString());
                    ImGui.NextColumn();
                }
            }

            //ImGui.EndChild();
        }
Exemple #29
0
        public static void Test()
        {
            int       x             = 4040;
            Stringify getTheString  = new Stringify(x.ToString);
            Stringify getStringify2 = x.ToString;



            Cons.WriteLine($"This is what stringify does but you have to us it as a method ()...{getTheString()}...or {getStringify2()}");
            Cons.WriteLine($"Trying the invoke method ...{getTheString.Invoke()}");


            var msg = "Test";

            TestS.ChgTest(ref msg);

            pTest = msg;
        }
Exemple #30
0
        private static bool HandleCommand(string command)
        {
            if (command == String.Empty &&  commands.Count > 0)
            {
                var source = string.Join(" ", commands);

                commands.Clear();
                Console.SetCursorPosition(Console.CursorLeft, Console.CursorTop - 1);

                try
                {
                    var compilationResult = compiler.Compile(parser.Parse(scanner.Scan(source)));

                    if (compilationResult.Errors.Count > 0)
                    {
                        compilationResult.Errors.ForEach(error =>
                        {
                            Console.WriteLine(error.Message);
                        });
                    }
                    else
                    {
                        vm.Run(compilationResult.CurrentScope.Instructions, compilationResult.Constants, compilationResult.BuiltIns);
                        Console.WriteLine(Stringify.Object((Object)vm.StackTop));
                    }
                }
                catch
                {
                    Console.WriteLine("Something went wrong with the execution of your command, sorry!");
                }
            }
            else
            {
                commands.Add(command);
            }

            if (commands.Count == 1 && (command == "q" || command == "quit"))
            {
                return(false);
            }

            return(true);
        }
Exemple #31
0
        public static Object To(this Object value, String type)
        {
            switch (type)
            {
            case "Number": return(value.ToNumber());

            case "String": return(Stringify.This(value));

            case "Boolean": return(value.ToBoolean());

            case "Matrix": return(value.ToNumber().ToMatrix());

            case "Function": return(value as Function);

            case "Object": return(value as IDictionary <String, Object>);

            case "Undefined": return(null);
            }

            return(null);
        }
Exemple #32
0
 /////////////////////////////////////////////////////////////////////////////////////
 public void SetStringify(int i, Stringify s)
 {
     stringify [i] = s;
 }
Exemple #33
0
 private bool checkFormat(string data)
 {
     Stringify stringsplit = new Stringify();
     char[] delim = { Convert.ToChar(".") };
     string[] data_arr = stringsplit.getArray(data, delim);
     string extension = data_arr[1];
     if (extension.ToLower() == "reminder")
     {
         return true;
     }
     else
     {
         return false;
     }
 }