示例#1
0
        public override void OnInspectorGUI()
        {
            JsonCreator      myScript      = (JsonCreator)target;
            SerializedObject serializedObj = new SerializedObject(myScript);

            switch (myScript.fType)
            {
            case FileType.SimplePotion:
                DrawPropertiesExcluding(serializedObj, new string[] { "jsonWeaponGem", "jsonArmorGem" });
                break;

            case FileType.WeaponGem:
                DrawPropertiesExcluding(serializedObj, new string[] { "jsonSimplePotion", "jsonArmorGem" });
                break;

            case FileType.ArmorGem:
                DrawPropertiesExcluding(serializedObj, new string[] { "jsonSimplePotion", "jsonWeaponGem" });
                break;

            default:
                break;
            }

            if (GUILayout.Button("Create JSON"))
            {
                myScript.CreateJSON();
            }

            GUILayout.Label(myScript.VerifyJSONCreation());
            serializedObj.ApplyModifiedProperties();
        }
示例#2
0
        private void сохранитьТестыToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var editableTests = ListTests.Where(p => p.Value.Editable);
            var jsonCreator   = new JsonCreator();

            foreach (var keyValue in editableTests)
            {
                var filename = new DynamicParams().GetPath() + "\\" + keyValue.Value.TestName + ".test";
                var testJson = jsonCreator.CreateTestCollection(new List <Test> {
                    keyValue.Value
                });
                // сохраняем текст в файл
                File.WriteAllText(filename, testJson);
            }
            File.WriteAllText(new DynamicParams().GetPath() + "\\PlatoonAndCourses.test", jsonCreator.CreatePlatoonAndCourses());

            var picureCreator = new PictureCreator();

            foreach (var keyValue in editableTests)
            {
                picureCreator.CreatePictures(keyValue.Value, new DynamicParams().GetPath());
            }

            MessageBox.Show("Файл сохранен");
        }
示例#3
0
    private static string LobbyIdJson(LobbyType lobbyType, string lobbyId)
    {
        var lobbyIdJson = new LobbyId()
        {
            lobbyId = lobbyId
        };
        var jsonString = JsonConvert.SerializeObject(lobbyIdJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(lobbyType.ToString(), jsonString)));
    }
示例#4
0
    private static string DisconnectFromLobbyJson(string lobbyId, string playerId)
    {
        var lobbyIdJson = new PlayerIdLobby()
        {
            lobbyId  = lobbyId,
            playerId = playerId,
        };
        var jsonString = JsonConvert.SerializeObject(lobbyIdJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(LobbyType.disconnect.ToString(), jsonString)));
    }
示例#5
0
    public static string CreateCardJson(string gameId, string cardId, string command)
    {
        var authAttributes = new CardActionAttributes()
        {
            gameId = gameId,
            cardId = cardId
        };
        var jsonString = JsonConvert.SerializeObject(authAttributes);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(command, jsonString)));
    }
示例#6
0
    private static string CreateAuthJson(AuthType authType, string username, string password)
    {
        var authAttributes = new AuthAttributes()
        {
            username = username,
            password = password
        };
        var jsonString = JsonConvert.SerializeObject(authAttributes);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(authType.ToString(), jsonString)));
    }
示例#7
0
    private static string UpdateLobbyInfoJson(string lobbyId, string playerId, string state)
    {
        var lobbyIdJson = new UpdateLobby()
        {
            lobbyId  = lobbyId,
            playerId = playerId,
            state    = state
        };
        var jsonString = JsonConvert.SerializeObject(lobbyIdJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(LobbyType.update.ToString(), jsonString)));
    }
示例#8
0
    private static string ConnectToLobbyJson(string lobbyId, string playerName, string sessionId)
    {
        var lobbyIdJson = new PlayerConnectLobby()
        {
            lobbyId     = lobbyId,
            playerName  = playerName,
            accessToken = sessionId
        };
        var jsonString = JsonConvert.SerializeObject(lobbyIdJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(LobbyType.connect.ToString(), jsonString)));
    }
        public IActionResult Calculate(string formula, string points, double taylorAround, uint taylorN, double startIntegral, double endIntegral)
        {
            if (string.IsNullOrEmpty(formula))
            {
                return(RedirectToAction("Index"));
            }

            var model = new CalculateViewModel();

            model.Original = formula;


            var parser = new StringParser(formula);
            var result = parser.GetOperator();

            model.NiceFormat = (result.DeepSimplyfy().ToMathString());

            model.DerivativeNiceFormat = (result.Derivate().DeepSimplyfy().ToMathString());
            model.DerivativePointJson  =
                JSONHelper.ToJSON(NewtonDerivative.CalculatePoints(result, 0.001d, 0.5d, -3, 3));

            model.IntegralStart = startIntegral;
            model.IntegralEnd   = endIntegral;

            model.IntegralSum = RiemannSum.CalculateSum(result, startIntegral, endIntegral);

            model.TaylorPoloynoomAround     = taylorAround;
            model.TaylorPoloynoomNiceFormat = Taylorpolynomial.CalculateNPolynomial(result, taylorAround, taylorN).ToMathString();

            model.McClairenPoloynoomNiceFormat = Taylorpolynomial.CalculateNPolynomial(result, 0, taylorN).ToMathString();

            model.Request = HttpContext;
            try
            {
                model.GausJordon = GausJordan.GetBaseMathOperatorFromList(GetPoints(points)).DeepSimplyfy()
                                   .ToMathString();
                model.GausJordonFault = false;
            }
            catch (Exception e)
            {
                model.GausJordonFault = true;
            }

            var json = JsonCreator.CreateFromBaseOpeator(result);

            model.JsonData = JsonConvert.SerializeObject(json);

            model.TaylorPossible = model.McClairenPoloynoomNiceFormat.IndexOf("NaN", StringComparison.Ordinal) >= 0 || model.TaylorPoloynoomNiceFormat.IndexOf("NaN", StringComparison.Ordinal) >= 0;

            return(View(model));
        }
示例#10
0
        public IActionResult Calculate(string formula)
        {
            if (string.IsNullOrEmpty(formula))
            {
                return(RedirectToAction("Index"));
            }

            var model = new CalculateViewModel();


            var parser            = StringParser.Create(formula);
            var calculatedFormula = parser.GetOperator();

            model.OriginalFormula = calculatedFormula.ToString();
            model.Logic           = calculatedFormula.ToLogicString();
            model.Nandify         = calculatedFormula.ToNandify().ToString();
            model.HasResult       = calculatedFormula.HasResult();

            var json = JsonCreator.CreateFromBaseOpeator(calculatedFormula);

            model.JsonData = JsonConvert.SerializeObject(json);


            SemanticTableauxParser tableaux;

            if (calculatedFormula.HasResult())
            {
                var stable           = new SimplifiedTruthTableCreator(calculatedFormula);
                var table            = new TruthTableCreator(calculatedFormula);
                var normal           = new DisjunctiveNormalDecorator(table);
                var simplifiedNormal = new DisjunctiveNormalDecorator(stable);
                model.Normalize            = normal.GetOperator().ToString();
                model.NormalizeLogicFormat = normal.GetOperator().ToLogicString();
                model.TruthTable           = table.GetTable();
                model.SimplifiedTruthTable = stable.GetTable();
                model.Arguments            = calculatedFormula.GetArguments();

                model.SimplifiedNormalize            = simplifiedNormal.GetOperator().ToString();
                model.SimplifiedNormalizeLogicFormat = simplifiedNormal.GetOperator().ToLogicString();

                model.Hex = table.ToHex();
            }


            tableaux               = new SemanticTableauxParser(calculatedFormula);
            model.isTautology      = tableaux.IsTautology();
            model.tableauxJsonData =
                JsonConvert.SerializeObject(JsonCreator.CreateFromTableauxStep(tableaux.GetStep()));
            return(View(model));
        }
示例#11
0
文件: Test.cs 项目: Voenkaff/Test
        private void сохранитьТестToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // получаем выбранный файл
            string filename = new DynamicParams().GetPath() + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".test";

            string testJson = new JsonCreator().CreateTestCollection(new List <Test> {
                this
            });

            new PictureCreator().CreatePictures(this, filename.Substring(0, filename.LastIndexOf("\\", StringComparison.Ordinal)));
            // сохраняем текст в файл
            System.IO.File.WriteAllText(filename, testJson);
            MessageBox.Show(@"Пожалуйста, введите имя пользователя и пароль");
        }
示例#12
0
    private static string LobbyInfoJson(string ownerName, string lobbyName, int maxPlayers,
                                        int moveTime, string accessToken)
    {
        var lobbyInfoJson = new LobbyInfo()
        {
            ownerName   = ownerName,
            lobbyName   = lobbyName,
            maxPlayers  = maxPlayers.ToString(),
            moveTime    = moveTime.ToString(),
            accessToken = accessToken
        };
        var jsonString = JsonConvert.SerializeObject(lobbyInfoJson);

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(LobbyType.create.ToString(), jsonString)));
    }
示例#13
0
        static void Main(string[] args)
        {
            JsonCreator creatorJson = new JsonCreator();
            PngCreator  creatorPng  = new PngCreator();
            TxtCreator  creatorTxt  = new TxtCreator();

            Console.WriteLine("Создание файлов с помощью фабрик: ");
            IDocument txt_1 = creatorTxt.CreateDocument();

            IDocument json_1 = creatorTxt.CreateDocument();

            IImageDocument png_1 = creatorPng.CreateImageDocument();

            Console.ReadKey();
        }
        async private Task ExportToMongo(IEnumerable<ProductSales> sales)
        {
            List<BsonDocument> documentsToExport = new List<BsonDocument>();
            
            foreach (var entry in sales)
            {
                var newDoc = CreateBson(entry);
                documentsToExport.Add(newDoc);
            }

            var jsonCreator = new JsonCreator();
            jsonCreator.WriteJsonFiles(documentsToExport, this.directoryPath);

            var collection = this.supermarketsDb.GetCollection<BsonDocument>("SalesByProductReports");
            await collection.InsertManyAsync(documentsToExport);
        }
示例#15
0
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join(" ", args));
//#if DEBUG
//            string pathBase = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\"));
//            args = new[] { Path.Combine(pathBase, "ConfigFiles"), "Info"};
//#endif
            string key   = "aspnet:RoslynCompilerLocation";
            string value = Path.Combine(AppContext.BaseDirectory, "roslyn");

            if (ConfigurationManager.AppSettings[key] != value)
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings[key].Value = value;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
            }

            JsonCreator jsonCreator = new JsonCreator();

            jsonCreator.GenerateJson(args[0], args[1]);
        }
示例#16
0
        private void TestCurrentDownload(object sender, EventArgs e)
        {
            var parentPanel = (Panel)((Button)sender).Parent;

            saveTests.Filter   = Resources.SaveTestFilter;
            saveTests.FileName = ListTests[parentPanel].TestName;
            if (saveTests.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string filename = saveTests.FileName;

            string testJson = new JsonCreator().CreateTestCollection(new List <Test> {
                ListTests[parentPanel]
            });

            new PictureCreator().CreatePictures(ListTests[parentPanel], filename.Substring(0, filename.LastIndexOf("\\", StringComparison.Ordinal)));
            // сохраняем текст в файл
            System.IO.File.WriteAllText(filename, testJson);
            MessageBox.Show("Файл сохранен");
        }
示例#17
0
        private void сохранитьТестыToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Directory.Delete(new DynamicParams().GetPath(), true);

            DirectoryInfo dirTests = new DirectoryInfo(new DynamicParams().GetPath());
            DirectoryInfo dirPics  = new DirectoryInfo(new DynamicParams().GetPath() + "\\" + "picture");

            foreach (FileInfo file in dirTests.GetFiles())
            {
                file.Delete();
            }

            foreach (FileInfo file in dirPics.GetFiles())
            {
                file.Delete();
            }
            //string sadasd = new DynamicParams().GetPath() + "\\" + "picture";
            //dirTests.CreateSubdirectory(sadasd);

            foreach (KeyValuePair <Panel, Test> keyValue in ListTests)
            {
                string filename = new DynamicParams().GetPath() + "\\" + keyValue.Value.TestName + ".test";
                string testJson = new JsonCreator().CreateTestCollection(new List <Test> {
                    keyValue.Value
                });
                // сохраняем текст в файл
                File.WriteAllText(filename, testJson);
            }

            var picureCreator = new PictureCreator();

            foreach (KeyValuePair <Panel, Test> keyValue in ListTests)
            {
                picureCreator.CreatePictures(keyValue.Value, new DynamicParams().GetPath());
            }

            MessageBox.Show(@"Пожалуйста, введите имя пользователя и пароль");
        }
        public ActionResult StockCatalogues()
        {
            #region NoInternetConnection
            StockPortfolio largeCapPortfolio            = new StockPortfolio("Large Cap");
            StockPortfolio avanzaLargeCapStockPortfolio = AvanzaParsers.ParseAvanzaOldList("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_LargeCap.SE&sortField=NAME&sortOrder=ASCENDING&activeTab=quote", largeCapPortfolio);
            //StockPortfolio viewAvanzaLargeCapStockPortfolio = Calculator.SetStockParameters(avanzaLargeCapStockPortfolio);
            StockPortfolio avanzaLargeCapStockPortfolioHistory      = AvanzaParsers.ParseAvanzaOldListHistory("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_LargeCap.SE&sectorId=ALL&page=1&sortField=NAME&sortOrder=ASCENDING&activeTab=history", avanzaLargeCapStockPortfolio);
            StockPortfolio avanzaLargeCapStockPortfolioOverview     = AvanzaParsers.ParseAvanzaOldListOverview("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_LargeCap.SE&sectorId=ALL&page=1&sortField=NAME&sortOrder=ASCENDING&activeTab=overview", avanzaLargeCapStockPortfolioHistory);
            StockPortfolio viewAvanzaLargeCapStockPortfolioOverview = Calculator.SetStockParameters(avanzaLargeCapStockPortfolioOverview);

            StockPortfolio midCapPortfolio            = new StockPortfolio("Mid Cap");
            StockPortfolio avanzaMidCapStockPortfolio = AvanzaParsers.ParseAvanzaOldList("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_MidCap.SE&sortField=NAME&sortOrder=ASCENDING&activeTab=quote", midCapPortfolio);
            //StockPortfolio viewAvanzaMidCapStockPortfolio = Calculator.SetStockParameters(avanzaMidCapStockPortfolio);
            StockPortfolio avanzaMidCapStockPortfolioHistory      = AvanzaParsers.ParseAvanzaOldListHistory("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_LargeCap.SE&sectorId=ALL&page=1&sortField=NAME&sortOrder=ASCENDING&activeTab=history", avanzaMidCapStockPortfolio);
            StockPortfolio avanzaMidCapStockPortfolioOverview     = AvanzaParsers.ParseAvanzaOldListOverview("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_MidCap.SE&sortField=NAME&sortOrder=ASCENDING&activeTab=overview", avanzaMidCapStockPortfolioHistory);
            StockPortfolio viewAvanzaMidCapStockPortfolioOverview = Calculator.SetStockParameters(avanzaMidCapStockPortfolioOverview);


            StockPortfolio smallCapPortfolio            = new StockPortfolio("Small Cap");
            StockPortfolio avanzaSmallCapStockPortfolio = AvanzaParsers.ParseAvanzaOldList("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_SmallCap.SE&sortField=NAME&sortOrder=ASCENDING&activeTab=quote", smallCapPortfolio);
            //StockPortfolio viewAvanzaSmallCapStockPortfolio = Calculator.SetStockParameters(avanzaSmallCapStockPortfolio);
            StockPortfolio avanzaSmallCapStockPortfolioHistory      = AvanzaParsers.ParseAvanzaOldListHistory("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_LargeCap.SE&sectorId=ALL&page=1&sortField=NAME&sortOrder=ASCENDING&activeTab=history", avanzaSmallCapStockPortfolio);
            StockPortfolio avanzaSmallCapStockPortfolioOverview     = AvanzaParsers.ParseAvanzaOldListOverview("https://www.avanza.se/aktier/gamla-aktielistan.html?countryCode=SE&marketPlaceOrList=LIST_SmallCap.SE&sortField=NAME&sortOrder=ASCENDING&activeTab=overview", avanzaSmallCapStockPortfolioHistory);
            StockPortfolio viewAvanzaSmallCapStockPortfolioOverview = Calculator.SetStockParameters(avanzaSmallCapStockPortfolioOverview);

            StockPortfolio allAvanzaStocks = new StockPortfolio("Avanza Stocks");
            allAvanzaStocks.Stocks = AddAllStocks(viewAvanzaLargeCapStockPortfolioOverview.Stocks, viewAvanzaMidCapStockPortfolioOverview.Stocks, viewAvanzaSmallCapStockPortfolioOverview.Stocks);
            allAvanzaStocks.Stocks = allAvanzaStocks.Stocks.OrderBy(x => x.Name).ToList();
            StockPortfolio allAvanzaStocksView = Calculator.SetStockParameters(allAvanzaStocks);

            string allAvanzaStocksJson = JsonCreator.CreateJson(allAvanzaStocksView);
            JsonCreator.SaveToRoot(allAvanzaStocksJson);
            #endregion
            ViewBag.Message = "These are the stocks currently added.";
            return(View(allAvanzaStocksView));
        }
示例#19
0
    public static string GetLobbyListJson()
    {
        var jsonString = JsonConvert.SerializeObject(new NoAttributes());

        return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(LobbyType.getLobby.ToString(), jsonString)));
    }
示例#20
0
 static void ParseFile(string InputFileName,string OutputFileName)
 {
     JsonCreator Creator=new JsonCreator();
     WzFile File=new WzFile(InputFileName,WzMapleVersion.BMS);
     File.ParseWzFile();
     List<WzDirectory> RootDirectory=new List<WzDirectory>();
     RootDirectory.Add(File.WzDirectory);
     var Dirs=new Stack<DirObject>();
     var RootHash=new Dictionary<string,object>();
     Dirs.Push(new DirObject(RootDirectory.GetEnumerator(),RootHash));
     for(;Dirs.Count>0;){
         if(!Dirs.Peek().Dir.MoveNext()){
             Dirs.Pop();
             continue;
         }else{
             foreach(WzImage Image in Dirs.Peek().Dir.Current.WzImages){
                 var Props=new Stack<PropObject>();
                 var Temp1=new Dictionary<string,object>();
                 Dirs.Peek().Hash.Add(Image.Name,Temp1);
                 Props.Push(new PropObject(Image.WzProperties.GetEnumerator(),Temp1));
                 for(;Props.Count>0;){
                     if(!Props.Peek().Prop.MoveNext()){
                         Props.Pop();
                         continue;
                     }
                     var Obj=Props.Peek().Prop.Current;
                     switch(Props.Peek().Prop.Current.PropertyType){
                     case WzPropertyType.ByteFloat:
                         Props.Peek().Hash.Add(Obj.Name,(double)((WzByteFloatProperty)Obj).Value);
                         break;
                     case WzPropertyType.Canvas:
                         //Not Implemented
                         break;
                     case WzPropertyType.CompressedInt:
                         Props.Peek().Hash.Add(Obj.Name,(long)((WzCompressedIntProperty)Obj).Value);
                         break;
                     case WzPropertyType.Convex:
                         //Not Implemented
                         break;
                     case WzPropertyType.Double:
                         Props.Peek().Hash.Add(Obj.Name,((WzDoubleProperty)Obj).Value);
                         break;
                     case WzPropertyType.Null:
                         Props.Peek().Hash.Add(Obj.Name,null);
                         break;
                     case WzPropertyType.PNG:
                         var Temp2=((WzPngProperty)Obj).GetCompressedBytes(false).OfType<long>().ToList();
                         var Temp3=new Dictionary<string,object>();
                         Temp3.Add("Width",(long)((WzPngProperty)Obj).Width);
                         Temp3.Add("Height",(long)((WzPngProperty)Obj).Height);
                         Temp3.Add("Data",Temp2);
                         break;
                     case WzPropertyType.Sound:
                         var Temp4=((WzSoundProperty)Obj).GetBytes(false).OfType<long>().ToList();
                         var Temp5=new Dictionary<string,object>();
                         Temp5.Add("Frequency",(long)((WzSoundProperty)Obj).Frequency);
                         Temp5.Add("Length",(long)((WzSoundProperty)Obj).Length);
                         Temp5.Add("Data",Temp4);
                         Props.Peek().Hash.Add(Obj.Name,Temp5);
                         break;
                     case WzPropertyType.String:
                         Props.Peek().Hash.Add(Obj.Name,((WzStringProperty)Obj).Value);
                         break;
                     case WzPropertyType.SubProperty:
                         var Temp6=new Dictionary<string,object>();
                         Props.Peek().Hash.Add(Obj.Name,Temp6);
                         Props.Push(new PropObject(((WzSubProperty)Obj).WzProperties.GetEnumerator(),Temp6));
                         break;
                     case WzPropertyType.UnsignedShort:
                         Props.Peek().Hash.Add(Obj.Name,(long)((WzUnsignedShortProperty)Obj).Value);
                         break;
                     case WzPropertyType.UOL:
                         //Not Implemented
                         break;
                     case WzPropertyType.Vector:
                         var Temp7=new Dictionary<string,object>();
                         Temp7.Add("X",(long)((WzVectorProperty)Obj).X);
                         Temp7.Add("Y",(long)((WzVectorProperty)Obj).Y);
                         Props.Peek().Hash.Add(Obj.Name,Temp7);
                         break;
                     }
                 }
             }
             var Temp8=new Dictionary<string,object>();
             Dirs.Peek().Hash.Add(Dirs.Peek().Dir.Current.Name,Temp8);
             Dirs.Push(new DirObject(Dirs.Peek().Dir.Current.WzDirectories.GetEnumerator(),Temp8));
         }
     }
     var Json=Creator.Create(RootHash);
     System.IO.File.WriteAllText(OutputFileName,Json,Encoding.UTF8);
     return;
 }
        private int ExportToMongo(IEnumerable<ProductSales> sales)
        {
            List<MongoDB.Document> documentsToExport = new List<MongoDB.Document>();

            foreach (var entry in sales)
            {
                var doc = CreateDocument(entry);
                documentsToExport.Add(doc);
            }

            var mongo = new Mongo();
            mongo.Connect();
            var db = mongo.GetDatabase("supermarkets");

            var collection = db.GetCollection("SalesByProductReports");
            collection.Insert(documentsToExport);

            mongo.Disconnect();

            var jsonCreator = new JsonCreator();
            jsonCreator.WriteJsonFiles(documentsToExport, directoryPath);

            return documentsToExport.Count();
        }