Пример #1
0
        private void ApplyGenerator(IGeneratorDef generator)
        {
            var hbmGenerator = new HbmGenerator {
                @class = generator.Class
            };

            if (hbmId.name == null)
            {
                // no member for the id
                var defaultReturnType = generator.DefaultReturnType;
                // where a DefaultReturnType is not available, let NH discover it during the mapping-binding process
                if (defaultReturnType != null)
                {
                    hbmId.type1 = defaultReturnType.GetNhTypeName();
                }
            }
            object generatorParameters = generator.Params;

            if (generatorParameters != null)
            {
                hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
                                      let pname = pi.Name
                                                  let pvalue = pi.GetValue(generatorParameters, null)
                                                               select
                                                               new HbmParam {
                    name = pname, Text = new[] { ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString() }
                }).
                                     ToArray();
            }
            else
            {
                hbmGenerator.param = null;
            }
            hbmId.generator = hbmGenerator;
        }
Пример #2
0
        private void ApplyGenerator(IGeneratorDef generator)
        {
            var hbmGenerator = new HbmGenerator {
                @class = generator.Class
            };

            if (hbmId.name == null)
            {
                // no member for the id
                hbmId.type1 = generator.DefaultReturnType.GetNhTypeName();
            }
            object generatorParameters = generator.Params;

            if (generatorParameters != null)
            {
                hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
                                      let pname = pi.Name
                                                  let pvalue = pi.GetValue(generatorParameters, null)
                                                               select
                                                               new HbmParam {
                    name = pname, Text = new[] { ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString() }
                }).
                                     ToArray();
            }
            else
            {
                hbmGenerator.param = null;
            }
            hbmId.generator = hbmGenerator;
        }
Пример #3
0
		private void ApplyGenerator(IGeneratorDef generator)
		{
			var hbmGenerator = new HbmGenerator {@class = generator.Class};
			if(hbmId.name == null)
			{
				// no member for the id
				var defaultReturnType = generator.DefaultReturnType;
				// where a DefaultReturnType is not available, let NH discover it during the mapping-binding process
				if (defaultReturnType != null)
				{
					hbmId.type1 = defaultReturnType.GetNhTypeName();
				}
			}
			object generatorParameters = generator.Params;
			if (generatorParameters != null)
			{
				hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
									  let pname = pi.Name
									  let pvalue = pi.GetValue(generatorParameters, null)
									  select
										new HbmParam {name = pname, Text = new[] {ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString()}}).
					ToArray();
			}
			else
			{
				hbmGenerator.param = null;
			}
			hbmId.generator = hbmGenerator;
		}
Пример #4
0
        private void ApplyGenerator(IGeneratorDef generator)
        {
            var hbmGenerator = new HbmGenerator {
                @class = generator.Class
            };
            object generatorParameters = generator.Params;

            if (generatorParameters != null)
            {
                hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
                                      let pname = pi.Name
                                                  let pvalue = pi.GetValue(generatorParameters, null)
                                                               select
                                                               new HbmParam {
                    name = pname, Text = new[] { ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString() }
                }).
                                     ToArray();
            }
            else
            {
                hbmGenerator.param = null;
            }
            hbmId.generator = hbmGenerator;
            AutosetTypeThroughGeneratorDef(generator);
        }
Пример #5
0
 public static Configuration AddIdentityMapping <TUser, TKey>(
     this Configuration configuration,
     IGeneratorDef generatorDef)
     where TKey : IEquatable <TKey>
     where TUser : IdentityUser <TKey>
 {
     return(configuration.AddIdentityMapping <TUser, IdentityRole <TKey>, TKey>(generatorDef));
 }
Пример #6
0
 private void AutosetTypeThroughGeneratorDef(IGeneratorDef generator)
 {
     if (Equals(hbmId.type, autosetType) && generator.DefaultReturnType != null)
     {
         autosetType = generator.DefaultReturnType.GetNhTypeName();
         hbmId.type  = autosetType;
     }
 }
		public void Generator(IGeneratorDef generator, Action<IGeneratorMapper> generatorMapping)
		{
			if (generator == null)
			{
				return;
			}
			if(!generator.SupportedAsCollectionElementId)
			{
				throw new NotSupportedException("The generator '" + generator.Class + "' cannot be used as collection element id.");
			}
			ApplyGenerator(generator);
			generatorMapping(new GeneratorMapper(hbmId.generator));
		}
Пример #8
0
 public void Generator(IGeneratorDef generator, Action <IGeneratorMapper> generatorMapping)
 {
     if (generator == null)
     {
         return;
     }
     if (!generator.SupportedAsCollectionElementId)
     {
         throw new NotSupportedException("The generator '" + generator.Class + "' cannot be used as collection element id.");
     }
     ApplyGenerator(generator);
     generatorMapping(new GeneratorMapper(hbmId.generator));
 }
		private void ApplyGenerator(IGeneratorDef generator)
		{
			var hbmGenerator = new HbmGenerator { @class = generator.Class };
			object generatorParameters = generator.Params;
			if (generatorParameters != null)
			{
				hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
															let pname = pi.Name
															let pvalue = pi.GetValue(generatorParameters, null)
															select
																new HbmParam { name = pname, Text = new[] { ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString() } }).
					ToArray();
			}
			else
			{
				hbmGenerator.param = null;
			}
			hbmId.generator = hbmGenerator;
			AutosetTypeThroughGeneratorDef(generator);
		}
Пример #10
0
        public static Configuration AddIdentityMapping <TUser, TRole, TKey>(
            this Configuration configuration,
            IGeneratorDef generatorDef)
            where TKey : IEquatable <TKey>
            where TUser : IdentityUser <TKey>
            where TRole : IdentityRole <TKey>
        {
            var mapper = new ModelMapper();

            mapper.AddMapping(new IdentityRoleMapping <TRole, TKey>(generatorDef));
            mapper.AddMapping(new IdentityRoleClaimMapping <TKey>(generatorDef));
            mapper.AddMapping(new IdentityUserMapping <TUser, TKey>(generatorDef));
            mapper.AddMapping(new IdentityUserClaimMapping <TKey>(generatorDef));
            mapper.AddMapping <IdentityUserLoginMapping <TKey> >();
            mapper.AddMapping <IdentityUserRoleMapping <TKey> >();
            mapper.AddMapping <IdentityUserTokenMapping <TKey> >();

            configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            return(configuration);
        }
Пример #11
0
		private void ApplyGenerator(IGeneratorDef generator)
		{
			var hbmGenerator = new HbmGenerator {@class = generator.Class};
			if(hbmId.name == null)
			{
				// no member for the id
				hbmId.type1 = generator.DefaultReturnType.GetNhTypeName();
			}
			object generatorParameters = generator.Params;
			if (generatorParameters != null)
			{
				hbmGenerator.param = (from pi in generatorParameters.GetType().GetProperties()
				                      let pname = pi.Name
				                      let pvalue = pi.GetValue(generatorParameters, null)
				                      select
				                      	new HbmParam {name = pname, Text = new[] {ReferenceEquals(pvalue, null) ? "null" : pvalue.ToString()}}).
					ToArray();
			}
			else
			{
				hbmGenerator.param = null;
			}
			hbmId.generator = hbmGenerator;
		}
Пример #12
0
 public void Generator(IGeneratorDef generator, Action <IGeneratorMapper> generatorMapping)
 {
     ApplyGenerator(generator);
     generatorMapping(new GeneratorMapper(hbmId.generator));
 }
Пример #13
0
 public void Generator(IGeneratorDef generator)
 {
     Generator(generator, x => { });
 }
Пример #14
0
 public static IGeneratorDef ShardedUUIDGenerator()
 {
     return(shardedUUIDGenerator ?? (shardedUUIDGenerator = new ShardedUUIDGeneratorDef()));
 }
Пример #15
0
 public IdentityRoleClaimMapping(
     IGeneratorDef generatorDef) :
     base(generatorDef)
 {
 }
Пример #16
0
 public IdentityUserMapping(
     IGeneratorDef generatorDef) :
     base(generatorDef)
 {
 }
Пример #17
0
 public IdentityUserMapping(
     string tableName,
     IGeneratorDef generatorDef) :
     base(tableName, generatorDef)
 {
 }
Пример #18
0
		private void AutosetTypeThroughGeneratorDef(IGeneratorDef generator)
		{
			if (Equals(hbmId.type, autosetType) && generator.DefaultReturnType != null)
			{
				autosetType = generator.DefaultReturnType.GetNhTypeName();
				hbmId.type = autosetType;
			}
		}
Пример #19
0
 public IdentityRoleClaimMapping(
     string tableName,
     IGeneratorDef generatorDef) :
     base(tableName, generatorDef)
 {
 }
Пример #20
0
		public void Generator(IGeneratorDef generator)
		{
			Generator(generator, x => { });
		}
Пример #21
0
		public void Generator(IGeneratorDef generator, Action<IGeneratorMapper> generatorMapping)
		{
			ApplyGenerator(generator);
			generatorMapping(new GeneratorMapper(hbmId.generator));
		}
Пример #22
0
 public static IGeneratorDef ShardedHighLowGenerator()
 {
     return(shardedHiLoGenerator ?? (shardedHiLoGenerator = new ShardedHighLowGeneratorDef()));
 }