Exemplo n.º 1
0
        public virtual PocoEntity Parse(WType type)
        {
            PocoEntity result = this.factory.GetPocoEntity();

            // this attribute is always set, otherwise we would not be here
            result.DbFactory = (IWormDbFactory)type.GetAttribute<WormDbFactoryAttribute>().DbFactoryType.CreateInstance();

            result.PocoClassName = type.Name;
            result.PocoNamespace = type.Namespace;
            result.PocoFilename = String.Format("{0}{1}{2}.cs",
                type.Namespace.Replace(".", Path.DirectorySeparatorChar.ToString())
                , Path.DirectorySeparatorChar
                , type.Name
            );
            result.TableName = this.GetTableName(type);

            this.AddProperties(result, type);

            result.WormClassName = String.Format("Worm{0}", type.Name);
            result.WormNamespace = String.Format("{0}.Db", result.PocoNamespace);
            result.WormFilename = String.Format("{0}{1}.cs",
                  this.NamespaceAsPathAssumingUseOfRootNamespace(result.WormNamespace)
                , result.WormClassName
            );

            return result;
        }
Exemplo n.º 2
0
        protected string GetTableName(WType type)
        {
            WormTableAttribute attr = type.GetAttribute<WormTableAttribute>();
            if (attr != default(WormTableAttribute))
            {
                return attr.TableName;
            }

            return type.Name;
        }