Exemple #1
0
        public Manager()
        {
            FindFiles();
            JsonSerializer serializer = new JsonSerializer();           //(De)serializes JSON, a la JSON.parse() and JSON.stringify()
            TextReader     fileReader = new StreamReader(dataLocation); //C# class to read file text
            JsonReader     reader     = new JsonTextReader(fileReader); //Newtonsoft class to read JSON from files

            reader.SupportMultipleContent = true;

            //Basically JSON.parse() but with static typing. "reader" arg is the poem.js JSON
            ReadPoem scannedPoem = serializer.Deserialize <ReadPoem>(reader);

            if (scannedPoem != null) //If the JSON serializer correctly converts the input JSON to a ReadPoem obj
            {
                //Now read the sentiment file and add that data to the ReadPoem
                fileReader            = new StreamReader(sentimentLocation);
                reader                = new JsonTextReader(fileReader);
                scannedPoem.sentiment = serializer.Deserialize <NeuralNet>(reader);

                //Now read the urgency file and add that data to the ReadPoem
                fileReader          = new StreamReader(urgencyLocation);
                reader              = new JsonTextReader(fileReader);
                scannedPoem.urgency = serializer.Deserialize <NeuralNet>(reader);

                //Now make a new Poem that has the data of the ReadPoem
                Poem poem = new Poem(scannedPoem);
                SavePoem(poem); //Write poem to file
            }

            Environment.Exit(0);
        }
Exemple #2
0
        public Poem(ReadPoem old)
        {
            //Add all the data that we're tracking from the scanned object
            poem      = old.poem;
            author    = old.author;
            syllables = old.syllables;
            midis     = old.midis;
            sentiment = old.sentiment;
            urgency   = old.urgency;

            //Assign values to the not-scanned properties for now
            //Eventually these will all be done programatically based on the scanned data
            colorArray     = new int[3];
            effect         = Effect.Empty;
            effectDuration = 2.0;
            effectScale    = 1.0;
        }