예제 #1
0
        /// <summary>
        /// Add the profile of type <typeparamref name="TProfile"/> to the configuration
        /// </summary>
        /// <typeparam name="TProfile">The type of the profile.</typeparam>
        /// <returns>
        /// A fluent builder to configure comparison.
        /// </returns>
        public ConfigurationBuilder Profile <TProfile>()
            where TProfile : IEntityProfile, new()
        {
            var profile = new TProfile();

            return(Profile(profile));
        }
예제 #2
0
        //public void Bind(TProfile entity)
        //{
        //    _entity = entity;
        //    Id = _entity.Id;
        //    UserId = _entity.IdUser.HasValue ? _entity.IdUser.Value : -1;
        //    FirstName = _entity.FirstName;
        //    LastName = _entity.LastName;
        //    Age = _entity.Age;
        //    Gender = _entity.Gender == "Male" ? true : false;
        //    Degree = _entity.Degree;
        //    Occupation = _entity.Occupation;
        //    YearsOfExp = _entity.YearOfExp;
        //    Nationality = _entity.Nationality;
        //    PhoneNumber = _entity.PhoneNo;
        //    Email = _entity.Email;
        //    Address = _entity.Address;
        //    AboutMe = _entity.AboutMe;
        //    PhotoPath = _entity.Photo;
        //    Website = _entity.Website;
        //}

        public TProfile GetNew()
        {
            //_entity = new TProfile();

            //if (UserId == -1) _entity.IdUser = null;
            //else _entity.IdUser = UserId;

            //_entity.LastName = LastName;
            //_entity.FirstName = FirstName;
            //_entity.Nationality = Nationality;
            //_entity.Gender = Gender ? "Male" : "Female";
            //_entity.Occupation = Occupation;
            //_entity.PhoneNo = PhoneNumber;
            //_entity.Website = Website;
            //_entity.YearOfExp = YearsOfExp;
            //_entity.Photo = PhotoPath;
            // this.IdProfile = Guid.NewGuid();

            var _entity = new TProfile();

            _entity.InjectFrom(this);
            if (_entity.Id == 0)
            {
                _entity.IdProfile = Guid.NewGuid();
            }

            return(_entity);
        }
예제 #3
0
        public static TProfile LoadCurrentProfile <TProfile>()
            where TProfile : TestProfileBase, new()
        {
            TProfile result = null;

            var className = typeof(TProfile).Name;
            var machineProfileFileName = string.Format(@"SPMetaRegressionProfiles/{0}.{1}.xml", Environment.MachineName, className);

            if (File.Exists(machineProfileFileName))
            {
                // pragmatic way
                var profileXml = File
                                 .ReadAllText(machineProfileFileName)
                                 .Replace("{$MachineName$}", Environment.MachineName);

                result = XmlSerializerUtils.DeserializeFromString <TProfile>(profileXml);
            }

            if (result != null)
            {
                return(result);
            }

            return(new TProfile());
        }
예제 #4
0
        /// <summary>
        /// Add the profile of type <typeparamref name="TProfile"/> to the configuration
        /// </summary>
        /// <typeparam name="TProfile">The type of the profile.</typeparam>
        /// <returns>
        /// A fluent builder to configure comparison.
        /// </returns>
        public ConfigurationBuilder Profile <TProfile>()
            where TProfile : IEntityProfile, new()
        {
            var profile      = new TProfile();
            var type         = profile.EntityType;
            var classMapping = GetClassMap(type);

            profile.Register(classMapping);

            return(this);
        }