コード例 #1
0
        public static string ResolveShortClassName(@class hClass, hibernatemapping hm)
        {
            // remove everything after the comma if there is one.
            int indexOfComma = Math.Max(hClass.name.IndexOf(","), hClass.name.Length);
            string className = hClass.name.Substring(0, indexOfComma);

            // If the classname is not fully qualified, return it.
            if (className.Contains(".") == false) return className;

            return className.Substring(className.LastIndexOf(".") + 1);
        }
コード例 #2
0
        public static void AddClass(this hibernatemapping hm, @class @class)
        {
            if (hm.Items == null)
            {
                hm.Items = new object[0];
            }

            object[] items = hm.Items;
            Array.Resize(ref items, hm.Items.Length + 1);
            items[items.Length - 1] = @class;
            hm.Items = items;
        }
コード例 #3
0
        /// <summary>
        /// Gets a collection of @classes in the hibernatemapping.
        /// </summary>
        /// <param name="hm"></param>
        /// <returns></returns>
        public static IEnumerable <Mapping.@class> Classes(this hibernatemapping hm)
        {
            if (hm.Items == null)
            {
                yield break;
            }

            foreach (var item in hm.Items)
            {
                if (item is Mapping.@class)
                {
                    yield return(item as Mapping.@class);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets a collection of JoinedSubClasses in the hibernatemapping.
        /// </summary>
        /// <param name="hm"></param>
        /// <returns></returns>
        public static IEnumerable <joinedsubclass> JoinedSubClasses(this hibernatemapping hm)
        {
            if (hm.Items == null)
            {
                yield break;
            }

            foreach (var item in hm.Items)
            {
                if (item is joinedsubclass)
                {
                    yield return(item as joinedsubclass);
                }
            }
        }
コード例 #5
0
 public static string ToXml(this hibernatemapping hm)
 {
     // We need to use a memory stream or else the XML ends up
     // encoded as Unicode, which causes NHibernate to flip out.
     using (MemoryStream stream = new MemoryStream())
     {
         using (XmlTextWriter xtw = new XmlTextWriter(stream, Encoding.UTF8))
         {
             xtw.Formatting  = Formatting.Indented;
             xtw.Indentation = 1;
             xtw.IndentChar  = '\t';
             Utility.HibernateXmlSerializer.Serialize(xtw, hm);
             stream.Flush();
             return(Encoding.UTF8.GetString(stream.ToArray()));
         }
     }
 }
コード例 #6
0
        public static string ResolveFullClassName(@class hClass, hibernatemapping hm)
        {
            // remove everything after the comma if there is one.
            int indexOfComma = Math.Max(hClass.name.IndexOf(","), hClass.name.Length);
            string className = hClass.name.Substring(0, indexOfComma);

            // If there is no default namespace specified, return the classname
            if (string.IsNullOrEmpty(hm.@namespace))
            {
                return className;
            }

            // If the classname is already fully qualified, return it.
            if (className.Contains(".")) return className;

            // Otherwise prepend the default namespace
            return hm.@namespace + "." + className;
        }
コード例 #7
0
ファイル: EntityLoader.cs プロジェクト: uQr/Visual-NHibernate
 private void ProcessVersionProperty(hibernatemapping hm, @class hClass, Entity newEntity, Mapping mapping, ParseResults parseResults)
 {
     version version = hClass.Version();
     var typeName = string.IsNullOrEmpty(version.type) ? "int" : version.type;
     var columnName = string.IsNullOrEmpty(version.column1) ? version.name : version.column1;
     var property = CreateProperty(newEntity, mapping, typeName, version.name, columnName, "");
     property.SetPropertyIsVersion(true);
     SetPropertyInfoFromParsedCode(property, parseResults, hm.@namespace, mapping.FromTable.Schema, hClass.name);
 }
コード例 #8
0
ファイル: EntityLoader.cs プロジェクト: uQr/Visual-NHibernate
 private void ProcessCompositeKey(hibernatemapping hm, @class hClass, Entity newEntity, Mapping mapping, ParseResults parseResults, compositeid hCompId)
 {
     foreach (var prop in hCompId.KeyProperties())
     {
         var idProperty = CreateProperty(newEntity, mapping, prop);
         SetPropertyInfoFromParsedCode(idProperty, parseResults, hm.@namespace, mapping.FromTable.Schema, hClass.name);
         idProperty.IsKeyProperty = true;
     }
 }