public void Equality_OneNull_False()
        {
            CharacterReference notNull = new CharacterReference("pound");

            Assert.That(notNull == null, Is.False);
            Assert.That(null == notNull, Is.False);
        }
        public void Inequality_OneNull_True()
        {
            CharacterReference notNull = new CharacterReference("pound");

            Assert.That(notNull != null, Is.True);
            Assert.That(null != notNull, Is.True);
        }
        private void ReloadViewModel(CharacterViewModel vm)
        {
            CharacterReference @ref = (CharacterReference)vm.Metadata;

            CharacterViewModel nvm = CreateViewModel(@ref);

            OnCharacterUpdated(new CharacterViewModelProviderEventArgs(nvm, @ref));
        }
        public void CanBeConstructed_WithSimpleOrEntityNames(string ctorName, string entityName, string simpleName, string entityNumber, int codePoint, string character)
        {
            var reference = new CharacterReference(ctorName);

            Assert.That(reference.EntityName, Is.EqualTo(entityName));
            Assert.That(reference.EntityNumber, Is.EqualTo(entityNumber));
            Assert.That(reference.SimpleName, Is.EqualTo(simpleName));
            Assert.That(reference.CodePoint, Is.EqualTo(codePoint));
            Assert.That(reference.Character, Is.EqualTo(character));
            Assert.That(reference.IsEmpty, Is.False);
        }
示例#5
0
        public void some_currencies_have_an_character_reference_for_angly_bracket_languages()
        {
            Currency           qatariRial = Currency.Get(CurrencyIsoCode.QAR);
            CharacterReference reference  = qatariRial.Entity;

            Assert.That(reference, Is.Not.Null.And.Property("IsEmpty").True,
                        "the Rial does not have an reference, but a 'null' object");

            Currency euro = Currency.Euro;

            reference = euro.Entity;
            Assert.That(reference, Is.Not.Null.And.Property("IsEmpty").False, "the euro, does");
            Assert.That(reference.Character, Is.EqualTo("€"));
            Assert.That(reference.CodePoint, Is.EqualTo(8364));
            Assert.That(reference.EntityName, Is.EqualTo("€"));
            Assert.That(reference.EntityNumber, Is.EqualTo("€"));
            Assert.That(reference.SimpleName, Is.EqualTo("euro"));
        }
        private CharacterViewModel CreateViewModel(CharacterReference reference)
        {
            XDocument scanDocument = Core.LoadPlayDataXDocument();

            CharacterFile cf = CharacterFile.Load(reference.CharBytes);

            CharacterViewModel     vm       = new CharacterViewModel(cf, reference);
            DataBlockWrapperBuffer playData = new DataBlockWrapperBuffer(reference.PlayBytes, scanDocument);

            vm.ExtraData.Add("PLAY_SEAT", reference.Seat);
            vm.ExtraData.Add("PLAY_DATA", playData);

            vm.SaveCommand   = new RelayCommand(() => SaveViewModel(vm), () => SaveViewModelCanExecute(vm));
            vm.ReloadCommand = new RelayCommand(() => ReloadViewModel(vm));

            InstanceCache.Add(vm);

            return(vm);
        }
        private void SaveViewModel(CharacterViewModel vm)
        {
            CharacterReference @ref = (CharacterReference)vm.Metadata;

            CharacterFile          cf = vm.Character;
            DataBlockWrapperBuffer pd = (DataBlockWrapperBuffer)vm.ExtraData["PLAY_DATA"];

            if (cf.HasChanges)
            {
                //[Var]Card Bytes + [3011]Data Bytes + [4]Thumb Lenght + [Var]Thumb Bytes + [4] Data Lenght Mark
                int          newCharBytesLen = cf.CardBytes.Length + cf.DataBytes.Length + cf.ThumbBytes.Length + 8;
                var          newCharData     = new byte[newCharBytesLen];
                MemoryStream ms = new MemoryStream(newCharData);
                // Card Bytes
                ms.Write(cf.CardBytes, 0, cf.CardBytes.Length);
                // Data Bytes
                ms.Write(cf.DataBytes, 0, cf.DataBytes.Length);
                // Thumbnail Lenght
                ms.Write(BitConverter.GetBytes(cf.ThumbBytes.Length), 0, 4);
                // Thumbnail Lenght
                ms.Write(cf.ThumbBytes, 0, cf.ThumbBytes.Length);
                // Identifier Mark
                int lastBytes = cf.DataBytes.Length + cf.ThumbBytes.Length + 8;
                ms.Write(BitConverter.GetBytes(lastBytes), 0, 4);
                ms.Flush();
                @ref.CharBytes = newCharData;
                cf.CardChanges = cf.DataChanges = cf.ThumbChanges = false;
            }

            if (pd.HasChanges)
            {
                var newPlayBytes = new byte[pd.DataBytes.Length];
                Buffer.BlockCopy(pd.DataBytes, 0, newPlayBytes, 0, newPlayBytes.Length);
                @ref.PlayBytes = newPlayBytes;
                pd.HasChanges  = false;
            }

            @ref.Female = (byte)vm.Profile.Gender.Value == 1;

            SaveTimeouTimer.Change(1000, Timeout.Infinite);
        }
        public IHttpActionResult GetUser(string username)
        {
            response.status = "FAILURE";
            string informationPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Information.txt";
            string skillPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Skill.txt";
            string strengthPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Strengths.txt";
            string postGraduatePath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "PostGraduate.txt";
            string tertiaryPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Tertiary.txt";
            string secondaryPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Secondary.txt";
            string primaryPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Primary.txt";
            string workExperiencePath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "WorkExperience.txt";
            string trainingPath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "Training.txt";
            string characterReferencePath = AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username + "\\" + "CharacterReference.txt";
            int    index = 0, iterationCount = 0;

            if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"ResumeList\" + username))
            {
                User user = new User();
                //Information
                if (System.IO.File.Exists(informationPath))
                {
                    string[] information = System.IO.File.ReadAllLines(informationPath);
                    //user.FirstName
                    user.FirstName     = information[0].Replace("�", "\u00f1");
                    user.MiddleName    = information[1].Replace("�", "\u00f1");
                    user.LastName      = information[2].Replace("�", "\u00f1");
                    user.Address       = information[3].Replace("�", "\u00f1");
                    user.ContactNo     = information[4].Replace("�", "\u00f1");
                    user.EmailAddress  = information[5].Replace("�", "\u00f1");
                    user.Objectives    = information[6].Replace("�", "\u00f1");
                    user.Age           = Convert.ToInt32(information[7]);
                    user.DateOfBirth   = Convert.ToDateTime(information[8]);
                    user.Gender        = information[9].Replace("�", "\u00f1");
                    user.CivilStatus   = information[10].Replace("�", "\u00f1");
                    user.Height        = information[11].Replace("�", "\u00f1");
                    user.Weight        = information[12].Replace("�", "\u00f1");
                    user.Citizenship   = information[13].Replace("�", "\u00f1");
                    user.Hobbies       = information[14].Replace("�", "\u00f1");
                    user.Template      = Convert.ToInt32(information[15]);
                    user.ImageName     = information[16].Replace("�", "\u00f1");
                    response.objParam1 = user;
                }
                //Skill
                if (System.IO.File.Exists(skillPath))
                {
                    string[] skill = System.IO.File.ReadAllLines(skillPath);
                    for (int i = 0; i < skill.Length; i++)
                    {
                        Skill skills = new Skill();
                        skills.Description = skill[i].Replace("�", "\u00f1");
                        user.Skills.Add(skills);
                    }
                }
                //Strengths
                if (System.IO.File.Exists(strengthPath))
                {
                    string[] strength = System.IO.File.ReadAllLines(strengthPath);
                    for (int i = 0; i < strength.Length; i++)
                    {
                        Strength strengths = new Strength();
                        strengths.Description = strength[i];
                        user.Strengths.Add(strengths);
                    }
                }
                //PostGraduate
                if (System.IO.File.Exists(postGraduatePath))
                {
                    string[] postGraduate = System.IO.File.ReadAllLines(postGraduatePath);
                    iterationCount = postGraduate.Length / 3;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        PostGraduate postGraduates = new PostGraduate();
                        postGraduates.School = postGraduate[index].Replace("�", "\u00f1");
                        index = index + 1;
                        postGraduates.Degree = postGraduate[index].Replace("�", "\u00f1");
                        index = index + 1;
                        postGraduates.Address = postGraduate[index].Replace("�", "\u00f1");
                        index = index + 1;
                        if (postGraduate[index].Equals("N"))
                        {
                            postGraduates.Achievement = "";
                        }
                        else
                        {
                            postGraduates.Achievement = postGraduate[index].Replace("�", "\u00f1");
                        }
                        index = index + 1;
                        user.PostGraduates.Add(postGraduates);
                    }
                }
                //Tertiary
                if (System.IO.File.Exists(tertiaryPath))
                {
                    string[] tertiary = System.IO.File.ReadAllLines(tertiaryPath);
                    iterationCount = tertiary.Length / 3;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        Tertiary tertiaries = new Tertiary();
                        tertiaries.School  = tertiary[index].Replace("�", "\u00f1");
                        index              = index + 1;
                        tertiaries.Degree  = tertiary[index].Replace("�", "\u00f1");
                        index              = index + 1;
                        tertiaries.Address = tertiary[index].Replace("�", "\u00f1");
                        index              = index + 1;
                        if (tertiary[index].Equals("N"))
                        {
                            tertiaries.Achievement = "";
                        }
                        else
                        {
                            tertiaries.Achievement = tertiary[index].Replace("�", "\u00f1");
                        }
                        index = index + 1;
                        user.Tertiaries.Add(tertiaries);
                    }
                }
                //Secondary
                if (System.IO.File.Exists(secondaryPath))
                {
                    string[] secondary = System.IO.File.ReadAllLines(secondaryPath);
                    iterationCount = secondary.Length / 2;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        Secondary secondaries = new Secondary();
                        secondaries.School = secondary[index].Replace("�", "\u00f1");
                        index = index + 1;
                        secondaries.Address = secondary[index].Replace("�", "\u00f1");
                        index = index + 1;
                        if (secondary[index].Equals("N"))
                        {
                            secondaries.Achievement = "";
                        }
                        else
                        {
                            secondaries.Achievement = secondary[index].Replace("�", "\u00f1");
                        }
                        index = index + 1;
                        user.Secondaries.Add(secondaries);
                    }
                }
                //Primary
                if (System.IO.File.Exists(primaryPath))
                {
                    string[] primary = System.IO.File.ReadAllLines(primaryPath);
                    iterationCount = primary.Length / 2;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        Primary primaries = new Primary();
                        primaries.School  = primary[index].Replace("�", "\u00f1");
                        index             = index + 1;
                        primaries.Address = primary[index].Replace("�", "\u00f1");
                        index             = index + 1;
                        if (primary[index].Equals("N"))
                        {
                            primaries.Achievement = "";
                        }
                        else
                        {
                            primaries.Achievement = primary[index].Replace("�", "\u00f1");
                        }
                        index = index + 1;
                        user.Primaries.Add(primaries);
                    }
                }
                //Work Experience
                if (System.IO.File.Exists(workExperiencePath))
                {
                    string[] workExperience = System.IO.File.ReadAllLines(workExperiencePath);
                    iterationCount = workExperience.Length / 5;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        WorkExperience workExperiences = new WorkExperience();
                        workExperiences.Company = workExperience[index].Replace("�", "\u00f1");
                        index = index + 1;
                        workExperiences.Address = workExperience[index].Replace("�", "\u00f1");
                        index = index + 1;
                        workExperiences.Period = workExperience[index].Replace("�", "\u00f1");
                        index = index + 1;
                        workExperiences.Position = workExperience[index].Replace("�", "\u00f1");
                        index = index + 1;
                        workExperiences.MainRole = workExperience[index].Replace("�", "\u00f1");
                        index = index + 1;
                        user.WorkExperiences.Add(workExperiences);
                    }
                }
                //Training
                if (System.IO.File.Exists(trainingPath))
                {
                    string[] training = System.IO.File.ReadAllLines(trainingPath);
                    iterationCount = training.Length / 3;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        Training trainings = new Training();
                        trainings.Name        = training[index].Replace("�", "\u00f1");
                        index                 = index + 1;
                        trainings.Description = training[index].Replace("�", "\u00f1");
                        index                 = index + 1;
                        trainings.Period      = training[index].Replace("�", "\u00f1");
                        index                 = index + 1;
                        user.Trainings.Add(trainings);
                    }
                }
                //character Reference
                if (System.IO.File.Exists(characterReferencePath))
                {
                    string[] characterReference = System.IO.File.ReadAllLines(characterReferencePath);
                    iterationCount = characterReference.Length / 3;
                    index          = 0;
                    for (int i = 0; i < iterationCount; i++)
                    {
                        CharacterReference characterReferences = new CharacterReference();
                        characterReferences.Name = characterReference[index];
                        index = index + 1;
                        characterReferences.Profession = characterReference[index].Replace("�", "\u00f1");
                        index = index + 1;
                        characterReferences.ContactNo = characterReference[index].Replace("�", "\u00f1");
                        index = index + 1;
                        user.CharacterReferences.Add(characterReferences);
                    }
                }
                TokenGenerator tokenGenerator = new TokenGenerator();
                response.stringParam1 = tokenGenerator.Encrypt(tokenGenerator.generateCode(10)) + ":" + tokenGenerator.Encrypt("ARJOCAMAHAMAGEAPP");
                response.status       = "SUCCESS";
            }
            else
            {
                response.message = "User not found.";
            }

            return(Ok(response));
        }
        public void Equality_BothNull_True()
        {
            CharacterReference one = null, two = null;

            Assert.That(one == two, Is.True);
        }
        public void Equals_Same_True()
        {
            var pound = new CharacterReference("pound");

            Assert.That(pound.Equals(pound), Is.True);
        }
        public void Inequality_NotEqual_True()
        {
            CharacterReference pound = new CharacterReference("pound"), cent = new CharacterReference("cent");

            Assert.That(pound != cent, Is.True);
        }
        public void Inequality_Equal_False()
        {
            CharacterReference pound = new CharacterReference("pound"), anotherPound = new CharacterReference("pound");

            Assert.That(pound != anotherPound, Is.False);
        }
        public void Inequality_BothNull_False()
        {
            CharacterReference one = null, two = null;

            Assert.That(one != two, Is.False);
        }
        public void Equality_NotEqual_False()
        {
            CharacterReference pound = new CharacterReference("pound"), cent = new CharacterReference("cent");

            Assert.That(pound == cent, Is.False);
        }
        public void Equality_Equal_True()
        {
            CharacterReference pound = new CharacterReference("pound"), anotherPound = new CharacterReference("pound");

            Assert.That(pound == anotherPound, Is.True);
        }
        private List <CharacterReference> ReadCharacters(byte[] saveData, int count, out int stopIndex)
        {
            var references = new List <CharacterReference>();

            XDocument scanDocument = Core.LoadPlayDataXDocument();

            int index = 0;

            byte[] pngBytes = { 0x89, 0x50, 0x4e, 0x47 }; // ‰PNG
            byte[] endBytes = { 0x49, 0x45, 0x4e, 0x44 }; // IEND
            while (count > 0)
            {
                //First PNG Mark
                int startIndex = BufferIndexOf(saveData, pngBytes, index);
                if (startIndex == -1)
                {
                    break;
                }
                //Find another PNG, the Thumbnail
                int thumbIndex = BufferIndexOf(saveData, pngBytes, startIndex + 1);
                //And its IEND Mark
                int endIndex = BufferIndexOf(saveData, endBytes, thumbIndex + 1);
                //Play Data index will be after the IEND: [4]Self+[4]Junk+[4]Identifier
                int playIndex = endIndex + 4 + 4 + 4;

                //Seat is 4 Bytes behind the Start
                int playSeat = BitConverter.ToInt32(saveData, startIndex - 4);
                //Another Gender identifier at 5 bytes behind
                bool isFemale = saveData[startIndex - 5] == 1;

                CharacterReference @ref = new CharacterReference();

                // From index until Start of PlayData. Includes Identifier mark
                int charLenght = playIndex - startIndex;
                var charBytes  = new byte[charLenght];
                Buffer.BlockCopy(saveData, startIndex, charBytes, 0, charLenght);

                // Scan PlayData Lenght via Loader, TODO: Create a Size Only Scanner, this EATS Memory
                int playLenght;
                // Probable Temporary Fix, release strings and shit
                var temp = Core.LoadDataBlocks(saveData, playIndex, scanDocument, out playLenght);
                temp.OfType <EnumDataBlock>()
                .ForEach
                    (block =>
                {
                    if (block is SeatDataBlock)
                    {
                        return;
                    }
                    block.Enum.Clear();
                });
                temp.Clear();

                var playBytes = new byte[playLenght];
                Buffer.BlockCopy(saveData, playIndex, playBytes, 0, playLenght);

                @ref.CharBytes = charBytes;
                @ref.PlayBytes = playBytes;
                @ref.Seat      = playSeat;
                @ref.Female    = isFemale;

                index = playIndex + playLenght;
                count--;

                references.Add(@ref);
            }
            stopIndex = index;
            return(references);
        }