Exemple #1
0
        UpdateReferenceSideEffect UpdateReferencesByBuild(int amount, EngineBuildHandle buildHandle)
        {
            var side_effect = UpdateReferenceSideEffect.None;

            if (Prototype.SystemRequiresReferenceTracking)
            {
                EngineBuildHandle engine, branch;
                buildHandle.ExtractHandles(out engine, out branch);

                int revisn_count, branch_count, engine_count;
                lock (mReferencesByBuildCounts)
                {
                    revisn_count = UpdateReferencesByHandle(amount, buildHandle, ref side_effect);
                    branch_count = UpdateReferencesByHandle(amount, branch, ref side_effect);
                    engine_count = UpdateReferencesByHandle(amount, engine, ref side_effect);
                }

                // Validate that a RemoveReference hasn't made a count go negative (ie, there was an extra call)
                if (amount < 0)
                {
                    if (revisn_count < 0 || branch_count < 0 || engine_count < 0)
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "Extra or bad RemoveReference call detected for {0} using the handle {1}",
                                                                Prototype, buildHandle.ToDisplayString()));
                    }
                }
            }
            else
            {
                int new_count = UpdateReferencesByHandle(amount, EngineBuildHandle.None, ref side_effect);

                // Validate that a RemoveReference hasn't made a count go negative (ie, there was an extra call)
                if (amount < 0)
                {
                    if (new_count < 0)
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "Extra or bad RemoveReference call detected for {0}",
                                                                Prototype));
                    }
                }
            }

            return(side_effect);
        }
Exemple #2
0
        EngineSystemBase GetSystem(Values.KGuid systemGuid, EngineBuildHandle forBuild)
        {
            if (!SupportsSystem(systemGuid))
            {
                string system_display_name = EngineRegistry.GetSystemDebugDisplayString(systemGuid);

                string msg = string.Format("{0} doesn't support the system {1}",
                                           forBuild.ToDisplayString(), system_display_name);

                throw new InvalidOperationException(msg);
            }

            var system_metadata = EngineRegistry.TryGetRegisteredSystem(systemGuid);

            Contract.Assume(system_metadata != null);

            return(GetNewOrExistingSystem(system_metadata));
        }