Пример #1
0
 protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list, string memberName, bool eagerLoading)
 {
     if (list != null && eagerLoading)
     {
         list.Add("Serialization.EagerLoadingSerialization", Templates.Serialization.SerializerType.Binary, null, null, memberName, true, false, null);
     }
 }
Пример #2
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            ObjectReferenceProperty prop)
        {
            if (host == null) { throw new ArgumentNullException("host"); }
            if (ctx == null) { throw new ArgumentNullException("ctx"); }
            if (prop == null) { throw new ArgumentNullException("prop"); }
            if (!prop.IsList()) { throw new ArgumentOutOfRangeException("prop", "prop must be a List-valued property"); }

            var rel = RelationExtensions.Lookup(ctx, prop);
            var relEnd = rel.GetEnd(prop);
            var otherEnd = rel.GetOtherEnd(relEnd);

            string name = prop.Name;

            // whether or not the collection will be eagerly loaded
            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;

            string wrapperName = "_" + name;
            string wrapperClass = "OneNRelationList";

            var exposedListType = otherEnd.HasPersistentOrder ? "IList" : "ICollection";
            // the name of the position property
            var positionPropertyName = rel.NeedsPositionStorage(otherEnd.GetRole()) ? Construct.ListPositionPropertyName(otherEnd) : String.Empty;
            var otherName = otherEnd.Navigator == null ? relEnd.RoleName : otherEnd.Navigator.Name;
            var referencedInterface = otherEnd.Type.GetDataTypeString();
            var referencedProxy = Mappings.ObjectClassHbm.GetProxyTypeReference(otherEnd.Type, host.Settings);

            Call(host, ctx, serializationList, name, eagerLoading, wrapperName, wrapperClass, exposedListType, positionPropertyName, otherName, referencedInterface, referencedProxy);
        }
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            ObjectReferenceProperty prop, bool callGetterSetterEvents,
            bool updateInverseNavigator)
        {
            if (ctx == null) { throw new ArgumentNullException("ctx"); }
            if (prop == null) { throw new ArgumentNullException("prop"); }

            string name = prop.Name;
            string ownInterface = prop.ObjectClass.GetDataTypeString();
            string referencedInterface = String.Format(
                "{0}.{1}",
                prop.GetReferencedObjectClass().Module.Namespace,
                prop.GetReferencedObjectClass().Name);

            var rel = RelationExtensions.Lookup(ctx, prop);
            var endRole = rel.GetEnd(prop).GetRole();
            Call(host, ctx, serializationList,
                ownInterface, name, referencedInterface, rel, endRole, callGetterSetterEvents, updateInverseNavigator, String.Empty);
        }
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            string ownInterface,
            string name,
            string referencedInterface,
            Relation rel,
            RelationEndRole endRole,
            bool callGetterSetterEvents,
            bool updateInverseNavigator,
            string assocNameSuffix)
        {
            if (host == null) { throw new ArgumentNullException("host"); }
            if (ctx == null) { throw new ArgumentNullException("ctx"); }
            if (rel == null) { throw new ArgumentNullException("rel"); }

            // TODO: split off relation expansion in own Call() method
            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string moduleNamespace = rel.Module.Namespace;
            string implName = name + Zetbox.API.Helper.ImplementationSuffix;
            string eventName = "On" + name;

            string fkBackingName = "_fk_" + name;
            string fkGuidBackingName = "_fk_guid_" + name;

            string referencedImplementation = referencedInterface
                + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string associationNameUnused = rel.GetAssociationName() + assocNameSuffix;
            string targetRoleNameUnused = otherEnd.RoleName;

            string positionPropertyName = rel.NeedsPositionStorage(endRole)
                ? Construct.ListPositionPropertyName(relEnd)
                : null;

            string inverseNavigatorName = updateInverseNavigator && otherEnd.Navigator != null
                ? otherEnd.Navigator.Name
                : null;
            bool inverseNavigatorIsList = otherEnd.Navigator != null && otherEnd.Navigator.GetIsList();
            bool notifyInverseCollection = false;

            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool relDataTypeExportable = rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable();

            Call(host,
                ctx,
                serializationList,
                moduleNamespace,
                ownInterface,
                name,
                implName,
                eventName,
                fkBackingName,
                fkGuidBackingName,
                referencedInterface,
                referencedImplementation,
                associationNameUnused,
                targetRoleNameUnused,
                positionPropertyName,
                inverseNavigatorName,
                inverseNavigatorIsList,
                notifyInverseCollection,
                eagerLoading,
                relDataTypeExportable,
                callGetterSetterEvents,
                false,
                false);
        }
        protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list, string sourceMember, string targetMember, string targetGuidMember)
        {
            if (list != null)
            {
                var proxyName = "this.Proxy." + name;

                if (relDataTypeExportable && !disableExport)
                {
                    list.Add("Serialization.ObjectReferencePropertySerialization", Templates.Serialization.SerializerType.ImportExport, moduleNamespace, name, proxyName, targetMember, targetGuidMember);
                }
                list.Add("Serialization.ObjectReferencePropertySerialization",
                    Templates.Serialization.SerializerType.Service, moduleNamespace, name, proxyName, targetMember, targetGuidMember);
            }
        }
Пример #6
0
 protected override void ApplyNotifyingValueProperty(
     Property prop,
     Templates.Serialization.SerializationMembersList serList)
 {
     Properties.ProxyProperty.Call(Host, ctx,
         serList, prop.Module.Namespace, prop.GetElementTypeString(), prop.Name, false, true,
         prop.DefaultValue != null, prop.ObjectClass.GetDataTypeString(),
         prop.GetClassName(),
         prop.IsNullable(),
         "_is" + prop.Name + "Set",
         prop.ExportGuid,
         prop.GetElementTypeString(),
         "Proxy." + prop.Name,
         prop.IsCalculated(),
         prop.DisableExport == true);
 }
Пример #7
0
 protected override void ApplyListProperty(Property prop, Templates.Serialization.SerializationMembersList serList)
 {
     base.ApplyListProperty(prop, serList);
 }