예제 #1
0
        public void ShuffleEntries()
        {
            int          count      = EntryList.Count();
            List <Entry> ListtoSort = new List <Entry>(EntryList);
            List <int>   rngList    = new List <int>();
            Random       r          = new Random();

            for (int i = 0; i < count; i++)
            {
                while (true)
                {
                    int newrng = r.Next(0, count);
                    if (!rngList.Contains(EntryList[newrng].UniqueID))
                    {
                        rngList.Add(EntryList[newrng].UniqueID); break;
                    }
                }
            }
            ListtoSort = ListtoSort.OrderBy(x => rngList.IndexOf(x.UniqueID)).ToList();
            EntryList.Clear();
            for (int i = 0; i < count; i++)
            {
                EntryList.Add(ListtoSort[i]);
            }
        }
예제 #2
0
        public EntryItemViewModel AddEntryItemFromChild(EntryItemViewModel priorEntryItemViewModel, TimeSpan newTime)
        {
            EntryItemViewModel entryItemViewModel = new EntryItemViewModel(this, priorEntryItemViewModel, newTime.ToString(), newTime, "", "", false);

            EntryList.Add(entryItemViewModel);
            return(entryItemViewModel);
        }
예제 #3
0
    public bool UpdateEntry(string userId, FriendEntryBase.Model model, bool?isReceived = null)
    {
        if (!base.UpdateEntry(userId, model))
        {
            return(false);
        }

        var entry = entries[userId] as FriendRequestEntry;

        if (isReceived.HasValue)
        {
            entry.SetReceived(isReceived.Value);

            if (isReceived.Value)
            {
                receivedRequestsList.Add(userId, entry);
            }
            else
            {
                sentRequestsList.Add(userId, entry);
            }
        }

        return(true);
    }
예제 #4
0
 private void AddEntryItem()
 {
     if (EntryList.Count == 0)
     {
         EntryList.Add(new EntryItemViewModel(this, null, ArrivalTime.ToString(), ArrivalTime, "", "", false));
     }
 }
예제 #5
0
        /// <summary>
        /// Save the state of this game to disk.
        /// </summary>
        public void SaveState()
        {
            if (!this.initialized)
            {
                throw new InvalidOperationException("Storage not yet Added to the game.");
            }
            Directory.CreateDirectory(this.path);
            Storage.LastSaved = DateTime.Now;

            EntryList entries = new EntryList();

            foreach (Saved save in this.saves)
            {
                entries.Add(save);
            }

            if (File.Exists(this.statefile))
            {
                EntryList prev = RawRead();
                if (prev != null)
                {
                    entries = EntryList.Merge(prev, entries);
                }
            }
            Stream     f         = new GZipStream(new FileStream(this.statefile, FileMode.Create), CompressionLevel.Fastest);
            IFormatter formatter = this.CreateFormatter();

            formatter.Serialize(f, entries.Export());
            f.Close();
        }
예제 #6
0
    public override bool UpdateEntry(string userId, FriendEntryBase.Model model)
    {
        if (!base.UpdateEntry(userId, model))
        {
            return(false);
        }

        var entry = entries[userId];

        if (model.status == PresenceStatus.ONLINE)
        {
            offlineFriendsList.Remove(userId);
            onlineFriendsList.Add(userId, entry);

            var removedTimestamp = offlineFriendsList.RemoveLastTimestamp(userId);
            onlineFriendsList.AddOrUpdateLastTimestamp(removedTimestamp);
        }
        else
        {
            onlineFriendsList.Remove(userId);
            offlineFriendsList.Add(userId, entry);

            var removedTimestamp = onlineFriendsList.RemoveLastTimestamp(userId);
            offlineFriendsList.AddOrUpdateLastTimestamp(removedTimestamp);
        }

        return(true);
    }
예제 #7
0
    public override bool UpdateEntry(string userId, FriendEntryBase.Model model)
    {
        if (!base.UpdateEntry(userId, model))
        {
            //Replace the queued model for creation for the updated one.
            if (creationQueue.ContainsKey(userId))
            {
                creationQueue[userId] = model;
            }
            return(false);
        }

        var entry = entries[userId];

        if (model.status == PresenceStatus.ONLINE)
        {
            offlineFriendsList.Remove(userId);
            onlineFriendsList.Add(userId, entry);

            var removedTimestamp = offlineFriendsList.RemoveLastTimestamp(userId);
            onlineFriendsList.AddOrUpdateLastTimestamp(removedTimestamp);
        }
        else
        {
            onlineFriendsList.Remove(userId);
            offlineFriendsList.Add(userId, entry);

            var removedTimestamp = onlineFriendsList.RemoveLastTimestamp(userId);
            offlineFriendsList.AddOrUpdateLastTimestamp(removedTimestamp);
        }

        return(true);
    }
예제 #8
0
        protected override void OnNoClick(Game g, Widget w)
        {
            CloseOverlay();
            EntryList denied = PluginLoader.Denied;

            if (IndexOfWidget(w) >= 2 && !denied.Has(Metadata))
            {
                denied.Add(Metadata);
            }
        }
예제 #9
0
        private async Task UpdateEntryList(RaffleEntry entry)
        {
            // TODO: Replace Console.WriteLine with ILogger
            Console.WriteLine($"{DateTime.Now}: Adding {entry.MessageSid} to the entry list");
            await Task.Run(() => EntryList.Add(entry));

            Console.WriteLine($"{DateTime.Now}: Adding {entry.MessageSid} to the entry list");
            ToggleEnabledButtons(false, true, true);
            StateHasChanged();
        }
예제 #10
0
        protected override void OnNoClick(Game g, Widget w)
        {
            game.Gui.DisposeOverlay(this);
            EntryList denied = PluginLoader.Denied;

            if (IsAlways(w) && !denied.Has(Plugin))
            {
                denied.Add(Plugin);
            }
        }
예제 #11
0
        protected override void OnYesClick(Game g, Widget w)
        {
            game.Gui.DisposeOverlay(this);
            EntryList accepted = PluginLoader.Accepted;

            if (IsAlways(w) && !accepted.Has(Plugin))
            {
                accepted.Add(Plugin);
            }
            PluginLoader.Load(Plugin, true);
        }
예제 #12
0
        protected override void OnYesClick(Game g, Widget w)
        {
            CloseOverlay();
            EntryList accepted = PluginLoader.Accepted;

            if (IndexOfWidget(w) >= 2 && !accepted.Has(Metadata))
            {
                accepted.Add(Metadata);
            }
            PluginLoader.Load(Metadata, true);
        }
예제 #13
0
        /// <summary>
        /// Gets all metainfo concerning a given class and creates an empty block if not found
        /// </summary>
        /// <param name="target">The class name</param>
        /// <returns>All metainfo about a class</returns>
        private static MetaInfoEntry GetEntryForced(string target)
        {
            MetaInfoEntry entry = MetaInfo.GetEntry(target);

            if (entry == null)
            {
                entry = new MetaInfoEntry(target);
                _targets.Add(entry);
            }

            return(entry);
        }
예제 #14
0
파일: MAP.cs 프로젝트: djey47/tdumt
        /// <summary>
        /// Met à jour les tailles des entrées spécifiées.
        /// Ecrit directement dans le fichier
        /// </summary>
        /// <param name="idList">liste d'identifiants internes de fichiers</param>
        /// <param name="size1List">liste des tailles 1 à appliquer</param>
        /// <param name="size2List">liste des tailles 2 à appliquer</param>
        public void UpdateEntrySizes(Collection <uint> idList, Collection <uint> size1List, Collection <uint> size2List)
        {
            if (idList == null || size1List == null || size2List == null)
            {
                return;
            }

            // Parcours des entrées
            for (int i = 0; i < idList.Count; i++)
            {
                uint fileId = idList[i];
                uint size1  = size1List[i];
                uint size2  = size2List[i];

                // Récupération de l'entrée
                Entry e = EntryList[fileId];

                // Mise à jour de la structure
                e.firstSize  = size1;
                e.secondSize = size2;

                // Enregistrement dans le fichier
                BinaryWriter mapWriter = null;
                try
                {
                    // ANO_22 : on enlève l'attribut 'lecture seule' sur le fichier
                    File2.RemoveAttribute(FileName, FileAttributes.ReadOnly);

                    mapWriter = new BinaryWriter(new FileStream(FileName, FileMode.Open));
                    mapWriter.BaseStream.Seek(e.address, SeekOrigin.Begin);

                    // Taille 1
                    mapWriter.BaseStream.Seek(0x4, SeekOrigin.Current);
                    mapWriter.Write(BinaryTools.ToLittleEndian(size1));

                    // Taille 2
                    mapWriter.BaseStream.Seek(0x4, SeekOrigin.Current);
                    mapWriter.Write(BinaryTools.ToLittleEndian(size2));

                    // Mise à jour de la liste d'entrées
                    EntryList.Remove(fileId);
                    EntryList.Add(fileId, e);
                }
                finally
                {
                    if (mapWriter != null)
                    {
                        mapWriter.Close();
                    }
                }
            }
        }
예제 #15
0
        public void SetReplacement(IList <ReplacementEntry> indexList)
        {
            EntryList.Clear();
            foreach (ReplacementEntry Index in indexList)
            {
                EntryList.Add(Index);
            }

            if (listOptions.SelectedIndex < 0 && EntryList.Count > 0)
            {
                listOptions.SelectedIndex = 0;
            }
        }
예제 #16
0
        /// <summary>
        /// Protected initializer required for custom serialization.
        /// </summary>
        protected Schema(SerializationInfo info, StreamingContext context)
        {
            _CaseSensitiveNames = info.GetBoolean("CaseSensitiveNames");
            _Aliases            = info.GetExtended <IElementAliasCollection>("Aliases");

            _Members = new EntryList(_CaseSensitiveNames);
            int count = (int)info.GetValue("MembersCount", typeof(int));

            for (int i = 0; i < count; i++)
            {
                var member = info.GetExtended <ISchemaEntry>("Member" + i);
                _Members.Add(member);
            }
        }
예제 #17
0
        protected override void OnNoClick(Game g, Widget w, MouseButton btn, int x, int y)
        {
            if (btn != MouseButton.Left)
            {
                return;
            }
            CloseOverlay();

            EntryList denied = PluginLoader.Denied;

            if (IndexOfWidget(w) >= 2 && !denied.Has(Metadata))
            {
                denied.Add(Metadata);
            }
        }
예제 #18
0
        private void Handle_CreatureQuery(WoWReader wr)
        {
            Entry entry = new Entry();

            entry.entry   = wr.ReadUInt32();
            entry.name    = wr.ReadString();
            entry.blarg   = wr.ReadBytes(3);
            entry.subname = wr.ReadString();
            entry.flags   = wr.ReadUInt32();
            entry.subtype = wr.ReadUInt32();
            entry.family  = wr.ReadUInt32();
            entry.rank    = wr.ReadUInt32();

            BoogieCore.Log(LogType.NeworkComms, "Got CreatureQuery Response - Entry: {0} - Name: {1} - SubName {2}", entry.entry, entry.name, entry.subname);
            if (EntryList.ContainsKey(entry.entry) == false)
            {
                EntryList.Add(entry.entry, entry);
            }

            if (EntryQueue.ContainsKey(entry.entry))
            {
                EntryQueue.Remove(entry.entry);
            }

            foreach (Object obj in BoogieCore.world.getObjectList())
            {
                if (obj.Fields != null)
                {
                    if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry)
                    {
                        if (entry.name.Contains("Auctioneer") && SentHello == false)
                        {
                            WoWWriter ww = new WoWWriter(OpCode.MSG_AUCTION_HELLO);
                            ww.Write(obj.GUID.GetOldGuid());
                            Send(ww.ToArray());
                            BoogieCore.Log(LogType.SystemDebug, "Sent AH Hello!");
                            SentHello = true;
                        }

                        obj.Name    = entry.name;
                        obj.SubName = entry.subname;
                        obj.SubType = entry.subtype;
                        obj.Family  = entry.family;
                        obj.Rank    = entry.rank;
                    }
                }
            }
        }
예제 #19
0
        public void SyncPeriod()
        {
            try
            {
                List <Entry> list = Cache.GetEntryCache(date)[(int)period];

                foreach (Entry e in list)
                {
                    bool HadIt = false;
                    foreach (var VM in EntryList)
                    {
                        if (VM.IsForEntry(e))
                        {
                            HadIt = true;
                            VM.NotifyIfChanged();
                        }
                    }
                    if (!HadIt)
                    {
                        //EntryList.Insert(0, new EntryVM(e));
                        EntryList.Add(new EntryRowVM(e));
                        if (EntryList.Count == 1)
                        {
                            NotifyPropertyChanged("NoEntriesVisibility");
                        }
                    }
                }

                for (int i = 0; i < EntryList.Count;)
                {
                    if (list.Count(e => EntryList[i].IsForEntry(e)) == 0)
                    {
                        EntryList.RemoveAt(i);
                        if (EntryList.Count == 0)
                        {
                            NotifyPropertyChanged("NoEntriesVisibility");
                        }
                    }
                    else
                    {
                        i++;
                    }
                }

                NotifyPropertyChanged("TotalValue");
            }
            catch (Exception ex) { LittleWatson.ReportException(ex); }
        }
예제 #20
0
        protected override void OnYesClick(Game g, Widget w, MouseButton btn, int x, int y)
        {
            if (btn != MouseButton.Left)
            {
                return;
            }
            CloseOverlay();

            EntryList accepted = PluginLoader.Accepted;

            if (IndexOfWidget(w) >= 2 && !accepted.Has(Metadata))
            {
                accepted.Add(Metadata);
            }
            PluginLoader.Load(Metadata, true);
        }
예제 #21
0
    public App()
    {
        HarvestApp.GoogleAPIManager GAPImanager = new HarvestApp.GoogleAPIManager();

        List <Event> todayCalendar = GAPImanager.GetCalendarEventsForDate(DateTime.Today);

        HarvestApp.HarvestManager HAPIManager = new HarvestApp.HarvestManager();

        Console.WriteLine("Entries found for Today :" + todayCalendar.Count);

        foreach (Event todayEvent in todayCalendar)
        {
            var addEvent = new HarvestApp.Harvest_TimeSheetEntry(todayEvent);
            EntryList.Add(addEvent);
            HAPIManager.postHarvestEntry(addEvent);
        }
    }
예제 #22
0
            public static EntryList Import(object[,] raw)
            {
                EntryList result = new EntryList();

                int len = raw.GetLength(0);

                for (int i = 0; i < len; i++)
                {
                    result.Add(new Entry(
                                   (string)raw[i, Entry.TypeIndex],
                                   (string)raw[i, Entry.FieldIndex],
                                   (int)raw[i, Entry.VersionIndex],
                                   raw[i, Entry.ValueIndex]
                                   ));
                }

                return(result);
            }
예제 #23
0
        ///<summary> Формирование элементов альбома по путям. </summary>
        public void LoadDir()
        {
            AlbAbsDir.Refresh();
            if (!AlbAbsDir.Exists)
            {
                return;
            }
            List <FileInfo> vidList = null;

            try {
                if (WithSubDir)
                {
                    vidList = AlbAbsDir.EnumerateFiles("*.*", SearchOption.AllDirectories).Where(f => CatalogEngine.vidExt.ContainsIC(f.Extension)).ToList();
                }
                else
                {
                    vidList = AlbAbsDir.EnumerateFiles("*.*", SearchOption.TopDirectoryOnly).Where(f => CatalogEngine.vidExt.ContainsIC(f.Extension)).ToList();
                }
            } catch (UnauthorizedAccessException) {
                Console.WriteLine("No access to folder " + AlbAbsDir.FullName);
                return;
            }

            // удаляем файлы с пустым расширением, почему то они проходят проверку на расширения
            vidList.RemoveAll(vid => string.IsNullOrWhiteSpace(vid.Extension));

            Parallel.ForEach(vidList, new ParallelOptions {
                MaxDegreeOfParallelism = CatalogEngine.maxThreads
            },
                             file => {
                // не формируем, если такое было
                lock (locker) if (EntryList.Any(ent2 => ent2.EntAbsFile.FullName == file.FullName))
                    {
                        return;
                    }
                CatalogEntry newEnt = new CatalogEntry(file, this);
                lock (locker) EntryList.Add(newEnt);
            }
                             );

            // сортируем, т.к. потоки закончились в разнобой
            EntryList = EntryList.OrderBy(x => x.Name, new AlphanumComparatorFast()).ToList();
        }
예제 #24
0
        private void Handle_GameObjectQuery(WoWReader wr)
        {
            Entry entry = new Entry();

            entry.entry = wr.ReadUInt32();
            if (entry.entry < 1 || wr.Remaining < 4)
            {
                BoogieCore.Log(LogType.System, "Got {1} in GameObject query response for entryid or remaining in packet too small {0}", wr.Remaining, entry.entry);
                return;
            }

            entry.Type      = wr.ReadUInt32();
            entry.DisplayID = wr.ReadUInt32();
            entry.name      = wr.ReadString();

            BoogieCore.Log(LogType.NeworkComms, "Got GameObject Query Response - Entry: {0} - Name: {1} - Type {2}", entry.entry, entry.name, entry.Type);
            if (EntryList.ContainsKey(entry.entry) == false)
            {
                EntryList.Add(entry.entry, entry);
            }

            if (EntryQueue.ContainsKey(entry.entry))
            {
                EntryQueue.Remove(entry.entry);
            }

            foreach (Object obj in BoogieCore.world.getObjectList())
            {
                if (obj.Fields != null)
                {
                    if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry)
                    {
                        obj.Type = (byte)entry.Type;
                        obj.Name = entry.name;
                    }
                }
            }
        }
예제 #25
0
 void ShowInvalidData()
 {
     EntryList.Clear();
     EntryList.Add(CreateEntry(SystemUtil.GetStringResource("Exif_NoData")));
 }
예제 #26
0
파일: Trade.cs 프로젝트: raginpm/Ragin
 public Entry()
 {
     globalId = Count; Count++;
     EntryList.Add(this);
 }
예제 #27
0
		/// <summary>
		/// Protected initializer required for custom serialization.
		/// </summary>
		protected Schema(SerializationInfo info, StreamingContext context)
		{
			_CaseSensitiveNames = info.GetBoolean("CaseSensitiveNames");
			_Aliases = info.GetExtended<IElementAliasCollection>("Aliases");

			_Members = new EntryList(_CaseSensitiveNames);
			int count = (int)info.GetValue("MembersCount", typeof(int));
			for (int i = 0; i < count; i++)
			{
				var member = info.GetExtended<ISchemaEntry>("Member" + i);
				_Members.Add(member);
			}
		}
예제 #28
0
        private void UpdateEntryList(JpegMetaData metadata)
        {
            EntryList.Clear();

            var exposureModeEntry = FindFirstEntry(metadata, ExifKeys.ExposureProgram);

            if (exposureModeEntry != null)
            {
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.ExposureProgram),
                                          MetaDataValueConverter.ExposuteProgramName(exposureModeEntry.UIntValues[0])));
            }

            var ssEntry = FindFirstEntry(metadata, ExifKeys.ExposureTime);

            if (ssEntry != null)
            {
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.ExposureTime),
                                          MetaDataValueConverter.ShutterSpeed(ssEntry.UFractionValues[0].Numerator, ssEntry.UFractionValues[0].Denominator)));
            }

            var focalLengthEntry = FindFirstEntry(metadata, ExifKeys.FocalLength);

            if (focalLengthEntry != null)
            {
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.FocalLength),
                                          GetStringValue(metadata, ExifKeys.FocalLength) + "mm"));
            }

            foreach (uint key in GeneralMetaDataKeys)
            {
                if (FindFirstEntry(metadata, key) == null)
                {
                    continue;
                }
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(key),
                                          GetStringValue(metadata, key)));
            }

            var wbEntry       = FindFirstEntry(metadata, ExifKeys.WhiteBalanceMode);
            var wbDetailEntry = FindFirstEntry(metadata, ExifKeys.WhiteBalanceDetailType);

            if (wbEntry != null && wbDetailEntry != null)
            {
                string value;
                if (wbEntry.UIntValues[0] == 0x0)
                {
                    value = SystemUtil.GetStringResource("WB_Auto");
                }
                else
                {
                    value = MetaDataValueConverter.WhitebalanceName(wbDetailEntry.UIntValues[0]);
                }
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.WhiteBalanceMode), value));
            }

            var evEntry = FindFirstEntry(metadata, ExifKeys.ExposureCompensation);

            if (evEntry != null)
            {
                EntryList.Add(CreateEntry(SystemUtil.GetStringResource("MetaDataName_ExposureCompensation"), MetaDataValueConverter.EV(evEntry.DoubleValues[0])));
            }

            var meteringModeEntry = FindFirstEntry(metadata, ExifKeys.MeteringMode);

            if (meteringModeEntry != null)
            {
                EntryList.Add(CreateEntry(SystemUtil.GetStringResource("MetaDataName_MeteringMode"), MetaDataValueConverter.MeteringModeName(meteringModeEntry.UIntValues[0])));
            }

            var flashEntry = FindFirstEntry(metadata, ExifKeys.Flash);

            if (flashEntry != null)
            {
                EntryList.Add(CreateEntry(SystemUtil.GetStringResource("MetaDataName_Flash"), MetaDataValueConverter.FlashNames(flashEntry.UIntValues[0])));
            }

            var heightEntry = FindFirstEntry(metadata, ExifKeys.ImageHeight);
            var widthEntry  = FindFirstEntry(metadata, ExifKeys.ImageWidth);

            if (heightEntry != null && widthEntry != null)
            {
                EntryList.Add(CreateEntry(SystemUtil.GetStringResource("MetaDataName_ImageSize"),
                                          widthEntry.UIntValues[0] + " x " + heightEntry.UIntValues[0]));
            }

            var makerEntry = FindFirstEntry(metadata, ExifKeys.CameraMaker);
            var modelEntry = FindFirstEntry(metadata, ExifKeys.CameraModel);

            if (makerEntry != null && modelEntry != null)
            {
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.CameraModel),
                                          makerEntry.StringValue + " " + modelEntry.StringValue));
            }

            var lensNameEntry = FindFirstEntry(metadata, ExifKeys.LensModel);

            if (lensNameEntry != null)
            {
                EntryList.Add(CreateEntry(MetaDataValueConverter.MetaDataEntryName(ExifKeys.LensModel), lensNameEntry.StringValue));
            }

            var geotagEntry = FindFirstEntry(metadata, ExifKeys.GpsLatitude);

            if (geotagEntry != null)
            {
                EntryList.Add(CreateEntry(SystemUtil.GetStringResource("MetaData_Geotag"), MetaDataValueConverter.Geoinfo(metadata.GpsIfd)));
            }
        }
예제 #29
0
 void ShowInvalidData()
 {
     EntryList.Clear();
     EntryList.Add(CreateEntry("NO DATA"));
 }
예제 #30
0
        public int EntryAdd(Entry entry)
        {
            if (IsDisposed)
            {
                if (AllowExceptions)
                {
                    throw new InvalidOperationException("This Wheel has been Disposed.");
                }
                else
                {
                    return(-1);
                }
            }
            if (IsBusy)
            {
                if (AllowExceptions)
                {
                    throw new InvalidOperationException("Wheel is currently busy");
                }
                else
                {
                    return(-1);
                }
            }
            if (entry.UniqueID == -1)
            {
                if (EntryList.Count() == 0)
                {
                    entry.UniqueID = 0;
                }
                else
                {
                    entry.UniqueID = EntryList.Last().UniqueID + 1;
                }
            }

            int check1 = EntryList.FindIndex(x => x.UniqueID == entry.UniqueID);

            if (check1 != -1)
            {
                return(-1);
            }

            if (ToolProperties.ForceUniqueEntryColors)
            {
                int check2 = EntryList.FindIndex(x => x.Name == entry.Name);
                if (check2 != -1)
                {
                    entry.Aura = EntryList[check2].Aura;
                }                                       //use same color as others with same name
                else
                {
                    int check3 = EntryList.FindIndex(x => x.Aura == entry.Aura);
                    if (check3 != -1)
                    {
                        entry.Aura = ColorIncrementRnd(EntryList[check3].Aura, 25);
                        int check4 = EntryList.FindIndex(x => x.Aura == entry.Aura);
                        if (check4 != -1)
                        {
                            entry.Aura = ColorIncrementRnd(EntryList[check3].Aura, 50);
                        } //use new color since another name is using this color
                    }     //use new color since another name is using this color
                }
            }

            EntryList.Add(entry);

            return(entry.UniqueID);
        }
예제 #31
0
        public EntryData GetEntryData(string url) 
        {

            WebRequest request = WebRequest.Create(url);
            XmlDocument atomDoc = null;

            using (WebResponse response = request.GetResponse())
            {
                Stream atomStream = response.GetResponseStream();
                
                atomDoc = new XmlDocument();
                atomDoc.Load(atomStream);

                atomStream.Close();
                response.Close();
            }

            XmlNamespaceManager nsmanager = new XmlNamespaceManager(atomDoc.NameTable);
            nsmanager.AddNamespace("default", "http://www.w3.org/2005/Atom");

            EntryData entryData = new EntryData();

            EntryList entryList = new EntryList();
            entryData.EntryList = entryList;

            XmlNode updatedNode = atomDoc.SelectSingleNode("default:feed/default:updated", nsmanager);
            if (updatedNode != null)
            {
                // format 2009-12-24T05:53:20Z
                // format 2013-01-23T11:51:59-07:0 +0
                string dateString = updatedNode.InnerText;
                if (dateString.Contains("-07:0"))
                {
                    dateString = dateString.Replace("-07:0", " -7");
                }
                else
                {
                    dateString = dateString.Substring(0, dateString.Length - 1) + " +0";
                }
                DateTime updatedDate = DateParser.Parse(dateString, "yyyy'-'MM'-'dd'T'HH':'mm':'ss z");
                entryData.LastBuildDate = updatedDate;
            }

            XmlNodeList atomEntryNodeList = atomDoc.SelectNodes("default:feed/default:entry", nsmanager);

            if (atomEntryNodeList != null)
            {
                Console.WriteLine("LIST " + atomEntryNodeList.Count);

                foreach (XmlNode atomEntryNode in atomEntryNodeList)
                {
                    Entry entry = new Entry();

                    foreach (XmlNode childNode in atomEntryNode.ChildNodes)
                    {
                        if (childNode.Name == "title")
                        {
                            entry.Title = childNode.InnerText;
                        }
                        else if (childNode.Name == "id")
                        {
                            entry.ID = childNode.InnerText;
                        }
                        else if (childNode.Name == "content")
                        {
                            entry.Content = childNode.InnerText;
                        }
                        else
                        {
                            entry.Set(childNode.Name, childNode.InnerText);
                        }
                    }
                    entryList.Add(entry);
                }
            }
            return entryData;
        }
예제 #32
0
        /// <summary>
        /// Adds the given orphan instance into this collection.
        /// </summary>
        /// <param name="member">The orphan instance to add into this collection.</param>
        public void Add(ISchemaEntry member)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }

            if (member == null)
            {
                throw new ArgumentNullException("member", "Member cannot be null.");
            }
            if (member.IsDisposed)
            {
                throw new ObjectDisposedException(member.ToString());
            }

            if (object.ReferenceEquals(this, member.Owner))
            {
                return;
            }
            if (member.Owner != null)
            {
                throw new NotOrphanException(
                          "Cannot add member '{0}' into this '{1}' because it is not orphan."
                          .FormatWith(member, this));
            }

            Core.SchemaEntry.ValidateTable(member.TableName);
            Core.SchemaEntry.ValidateColumn(member.ColumnName);

            var alias = (IElementAlias)(member.TableName == null ? null : Aliases.FindAlias(member.TableName));

            if (alias != null)
            {
                member.TableName = alias.Element;
            }

            var temp = FindEntry(member.TableName, member.ColumnName);

            if (temp != null)
            {
                throw new DuplicateException(
                          "Cannot add member '{0}' into this '{1}' because its name is already used."
                          .FormatWith(member, this));
            }

            var list = FindColumn(member.ColumnName).ToList(); if (list.Count != 0)

            {
                if (member.TableName == null)
                {
                    throw new DuplicateException(
                              "Cannot add member '{0}' into this '{1}' because its column is already used in a non-default table."
                              .FormatWith(member, this));
                }

                temp = list.Find(x => x.TableName == null);
                if (temp != null)
                {
                    throw new DuplicateException(
                              "Cannot add member '{0}' into this '{1}' because its name is already used in the default table."
                              .FormatWith(member, this));
                }
            }

            _Members.Add(member);             // To intercept re-entrant operation...
            member.Owner = this;
        }