Example #1
0
        internal override void RegenerateDb(IProgress <RegenerateProgress> progress)
        {
            List <AniDB_Episode> episodes;

            using (CacheLock.ReaderLock())
            {
                episodes = IsCached ? Cache.Values.Where(episode => episode.EnglishName.Contains('`') || episode.RomajiName.Contains('`')).ToList() : Table.Where((episode => episode.EnglishName.Contains('`') || episode.RomajiName.Contains('`'))).ToList();
            }
            using (IAtomic <List <AniDB_Episode>, object> update = BeginAtomicBatchUpdate(episodes))
            {
                RegenerateProgress regen = new RegenerateProgress();
                regen.Title = "Fixing Episode Titles";
                regen.Step  = 0;
                regen.Total = update.Updatable.Count;
                foreach (AniDB_Episode episode in update.Updatable)
                {
                    episode.EnglishName = episode.EnglishName.Replace('`', '\'');
                    episode.RomajiName  = episode.RomajiName.Replace('`', '\'');
                    regen.Step++;
                    progress.Report(regen);
                }
                update.Commit();
                regen.Step = regen.Total;
                progress.Report(regen);
            }
        }
Example #2
0
        private static int CompareTypes(IAtomic x, IAtomic y)
        {
            if (x.GetType() == y.GetType())
            {
                return(0);
            }
            if (x is Compound && (y is Atom || y is Isotope))
            {
                return(1);
            }
            if (x is Isotope)
            {
                if (y is Atom)
                {
                    return(1);
                }
                if (y is Compound)
                {
                    return(-1);
                }
            }

            if (x is Atom && (y is Isotope || y is Compound))
            {
                return(-1);
            }
            return(0);
        }
 internal override void RegenerateDb(IProgress<RegenerateProgress> progress)
 {
     const int batchSize = 50;
     List<SVR_AniDB_Anime> animeToUpdate = Where(a => a.ContractVersion < SVR_AniDB_Anime.CONTRACT_VERSION).ToList();
     int max = animeToUpdate.Count;
     int count = 0;
     RegenerateProgress prog = new RegenerateProgress();
     prog.Title = "Regenerating AniDB_Anime Contracts";
     prog.Step = 0;
     prog.Total = max;
     if (max <= 0) return;
     progress.Report(prog);
     foreach (SVR_AniDB_Anime[] animeBatch in animeToUpdate.Batch(batchSize))
     {
         using (IAtomic<List<SVR_AniDB_Anime>,object> update = BeginAtomicBatchUpdate(animeBatch))
         {
             SVR_AniDB_Anime.UpdateContractDetailedBatch(update.Updatable);
             foreach (SVR_AniDB_Anime anime in animeBatch)
             {
                 anime.Description = anime.Description?.Replace("`", "\'") ?? string.Empty;
                 anime.MainTitle = anime.MainTitle.Replace("`", "\'");
                 anime.AllTags = anime.AllTags.Replace("`", "\'");
                 anime.AllTitles = anime.AllTitles.Replace("`", "\'");
                 count++;
             }
         }
         prog.Step = count;
         progress.Report(prog);                    
     }
     prog.Step = max;
     progress.Report(prog);
 }
Example #4
0
        internal override void RegenerateDb(IProgress <RegenerateProgress> progress, int batchSize)
        {
            //TODO Do we still need to run this every time?
            List <AniDB_Anime_Title> titles = GetTitleContains("`");

            if (titles.Count == 0)
            {
                return;
            }
            BatchAction(titles, batchSize, (update) =>
            {
                RegenerateProgress regen = new RegenerateProgress();
                regen.Title = "Fixing Anime Titles";
                regen.Step  = 0;
                regen.Total = update.Updatable.Count;
                foreach (AniDB_Anime_Title title in update.Updatable)
                {
                    title.Title = title.Title.Replace('`', '\'');
                    regen.Step++;
                    progress.Report(regen);
                }
                update.Commit();
                regen.Step = regen.Total;
                progress.Report(regen);
            });
            using (IAtomic <List <AniDB_Anime_Title>, object> update = BeginAtomicBatchUpdate(titles))
            {
            }
        }
Example #5
0
 /// <summary>
 /// Инициализация экземляра класса <see cref="Ion"/>
 /// </summary>
 /// <param name="content">Атомарное состояние иона</param>
 /// <exception cref="ArgumentException"></exception>
 public Ion(IAtomic content)
 {
     if (!content.IsIon())
     {
         throw new ArgumentException("Не является ионом");
     }
     Content = content;
 }
Example #6
0
 public MinimumInterval([NotNull] IClock clock, long minimumInterval)
 {
     if (minimumInterval < 0)
     {
         throw new ArgumentException($"Parameter '{nameof(minimumInterval)}' must be non-negative.");
     }
     _clock           = clock;
     _minimumInterval = minimumInterval;
     _nextAt          = Atomics.Long(_clock.Time);
 }
Example #7
0
 private CLRAtomic()
 {
     switch(RelaEngine.Mode)
     {
         case EngineMode.Test:
             _atomic = new Atomic<T>();
             break;
         case EngineMode.Live:
             _atomic = new LiveAtomic<T>();
             break;
         default:
             throw new EngineException($"{nameof(CLRAtomic<T>)} must only be used when RelaEngine.Mode is {EngineMode.Test} or {EngineMode.Live}, but it is {RelaEngine.Mode} (did you forget to assign it?).");
     }
 }
Example #8
0
        /// <summary>Returns a string that represents the current object.</summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            IAtomic atomic = Atom as Compound;

            if (atomic != null)
            {
                if (Size == 1)
                {
                    sb.Append($"{atomic}");
                    return(sb.ToString());
                }

                sb.Append($"{Size}({atomic})");
                return(sb.ToString());
            }

            sb.Append($"{Atom.GetElements().ToArray()[0].Symbol}{(Size == 1 ? string.Empty : Size.ToString())}");
            return(sb.ToString());
        }
        internal override void RegenerateDb(IProgress <RegenerateProgress> progress)
        {
            List <AniDB_Tag> tags = Where(tag => (tag.TagDescription?.Contains('`') ?? false) || tag.TagName.Contains('`')).ToList();

            using (IAtomic <List <AniDB_Tag>, object> update = BeginAtomicBatchUpdate(tags))
            {
                RegenerateProgress regen = new RegenerateProgress();
                regen.Title = "Fixing Tag Names";
                regen.Step  = 0;
                regen.Total = update.Updatable.Count;
                foreach (AniDB_Tag tag in update.Updatable)
                {
                    tag.TagDescription = tag.TagDescription?.Replace('`', '\'');
                    tag.TagName        = tag.TagName.Replace('`', '\'');
                    regen.Step++;
                    progress.Report(regen);
                }
                update.Commit();
                regen.Step = regen.Total;
                progress.Report(regen);
            }
        }
        public Material(float noise)
        {
            Noise = noise;
            AcousticProperties       = new Acoustic();
            AtomicProperties         = new Atomic();
            ChemicalProperties       = new Chemical();
            ElectricalProperties     = new Electrical();
            EnvironmentalProperties  = new Environmental();
            MagneticProperties       = new Magnetic();
            ManufacturingProperties  = new Manufacturing();
            MechanicalProperties     = new Mechanical();
            OpticalProperties        = new Optical();
            RadiologicalProperties   = new Radiological();
            ThermoDynamicsProperties = new ThermoDynamics();

            float input_start  = -1;
            float input_end    = 1;
            float output_start = 0;
            float output_end   = 256 * 256 * 256;

            double output;

            double slope = 1.0 * (output_end - output_start) / (input_end - input_start);

            output = output_start + slope * (Noise - input_start);

            float Positive = Noise.Spread(-1, 1, 0, 1);

            float r = Voxel.GetRed(Positive);
            float g = Voxel.GetGreen(Positive);
            float b = Voxel.GetBlue(Positive);
            float a = Voxel.GetAlpha(Noise);

            PhysicalMaterial = new PhongMaterial
            {
                DiffuseColor = new Color4(r, g, b, a)
            };
        }
Example #11
0
 /// <summary>
 /// Initializes an instance of the <see cref="RedoxDelta"/> class.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="leftContent">The left-hand atomic content.</param>
 /// <param name="rightContent">The right-hand atomic content.</param>
 /// <param name="left">The left-hand oxidation number.</param>
 /// <param name="right">The right-hand oxidation number.</param>
 internal RedoxDelta(Element element, IAtomic leftContent, IAtomic rightContent, int left, int right)
 {
     Element = element;
     Left    = new Tuple <IAtomic, int>(leftContent, left);
     Right   = new Tuple <IAtomic, int>(rightContent, right);
 }
Example #12
0
 public LockBasedAtomic(IAtomic <T> atomic)
 {
     _atomic = atomic;
 }
Example #13
0
 public static bool IsUpdate <T, TT>(this IAtomic <T, TT> at)
 {
     return(at.Original != null);
 }
Example #14
0
 public static bool IsNew <T, TT>(this IAtomic <T, TT> at)
 {
     return(at.Original == null);
 }
Example #15
0
 /// <summary>
 /// Initializes an instance of the <see cref="Ion"/> class.
 /// </summary>
 /// <param name="content">The atomic content.</param>
 public Ion(IAtomic content)
 {
     Content = content;
 }
 public AtomicPtrAsDummyImmutableValWrapper()
 {
     _castPtr = _ptr;
 }
Example #17
0
 /// <summary>
 /// Initializes an instance of the <see cref="Stack"/> class.
 /// </summary>
 /// <param name="atom">The element.</param>
 /// <param name="size">The size.</param>
 public Stack(IAtomic atom, int size = 1)
 {
     Atom = atom;
     Size = size;
 }
Example #18
0
 /// <summary>
 /// Initializes an instance of the <see cref="OxidationResult"/> class.
 /// </summary>
 /// <param name="content">The atomic content.</param>
 /// <param name="numbers">The oxidation numbers.</param>
 internal OxidationResult(IAtomic content, Dictionary <Element, int> numbers)
 {
     Content = content;
     Numbers = numbers;
 }