/// <summary>
        /// Projects the event onto the FullName Model provided.
        /// </summary>
        /// <typeparam name="T">Type of the Event</typeparam>
        /// <param name="eventData"></param>
        /// <param name="fullNameModel"></param>
        public void HandleEvent <T>(T eventData, ref NameDTO fullNameModel) where T : IEvent
        {
            var referenceHolder = new ReferenceHolder <NameDTO>(fullNameModel);

            _eventHandlers[eventData.GetType().Name](eventData, referenceHolder);
            fullNameModel = referenceHolder.Value;
        }
Beispiel #2
0
        public void PkTypeIsValueType()
        {
            var bookRepo = new Mock <IRepository <Book> >();
            var book     = new ReferenceHolder <Book, long>(bookRepo.Object);

            Assert.DoesNotThrow(() => book.Object = new Mock <Book>().Object);
        }
 // Start is called before the first frame update
 void Start()
 {
     referenceHolder = GetComponentInParent <ReferenceHolder>();
     isVisible       = false;
     once            = false;
     UpdateVisible();
 }
 // Use this for initialization
 void Start()
 {
     referenceHolder = FindObjectOfType <ReferenceHolder>();
     lineIndex       = 0;
     //currentConvo = referenceHolder.convoHandler != null ? referenceHolder.convoHandler.currentConvo : null;
     UpdateSpeechBubble();
 }
 // Start is called before the first frame update
 void Start()
 {
     referenceHolder = GetComponentInParent <ReferenceHolder>();
     panel           = transform.GetChild(0).gameObject;
     panel.SetActive(false);
     missedImage.SetActive(false);
     runButton.SetActive(false);
 }
Beispiel #6
0
        public void NullValuesEqual()
        {
            var first = ReferenceHolder <object?> .Strong(null);

            var second = ReferenceHolder <object?> .Weak(null);

            VerifyEqual(first, second);
        }
 // Start is called before the first frame update
 void Start()
 {
     referenceHolder = GetComponentInParent <ReferenceHolder>();
     panel           = transform.GetChild(0).gameObject;
     panel.SetActive(true);
     numberText = GetComponentInChildren <Text>();
     panel.SetActive(false);
 }
Beispiel #8
0
 public Match()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _gameStep   = new ReferenceHolder <IGameStep, Guid>(GameStepRepository);
     _team1      = new ReferenceHolder <ITeam, Guid>(TeamRepository);
     _team2      = new ReferenceHolder <ITeam, Guid>(TeamRepository);
     _matchField = new ReferenceHolder <IField, Guid>(FieldRepository);
     _setting    = new ReferenceHolder <IMatchSetting, Guid>(MatchSettingRepository);
 }
Beispiel #9
0
        public void SameMixedObjectsEqual()
        {
            var obj   = new object();
            var first = ReferenceHolder <object?> .Strong(obj);

            var second = ReferenceHolder <object?> .Weak(obj);

            VerifyEqual(first, second);
        }
 void OnEnable()
 {
     m_RefHolder  = (ReferenceHolder)target;
     m_ReorderLst = new ReorderableList(serializedObject, serializedObject.FindProperty("Datas"));
     m_ReorderLst.drawElementCallback = DrawChild;
     m_ReorderLst.onAddCallback       = AddButton;
     m_ReorderLst.drawHeaderCallback  = DrawHeader;
     m_ReorderLst.onRemoveCallback    = RemoveButton;
 }
Beispiel #11
0
 public static void BuildSinglePlatformPackages(PackageSharedBuildInfo sharedBuildInfo, PackagePlatform platform)
 {
     //NOTE: 命令行模式下, ScriptableObject 会被编辑器主动 Destroy, 这里利用一个临时的 GameObject 强制保持引用
     //NOTE: 之后考虑将 data 改为普通对象使用 json 序列化
     using (var hold = ReferenceHolder.Create(sharedBuildInfo.data))
     {
         _BuildPackages(new PackageBuildInfo(sharedBuildInfo, platform, ToBuildTarget(platform)));
     }
 }
Beispiel #12
0
 int GetDisposePriority(ReferenceHolder<RefCounted> refHolder)
 {
     const int defaulPriority = 1000;
     var obj = refHolder?.Reference;
     if (obj == null)
         return defaulPriority;
     if (obj is Scene)
         return 1;
     //TODO:
     return defaulPriority;
 }
Beispiel #13
0
 public Team()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _contest   = new ReferenceHolder <IContest, Guid>(ContestRepository);
     _matchList = new Lazy <IList <IMatch> >(() => MatchRepository.Find(_ => _.Team1Id == Id)
                                             .Union(MatchRepository.Find(_ => _.Team2Id == Id))
                                             .ToList());
     _memberList = new Lazy <IList <IRelationship <ITeam, IPerson> > >(() => TeamPersonRelationshipRepository.Find(_ => _.FirstItemInvolveId == Id).ToList());
     _gameStepTeamRelationshipList = new Lazy <IList <IRelationship <ITeam, IGameStep> > >(() => TeamGameStepRelationshipRepository.Find(_ => _.FirstItemInvolveId == Id).ToList());
     _phaseTeamRelationshipList    = new Lazy <IList <IRelationship <ITeam, IPhase> > >(() => TeamPhaseRelationshipRepository.Find(_ => _.SecondItemInvolveId == Id).ToList());
 }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Beispiel #15
0
        public void ExpiredValueNotEqualToNull()
        {
            var strongNull = ReferenceHolder <object?> .Strong(null);

            var weakNull = ReferenceHolder <object?> .Weak(null);

            var expired = ReferenceHolder <object?> .TestAccessor.ReleasedWeak(hashCode : EqualityComparer <object?> .Default.GetHashCode(null !));

            Assert.Equal(strongNull.GetHashCode(), expired.GetHashCode());
            VerifyNotEqual(strongNull, expired);
            VerifyNotEqual(weakNull, expired);
        }
Beispiel #16
0
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;

        /*if (instance != null && instance != this)
         * {
         *  Destroy(gameObject);
         *  return;
         * }
         * instance = this;
         * DontDestroyOnLoad(gameObject);*/
    }
Beispiel #17
0
 public Contest()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _gameSetting                 = new ReferenceHolder <IGameSetting, Guid>(GameSettingRepository);
     _physicalSetting             = new ReferenceHolder <IPhysicalSetting, Guid>(PhysicalSettingRepository);
     _eliminationSetting          = new ReferenceHolder <IEliminationStepSetting, Guid>(EliminationStepSettingRepository);
     _consolingEliminationSetting = new ReferenceHolder <IEliminationStepSetting, Guid>(EliminationStepSettingRepository);
     _qualificationSetting        = new ReferenceHolder <IQualificationStepSetting, Guid>(QualificationStepSettingRepository);
     _phaseList = new Lazy <IList <IPhase> >(() => PhaseRepository.Find(_ => _.ContestId == Id).ToList());
     _fieldList = new Lazy <IList <IField> >(() => FieldRepository.Find(_ => _.CurrentContestId == Id).ToList());
     _teamList  = new Lazy <IList <ITeam> >(() => TeamRepository.Find(_ => _.ContestId == Id).ToList());
 }
Beispiel #18
0
        public void SameWeakObjectsEqual()
        {
            var obj   = new object();
            var first = ReferenceHolder <object?> .Weak(obj);

            var second = ReferenceHolder <object?> .Weak(obj);

            // 📝 There is no need for a GC.KeepAlive(obj) here. 'VerifyEqual' will produce correct results whether
            // or not the object is still alive. When the object is alive, the equality path is the same as
            // SameStrongObjectsEqual. When the object is not alive, the equality path is the same as
            // ExpiredSameValuesEqual.
            VerifyEqual(first, second);
        }
Beispiel #19
0
        public void WhenFirstSetByObject_ReferenceShouldBeConsistant()
        {
            var book = new Book {
                Id = 10
            };
            var repo = new Mock <IRepository <Book> >();

            repo.Setup(_ => _.GetByPk(book.Id)).Returns(book);
            var manadatory = new ReferenceHolder <Book, long?>(repo.Object)
            {
                Object = book
            };


            CheckIsConsistant(book, manadatory);
        }
Beispiel #20
0
        public void Test_World()
        {
            IActor parent;

            using (IWorld world = Root.CreateWorld())
            {
                parent = world.CreateActor();
                ReferenceHolder referenceHolder = HandleUtils.TryGetReferenceHolder(parent.Handle);

                Assert.IsNotNull(world);
                Assert.AreEqual(world, parent.World);
                Assert.IsNotNull(referenceHolder);
                Assert.IsTrue(referenceHolder.IsStrong);
                Assert.IsFalse(referenceHolder.IsWeak);
            }

            Assert.IsTrue(HandleUtils.IsDestroyed(parent.Handle));
        }
Beispiel #21
0
 protected GameStep()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _phase = new ReferenceHolder <IPhase, Guid>(PhaseRepository);
     _currentMatchSetting          = new ReferenceHolder <IMatchSetting, Guid>(MatchSettingRepository);
     _gameStepTeamRelationshipList = new Lazy <IList <IRelationship <ITeam, IGameStep> > >(() =>
                                                                                           TeamGameStepRelationshipRepository
                                                                                           .Find(_ => _.SecondItemInvolveId == Id).ToList());
     _matchList = new Lazy <IList <IMatch> >(() =>
     {
         IList <IMatch> result = MatchRepository.Find(_ => _.GameStepId == Id).ToList();
         foreach (var match in result)
         {
             RegisterHandler(match);
         }
         return(result);
     });
 }
Beispiel #22
0
        /// <include file='doc\ReferenceService.uex' path='docs/doc[@for="ReferenceService.GetReference"]/*' />
        /// <devdoc>
        ///     Finds a reference with the given name, returning null if not found.
        /// </devdoc>
        public virtual object GetReference(string name)
        {
            Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "ReferenceService.GetReference(" + name + ")");
            EnsureReferences();
            int size = referenceList.Count;

            for (int i = 0; i < size; i++)
            {
                ReferenceHolder referenceHolder = (ReferenceHolder)referenceList[i];
                if (string.Compare(referenceHolder.Name, name, ignoreCase, CultureInfo.InvariantCulture) == 0)
                {
                    Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "    ... " + referenceHolder.Reference.GetType().FullName);
                    return(referenceHolder.Reference);
                }
            }
            Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "    ...nothing found");
            return(null);
        }
Beispiel #23
0
        /// <include file='doc\ReferenceService.uex' path='docs/doc[@for="ReferenceService.GetName"]/*' />
        /// <devdoc>
        ///     Finds name for a given reference, returning null if not found.
        /// </devdoc>
        public virtual string GetName(object reference)
        {
            Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "ReferenceService.GetName");
            EnsureReferences();
            int size = referenceList.Count;

            for (int i = 0; i < size; i++)
            {
                ReferenceHolder referenceHolder = (ReferenceHolder)referenceList[i];
                if (referenceHolder.Reference == reference)
                {
                    Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "    ... " + referenceHolder.Name);
                    return(referenceHolder.Name);
                }
            }
            Debug.WriteLineIf(Switches.NamespaceRefs.TraceVerbose, "    ...nothing found");
            return(null);
        }
Beispiel #24
0
 public BookVersion(IRepository <Book> repo)
 {
     _book = new ReferenceHolder <Book, long?>(repo);
 }
Beispiel #25
0
 public Tree(IRepository <Tree> repo)
 {
     _parent    = new ReferenceHolder <Tree, long?>(repo);
     _childList = new ReferenceCollectionHolder <Tree, Tree>(repo, this);
 }
Beispiel #26
0
 private static void CheckIsConsistant(IDistinctableEntity book, ReferenceHolder <Book, long?> manadatory)
 {
     Assert.AreEqual(book, manadatory.Object);
     Assert.AreEqual(book.GetPkValue(), manadatory.Id);
 }
Beispiel #27
0
 public Field()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _matchInProgess = new ReferenceHolder <IMatch, Guid>(MatchRepository);
     _currentContest = new ReferenceHolder <IContest, Guid>(ContestRepository);
 }
Beispiel #28
0
 public Relationship()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _firstItem  = new ReferenceHolder <TIObj1, Guid>(FirstItemRepository);
     _secondItem = new ReferenceHolder <TIObj2, Guid>(SecondItemRepository);
 }
Beispiel #29
0
 private static void VerifyEqual <T>(ReferenceHolder <T> x, ReferenceHolder <T> y)
     where T : class?
 {
Beispiel #30
0
 public PhysicalSetting()
 {
     FlippingContainer.Instance.ComposeParts(this);
     _address = new ReferenceHolder <IAddress, Guid>(AddressRepository);
 }
Beispiel #31
0
 // Start is called before the first frame update
 void Start()
 {
     referenceHolder = GetComponentInParent <ReferenceHolder>();
     text            = GetComponentInChildren <Text>();
 }