コード例 #1
0
        public override void Generate()
        {
#line 31 "P:\zetbox\Zetbox.DalProvider.NHibernate.Generator\Templates\ObjectClasses\ReloadReferences.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("        public override void ReloadReferences()\r\n");
            this.WriteObjects("        {\r\n");
            this.WriteObjects("            // Do not reload references if the current object has been deleted.\r\n");
            this.WriteObjects("            // TODO: enable when MemoryContext uses MemoryDataObjects\r\n");
            this.WriteObjects("            //if (this.ObjectState == DataObjectState.Deleted) return;\r\n");
            this.WriteObjects("            base.ReloadReferences();\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("            // fix direct object references\r\n");
#line 41 "P:\zetbox\Zetbox.DalProvider.NHibernate.Generator\Templates\ObjectClasses\ReloadReferences.cst"
// TODO: Use only 1 side relation ends
            foreach (var prop in cls.Properties.OfType <ObjectReferenceProperty>()
                     .Where(orp => !orp.IsList())
                     .OrderBy(orp => orp.ObjectClass.Name)
                     .ThenBy(orp => orp.Name))
            {
                ReloadOneReference.Call(Host, ctx, prop);
            }

#line 50 "P:\zetbox\Zetbox.DalProvider.NHibernate.Generator\Templates\ObjectClasses\ReloadReferences.cst"
            this.WriteObjects("        }\r\n");
        }
コード例 #2
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, ObjectReferenceProperty prop)
        {
            if (_host == null)
            {
                throw new ArgumentNullException("_host");
            }
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }
            if (prop == null)
            {
                throw new ArgumentNullException("prop");
            }

            Relation    rel      = Zetbox.App.Extensions.RelationExtensions.Lookup(ctx, prop);
            RelationEnd relEnd   = rel.GetEnd(prop);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string referencedInterface      = otherEnd.Type.Module.Namespace + "." + otherEnd.Type.Name;
            string referencedImplementation = Mappings.ObjectClassHbm.GetWrapperTypeReference(otherEnd.Type, _host.Settings);
            string name              = prop.Name;
            string implNameUnused    = null;
            string fkBackingName     = "_fk_" + name;
            string fkGuidBackingName = "_fk_guid_" + name;
            bool   isExportable      = relEnd.Type.ImplementsIExportable() && otherEnd.Type.ImplementsIExportable();

            ReloadOneReference.Call(_host, ctx, referencedInterface, referencedImplementation, name, implNameUnused, fkBackingName, fkGuidBackingName, isExportable);
        }