Пример #1
0
        public static Id DetermineFreeGroup(Dictionary <Id, List <Interval> > groups, Interval givenInterval)
        {
            foreach (var groupId in groups.Keys)
            {
                bool occupied = false;
                foreach (var interval in groups[groupId])
                {
                    if (givenInterval.IntersectsExclusive(interval))
                    {
                        occupied = true;
                    }
                }

                if (occupied == false)
                {
                    groups[groupId].Add(givenInterval);
                    return(groupId);
                }
            }

            Id newGroupId = IdGeneratorHolder.GetIdGenerator().GetNewId();

            groups.Add(newGroupId, new List <Interval>());
            groups[newGroupId].Add(givenInterval);
            return(newGroupId);
        }
Пример #2
0
        protected BaseEntity()
        {
            if (Configuration.TrackObjects)
            {
                // create id && track callers of this constructor

                // 1st frame should be the constructor calling
                // 2nd frame should be the constructor of the inherited class
                MethodBase methodFromCaller        = new StackFrame(1).GetMethod();
                StackFrame stackFrameFromRequester = new StackFrame(2);
                MethodBase methodFromRequester     = stackFrameFromRequester.GetMethod();

                // return the type of the inherited class
                Type caller = null;
                if (methodFromCaller != null && methodFromCaller.ReflectedType != null)
                {
                    caller = methodFromCaller.ReflectedType;
                }

                string requester = "";
                if (methodFromRequester != null && methodFromRequester.ReflectedType != null)
                {
                    requester = $"{methodFromRequester.ReflectedType.Name}: ";
                }
                if (methodFromRequester != null)
                {
                    requester += methodFromRequester.Name;
                }

                Id = IdGeneratorHolder.GetIdGenerator().GetNewId(caller, requester).GetValue();
            }
            else
            {
                Id = IdGeneratorHolder.GetIdGenerator().GetNewId().GetValue();
            }
        }