Exemplo n.º 1
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost _host,
            string prefix,
            ValueTypeProperty prop,
            string propName,
            string columnName,
            bool forceDefinition,
            string implementationSuffix,
            bool needsConcurrency)
        {
            if (_host == null) throw new ArgumentNullException("_host");
            if (prop == null) throw new ArgumentNullException("prop");

            // shortcut unmapped properties
            if (prop.IsCalculated)
            {
                _host.WriteOutput(string.Format("<!-- ValueTypeProperty {0} is calculated and persisted -->\n", prop.Name));
            }

            propName = string.IsNullOrEmpty(propName) ? prop.Name : propName;
            columnName = string.IsNullOrEmpty(columnName) ? Construct.ColumnName(prop, prefix) : prefix + columnName;
            var optimisticLock = needsConcurrency && propName == "ChangedOn";

            string typeAttr = String.Empty;
            if (prop is DateTimeProperty)
            {
                typeAttr = "type=\"Timestamp\"";
            }

            string ceClassAttr;
            if (prop.IsList && !forceDefinition)
            {
                // set the proper type for collection entries
                ceClassAttr = String.Format("class=\"{0}.{1}{2}+{1}Proxy,Zetbox.Objects.NHibernateImpl\"",
                    prop.GetCollectionEntryNamespace(),
                    prop.GetCollectionEntryClassName(),
                    implementationSuffix);
            }
            else
            {
                // not needed
                ceClassAttr = String.Empty;
            }

            string ceReverseKeyColumnName = Construct.ForeignKeyColumnName(prop);
            string listPositionColumnName = Construct.ListPositionColumnName(prop);

            Call(_host,
                prefix,
                propName,
                columnName,
                prop.IsList && !forceDefinition,
                typeAttr,
                ceClassAttr,
                ceReverseKeyColumnName,
                listPositionColumnName,
                optimisticLock);
        }