Пример #1
0
        public SoundGroup(SaveSoundGroup data)
        {
            this.Title = data.Title;
            this.Items = new List<Group<SoundData>>();

            foreach (var group in data.Items.GroupBy(item => item.Groups))
            {
                this.Items.Add(new Group<SoundData>(group.Key, group.ToList()));
            }
        }
Пример #2
0
        public SoundGroup(SaveSoundGroup data)
        {
            this.Title = data.Title;
            this.Items = new List <Group <SoundData> >();

            foreach (var group in data.Items.GroupBy(item => item.Groups))
            {
                this.Items.Add(new Group <SoundData>(group.Key, group.ToList()));
            }
        }
Пример #3
0
        private SoundGroup LoadFromXml(string xmlName)
        {
            SaveSoundGroup isolatedGroup = new SaveSoundGroup();
            SaveSoundGroup assetsGroup;
            XmlSerializer  serializer = new XmlSerializer(typeof(SaveSoundGroup));

            using (Stream fileStream = Application.GetResourceStream(new Uri("Xmls/" + xmlName, UriKind.Relative)).Stream)
            {
                assetsGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
            }

            if (IsolatedStorageFile.GetUserStoreForApplication().FileExists(xmlName))
            {
                using (Stream fileStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(xmlName, FileMode.Open, FileAccess.Read))
                {
                    isolatedGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
                }

                foreach (var entry in assetsGroup.Items)
                {
                    if (!isolatedGroup.Items.Contains(entry))
                    {
                        isolatedGroup.Items.Add(entry);
                    }
                }
                for (int i = 0; i < isolatedGroup.Items.Count; i++)
                {
                    if (!assetsGroup.Items.Contains(isolatedGroup.Items[i]))
                    {
                        isolatedGroup.Items.RemoveAt(i);
                        i--;
                    }
                }
            }
            else
            {
                isolatedGroup = assetsGroup;
            }

            return(new SoundGroup(isolatedGroup));
        }
Пример #4
0
        private SoundGroup LoadFromXml(string xmlName)
        {
            SaveSoundGroup isolatedGroup = new SaveSoundGroup();
            SaveSoundGroup assetsGroup;
            XmlSerializer serializer = new XmlSerializer(typeof(SaveSoundGroup));

            using (Stream fileStream = Application.GetResourceStream(new Uri("Xmls/" + xmlName, UriKind.Relative)).Stream)
            {
                assetsGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
            }

            if (IsolatedStorageFile.GetUserStoreForApplication().FileExists(xmlName))
            {
                using (Stream fileStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(xmlName, FileMode.Open, FileAccess.Read))
                {
                    isolatedGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
                }

                foreach (var entry in assetsGroup.Items)
                {
                    if (!isolatedGroup.Items.Contains(entry))
                    {
                        isolatedGroup.Items.Add(entry);
                    }
                }
            }
            else
            {
                isolatedGroup = assetsGroup;
            }

            return new SoundGroup(isolatedGroup);
        }