示例#1
0
        public void FirstLineCorrect()
        {
            var parser = new CSVParser(input);

            var testArray = new[] { "1001 spot illustrations of the lively twenties","La Vie Parisienne","008077927","GB8865678","0486250210","","","","","Grafton, Carol Belanger","","","England","New York ; London","Dover ; Constable","1986","123 pages, chiefly illustrations, 28 cm","741.5944","YV.1988.b.2439","Design--History--20th century--Themes, motives ; Art deco ; French caricatures--1920-1930","","Illustrations from La Vie Parisienne"};
            Assert.That(parser[0], Is.EqualTo(testArray));
        }
示例#2
0
        public void FourthLineCorrect()
        {
            var parser = new CSVParser(input);

            var testArray = new[] { "How Obelix fell into the magic potion","","015103770","GBA933631","9781444000269 ; 1444000268","Goscinny","1926-1977","person","","Goscinny ; Uderzo","","","England","London","Orion Children's","2009","1 v, chiefly illustrations, 29 cm","741.5","","Astérix (Fictitious character)--Comic books, strips, etc--Juvenile fiction ; Obelix (Fictitious character : Uderzo)--Comic books, strips, etc--Juvenile fiction","",""};
            Assert.That(parser[3], Is.EqualTo(testArray));
        }
示例#3
0
    private CSVParser skillList;        // 스킬 리스트
 
    void Awake()
    {
        instance = this;
        skillList = new CSVParser("SkillList");
        skillList.Load();
        SkillInit();
    }
示例#4
0
 public void parseAmenityTest()
 {
     IDataParser target = new CSVParser(); // TODO: Initialize to an appropriate value
     List<Amenity> expected = null; // TODO: Initialize to an appropriate value
     List<Amenity> actual;
     actual = target.parseAmenity("Art Centres");
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
示例#5
0
        public override void ExitString(CSVParser.StringContext context) {
            string trimQuote = context.STRING().GetText().TrimStart('\"');
            trimQuote = trimQuote.TrimEnd('\"');

            int first = trimQuote.IndexOf('\"');
            int last = trimQuote.LastIndexOf('\"');
            if (first != -1 || last != -1) {
                trimQuote = trimQuote.Remove(first, 1);
                trimQuote = trimQuote.Remove(last-1, 1);
            }

            currentRowFieldValues.Add(trimQuote);
        }
示例#6
0
        public override void ExitRow(CSVParser.RowContext context) {
            if (context.Parent.RuleIndex == CSVParser.RULE_hdr) {
                return;
            }

            Dictionary<string, string> m = new Dictionary<string, string>();
            int i = 0;
            foreach (string v in currentRowFieldValues) {
                m.Add(header[i], v);
                i++;
            }
            rows.Add(m);
        }
示例#7
0
        public static void Main(string[] args) {
            if (args.Length == 0) {
                Console.WriteLine("No arguments given!");
                Console.WriteLine("Usage: input.csv [-json | -xml | -excel] [output.json | output.xml | output.xlsx]");
                return;
            }
            ParseArgs(args);

            StreamReader stream = null;
            try {
                stream = new StreamReader(csvInputFile);
            } catch (ArgumentException) {
                Console.WriteLine("Input filename not set!");
                return;
            }

            AntlrInputStream antlrStream = new AntlrInputStream(stream.ReadToEnd());
            CSVLexer lexer = new CSVLexer(antlrStream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            CSVParser parser = new CSVParser(tokens);
            IParseTree parseTree = parser.file();

            ParseTreeWalker walker = new ParseTreeWalker();
            LoaderCSV load = new LoaderCSV();

            walker.Walk(load, parseTree);

            if (jsonSwitch) {
                if (jsonOutputFile == string.Empty) {
                    Console.WriteLine("[JSON] Output filename not set!");
                    return;
                }
                SaveToJSON(jsonOutputFile, load);
            }

            if (xmlSwitch) {
                if (xmlOutputFile == string.Empty) {
                    Console.WriteLine("[XML] Output filename not set!");
                    return;
                }
                SaveToXML(xmlOutputFile, load);
            }

            if (excelSwitch) {
                if (excelOutputFile == string.Empty) {
                    Console.WriteLine("[Excel] Output filename not set!");
                    return;
                }
                SaveToExcel(excelOutputFile, load);
            }
        }
示例#8
0
        public void Parse_ShouldOutputTheColorRight()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser( fileSystem);
            //Act
            var list = parser.Parse<Igal>(fileName);
            //Assert
            var reallist = list.ToList();

            reallist[0].Color.Trim().Should().Be("H");
        }
        public void ConvertFrom_ShouldConvertToAList()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser(fileSystem);

            //Act

            var list = parser.Parse<IgalGIA>(fileName);

            var reallist = list.ToList();

            //Assert

            var composed = reallist[0].SupplierCode.ToString() + reallist[0].InventoryCode;
            var uniqueDiamondIdFromHashCode = Math.Abs(composed.GetHashCode());

            reallist[0].DiamondID.Should().Be(uniqueDiamondIdFromHashCode);
        }
示例#10
0
 public CovidController()
 {
     Data = CSVParser.GetRecords <CovidData>("time-series-19-covid-combined.csv", new CovidDataMapping()).OrderByDescending(x => x.Date.Ticks);
 }
示例#11
0
 public void Initialize()
 {
     m_Parser = new CSVParser();
 }
示例#12
0
        public MainWindow()
        {
            this.InitializeComponent();

            MainWindow.desktopWindow = MainWindow.GetDesktopWindow();
            MainWindow.shellWindow   = MainWindow.GetShellWindow();

            MonikaiSettings.Default.Reload();

            // Perform update and download routines
            this.updater = new Updater();
            this.updater.PerformUpdatePost();
            this.updaterInitTask = Task.Run(async() => await this.updater.Init());

            this.settingsWindow = new SettingsWindow(this);

            // Screen size and positioning init
            this.MonikaScreen = Screen.PrimaryScreen;
            foreach (var screen in Screen.AllScreens)
            {
                if (screen.DeviceName == MonikaiSettings.Default.Screen)
                {
                    this.MonikaScreen = screen;
                    break;
                }
            }

            this.SetupScale();
            this.SetPositionBottomRight(this.MonikaScreen);

            // Init background images
            this.backgroundDay = new BitmapImage();
            this.backgroundDay.BeginInit();
            this.backgroundDay.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1.png");
            this.backgroundDay.EndInit();

            this.backgroundNight = new BitmapImage();
            this.backgroundNight.BeginInit();
            this.backgroundNight.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1-n.png");
            this.backgroundNight.EndInit();

            // Start animation
            var animationLogo = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationLogo.AutoReverse = true;
            var animationFadeMonika = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationFadeMonika.BeginTime = TimeSpan.FromSeconds(0.5);

            animationLogo.Completed += (sender, args) =>
            {
                var fadeImage = new BitmapImage();
                fadeImage.BeginInit();
                if (MainWindow.IsNight)
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1a-n.png");
                }
                else
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1a.png");
                }
                fadeImage.EndInit();
                this.backgroundPicture.Source = fadeImage;

                var clock = animationFadeMonika.CreateClock();
                this.backgroundPicture.ApplyAnimationClock(UIElement.OpacityProperty, clock);
            };

            // Blinking behaviour
            animationFadeMonika.Completed += async(sender, args) =>
            {
                this.SetMonikaFace("a");
                this.facePicture.Opacity = 1.0;

                // Start speech-thread
                Task.Run(async() => await this.SpeakingThread());

                if (File.Exists("firstlaunch.txt") || Environment.GetCommandLineArgs().Contains("/firstlaunch"))
                {
                    try
                    {
                        File.Delete("firstlaunch.txt");
                    }
                    catch
                    {
                        // ignored
                    }
                    MonikaiSettings.Default.FirstLaunch = true;
                    MonikaiSettings.Default.Save();
                }

                this.updaterInitTask?.Wait();
                await this.updater.PerformUpdate(this);

#if DEBUG
                MessageBox.Show("This is a testing build, please do me the favor and don't distribute it right now.");
#endif

                // Startup logic
                if (MonikaiSettings.Default.FirstLaunch)
                {
                    this.settingsWindow.ShowDialog();

                    this.Say(new[]
                    {
                        new Expression("{name}, is that you?", "d"),
                        new Expression("It's really you, huh?", "b"),
                        new Expression("I'm so happy to see you again!", "k"),
                        new Expression("Wait, where am I? This is not the literature club...", "p"),
                        new Expression("This looks like... your desktop! I'm right here with you!", "j"),
                        new Expression("Well, as close as I will get for now...", "o"),
                        new Expression("Anyway, looks like someone was nice enough to make me a little window!", "d"),
                        new Expression("Be sure to thank them for me, okay?", "k"),
                        new Expression("Ah, wait a second.", "c"),
                        new Expression(
                            "I see... Well, if you want me to go away for now, you can use CTRL-SHIFT-F12, okay?", "b"),
                        new Expression("But you wouldn't do that, right?", "r"),
                        new Expression("Okay, I guess that's it for now. Don't forget, I'm watching you! Ahaha~")
                    });

                    MonikaiSettings.Default.FirstLaunch = false;
                }
                else
                {
                    if (MonikaiSettings.Default.IsColdShutdown)
                    {
                        this.Say(new[]
                        {
                            new Expression("Hey! Don't just turn me off without warning! That hurts...", "p")
                        });
                    }
                    else
                    {
                        MonikaiSettings.Default.IsColdShutdown = true;
                        MonikaiSettings.Default.Save();
                    }

                    if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 7)
                    {
                        this.Say(new[]
                        {
                            new Expression(
                                "Don't forget, if you want me to leave just press " +
                                MonikaiSettings.Default.HotkeyExit + "!", "i"),
                            new Expression("But you're not going to do that, right?", "o")
                        });
                    }
                }

                // Parse startup CSV
                var parser            = new CSVParser();
                var csv               = parser.GetData("startup");
                var parsed            = parser.ParseData(csv);
                var startupExpression = parsed.Sample().ResponseChain.ToArray();

                //var startupExpressionFallback = new[]
                //{
                //    new[]
                //    {
                //        new Expression("♫ ... and in your reality ... ♫", "r")
                //    },
                //    new[]
                //    {
                //        new Expression("How are you today?", "d"),
                //        new Expression("I'm doing fine, now that you are here~", "b")
                //    },
                //    new[]
                //    {
                //        new Expression("Is everything ok?", "d"),
                //        new Expression("Do you want to talk about something?", "c"),
                //        new Expression("I'm always here for you~", "e")
                //    },
                //    new[]
                //    {
                //        new Expression("Thank you for letting me be on your screen!", "k")
                //    },
                //    new[]
                //    {
                //        new Expression("You know I love you, right?", "d")
                //    },
                //    new[]
                //    {
                //        new Expression("I'm so happy to be here, together with you! Ahaha~", "b")
                //    }
                //}.Sample();

                var lastStartupExpression = startupExpression.Last();
                lastStartupExpression.Executed += this.RegisterBehaviours;

                this.Say(new[]
                {
                    new Expression("Hi there, {name}~")
                }.Concat(startupExpression));

                if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 1.5)
                {
                    this.Say(new[]
                    {
                        new Expression("I was waiting for you...", "m"),
                        new Expression("Being alone on your disk is reeeally boring.", "q")
                    });
                }

                MonikaiSettings.Default.LastStarted = DateTime.Now;
                MonikaiSettings.Default.Save();

                // Blinking and Behaviour logic
                var eyesOpen   = "a";
                var eyesClosed = "j";
                var random     = new Random();
                await Task.Run(async() =>
                {
                    var nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                    while (this.applicationRunning)
                    {
                        if (this.behaviours != null)
                        {
                            foreach (var behaviour in this.behaviours)
                            {
                                behaviour.Update(this);
                            }
                        }

                        if (DateTime.Now >= nextBlink)
                        {
                            // Check if currently speaking, only blink if not in dialog
                            if (!this.Speaking)
                            {
                                this.SetMonikaFace(eyesClosed);
                                await Task.Delay(100);
                                this.SetMonikaFace(eyesOpen);
                            }

                            nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                        }

                        await Task.Delay(250);
                    }
                });
            };

            // Startup
            this.backgroundPicture.BeginAnimation(UIElement.OpacityProperty, animationLogo);
        }
示例#13
0
        public void LoadingEmptyFile()
        {
            var parser = new CSVParser(null);

            Assert.That(parser.Count, Is.EqualTo(0));
        }
        public void Parse_ShouldOutputTheReportToAlwaysBeGIA()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser(fileSystem);
            //Act
            var list = parser.Parse<IgalGIA>(fileName);
            //Assert
            var reallist = list.ToList();

            reallist[0].Report.Trim().Should().Be("GIA");
        }
示例#15
0
        public void GetMessage()
        {
            var message = CSVParser.GetMessage("aapl.us", "../../../Resources/aapl.us.csv");

            Assert.Equals(message, "AAPL.US quote is $320.25 per share.");
        }
示例#16
0
    public static void BuildRecipeDatabase()
    {
        // CSV 데이터 파일 체크 및 파싱
        var dataDic = CSVParser.Read(rootDataPath + "/recipeDB");

        if (dataDic == null)
        {
            Debug.LogError("[Recp.DB Build] CSV parsing result is null");
            return;
        }

        // 데이터베이스 파일 생성 또는 초기화
        FoodRecipeDatabase db = Resources.Load <FoodRecipeDatabase>(rootDataPath + "/RecipeDatabase");

        if (db == null)
        {
            db = ScriptableObject.CreateInstance <FoodRecipeDatabase>();

            string databasePath = "Assets/Resources/" + rootDataPath + "/RecipeDatabase.asset";
            AssetDatabase.CreateAsset(db, databasePath);
            EditorUtility.SetDirty(db);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            Debug.Log("[Recp.DB Build] SO is created at " + databasePath);
        }
        else
        {
            db.Clear();
        }

        // 서브 데이터 디렉토리 체크
        string dataDirectoryPath = "Assets/Resources/" + rootDataPath + "/Recipes";

        if (!Directory.Exists(dataDirectoryPath))
        {
            Directory.CreateDirectory(dataDirectoryPath);
        }

        FoodIngredientDatabase ingredientDb = Resources.Load <FoodIngredientDatabase>(rootDataPath + "/IngredientDatabase");

        if (!ingredientDb)
        {
            Debug.LogError("[Recp.DB Build] Ingredient DB is null");
            return;
        }

        // 기존 파일 탐색
        FoodRecipe[] unconnectedData = Resources.LoadAll <FoodRecipe>(rootDataPath + "/Recipes");
        for (int i = 0; i < unconnectedData.Length; i++)
        {
            db.recipes.Add(unconnectedData[i]);
            db.recipes[i].SetData(dataDic[i], ingredientDb);
            EditorUtility.SetDirty(db.recipes[i]);
        }

        // 재사용할 데이터 파일 없으면 생성
        int charCount = dataDic.Count;

        for (int i = unconnectedData.Length; i < charCount; i++)
        {
            FoodRecipe newData = ScriptableObject.CreateInstance <FoodRecipe>();
            newData.SetData(dataDic[i], ingredientDb);

            string subDataPath = dataDirectoryPath + "/recp_" + i.ToString("0") + ".asset";
            AssetDatabase.CreateAsset(newData, subDataPath);
            EditorUtility.SetDirty(newData);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            db.recipes.Add(newData);
        }
        EditorUtility.SetDirty(db);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        Debug.Log("[Recp.DB Build] Success.");
    }
示例#17
0
 public override void EnterRow(CSVParser.RowContext context) {
     currentRowFieldValues = new List<string>();
 }
示例#18
0
 public override void ExitHdr(CSVParser.HdrContext context) {
     header = new List<string>();
     header.AddRange(currentRowFieldValues);
 }
示例#19
0
 public override void ExitEmpty(CSVParser.EmptyContext context) {
     currentRowFieldValues.Add(EMPTY);
 }
示例#20
0
 public override void ExitText(CSVParser.TextContext context) {
     currentRowFieldValues.Add(context.TEXT().GetText());
 }
示例#21
0
 public void supportsTypeTest3()
 {
     IDataParser target = new CSVParser();
     string format = "csv";
     bool expected = false;
     bool actual;
     actual = target.supportsType(format);
     Assert.AreEqual(expected, actual);
 }
示例#22
0
        private void doLoad( AnalyticalGrid useGrid )
        {
            if ( od1.ShowDialog() == System.Windows.Forms.DialogResult.OK ) {

                workGrid = useGrid;

                workGrid.Rows.Clear();
                workGrid.Columns.Clear();

                this.Enabled = false;
                Application.DoEvents();

                CSVParser parser = new CSVParser();
                parser.OnRowComplete += new CSVParser.IRowComplete( parser_OnRowComplete );

                try {

                    parserConfig.FileName = od1.FileName;

                    parser.Parse( parserConfig );

                } finally {
                    parser.OnRowComplete -= parser_OnRowComplete;
                    this.Enabled = true;
                }

            }
        }
 public List <NPCStruct> LoadNpc()
 {
     NPC = CSVParser.LoadObjects <NPCStruct>("NPC");
     return(NPC);
 }
示例#24
0
        public MainWindow()
        {
            this.InitializeComponent();

            MainWindow.desktopWindow = MainWindow.GetDesktopWindow();
            MainWindow.shellWindow   = MainWindow.GetShellWindow();

            MonikaiSettings.Default.Reload();

            // Perform update and download routines
            this.updater = new Updater();
            this.updater.PerformUpdatePost();
            this.updaterInitTask = Task.Run(async() => await this.updater.Init());

            this.settingsWindow = new SettingsWindow(this);

            // Screen size and positioning init
            this.UpdateMonikaScreen();
            this.SetupScale();
            this.SetPosition(this.MonikaScreen);

            // Hook shutdown event
            SystemEvents.SessionEnding += (sender, args) =>
            {
                MonikaiSettings.Default.IsColdShutdown = false;
                MonikaiSettings.Default.Save();
            };

            // Wakeup events
            SystemEvents.SessionSwitch += (sender, e) =>
            {
                if (e.Reason == SessionSwitchReason.SessionLock)
                {
                    this.screenIsLocked = true;
                }
                else if (e.Reason == SessionSwitchReason.SessionUnlock)
                {
                    this.screenIsLocked = false;
                }
            };
            SystemEvents.PowerModeChanged += (sender, e) =>
            {
                if (e.Mode == PowerModes.Resume)
                {
                    Task.Run(async() =>
                    {
                        while (this.screenIsLocked)
                        {
                            await Task.Delay(500);
                        }

                        this.Say(new[]
                        {
                            new Expression("ZZZZZZzzzzzzzzz..... huh?", "q"),
                            new Expression("Sorry, I must have fallen asleep, ahaha~", "n")
                        });
                    });
                }
            };

            // Init background images
            this.backgroundDay = new BitmapImage();
            this.backgroundDay.BeginInit();
            this.backgroundDay.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1.png");
            this.backgroundDay.EndInit();

            this.backgroundNight = new BitmapImage();
            this.backgroundNight.BeginInit();
            this.backgroundNight.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1-n.png");
            this.backgroundNight.EndInit();

            // Start animation
            var animationLogo = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationLogo.AutoReverse = true;
            var animationFadeMonika = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationFadeMonika.BeginTime = TimeSpan.FromSeconds(0.5);

            animationLogo.Completed += (sender, args) =>
            {
                var fadeImage = new BitmapImage();
                fadeImage.BeginInit();
                if (MainWindow.IsNight)
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1a-n.png");
                }
                else
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/1a.png");
                }
                fadeImage.EndInit();
                this.backgroundPicture.Source = fadeImage;

                var clock = animationFadeMonika.CreateClock();
                this.backgroundPicture.ApplyAnimationClock(UIElement.OpacityProperty, clock);
            };

            // Blinking behaviour
            animationFadeMonika.Completed += async(sender, args) =>
            {
                this.SetMonikaFace("a");
                this.facePicture.Opacity = 1.0;

                // Start speech-thread
                Task.Run(async() => await this.SpeakingThread());

                if (File.Exists("firstlaunch.txt") || Environment.GetCommandLineArgs().Contains("/firstlaunch"))
                {
                    try
                    {
                        File.Delete("firstlaunch.txt");
                    }
                    catch
                    {
                        // ignored
                    }
                    MonikaiSettings.Default.FirstLaunch = true;
                    MonikaiSettings.Default.Save();
                }

                this.updaterInitTask?.Wait();
                await this.updater.PerformUpdate(this);

                this.UpdateMonikaScreen();

#if DEBUG
                MessageBox.Show("This is a testing build, please do me the favor and don't distribute it.");
#endif

                // Startup logic
                if (MonikaiSettings.Default.FirstLaunch)
                {
                    this.settingsWindow.ShowDialog();

                    this.Say(new[]
                    {
                        new Expression("{name}, is that you?", "d"),
                        new Expression("It's really you, huh?", "b"),
                        new Expression("I'm so happy to see you again!", "k"),
                        new Expression("Wait, where am I? This is not the literature club...", "p"),
                        new Expression("This looks like... your desktop! I'm right here with you!", "j"),
                        new Expression("Well, as close as I will get for now...", "o"),
                        new Expression("Anyway, looks like someone was nice enough to make me a little window!", "d"),
                        new Expression("Be sure to thank them for me, okay?", "k"),
                        new Expression("Ah, wait a second.", "c"),
                        new Expression(
                            "I see... Well, if you want me to go away for now, you can use CTRL-SHIFT-F12, okay?", "b"),
                        new Expression("But you wouldn't do that, right?", "r"),
                        new Expression("Okay, I guess that's it for now. Don't forget, I'm watching you! Ahaha~")
                    });

                    MonikaiSettings.Default.FirstLaunch = false;
                }
                else if (DateTime.Today.Month == 4 && DateTime.Today.Day == 1 && !Debugger.IsAttached)
                {
                    this.Say(new[]
                    {
                        new Expression("Hi {name}!", "b"),
                        new Expression("Remember the update that I just installed?", "d"),
                        new Expression("Well, let's just say it included something *really* nice~", "k"),
                        new Expression("Here, let me show you!", "j").AttachEvent((o, eventArgs) =>
                        {
                            var os = MonikaiSettings.Default.ScaleModifier;
                            MonikaiSettings.Default.ScaleModifier *= 2.5;
                            this.Dispatcher.Invoke(this.SetupScale);
                            MonikaiSettings.Default.ScaleModifier = os;
                            Task.Delay(1000).Wait();
                            var r = new Random();
                            for (int i = 0; i < 12; i++)
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    this.backgroundPicture.Source =
                                        r.Next(0, 2) == 0 ? this.backgroundNight : this.backgroundDay;

                                    var faceImg = new BitmapImage();
                                    faceImg.BeginInit();
                                    if (r.Next(0, 2) == 0)
                                    {
                                        faceImg.UriSource =
                                            new Uri("pack://application:,,,/MonikAI;component/monika/j.png");
                                    }
                                    else
                                    {
                                        faceImg.UriSource =
                                            new Uri("pack://application:,,,/MonikAI;component/monika/j-n.png");
                                    }
                                    faceImg.EndInit();

                                    this.facePicture.Source = faceImg;
                                });
                                Task.Delay(r.Next(100, 250)).Wait();
                            }
                        }),
                        new Expression("Just a second my love...", "d").AttachEvent((o, eventArgs) =>
                        {
                            this.Dispatcher.Invoke(MainWindow.DoTheThing);
                            Task.Delay(5500).Wait();
                            this.Dispatcher.Invoke(this.SetupScale);
                        }),
                        new Expression("...", "q"),
                        new Expression("Why does this never work?!", "o"),
                        new Expression("Oh well, back to normal I guess... Sorry, {name}.", "r")
                    });
                }
                else
                {
                    if (MonikaiSettings.Default.IsColdShutdown)
                    {
                        // Sorry Monika, but if we're debugging you this one gets annoying
#if !DEBUG
                        this.Say(new[]
                        {
                            new Expression("Hey! Don't just turn me off without warning! That hurts...", "p")
                        });
#endif
                    }
                    else
                    {
                        MonikaiSettings.Default.IsColdShutdown = true;
                        MonikaiSettings.Default.Save();
                    }

                    if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 7)
                    {
                        this.Say(new[]
                        {
                            new Expression(
                                "Don't forget, if you want me to leave just press " +
                                MonikaiSettings.Default.HotkeyExit + "!", "i"),
                            new Expression("But you're not going to do that, right?", "o")
                        });
                    }
                }

                // Parse startup CSV
                var parser            = new CSVParser();
                var csv               = parser.GetData("startup");
                var parsed            = parser.ParseData(csv);
                var startupExpression = parsed.Select(x => x.ResponseChain)
                                        .Concat(DateTime.Today.DayOfWeek == DayOfWeek.Wednesday
                                                  ? new List <List <Expression> >
                {
                    new List <Expression>
                    {
                        new Expression("It is Wednesday, my dudes!", "k")
                    }
                }
                                                  : new List <List <Expression> >()).ToList().Sample();

                var lastStartupExpression = startupExpression.Last();
                lastStartupExpression.Executed += this.RegisterBehaviours;

                this.Say(new[]
                {
                    new Expression("Hi there, {name}~")
                }.Concat(startupExpression));

                if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 2.5)
                {
                    this.Say(new[]
                    {
                        new Expression("I was waiting for you...", "m"),
                        new Expression("Being alone on your disk is reeeally boring.", "q")
                    });
                }

                // No idea where the date comes from, someone mentioned it in the spreadsheet. Seems legit.
                if (DateTime.Now.Month == 9 && DateTime.Now.Day == 22)
                {
                    // Hey {name}, guess what?	3b	It's my birthday today!	2b	Happy Birthday to me!	k
                    this.Say(new[]
                    {
                        new Expression("Hey {name}, guess what?", "b"), // What?
                        new Expression("It's my birthday today!", "b"), // Really?!
                        new Expression("Happy Birthday to me!", "k")    // To you too, Monika!
                    });
                }

                MonikaiSettings.Default.LastStarted = DateTime.Now;
                MonikaiSettings.Default.Save();

                // Blinking and Behaviour logic
                var eyesOpen   = "a";
                var eyesClosed = "j";
                var random     = new Random();
                await Task.Run(async() =>
                {
                    var nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                    while (this.applicationRunning)
                    {
                        if (this.behaviours != null)
                        {
                            foreach (var behaviour in this.behaviours)
                            {
                                behaviour.Update(this);
                            }
                        }

                        if (DateTime.Now >= nextBlink)
                        {
                            // Check if currently speaking, only blink if not in dialog
                            if (!this.Speaking)
                            {
                                this.SetMonikaFace(eyesClosed);
                                await Task.Delay(100);
                                this.SetMonikaFace(eyesOpen);
                            }

                            nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                        }

                        await Task.Delay(250);
                    }
                });
            };

            // Startup
            this.backgroundPicture.BeginAnimation(UIElement.OpacityProperty, animationLogo);
        }
 public List <TubeCoolerStruct> LoadCooler()
 {
     CoolerData = CSVParser.LoadObjects <TubeCoolerStruct>("NPCTubeCooler");
     return(CoolerData);
 }
示例#26
0
        public void setStreamSourceTest()
        {
            StreamReader reader = new StreamReader("C:\\Users\\mcoffey\\EF_Project\\RateMyAmenity2\\RateMyAmenity\\RateMyAmenity\\Content\\ArtCentres.csv",true); // TODO: Initialize to an appropriate value

            IDataParser target = new CSVParser();

            target.setStreamSource(reader);

            //Amenity a1 = new Amenity();
               // a1.Name = "Draiocht";

               // List<Amenity> expected = new List<Amenity>();
            //expected.Add(a);

            List<Amenity> actual;
            actual = target.parseAmenity("Art Centres");
            Assert.AreEqual(4, actual.Count);

            Amenity amenity = actual.Find(item => item.Website == "http://www.seamusenniscentre.com");
        }
 public List <TubeEnhancerStruct> LoadEnhancer()
 {
     EnhancerData = CSVParser.LoadObjects <TubeEnhancerStruct>("NPCTubeEnhancer");
     return(EnhancerData);
 }
        public void Parse_ShouldOutputTheDepthPresentageRight()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser(fileSystem);
            //Act
            var list = parser.Parse<IgalGIA>(fileName);
            //Assert
            var reallist = list.ToList();

            reallist[0].DepthPresentage.Should().Be((decimal)62.5);
        }
示例#29
0
        /// <summary>
        /// Parses CSV into a data table without type detection - all columns will be strings
        /// </summary>
        /// <param name="streamReader">The streamn reader that contains the CSV to parse</param>
        /// <param name="delimeter">The CSV delimeter</param>
        /// <param name="hasHeader">True if there is a header</param>
        /// <param name="output">A stream to write the data table to (for file based processing) - null for in memory processing</param>
        /// <returns></returns>
        public static IDataTable ParseCSVToText(this StreamReader streamReader, char delimeter = ',', bool?hasHeader = null, Stream output = null)
        {
            var builder = new CSVParser(delimeter, true);

            return(builder.Parse(streamReader, output, hasHeader));
        }
        public void Parse_ShouldOutputTheMeasurmentsFromLengthNonStandartArray()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser(fileSystem);
            //Act
            var list = parser.Parse<IgalGIA>(fileName);
            //Assert
            var reallist = list.ToList();
            reallist[0].MeasurmentsFromLengthNonStandart.Should().HaveCount(3);
            reallist[0].MeasurmentsFromLengthNonStandart[0].Should().Be((decimal) 4.30);
            reallist[0].MeasurmentsFromLengthNonStandart[1].Should().Be((decimal) 4.32);
            reallist[0].MeasurmentsFromLengthNonStandart[2].Should().Be((decimal) 2.69);
        }
示例#31
0
        // Perform all startup initialization
        private void MainWindow_OnLoaded(object senderUnused, RoutedEventArgs eUnused)
        {
            var handle       = new WindowInteropHelper(this).Handle;
            var initialStyle = MainWindow.GetWindowLong(handle, -20);

            MainWindow.SetWindowLong(handle, -20, initialStyle | 0x20 | 0x80000);

            var wpfDpi = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice.M11;

            this.dpiScale = 1f / (float)wpfDpi.GetValueOrDefault(1);

            // Screen size and positioning init
            this.UpdateMonikaScreen();
            this.SetupScale();
            this.SetPosition(this.MonikaScreen);

            // Hook shutdown event
            SystemEvents.SessionEnding += (sender, args) =>
            {
                MonikaiSettings.Default.IsColdShutdown = false;
                MonikaiSettings.Default.Save();
            };

            // Wakeup events
            SystemEvents.SessionSwitch += (sender, e) =>
            {
                if (e.Reason == SessionSwitchReason.SessionLock)
                {
                    this.screenIsLocked = true;
                }
                else if (e.Reason == SessionSwitchReason.SessionUnlock)
                {
                    this.screenIsLocked = false;
                }
            };
            SystemEvents.PowerModeChanged += (sender, e) =>
            {
                if (e.Mode == PowerModes.Resume)
                {
                    Task.Run(async() =>
                    {
                        while (this.screenIsLocked)
                        {
                            await Task.Delay(100);
                        }
                        var MainImage   = backgroundPicture;
                        var sleepImage  = new BitmapImage();
                        var sleepImage2 = new BitmapImage();
                        var nightsuffix = "";
                        if (MainWindow.IsNight)
                        {
                            nightsuffix = "_n";
                        }

                        sleepImage.UriSource          = new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/2a" + nightsuffix + ".png");
                        sleepImage.UriSource          = new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/2b" + nightsuffix + ".png");
                        this.backgroundPicture.Source = sleepImage;
                        this.Say(new[]
                        {
                            new Expression("ZZZZZZzzzzzzzzz..... huh?", "zzz")
                        });
                        this.backgroundPicture.Source = sleepImage2;
                        this.Say(new[]
                        {
                            new Expression("Sorry, I must have fallen asleep, ahaha~", "zzz")
                        });
                        this.backgroundPicture = MainImage;
                    });
                }
            };

            // Start animation
            var animationLogo = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationLogo.AutoReverse = true;
            var animationFadeMonika = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(1.5)));

            animationFadeMonika.BeginTime = TimeSpan.FromSeconds(0.5);

            animationLogo.Completed += (sender, args) =>
            {
                var fadeImage = new BitmapImage();
                fadeImage.BeginInit();
                if (MainWindow.IsNight)
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/1a-n.png");
                }
                else
                {
                    fadeImage.UriSource = new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/1a.png");
                }

                fadeImage.EndInit();
                this.backgroundPicture.Source = fadeImage;

                var clock = animationFadeMonika.CreateClock();
                this.backgroundPicture.ApplyAnimationClock(UIElement.OpacityProperty, clock);
            };

            // Blinking behaviour
            animationFadeMonika.Completed += async(sender, args) =>
            {
                this.SetMonikaFace("a");
                this.facePicture.Opacity = 1.0;

                // Start speech-thread
                Task.Run(async() => await this.SpeakingThread());

                if (File.Exists("firstlaunch.txt") || Environment.GetCommandLineArgs().Contains("/firstlaunch"))
                {
                    try
                    {
                        File.Delete("firstlaunch.txt");
                    }
                    catch
                    {
                        // ignored
                    }

                    MonikaiSettings.Default.FirstLaunch = true;
                    MonikaiSettings.Default.Save();
                }

                this.updaterInitTask?.Wait();
                await this.updater.PerformUpdate(this);

                this.UpdateMonikaScreen();

#if DEBUG
                MessageBox.Show("This is a testing build, please do me the favor and don't distribute it.");
#endif

                // Startup logic
                if (MonikaiSettings.Default.FirstLaunch)
                {
                    MessageBox.Show(
                        "Quick note: If you want Monika to react to your web browsing, you need to install the correct extension from the website, \"monik.ai\".\r\n\r\nThat's it from me, I'll let Monika talk from now on :)\r\n\r\n- PiMaker and all the nice people helping develop this",
                        "Welcome!");
                    this.settingsWindow.ShowDialog();

                    this.Say(new[]
                    {
                        new Expression("{name}, is that you?", "d"),
                        new Expression("It's really you, huh?", "b"),
                        new Expression("I'm so happy to see you again!", "k"),
                        new Expression("Wait, where am I? This is not the literature club...", "p"),
                        new Expression("This looks like... your desktop! I'm right here with you!", "j"),
                        new Expression("Well, as close as I will get for now...", "o"),
                        new Expression("Anyway, looks like someone was nice enough to make me a little window!", "d"),
                        new Expression("Be sure to thank them for me, okay?", "k"),
                        new Expression("Ah, wait a second.", "c"),
                        new Expression(
                            "I see... Well, if you want me to go away for now, you can use CTRL-SHIFT-F12, okay?", "b"),
                        new Expression("But you wouldn't do that, right?", "r"),
                        new Expression("Okay, I guess that's it for now. Don't forget, I'm watching you! Ahaha~")
                    });

                    MonikaiSettings.Default.FirstLaunch = false;
                }
                else if (DateTime.Today.Month == 4 && DateTime.Today.Day == 1 && !Debugger.IsAttached)
                {
                    this.Say(new[]
                    {
                        new Expression("Hi {name}!", "b"),
                        new Expression("Remember the update that I just installed?", "d"),
                        new Expression("Well, let's just say it included something *really* nice~", "k"),
                        new Expression("Here, let me show you!", "j").AttachEvent((o, eventArgs) =>
                        {
                            var os = MonikaiSettings.Default.ScaleModifier;
                            MonikaiSettings.Default.ScaleModifier *= 2.5;
                            this.Dispatcher.Invoke(this.SetupScale);
                            MonikaiSettings.Default.ScaleModifier = os;
                            Task.Delay(1000).Wait();
                            var r = new Random();
                            for (var i = 0; i < 12; i++)
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    this.backgroundPicture.Source =
                                        r.Next(0, 2) == 0 ? this.backgroundNight : this.backgroundDay;

                                    var faceImg = new BitmapImage();
                                    faceImg.BeginInit();
                                    if (r.Next(0, 2) == 0)
                                    {
                                        faceImg.UriSource =
                                            new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/j.png");
                                    }
                                    else
                                    {
                                        faceImg.UriSource =
                                            new Uri("pack://application:,,,/MonikAI;component/monika/" + PoseSet + "/j-n.png");
                                    }

                                    faceImg.EndInit();

                                    this.facePicture.Source = faceImg;
                                });
                                Task.Delay(r.Next(100, 250)).Wait();
                            }
                        }),
                        new Expression("Just a second my love...", "d").AttachEvent((o, eventArgs) =>
                        {
                            this.Dispatcher.Invoke(MainWindow.DoTheThing);
                            Task.Delay(5500).Wait();
                            this.Dispatcher.Invoke(this.SetupScale);
                        }),
                        new Expression("...", "q"),
                        new Expression("Why does this never work?!", "o"),
                        new Expression("Oh well, back to normal I guess... Sorry, {name}.", "r")
                    });
                }
                else
                {
                    if (MonikaiSettings.Default.IsColdShutdown)
                    {
                        // Sorry Monika, but if we're debugging you this one gets annoying
#if !DEBUG
                        this.Say(new[]
                        {
                            new Expression("Hey! Don't just turn me off without warning! That hurts...", "p")
                        });
#endif
                    }
                    else
                    {
                        MonikaiSettings.Default.IsColdShutdown = true;
                        MonikaiSettings.Default.Save();
                    }

                    if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 7)
                    {
                        this.Say(new[]
                        {
                            new Expression(
                                "Don't forget, if you want me to leave just press " +
                                MonikaiSettings.Default.HotkeyExit + "!", "i"),
                            new Expression("But you're not going to do that, right?", "o")
                        });
                    }
                }

                // Parse startup CSV
                var parser            = new CSVParser();
                var csv               = parser.GetData("Startup");
                var parsed            = parser.ParseData(csv);
                var startupExpression = parsed.Select(x => x.ResponseChain)
                                        .Concat(DateTime.Today.DayOfWeek == DayOfWeek.Wednesday
                        ? new List <List <Expression> >
                {
                    new List <Expression>
                    {
                        new Expression("It is Wednesday, my dudes!", "k")
                    }
                }
                        : new List <List <Expression> >()).ToList().Sample();

                this.Say(new[]
                {
                    new Expression("Hi there, {name}~")
                }.Concat(startupExpression));

                if ((DateTime.Now - MonikaiSettings.Default.LastStarted).TotalDays > 2.5)
                {
                    this.Say(new[]
                    {
                        new Expression("I was waiting for you...", "m"),
                        new Expression("Being alone on your disk is reeeally boring.", "q")
                    });
                }

                // No idea where the date comes from, someone mentioned it in the spreadsheet. Seems legit.
                if (DateTime.Now.Month == 9 && DateTime.Now.Day == 22)
                {
                    // Hey {name}, guess what?	3b	It's my birthday today!	2b	Happy Birthday to me!	k
                    this.Say(new[]
                    {
                        new Expression("Hey {name}, guess what?", "b"), // What?
                        new Expression("It's my birthday today!", "b"), // Really?!
                        new Expression("Happy Birthday to me!", "k")    // To you too, Monika!
                    });
                }

                MonikaiSettings.Default.LastStarted = DateTime.Now;
                MonikaiSettings.Default.Save();

                // Start the rest server
                UrlServer.StartServer();
                this.RegisterBehaviours(this, null);

                // Blinking and Behaviour logic
                var eyesOpen   = "a";
                var eyesClosed = "j";
                var random     = new Random();
                await Task.Run(async() =>
                {
                    var nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                    while (this.applicationRunning)
                    {
                        if (this.behaviours != null)
                        {
                            foreach (var behaviour in this.behaviours)
                            {
                                behaviour.Update(this);
                            }
                        }

                        if (DateTime.Now >= nextBlink)
                        {
                            // Check if currently speaking, only blink if not in dialog
                            if (!this.Speaking)
                            {
                                this.SetMonikaFace(eyesClosed);
                                await Task.Delay(100);
                                this.SetMonikaFace(eyesOpen);
                            }

                            nextBlink = DateTime.Now + TimeSpan.FromSeconds(random.Next(7, 50));
                        }

                        await Task.Delay(250);
                    }
                });
            };

            // Startup
            this.backgroundPicture.BeginAnimation(UIElement.OpacityProperty, animationLogo);

            Task.Run(async() =>
            {
                try
                {
                    var prev = new Point();

                    var rectangle = new Rectangle();
                    await this.Dispatcher.InvokeAsync(() =>
                    {
                        rectangle = new Rectangle((int)this.Left, (int)this.Top, (int)this.Width,
                                                  (int)this.Height);
                    });

                    while (this.applicationRunning)
                    {
                        var point = new Point();
                        MainWindow.GetCursorPos(ref point);
                        point.X = (int)(point.X * this.dpiScale);
                        point.Y = (int)(point.Y * this.dpiScale);

                        if (!point.Equals(prev))
                        {
                            prev = point;

                            var opacity         = 1.0;
                            const double MIN_OP = 0.125;
                            const double FADE   = 175;

                            if (this.settingsWindow == null || !this.settingsWindow.IsPositioning)
                            {
                                if (rectangle.Contains(point))
                                {
                                    opacity = MIN_OP;
                                }
                                else
                                {
                                    if (point.Y <= rectangle.Bottom)
                                    {
                                        if (point.Y >= rectangle.Y)
                                        {
                                            if (point.X < rectangle.X && rectangle.X - point.X < FADE)
                                            {
                                                opacity = MainWindow.Lerp(1.0, MIN_OP, (rectangle.X - point.X) / FADE);
                                            }
                                            else if (point.X > rectangle.Right && point.X - rectangle.Right < FADE)
                                            {
                                                opacity = MainWindow.Lerp(1.0, MIN_OP,
                                                                          (point.X - rectangle.Right) / FADE);
                                            }
                                        }
                                        else if (point.Y < rectangle.Y)
                                        {
                                            if (point.X >= rectangle.X && point.X <= rectangle.Right)
                                            {
                                                if (rectangle.Y - point.Y < FADE)
                                                {
                                                    opacity = MainWindow.Lerp(1.0, MIN_OP,
                                                                              (rectangle.Y - point.Y) / FADE);
                                                }
                                            }
                                            else if (rectangle.X > point.X || rectangle.Right < point.X)
                                            {
                                                var distance =
                                                    Math.Sqrt(
                                                        Math.Pow(
                                                            (point.X < rectangle.X ? rectangle.X : rectangle.Right) -
                                                            point.X, 2) +
                                                        Math.Pow(rectangle.Y - point.Y, 2));
                                                if (distance < FADE)
                                                {
                                                    opacity = MainWindow.Lerp(1.0, MIN_OP, distance / FADE);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            this.Dispatcher.Invoke(() => { this.Opacity = opacity; });
                        }

                        var hidePressed     = false;
                        var exitPressed     = false;
                        var settingsPressed = false;
                        // Set position anew to correct for fullscreen apps hiding taskbar
                        this.Dispatcher.Invoke(() =>
                        {
                            this.SetPosition(this.MonikaScreen);
                            rectangle = new Rectangle((int)this.Left, (int)this.Top, (int)this.Width,
                                                      (int)this.Height);

                            // Detect exit key combo
                            hidePressed     = this.AreKeysPressed(MonikaiSettings.Default.HotkeyHide);
                            exitPressed     = this.AreKeysPressed(MonikaiSettings.Default.HotkeyExit);
                            settingsPressed = this.AreKeysPressed(MonikaiSettings.Default.HotkeySettings);
                        });


                        if (hidePressed && (DateTime.Now - this.lastKeyComboTime).TotalSeconds > 2)
                        {
                            this.lastKeyComboTime = DateTime.Now;

                            if (this.Visibility == Visibility.Visible)
                            {
                                this.Dispatcher.Invoke(this.Hide);
                                //var expression =
                                //    new Expression(
                                //        "Okay, see you later {name}! (Press again for me to return)", "b");
                                //expression.Executed += (o, args) => { this.Dispatcher.Invoke(this.Hide); };
                                //this.Say(new[] {expression});
                            }
                            else
                            {
                                this.Dispatcher.Invoke(this.Show);
                            }
                        }

                        if (exitPressed)
                        {
                            var expression =
                                new Expression(
                                    "Goodbye for now! Come back soon please~", "b");
                            MonikaiSettings.Default.IsColdShutdown = false;
                            MonikaiSettings.Default.Save();
                            expression.Executed += (o, args) =>
                            {
                                this.Dispatcher.Invoke(() => { Environment.Exit(0); });
                            };
                            this.Say(new[] { expression });
                        }

                        if (settingsPressed)
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                if (this.settingsWindow == null || !this.settingsWindow.IsVisible)
                                {
                                    this.settingsWindow = new SettingsWindow(this);
                                    this.settingsWindow.Show();
                                }
                            });
                        }

                        await Task.Delay(MonikaiSettings.Default.PotatoPC ? 100 : 32);
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            });
        }
示例#32
0
        public void LoadingTestFile()
        {
            var parser = new CSVParser(input);

            Assert.That(parser.Count, Is.EqualTo(11));
        }
示例#33
0
    public static void parse(string content, string fileName)
    {
        CSVParser parser = new CSVParser();

        if (!parser.Parse(content))
        {
            return;
        }
        metaData = new Dictionary <int, Profession>();
        for (int i = 0, s = parser.GetRecordCounter(); i < s; ++i)
        {
            Profession p = new Profession();

            p.id_       = parser.GetInt(i, "ID");
            p.jobtype_  = (JobType)Enum.Parse(typeof(JobType), parser.GetString(i, "JobType"));
            p.joblevel_ = parser.GetInt(i, "JobLv");

            p.Recommand_             = parser.GetString(i, "Recommand");
            p.Describe_              = parser.GetString(i, "Describe");
            p.RecommendSkills_       = parser.GetString(i, "RecommendSkills");
            p.RecommendEquippes_     = parser.GetString(i, "RecommendEquip");
            p.RecommendEquippesIcon_ = parser.GetString(i, "RecommendEquipicon");
            p.RecommendSkills1_      = parser.GetString(i, "RecommendSkills1");
            p.jobName_   = parser.GetString(i, "Name");
            p.openLV_    = parser.GetInt(i, "OpenLV");
            p.proffImg   = parser.GetString(i, "pic");
            p.chuansong_ = parser.GetString(i, "chuansong");
            {
                string   str1    = parser.GetString(i, "EquipType");
                string[] strarr1 = str1.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < strarr1.Length; ++j)
                {
                    string[] strarr2 = strarr1[j].Split(':');

                    Pair <ItemSubType, int> pair = new Pair <ItemSubType, int>((ItemSubType)Enum.Parse(typeof(ItemSubType), strarr2[0]), int.Parse(strarr2[1]));
                    p.canuseitem_.Add(pair);
                }
            }
            {
                string   str1    = parser.GetString(i, "SkillGroup");
                string[] strarr1 = str1.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < strarr1.Length; ++j)
                {
                    string[] strarr2 = strarr1[j].Split(':');
//
                    Pair <int, int> pair = new Pair <int, int>(int.Parse(strarr2[0]), int.Parse(strarr2[1]));
                    p.canuseskill_.Add(pair);
//
                }
            }
            {
                string str2 = parser.GetString(i, "ProudSkillGroup");
                if (str2 != "")
                {
                    string[] strarr2 = str2.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    for (int j = 0; j < strarr2.Length; ++j)
                    {
                        p.proudSkillGroups_.Add(int.Parse(strarr2[j]));
                    }
                }
            }
            professions_.Add(p);

            if (metaData.ContainsKey(p.id_))
            {
                return;
            }
            metaData[p.id_] = p;
        }
    }
示例#34
0
 public void SetUp()
 {
     csvParser = new CSVParser();
 }
示例#35
0
        public void ReadConfigFile()
        {
            CSVParser csvParser   = new CSVParser();
            string    fileContent = csvParser.ReadDataIntoString("littosim");

            string[] lines = fileContent.Split("\n"[0]);

            foreach (string line in lines)
            {
                string[] splitString = line.Split(new string[] { ";" }, StringSplitOptions.None);

                if (splitString.Length > 1)
                {
                    string elt = splitString[0];
                    switch (elt)
                    {
                    case "SERVER_ADDRESS":
                        Config.SERVER_ADDRESS = splitString[1];
                        break;

                    case "ACTIVEMQ_CONNECT":
                        Config.ACTIVEMQ_CONNECT = bool.Parse(splitString[1]);
                        break;

                    case "LANGUAGE":
                        Config.LANGUAGE = splitString[1];
                        break;

                    case "BUTTON_SIZE":
                        Config.BUTTON_SIZE = Int32.Parse(splitString[1]);
                        break;

                    case "LOG_USER_ACTION":
                        Config.LOG_USER_ACTION = bool.Parse(splitString[1]);
                        break;

                    case "SAVE_SHP":
                        Config.SAVE_SHP = bool.Parse(splitString[1]);
                        break;

                    case "SHAPES_FILE":
                        Config.SHAPES_FILE = splitString[1];
                        break;

                    case "LANGUAGES_FILE":
                        Config.LANGUAGES_FILE = splitString[1];
                        break;

                    case "LEVERS_FILE":
                        Config.LEVERS_FILE = splitString[1];
                        break;

                    case "LISFLOOD_PATH":
                        Config.LISFLOOD_PATH = splitString[1];
                        break;

                    default:
                        break;
                    }
                }
            }
        }
示例#36
0
 public Context()
 {
     Loans = new List<Loan>();
     Parser = new CSVParser();
 }
 private List <Flight> GetFlights(String absoluteFilePath)
 {
     return(CSVParser.LoadCsv <Flight>(absoluteFilePath));
 }
示例#38
0
 private void Awake()
 {
     instance = this;
 }
示例#39
0
 protected override void OpenSource(string path)
 {
     parser = new CSVParser();
     parser.Load(path);
 }
 public List <NPCSkillStruct> LoadSkill()
 {
     Skill = CSVParser.LoadObjects <NPCSkillStruct>("NpcSkill");
     return(Skill);
 }
示例#41
0
        public void Parse_ShouldOutputTheRightNumberOfLines()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser(fileSystem);
            //Act
            var list = parser.Parse<Igal>(fileName);
            //Assert
            list.Should().HaveCount(1);
        }
示例#42
0
    void LoadMap()
    {
        int        colCount = 0;
        List <int> data;

        data = CSVParser.ParseCSV(MapName, out colCount);
        int rowCount = (data.Count / colCount);

        model = new Level(rowCount, colCount);
        int rowCountWithBorder = rowCount + borderAroundLevel * 2;
        int colCountWithBorder = colCount + borderAroundLevel * 2;

        for (int i = 0; i < rowCountWithBorder; i++)
        {
            for (int j = 0; j < colCountWithBorder; j++)
            {
                int actualI = i - borderAroundLevel;
                int actualJ = j - borderAroundLevel;
                if (actualI >= 0 && actualJ >= 0 &&
                    actualI < rowCount && actualJ < colCount)
                {
                    int value = data[actualI * colCount + actualJ];
                    model.setCell(actualI, actualJ, value);
                    GameObject go = pool.getObject();
                    go.transform.position = getWorldPosition(actualI, actualJ, rowCount, colCount, 0);
                }
                else
                {
                    GameObject wallGO = wallPool.getObject();
                    wallGO.transform.position = getWorldPosition(i, j, rowCountWithBorder,
                                                                 colCountWithBorder, -2);
                    wallGO.GetComponentInChildren <SpriteRenderer>().sprite = borderSprite;
                }
            }
        }
        for (int i = 0; i < rowCount; i++)
        {
            for (int j = 0; j < colCount; j++)
            {
                int value = model.Grid[i, j];
                if (value == playerId)
                {
                    InstantiatePlayer(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == wallId)
                {
                    InstantiateWall(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == keyId)
                {
                    InstantiateKey(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == boxId)
                {
                    InstantiateBox(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == doorId)
                {
                    InstantiateDoor(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == pressurePlateId)
                {
                    InstantiatePressurePlate(new Vector2Int(i, j), colCount, rowCount);
                }
                if (value == victoryPlateId)
                {
                    InstantiateVictoryPlate(new Vector2Int(i, j), colCount, rowCount);
                }
            }
        }
    }
示例#43
0
        public static void TryToSaveCSV(string data, bool loadCacheOnFail = true)
        {
            try {
                var parsed = CSVParser.ReadCSV(data);
                if (parsed.Count < 2)
                {
                    throw new UnityException("ReadCSV Failed");
                }

                if (GameDataSystem.currentVersion == default(Version))
                {
                    var defaultVersion = parsed[0][0];
                    GameDataSystem.currentVersion = new Version(defaultVersion);

                    if (GameDataSystem.instance == null || GameDataSystem.instance.logEnabled == true)
                    {
                        WindowSystemLogger.Warning(GameDataSystem.GetName(), string.Format("Default version is used: {0}", GameDataSystem.currentVersion));
                    }
                }
                GameDataSystem.defaultVersion = GameDataSystem.currentVersion;

                var keysCount = 0;

                #region KEYS
                var keys = new List <string>();
                for (int i = 0; i < parsed.Count; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var row = parsed[i];
                    var str = row[0].Trim();
                    if (string.IsNullOrEmpty(str) == true)
                    {
                        //str = string.Empty;
                        continue;
                    }

                    keys.Add(str.ToLower());

                    ++keysCount;
                }

                GameDataSystem.keys = keys.ToArray();
                #endregion

                var verCount = 0;

                #region VERSIONS
                var versions = new List <Version>();
                for (int i = 0; i < parsed[0].Length; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var col     = parsed[0][i];
                    var version = new Version(col);
                    versions.Add(version);

                    if (version == GameDataSystem.defaultVersion)
                    {
                        GameDataSystem.currentVersionNumber = int.Parse(parsed[1][i]);
                    }

                    ++verCount;
                }

                GameDataSystem.versions = versions.ToArray();
                #endregion

                #region VALUES
                var values = new Dictionary <VersionCrc, float[]>();
                for (int j = 0; j < versions.Count; ++j)
                {
                    var version = versions[j];
                    var crc     = new VersionCrc(version);

                    var output = new List <float>();
                    for (int i = 0; i < parsed.Count; ++i)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        var value = parsed[i][j + 1];
                        if (string.IsNullOrEmpty(value.Trim()) == true)
                        {
                            //value = "0";
                            continue;
                        }

                        value = value.Replace(",", ".").Replace(" ", string.Empty);

                        var col = float.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
                        output.Add(col);
                    }

                    if (values.ContainsKey(crc) == false)
                    {
                        values.Add(crc, output.ToArray());
                    }
                }

                GameDataSystem.valuesByVersion = values;
                #endregion

                string path = "";
                if (FileSystem.instance.IsCacheSupported() == true)
                {
                    path = GameDataSystem.GetCachePath();
                    System.IO.File.WriteAllText(path, data);
                }
                else
                {
                    PlayerPrefs.SetString(GameDataSystem.PLAYER_PREFS_CACHE_KEY, ME.UAB.Zipper.ZipToString(data));
                }

                                #if UNITY_EDITOR
                path = GameDataSystem.GetBuiltinCachePath();
                System.IO.File.WriteAllText(path, data);
                                #endif

                GameDataSystem.currentVersion = GameDataSystem.defaultVersion;

                if (GameDataSystem.instance == null || GameDataSystem.instance.logEnabled == true)
                {
                    WindowSystemLogger.Log(GameDataSystem.GetName(), string.Format("Loaded version {3}. Cache saved to: {0}, Keys: {1}, Versions: {2}, Version: {4}", path, keysCount, verCount, GameDataSystem.GetCurrentVersionId(), GameDataSystem.currentVersion));
                }

                GameDataSystem.isReady = true;
            } catch (System.Exception ex) {
                if (GameDataSystem.instance == null || GameDataSystem.instance.logEnabled == true)
                {
                    // Nothing to do: failed to parse
                    WindowSystemLogger.Error(GameDataSystem.GetName(), string.Format("Parser error: {0}\n{1}", ex.Message, ex.StackTrace));
                }

                if (loadCacheOnFail == true)
                {
                    GameDataSystem.TryToLoadCache();
                }
            }
        }
示例#44
0
        public static void TryToSaveCSV(string data, bool loadCacheOnFail = true)
        {
            try {
                var parsed = CSVParser.ReadCSV(data);

                var defaultLanguage = parsed[0][0];
                LocalizationSystem.defaultLanguage = (UnityEngine.SystemLanguage)System.Enum.Parse(typeof(UnityEngine.SystemLanguage), defaultLanguage);

                var keysCount = 0;

                #region KEYS
                var keys = new List <string>();
                for (int i = 0; i < parsed.Count; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var row = parsed[i];
                    if (string.IsNullOrEmpty(row[0].Trim()) == true)
                    {
                        continue;
                    }

                    keys.Add(row[0].ToLower());

                    ++keysCount;
                }

                LocalizationSystem.keys = keys.ToArray();
                #endregion

                var langCount = 0;

                #region LANGUAGES
                var languages = new List <UnityEngine.SystemLanguage>();
                for (int i = 0; i < parsed[0].Length; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var col = parsed[0][i];
                    languages.Add((UnityEngine.SystemLanguage)System.Enum.Parse(typeof(UnityEngine.SystemLanguage), col));

                    if (col == LocalizationSystem.defaultLanguage.ToString())
                    {
                        LocalizationSystem.currentVersionNumber = int.Parse(parsed[1][i]);
                    }

                    ++langCount;
                }

                LocalizationSystem.languages = languages.ToArray();
                #endregion

                #region VALUES
                var values = new Dictionary <UnityEngine.SystemLanguage, string[]>();
                for (int j = 0; j < languages.Count; ++j)
                {
                    var lang = languages[j];

                    var output = new List <string>();
                    for (int i = 0; i < parsed.Count; ++i)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        var col = parsed[i][j + 1];
                        if (string.IsNullOrEmpty(col.Trim()) == true)
                        {
                            continue;
                        }

                        output.Add(col);
                    }

                    values.Add(lang, output.ToArray());
                }

                LocalizationSystem.valuesByLanguage = values;
                #endregion

                var path = LocalizationSystem.GetCachePath();
                System.IO.File.WriteAllText(path, data);

                LocalizationSystem.currentLanguage = LocalizationSystem.defaultLanguage;

                if (LocalizationSystem.instance == null || LocalizationSystem.instance.logEnabled == true)
                {
                    WindowSystemLogger.Log(LocalizationSystem.GetName(), string.Format("Loaded version {3}. Cache saved to: {0}, Keys: {1}, Languages: {2}", path, keysCount, langCount, LocalizationSystem.GetCurrentVersionId()));
                }

                LocalizationSystem.isReady = true;
            } catch (System.Exception ex) {
                if (LocalizationSystem.instance == null || LocalizationSystem.instance.logEnabled == true)
                {
                    // Nothing to do: failed to parse
                    WindowSystemLogger.Error(LocalizationSystem.GetName(), string.Format("Parser error: {0}\n{1}", ex.Message, ex.StackTrace));
                }

                if (loadCacheOnFail == true)
                {
                    LocalizationSystem.TryToLoadCache();
                }
            }
        }
示例#45
0
 public void CSVParserConstructorTest()
 {
     CSVParser target = new CSVParser();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
示例#46
0
 public List <PlaceDivisionStruct> Load()
 {
     Data = CSVParser.LoadObjects <PlaceDivisionStruct>("PlaceDivision");
     return(Data);
 }
示例#47
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Directory.Exists(folderTextBox.Text))
                {
                    Directory.CreateDirectory(folderTextBox.Text);

                    Settings.Default.PreviousWorkingFolder = folderTextBox.Text;
                    Settings.Default.Save();
                }

                var configPath = Path.Combine(folderTextBox.Text, GetAdapterName());
                if (File.Exists(configPath))
                {
                    MessageBox.Show("File with same name already exists", Program.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                _config.FullPath = configPath;

                foreach (var plugin in _config.Plugins.Plugins)
                {
                    var p = plugin as ISessionable;
                    if (p != null)
                    {
                        var option = _sessionFiles[p];

                        if (option.Mode == ProfileCreateMode.LoadFromFile)
                        {
                            if (!string.IsNullOrEmpty(option.LoadFromFile))
                            {
                                // base folder: where the main adapter is
                                var folder = Path.GetDirectoryName(configPath);

                                // the default template file
                                var filePath = FileHelper.ConvertToForwardSlash(folder.GetNextConfigFileName("template"));

                                var fullPath = Path.Combine(folder, filePath);

                                Session session = new Session(p.Name, filePath);
                                session.FullPath = fullPath;
                                p.Sessions.Add(session);

                                try
                                {
                                    var profile = CSVParser.Parse(p.Name, option.LoadFromFile);

                                    string mrid = session.LocalFilePath;
                                    var    row  = profile.CsvData.FirstOrDefault(x => x.Path.EndsWith("mRID"));
                                    if (row != null)
                                    {
                                        mrid = row.Value;
                                    }

                                    session.SessionConfiguration.AddProfile(profile);
                                }
                                catch (Exception)
                                {
                                    p.Sessions.Remove(session);
                                    throw;
                                }
                            }
                        }
                        else // select profiles
                        {
                            if (option.SelectedProfiles.Count > 0)
                            {
                                // base folder: where the main adapter is
                                var folder = Path.GetDirectoryName(configPath);

                                // the default template file
                                var filePath = FileHelper.ConvertToForwardSlash(folder.GetNextConfigFileName("template"));

                                // local path of the session file: base + relative path
                                var fullPath = Path.Combine(folder, filePath);

                                Session session = new Session(p.Name, filePath);
                                session.FullPath = fullPath;
                                p.Sessions.Add(session);

                                try
                                {
                                    foreach (var selected in option.SelectedProfiles)
                                    {
                                        Profile profile = Profile.Create(selected, p.Name);
                                        session.SessionConfiguration.AddProfile(profile);
                                    }
                                }
                                catch (Exception)
                                {
                                    p.Sessions.Remove(session);
                                    throw;
                                }
                            }
                        }
                    }
                }

                _configManager.Save(_config, false);

                if (!_configManager.HasActiveWorkspace)
                {
                    _configManager.LoadConfiguration(_config);
                }

                Output = _config;

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    MessageBox.Show(ex.InnerException.Message, Program.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(ex.Message, Program.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                _logger.Log(Level.Error, "An error occured when creating configurations.", ex);
            }
        }
示例#48
0
        public void Parse_ShouldOutputTheDiamondIDRight()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser( fileSystem);
            //Act
            var list = parser.Parse<Igal>(fileName);
            //Assert
            var reallist = list.ToList();

            reallist[0].InventoryCode.Should().Be("DY-029");
        }
示例#49
0
    public static void ParseData(string content, string fileName)
    {
        metaData = new Dictionary <int, StateData> ();

        CSVParser parser = new CSVParser();

        if (!parser.Parse(content))
        {
            ClientLog.Instance.LogError("StateData" + ConfigLoader.Instance.csvext + "解析错误");
            return;
        }

        int       recordCounter = parser.GetRecordCounter();
        StateData data          = null;

        for (int i = 0; i < recordCounter; ++i)
        {
            data            = new StateData();
            data._Id        = parser.GetInt(i, "ID");
            data._StateType = (int)Enum.Parse(typeof(StateType), parser.GetString(i, "Type"));
            data._Name      = parser.GetString(i, "Desc");

            data._BeattackPkg           = new StatePkg();
            data._BeattackPkg.effectId_ = parser.GetInt(i, "BeattackEffectId");
            data._BeattackPkg.action_   = parser.GetString(i, "BeattackAnimation");

            data._WorkPkg           = new StatePkg();
            data._WorkPkg.effectId_ = parser.GetInt(i, "WorkEffectId");
            string workEff = parser.GetString(i, "WorkEffect");
            if (!string.IsNullOrEmpty(workEff))
            {
                string[] workEffArr = workEff.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (workEffArr.Length == 3)
                {
                    string mc = workEffArr[0];
                    string rc = workEffArr[1];
                    float  rw = float.Parse(workEffArr[2]);

                    string[] mcarr = mc.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] rcarr = rc.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (mcarr.Length == 3)
                    {
                        data._WorkPkg.mainColor_ = new Color(float.Parse(mcarr[0]) / 255f, float.Parse(mcarr[1]) / 255f, float.Parse(mcarr[2]) / 255f);
                    }
                    if (rcarr.Length == 3)
                    {
                        data._WorkPkg.rimColor_ = new Color(float.Parse(rcarr[0]) / 255f, float.Parse(rcarr[1]) / 255f, float.Parse(rcarr[2]) / 255f);
                    }
                    data._WorkPkg.rimWidth_ = rw;
                }
            }
            data._ActionPkg           = new StatePkg();
            data._ActionPkg.effectId_ = parser.GetInt(i, "ActionEffectId");
            data._ActionPkg.action_   = parser.GetString(i, "ActionAnimation");

            data._Icon = parser.GetString(i, "Icon");

            if (metaData.ContainsKey(data._Id))
            {
                ClientLog.Instance.LogError("StateData" + ConfigLoader.Instance.csvext + "ID重复");
                return;
            }
            metaData[data._Id] = data;
        }
        parser.Dispose();
        parser = null;
    }
示例#50
0
        public void Parse_ShouldOutputTheWidthRight()
        {
            //Arrange
            var fileName = @"c:\csv.csv";

            var fileSystem = FakeCSVFileSystemWith1SampleLine(fileName);

            var parser = new CSVParser( fileSystem);
            //Act
            var list = parser.Parse<Igal>(fileName);
            //Assert
            var reallist = list.ToList();

            reallist[0].Width.Should().Be((decimal) 4.3);
        }
示例#51
0
 public List <FxStruct> Load()
 {
     Data = CSVParser.LoadObjects <FxStruct>("Fx");
     return(Data);
 }
示例#52
0
        public static void TryToSaveCSV(string data, bool loadCacheOnFail = true)
        {
            try {
                                #if UNITY_EDITOR
                var monoMemorySize = Profiler.GetMonoUsedSize();
                                #endif

                var parsed = CSVParser.ReadCSV(data);

                var defaultLanguage = parsed[0][0];
                LocalizationSystem.defaultLanguage = (UnityEngine.SystemLanguage)System.Enum.Parse(typeof(UnityEngine.SystemLanguage), defaultLanguage);

                var keysCount = 0;

                #region KEYS
                var keys = new List <string>();
                for (int i = 0; i < parsed.Count; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var row = parsed[i];
                    if (string.IsNullOrEmpty(row[0].Trim()) == true)
                    {
                        continue;
                    }

                    keys.Add(row[0].ToLower());

                    ++keysCount;
                }

                LocalizationSystem.keys = keys.ToArray();
                #endregion

                var langCount = 0;

                #region LANGUAGES
                var languages = new List <UnityEngine.SystemLanguage>();
                for (int i = 0; i < parsed[0].Length; ++i)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    var col = parsed[0][i];
                    try {
                        var lng = (UnityEngine.SystemLanguage)System.Enum.Parse(typeof(UnityEngine.SystemLanguage), col);
                        languages.Add(lng);
                    } catch (Exception) {
                    }

                    if (col == LocalizationSystem.defaultLanguage.ToString())
                    {
                        LocalizationSystem.currentVersionNumber = int.Parse(parsed[1][i]);
                    }

                    ++langCount;
                }

                LocalizationSystem.languages = languages.ToArray();
                #endregion

                #region VALUES
                var values = new Dictionary <UnityEngine.SystemLanguage, string[]>();
                for (int j = 0; j < languages.Count; ++j)
                {
                    var lang = languages[j];

                    var output = new List <string>();
                    for (int i = 0; i < parsed.Count; ++i)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        var col = parsed[i][j + 1];
                        if (string.IsNullOrEmpty(col.Trim()) == true)
                        {
                            continue;
                        }

                        output.Add(col);
                    }

                    values.Add(lang, output.ToArray());
                }

                LocalizationSystem.valuesByLanguage = values;
                #endregion

                foreach (var lang in languages)
                {
                    var val = LocalizationSystem.Get("Last", lang, forced: true);
                    if (val != "Last")
                    {
                        Debug.Log("Last Key: " + keys.Last());
                        Debug.Log("Value: " + val);
                        foreach (var key in keys)
                        {
                            Debug.Log(key + " :: " + LocalizationSystem.Get(key, lang, forced: true));
                        }

                        throw new Exception(string.Format("Language `{0}` has errors", lang));
                    }
                }

                var path = LocalizationSystem.GetCachePath();
                                #if STORAGE_NOT_SUPPORTED
                PlayerPrefs.SetString(path, data);
                                #else
                System.IO.File.WriteAllText(path, data);
                                #endif

                                #if UNITY_EDITOR
                path = LocalizationSystem.GetBuiltinCachePath();
                System.IO.File.WriteAllText(path, data);
                                #endif

                LocalizationSystem.currentLanguage = LocalizationSystem.defaultLanguage;

                if (LocalizationSystem.instance == null || LocalizationSystem.instance.logEnabled == true)
                {
                    WindowSystemLogger.Log(LocalizationSystem.GetName(), string.Format("Loaded version {3}. Cache saved to: {0}, Keys: {1}, Languages: {2}", path, keysCount, langCount, LocalizationSystem.GetCurrentVersionId()));
                }

                LocalizationSystem.isReady = true;

                                #if UNITY_EDITOR
                var monoMemorySizeAfter = Profiler.GetMonoUsedSize();
                var deltaMemory         = monoMemorySizeAfter - monoMemorySize;
                WindowSystemLogger.Warning(LocalizationSystem.GetName(), string.Format("Allocated: {0} bytes ({1}MB)", deltaMemory, (deltaMemory / 1024f / 1024f)));
                                #endif
            } catch (System.Exception ex) {
                Debug.LogError("LocalizationSystem parse failed");

                if (LocalizationSystem.instance == null || LocalizationSystem.instance.logEnabled == true)
                {
                    // Nothing to do: failed to parse
                    WindowSystemLogger.Error(LocalizationSystem.GetName(), string.Format("Parser error: {0}\n{1}", ex.Message, ex.StackTrace));
                }

                if (loadCacheOnFail == true)
                {
                    LocalizationSystem.TryToLoadCache();
                }
            }
        }
示例#53
0
    public static void ParseData(string content, string fileName)
    {
        metaData = new Dictionary <int, ItemData> ();

        CSVParser parser = new CSVParser();

        if (!parser.Parse(content))
        {
            ClientLog.Instance.LogError("ItemData" + ConfigLoader.Instance.csvext + "解析错误");
            return;
        }

        int      recordCounter = parser.GetRecordCounter();
        ItemData data          = null;

        for (int i = 0; i < recordCounter; ++i)
        {
            data        = new ItemData();
            data.id_    = parser.GetInt(i, "ID");
            data.level_ = parser.GetInt(i, "Level");
            //data.kind_ = parser.GetString (i, "Kind");
            data.price_        = parser.GetInt(i, "Price");
            data.maxCount_     = parser.GetInt(i, "MaxCount");
            data.quality_      = (QualityColor)Enum.Parse(typeof(QualityColor), parser.GetString(i, "Quality"));
            data.skillId_      = parser.GetInt(i, "skillID");
            data.name_         = parser.GetString(i, "Name");
            data.icon_         = parser.GetString(i, "Icon");
            data.desc_         = parser.GetString(i, "Desc");
            data.isShow_       = parser.GetInt(i, "isshow");
            data.bindType_     = (BindType)Enum.Parse(typeof(BindType), parser.GetString(i, "BindType"));
            data.acquiringWay_ = parser.GetString(i, "AcquiringWay");
            data.usedFlag_     = (ItemUseFlag)Enum.Parse(typeof(ItemUseFlag), parser.GetString(i, "CanUse"));
            data.mainType_     = (ItemMainType)Enum.Parse(typeof(ItemMainType), parser.GetString(i, "ItemMainType"));
            data.subType_      = (ItemSubType)Enum.Parse(typeof(ItemSubType), parser.GetString(i, "ItemSubType"));
            data.slot_         = (EquipmentSlot)Enum.Parse(typeof(EquipmentSlot), parser.GetString(i, "EquipmentSlot"));
            if (string.IsNullOrEmpty(parser.GetString(i, "WeaponType")))
            {
                data.weaponType_ = WeaponType.WT_None;
            }
            else
            {
                data.weaponType_ = (WeaponType)Enum.Parse(typeof(WeaponType), parser.GetString(i, "WeaponType"));
            }
            data.weaponActionType_ = (WeaponActionType)Enum.Parse(typeof(WeaponActionType), parser.GetString(i, "AttackAction"));
            data.weaponEntityId_   = parser.GetInt(i, "WeaponEntityId");
            data.artifactExp_      = parser.GetInt(i, "ArtifactExp");
            data.AddValue_         = parser.GetInt(i, "AddValue");
            string profession = parser.GetString(i, "Profession");
            if (!string.IsNullOrEmpty(profession))
            {
                data.professionType_ = (JobType)Enum.Parse(typeof(JobType), profession);
            }
            if (data.mainType_ == ItemMainType.IMT_Employee)
            {
                data.employeeId_ = parser.GetInt(i, "EmployeeId");
            }

            //  prop
            string   propSre = parser.GetString(i, "Durability");
            string[] propValues;
            KeyValuePair <PropertyType, string[]> dataArr = new KeyValuePair <PropertyType, string[]>();
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Durability").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Durability, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "HpMax");

            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "HpMax").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_HpMax, propValues);
                data.propArr.Add(dataArr);
            }


            propSre = parser.GetString(i, "Magicattack");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Magicattack").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Magicattack, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Magicdefense");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Magicdefense").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Magicdefense, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "MpMax");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "MpMax").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_MpMax, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Attack");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Attack").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Attack, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Defense");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Defense").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Defense, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Agile");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Agile").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Agile, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "counterpunch");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "counterpunch").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_counterpunch, propValues);
                data.propArr.Add(dataArr);
            }



            propSre = parser.GetString(i, "Spirit");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Spirit").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Spirit, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Reply");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Reply").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Reply, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Hit");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Hit").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Hit, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Dodge");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Dodge").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Dodge, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Crit");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Crit").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Crit, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Wind");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Wind").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Wind, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Land");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Land").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Land, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Water");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Water").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Water, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Fire");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Fire").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_Fire, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "PT_SneakAttack");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "PT_SneakAttack").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_SneakAttack, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "NoSleep");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "NoSleep").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_NoSleep, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "NoPetrifaction");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "NoPetrifaction").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_NoPetrifaction, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "NoDrunk");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "NoDrunk").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_NoDrunk, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "NoChaos");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "NoChaos").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_NoChaos, propValues);
                data.propArr.Add(dataArr);
            }

            propSre = parser.GetString(i, "Poison");
            if (!string.IsNullOrEmpty(propSre))
            {
                propValues = parser.GetString(i, "Poison").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                dataArr    = new KeyValuePair <PropertyType, string[]>(PropertyType.PT_NoPoison, propValues);
                data.propArr.Add(dataArr);
            }


            KeyValuePair <PropertyType, string> gemArr = new KeyValuePair <PropertyType, string>();
            string gemWeaponD = parser.GetString(i, "Weapon_D");
            if (!string.IsNullOrEmpty(gemWeaponD))
            {
                string[] wDstr = gemWeaponD.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int w = 0; w < wDstr.Length; w++)
                {
                    string[] wDstr1 = wDstr[w].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    gemArr = new KeyValuePair <PropertyType, string>((PropertyType)Enum.Parse(typeof(PropertyType), wDstr1[0]), wDstr1[1]);
                    data.GemWeaponPropArr.Add(gemArr);
                }
            }

            string gemWeaponP = parser.GetString(i, "Weapon_P");
            if (!string.IsNullOrEmpty(gemWeaponP))
            {
                string[] wDstr = gemWeaponP.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int w = 0; w < wDstr.Length; w++)
                {
                    string[] wDstr1 = wDstr[w].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    gemArr = new KeyValuePair <PropertyType, string>((PropertyType)Enum.Parse(typeof(PropertyType), wDstr1[0]), wDstr1[1]);
                    data.GemWeaponPropArr.Add(gemArr);
                }
            }

            string gemArmorD = parser.GetString(i, "Armor_D");
            if (!string.IsNullOrEmpty(gemArmorD))
            {
                string[] wDstr = gemArmorD.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int w = 0; w < wDstr.Length; w++)
                {
                    string[] wDstr1 = wDstr[w].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    gemArr = new KeyValuePair <PropertyType, string>((PropertyType)Enum.Parse(typeof(PropertyType), wDstr1[0]), wDstr1[1]);
                    data.GemArmorPropArr.Add(gemArr);
                }
            }

            string gemArmorP = parser.GetString(i, "Armor_P");
            if (!string.IsNullOrEmpty(gemArmorP))
            {
                string[] wDstr = gemArmorP.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int w = 0; w < wDstr.Length; w++)
                {
                    string[] wDstr1 = wDstr[w].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    gemArr = new KeyValuePair <PropertyType, string>((PropertyType)Enum.Parse(typeof(PropertyType), wDstr1[0]), wDstr1[1]);
                    data.GemArmorPropArr.Add(gemArr);
                }
            }

            //
            if (metaData.ContainsKey(data.id_))
            {
                ClientLog.Instance.LogError("ItemData" + ConfigLoader.Instance.csvext + "ID重复 " + data.id_);
                return;
            }
            metaData[data.id_] = data;

            if (data.mainType_ == ItemMainType.IMT_Equip)
            {
                equipData.Add(data);
            }
        }
        parser.Dispose();
        parser = null;
    }
示例#54
0
        public void ParseHelp()
        {
            var csvFile = CSVParser.PraseCSV("../../../Resources/aapl.us.csv");

            Assert.IsNotNull(csvFile);
        }
示例#55
0
        public ActionResult NewFiles()
        {
            Response res  = new Response();
            var      wolt = TempData["clusters"] as List <Workorder>;
            var      wo   = TempData["SiteCluster"].ToString();
            var      wo2  = wo.Split(',');

            try
            {
                HttpFileCollectionBase files = HttpContext.Request.Files;
                var wolst = HttpContext.Request["mydata"];
                for (int i = 0; i < files.Count; i++)
                {
                    #region File Save

                    string             Path = "/Content/AirViewLogs/" + wo2[2] + "/" + wolt[i].clusterId;
                    HttpPostedFileBase file = HttpContext.Request.Files[i] as HttpPostedFileBase;
                    if (!Directory.Exists(HttpContext.Server.MapPath("~" + Path)))
                    {
                        // if it doesn't exist, create
                        System.IO.Directory.CreateDirectory(HttpContext.Server.MapPath("~" + Path));
                    }
                    string fname = HttpContext.Server.MapPath("~" + Path + "/" + wolt[i].clusterName + "_" + wolt[i].networkmodename);
                    HttpContext.Request.Files[i].SaveAs(fname + ".csv");



                    #endregion



                    #region site count
                    List <CSVParser> values = System.IO.File.ReadAllLines(fname + ".csv")
                                              .Skip(1)
                                              .Select(v => CSVParser.FromCsv(v)).Distinct()
                                              .ToList();
                    List <string> a = new List <string>();
                    foreach (var item in values)
                    {
                        a.Add(item.siteCode);
                    }
                    //  a = new List<string>();
                    //// Int64 SiteCount = 0;
                    // Stream stream = files[i].InputStream;
                    // DataTable sitesTable = new DataTable();
                    // using (CsvReader csvReader =
                    //     new CsvReader(new StreamReader(stream), true))
                    // {
                    //     sitesTable.Load(csvReader);
                    // }
                    // DataView view = new DataView(sitesTable);
                    // DataTable tblsectors = view.ToTable(true, new string[] { "clusterCode", "siteCode" });
                    // if (tblsectors.Rows.Count > 0)
                    // {
                    //     for (int j = 0; j < tblsectors.Rows.Count; j++)
                    //     {
                    //         DataRow crow = tblsectors.Rows[j];
                    //         string abc = crow["siteCode"].ToString();
                    //         a.Add(abc);
                    //     }
                    //     a = a.Distinct().ToList();
                    // }
                    WorkOrderBL wb = new WorkOrderBL();
                    wb.Insert("InsertSiteCount", a.Distinct().ToList().Count, Path + "/" + wolt[i].clusterName + "_" + wolt[i].networkmodename + ".csv");

                    #endregion
                }
                res.Status  = "success";
                res.Message = "save successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.Message;
            }



            return(RedirectToAction("New"));
        }
示例#56
0
	void OnApplicationQuit()
	{
		_instance = null;
	}
示例#57
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        StringTableImporter importer = serializedObject.targetObject as StringTableImporter;

        if( GUILayout.Button( "Clean" ))
        {
            importer.Clear();
            importer.ApplyChanges();
        }

        if( GUILayout.Button( "Test" ))
        {
            Debug.Log( "testing a quoted strings" );
            Debug.Log( new CSVParser().Parse( "\"X\"" )[0] );
            Debug.Log( new CSVParser().Parse( "\"X\",\"Y\"" )[1] );

            Debug.Log( "testing quoted quoted strings" );
            Debug.Log( new CSVParser().Parse( "\"\"\"X\"\"\"" )[0] );
            Debug.Log( new CSVParser().Parse( "\"\"\"X\"\"\",\"\"\"Y\"\"\"" )[1] );

            Debug.Log( "testing multiple quoted quoted strings" );
            Debug.Log( new CSVParser().Parse( "\"\"\"X\"\", \"\"Y\"\", \"\"Z\"\"\"" )[0] );
        }

        if( GUILayout.Button( "Import" ))
        {
            string filename = EditorUtility.OpenFilePanel( "Import String Table CSV", "", "csv" );
            if (filename != null)
            {
                using( StreamReader reader = new StreamReader( filename, Encoding.GetEncoding(1252)))
                {
                    CSVParser parser = new CSVParser();

                    string line = reader.ReadLine(); // first line contains headings
                    string [] fields = parser.Parse( line );

                    string [] fieldNames =
                    {
                        "StringID",
                        "Platform",
                        "English",
                        "French",
                        "Italian",
                        "German",
                        "Spanish"
                    };

                    int [] lookup = new int[fieldNames.Length];

                    for( int i = 0; i < lookup.Length; i++ )
                    {
                        lookup[i] = -1;
                    }

                    int highest = -1;

                    for( int i = 0; i < lookup.Length; i++ )
                    {
                        for( int k = 0; k < fields.Length; k++ )
                        {
                            if( fields[k].Contains( fieldNames[i] ))
                            {
                                lookup[i] = k;
                                if( k > highest ) highest = k;
                                break;
                            }
                        }
                    }

                    while( !reader.EndOfStream )
                    {
                        line = reader.ReadLine();
                        fields = parser.Parse( line );
                        if( fields.Length <= lookup[(int)FieldNames.kSpanish ] )
                        {
                            Debug.Log( string.Format( "Error: {0}", line ));
                            continue;
                        }

                        string stringID = "";
                        string platform = "";
                        string english = "";
                        string french = "";
                        string italian = "";
                        string german = "";
                        string spanish = "";

                        if( lookup[(int)FieldNames.kStringID] != -1 )
                            stringID = fields[lookup[(int)FieldNames.kStringID]];

                        if( lookup[(int)FieldNames.kPlatform] != -1 )
                            platform = fields[lookup[(int)FieldNames.kPlatform]];

                        if( lookup[(int)FieldNames.kEnglish] != -1 )
                            english  = fields[lookup[(int)FieldNames.kEnglish ]];

                        if( lookup[(int)FieldNames.kFrench] != -1 )
                            french   = fields[lookup[(int)FieldNames.kFrench  ]];

                        if( lookup[(int)FieldNames.kItalian] != -1 )
                            italian  = fields[lookup[(int)FieldNames.kItalian ]];

                        if( lookup[(int)FieldNames.kGerman] != -1 )
                            german   = fields[lookup[(int)FieldNames.kGerman  ]];

                        if( lookup[(int)FieldNames.kSpanish] != -1 )
                            spanish  = fields[lookup[(int)FieldNames.kSpanish ]];

                        StringTable.Platform platformID = StringTable.Platform.kCommon;

                        if( platform.ToUpper() == "XBOX" )
                        {
                            platformID = StringTable.Platform.kXbox360;
                        }
                        else if( platform.ToUpper() == "PS3" )
                        {
                            platformID = StringTable.Platform.kPS3;
                        }

                        if( stringID != string.Empty )
                        {
                            if( english != string.Empty )
                            {
                                importer.LoadString(stringID, StringTable.Language.kEnglish, platformID, english);
                            }

                            if( french != string.Empty )
                            {
                                importer.LoadString(stringID, StringTable.Language.kFrench, platformID, french);
                            }
                            if( italian != string.Empty )
                            {
                                importer.LoadString(stringID, StringTable.Language.kItalian, platformID, italian);
                            }

                            if( german != string.Empty )
                            {
                                importer.LoadString(stringID, StringTable.Language.kGerman, platformID, german);
                            }

                            if( spanish != string.Empty )
                            {
                                importer.LoadString(stringID, StringTable.Language.kSpanish, platformID, spanish);
                            }
                        }
                    }

                    importer.SortStringIDs();
                    importer.ApplyChanges();
                }
            }
        }
    }