コード例 #1
0
        public ApplicationForm(LoginResultData i_LoginResultData, AppSettings i_AppSettings)
        {
            m_LoggedInUser    = InputGuard.CheckNullArgument(i_LoginResultData, nameof(i_LoginResultData)).User;
            m_AppSettings     = InputGuard.CheckNullArgument(i_AppSettings, nameof(i_AppSettings));
            m_SettingsHandler = AppXmlSettingsHandler.Instance;
            m_LastAccessToken = i_LoginResultData.AccessToken;
            m_AlbumsUser      = m_LoggedInUser;
            m_UserMatcher     = new UserMatcher();

            InitializeComponent();
            CenterToScreen();
            setFormViewBySettings();
        }
コード例 #2
0
        /// <summary>
        /// Check if an user is existing with some rule.
        /// </summary>
        /// <param name="newUser"></param>
        /// <returns></returns>
        public static bool IsExisting(User newUser)
        {
            // new instant of user matcher
            IUserMatcher userMatcher = new UserMatcher();

            // add all rules for user matcher
            userMatcher.AddRule(new DistanceMatcher());
            userMatcher.AddRule(new NameAddressMatcher());
            userMatcher.AddRule(new ReferralCodeMatcher());

            if (existingUserList.Find(user => userMatcher.IsMatch(newUser, user)) != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public void IsMatch_MatchAddress_ReturnTrue()
        {
            var     addressMatcher = new UserMatcher();
            Address address1       = new Address()
            {
                Suburb        = "Level 3",
                StreetAddress = "51_Pitt Street",
                State         = "Sydney NSW-2000",
                Latitude      = 1100,
                Longitude     = 2000,
            };
            User newUser = new User()
            {
                Address      = address1,
                Name         = "Luong",
                ReferralCode = "ABC123"
            };

            Address address2 = new Address()
            {
                Suburb        = "Level 3",
                StreetAddress = "51_Pitt Street",
                State         = "Sydney NSW-2000",
                Latitude      = 110,
                Longitude     = 200,
            };
            User existingUser = new User()
            {
                Address      = address2,
                Name         = "Luong 2",
                ReferralCode = "ABC123"
            };

            var isMatch = addressMatcher.IsMatch(newUser, existingUser);

            Assert.True(isMatch);
        }