Exemplo n.º 1
0
 /// <summary>
 /// Uses the correct nhibernate custom mapping type for an Identity Property that is based on a Concept
 /// </summary>
 /// <typeparam name="T">Concrete type of the concept, that inherits from <see cref="ConceptAs{U}"/></typeparam>
 /// <typeparam name="U">The primitive that is the concept is based on</typeparam>
 /// <param name="identityPart">Fluent NHibernate IdentityPart</param>
 /// <returns>Fluent NHibernate IdentityPart<</returns>
 public static IdentityPart ConceptOf <T, U>(this IdentityPart identityPart)
     where U : IEquatable <U>
     where T : ConceptAs <U>
 {
     identityPart.CustomType <ConceptValueType <T, U> >();
     return(identityPart);
 }
Exemplo n.º 2
0
        public static IdentityPart CustomGeneratedBy(this IdentityPart idMapping, string sequenceName)
        {
            switch (NHibernateHelper.DatabaseType)
            {
            default: throw new ArgumentNullException("Unhandled database type");

            case NHibernateHelper.SupportedDatabaseType.SQLEXPRESS_2012:
                return(idMapping.GeneratedBy.Native(sequenceName));

            case NHibernateHelper.SupportedDatabaseType.SQLITE3:
                return(idMapping.GeneratedBy.Native(sequenceName).UnsavedValue(null));
            }
        }
 internal void GenerateGuidIdentity(IdentityPart identityPart)
 {
     /*1) Или CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
      *   и генерировать uuid так - select * from uuid_generate_v4()*/
     /*2) Или CREATE EXTENSION pgcrypto; и вызов - select gen_random_uuid()*/
     identityPart.GeneratedBy.Guid() /*
                                      * .Length(36)
                                      * .GeneratedBy
                                      * .Guid()
                                      * .Not
                                      * .Nullable()
                                      * .Default("public.gen_random_uuid()")*/;
 }
Exemplo n.º 4
0
        public static string GetIdentityPart(string identity, IdentityPart part)
        {
            if (identity == null)
            {
                throw new ArgumentNullException();
            }
            if (!Enum.IsDefined(typeof(IdentityPart), part))
            {
                throw new ArgumentException("part");
            }

            string chosenOption = string.Empty;

            switch (part)
            {
            case IdentityPart.Domainname:
                chosenOption = "domain";
                break;

            case IdentityPart.Username:
                chosenOption = "username";
                break;

            default:
                throw new InvalidOperationException(string.Format("IdentityPart {0} not implemented.", part));
            }
            // perform regex match
            Match m = Regex.Match(identity, REGEX_IDENTITYNAME);

            // if match was successful then return result..otherwise return empty string to avoid NullReferenceExceptions
            if (m.Success)
            {
                return(m.Groups[chosenOption].Value);
            }
            else
            {
                return(string.Empty);
            }
        }
 protected void AssignIdentity(IdentityPart part)
 {
     part.Identifier = Guid.NewGuid().ToString("n");
 }
Exemplo n.º 6
0
 protected void AssignIdentity(InitializingContentContext context, IdentityPart part) {
     part.Identifier = Guid.NewGuid().ToString("n");
 }
 protected void AssignIdentity(InitializingContentContext context, IdentityPart part)
 {
     part.Identifier = Guid.NewGuid().ToString("n");
 }
Exemplo n.º 8
0
 /// <summary>
 /// Applies the specified identity part.
 /// </summary>
 /// <param name="identityPart">The identity part.</param>
 public override void Apply(IdentityPart identityPart)
 {
     identityPart.GeneratedBy.Assigned();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Applies the specified identity part.
 /// </summary>
 /// <param name="identityPart">The identity part.</param>
 public override void Apply(IdentityPart identityPart)
 {
     identityPart.GeneratedBy.GuidComb();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Applies the specified identity part.
 /// </summary>
 /// <param name="identityPart">The identity part.</param>
 public override void Apply(IdentityPart identityPart)
 {
     identityPart.GeneratedBy.HiLo("100", "Id", "100000");
 }
Exemplo n.º 11
0
 /// <summary>
 /// Applies the specified identity part.
 /// </summary>
 /// <param name="identityPart">The identity part.</param>
 public override void Apply(IdentityPart identityPart)
 {
     identityPart.GeneratedBy.Identity();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Applies the specified identity part.
 /// </summary>
 /// <param name="identityPart">The identity part.</param>
 public abstract void Apply(IdentityPart identityPart);
Exemplo n.º 13
0
 protected void AssignIdentity(IdentityPart part) {
     part.Identifier = Guid.NewGuid().ToString("n");
 }
Exemplo n.º 14
0
 public static IdentityPart AutoIncrement(this IdentityPart id)
 {
     return(id.GeneratedBy.Sequence("global_seq"));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Uses the correct nhibernate custom mappingtype for an Identity Property that is based on a Concept{Guid}
 /// </summary>
 /// <typeparam name="T">Concrete type of the concept, that inherits from <see cref="ConceptAs{Guid}"/></typeparam>
 /// <param name="identityPart">Fluent NHibernate IdentityPart</param>
 /// <returns>Fluent NHibernate IdentityPart</returns>
 public static IdentityPart ConceptAsOracleGuid <T>(this IdentityPart identityPart)
     where T : ConceptAs <Guid>
 {
     identityPart.CustomType <ConceptAsOracleGuid <T> >();
     return(identityPart);
 }