/// <summary>
        ///     Resolves the name of given <paramref name="updatable"/>
        /// </summary>
        public static string ExtractName(this IUpdatable updatable)
        {
            if (updatable is IIndicator ind)
            {
                return(ind.Name);
            }

            return(updatable.GetType().Name);
        }
Beispiel #2
0
        /// <summary>
        /// Refresh the specified IUpdateable item.
        /// </summary>
        /// <param name="item"></param>
        internal void Refresh(IUpdatable item)
        {
            var methodInfo = (from m in this.GetType().GetMethods()
                              where m.Name == "Refresh" && m.ContainsGenericParameters
                              select m).First();

            var method = methodInfo.MakeGenericMethod(item.GetType());

            method.Invoke(this, new object[] { item.LoadContext, null, null });
        }
        private static string ResolveName(IUpdatable first, string argumentedName)
        {
            if (!string.IsNullOrEmpty(argumentedName))
            {
                return(argumentedName);
            }
            if (first is IIndicator ind)
            {
                argumentedName = $"function({ind.Name})";
            }
            else
            {
                argumentedName = $"function({first.GetType().Name})";
            }

            return(argumentedName);
        }
Beispiel #4
0
        public void Register(IUpdatable obj)
        {
            int index = obj.Index;

            if (index <= 0)
            {
                index     = _index++;
                obj.Index = index;
            }

            if (index >= _objects.Length)
            {
                Array.Resize(ref _objects, 2 * _objects.Length);
            }

            Updatable updatable = _objects[index];

            if (updatable == null)
            {
                updatable             = new Updatable();
                updatable.MaxPerFrame = obj.MaxRefFrame;
                updatable.SkipFrames  = obj.SkipFrames;

                _objects[index] = updatable;

                int hash = obj.TypeHash;
                if (hash == 0)
                {
                    hash = obj.GetType().GetHashCode();
                }

                if (!_updateLimits.ContainsKey(hash))
                {
                    _updateLimits[hash] = new SharedValue <uint>();
                }
                updatable.UpdatesCount = _updateLimits[hash];
            }

            updatable.Item = obj;
            _count++;
        }
Beispiel #5
0
        /// <summary>
        /// Register an updatable object.
        /// </summary>
        public void RegisterUpdatable(IUpdatable updatable)
        {
            Argument.NotNull(() => updatable);

            if (updatables.Contains(updatable))
            {
                throw new FormattedException("Updatable {TypeName} is already registered.", updatable.GetType().Name);
            }

            this.updatables.Add(updatable);
        }