示例#1
0
 protected override void AddSerialization(Templates.Serialization.SerializationMembersList list, string name)
 {
     if (list != null)
     {
         if (hasDefaultValue)
         {
             Templates.Serialization.EnumWithDefaultBinarySerialization.AddToSerializers(
                 list,
                 disableExport ? SerializerType.Binary : SerializerType.All,
                 modulenamespace,
                 name,
                 backingName,
                 type,
                 IsSetFlagName);
         }
         else
         {
             Templates.Serialization.EnumBinarySerialization.AddToSerializers(
                 list,
                 disableExport ? SerializerType.Binary : SerializerType.All,
                 modulenamespace,
                 name,
                 backingName,
                 type);
         }
     }
 }
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            Relation rel, RelationEndRole endRole, string backingCollectionType)
        {
            if (host == null) { throw new ArgumentNullException("host"); }
            if (rel == null) { throw new ArgumentNullException("rel"); }

            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string name = relEnd.Navigator.Name;
            string exposedCollectionInterface = rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList" : "ICollection";
            string referencedInterface = otherEnd.Type.GetDataTypeString();
            string backingName = "_" + name;

            string aSideType = rel.A.Type.GetDataTypeString();
            string bSideType = rel.B.Type.GetDataTypeString();
            string entryType = rel.GetRelationFullName() + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string providerCollectionType = (rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList<" : "ICollection<")
                + entryType + ">";

            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool serializeRelationEntries = rel.GetRelationType() == RelationType.n_m;

            string entryProxyType = entryType + "." + rel.GetRelationClassName() + "Proxy";

            string inverseNavigatorName = otherEnd.Navigator != null ? otherEnd.Navigator.Name : null;

            Call(host, ctx, serializationList, name, exposedCollectionInterface, referencedInterface, backingName, backingCollectionType, aSideType, bSideType, entryType, providerCollectionType, rel.ExportGuid, endRole, eagerLoading, serializeRelationEntries, entryProxyType, inverseNavigatorName);
        }
示例#3
0
        public static new void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList serializationList, Property prop)
        {
            if (host == null) { throw new ArgumentNullException("host"); }

            host.CallTemplate("Properties.NotifyingEnumProperty",
                ctx, serializationList, prop);
        }
            if (list != null && eagerLoading)
            {
                string efName = memberName + ImplementationPropertySuffix;
                list.Add("Serialization.EagerLoadingSerialization", Templates.Serialization.SerializerType.Binary, null, null, memberName, false, rel.GetRelationType() == RelationType.n_m, efName);
            }
        }
    }
}
示例#5
0
 protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list, string underlyingCollectionName)
 {
     // TODO: XML Namespace
     if (list != null)
     {
         Templates.Serialization.CollectionSerialization.Add(list, ctx, moduleNamespace, name, underlyingCollectionName, orderByValue, disableExport);
     }
 }
示例#6
0
 public static void Call(Arebis.CodeGeneration.IGenerationHost host,
     IZetboxContext ctx,
     Templates.Serialization.SerializationMembersList serializationList,
     ValueTypeProperty prop)
 {
     if (prop == null)
         throw new ArgumentNullException("prop");
     Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, !prop.HasPersistentOrder);
 }
示例#7
0
 protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list, string efName)
 {
     if (list != null)
     {
         bool hasPersistentOrder = prop is ValueTypeProperty
             ? ((ValueTypeProperty)prop).HasPersistentOrder
             : ((CompoundObjectProperty)prop).HasPersistentOrder;
         Serialization.CollectionSerialization.Add(list, ctx, this.prop.Module.Namespace, this.prop.Name, efName, !hasPersistentOrder, prop.DisableExport == true);
     }
 }
 protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list)
 {
     if (list != null)
     {
         var backingStoreName = String.Format("(({0})this).{1}",
             prop.ObjectClass.Module.Namespace + "." + prop.ObjectClass.Name,
             prop.Name);
         Templates.Serialization.EnumBinarySerialization.AddToSerializers(list, prop, backingStoreName);
     }
 }
示例#9
0
 protected override void AddSerialization(Templates.Serialization.SerializationMembersList list, string name)
 {
     if (list != null)
     {
         Templates.Serialization.SimplePropertySerialization
             .AddToSerializers(list,
             disableExport ?  Templates.Serialization.SerializerType.Binary : Templates.Serialization.SerializerType.All,
                 modulenamespace, name, type, backingName);
     }
 }
        protected virtual void AddSerialization(
            Templates.Serialization.SerializationMembersList list,
            string memberType, string memberName,
            string backingStoreType, string backingStoreName)
        {
            if (list != null)
            {
                var xmlname = memberName;

                list.Add("Serialization.CompoundObjectSerialization", disableExport ? Templates.Serialization.SerializerType.Binary : Templates.Serialization.SerializerType.All,
                    this.xmlNamespace, xmlname, memberType, memberName, backingStoreType, backingStoreName);
            }
        }
示例#11
0
 public CollectionSerialization(
     Arebis.CodeGeneration.IGenerationHost _host,
     IZetboxContext ctx,
     Templates.Serialization.SerializerDirection direction,
     string streamName,
     string xmlnamespace,
     string xmlname,
     string collectionName,
     bool orderByValue,
     bool disableExport)
     : base(_host, ctx, direction, streamName, xmlnamespace, xmlname, collectionName, orderByValue, disableExport)
 {
 }
示例#12
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            CompoundObjectProperty prop)
        {
            if (prop == null)
                throw new ArgumentNullException("prop");

            // CompoundObjects cannot be compared, therefore we have to avoid sorting the list here
            // although it would be required to keep the exported collection stable
            // TODO: implement a comparer for COs using a DefaultSortOrder property(-list) to re-enable this
            Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, false);
        }
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            Relation rel, RelationEndRole endRole)
        {
            if (rel == null) { throw new ArgumentNullException("rel"); }

            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string backingCollectionType = RelationToBackingCollectionType(rel, otherEnd);

            Call(host, ctx, serializationList, rel, endRole, backingCollectionType);
        }
 protected virtual void AddSerialization(Templates.Serialization.SerializationMembersList list, string sourceMember, string targetMember, string targetGuidMember, string clsFullName, string assocName, string targetRoleName)
 {
     if (list != null)
     {
         if (relDataTypeExportable && !disableExport)
         {
             list.Add("Serialization.ObjectReferencePropertySerialization",
                 Templates.Serialization.SerializerType.ImportExport, moduleNamespace, name, sourceMember, targetMember, targetGuidMember, clsFullName, assocName, targetRoleName);
         }
         list.Add("Serialization.ObjectReferencePropertySerialization",
             Templates.Serialization.SerializerType.Service, moduleNamespace, name, sourceMember, targetMember, targetGuidMember, clsFullName, assocName, targetRoleName);
         if (eagerLoading)
         {
             list.Add("Serialization.EagerObjectLoadingSerialization",
                 Templates.Serialization.SerializerType.Binary, moduleNamespace, name, sourceMember);
         }
     }
 }
示例#15
0
        private static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            Property prop, bool hasPersistentOrder, bool isList, bool orderByValue)
        {
            if (prop == null) { throw new ArgumentNullException("prop"); }
            if (!isList) { throw new ArgumentOutOfRangeException("prop", "prop must be a List-valued property"); }

            string name = prop.Name;
            string backingName = "_" + name;
            string exposedCollectionInterface = hasPersistentOrder ? "IList" : "ICollection";

            string thisInterface = prop.ObjectClass.Name;
            string referencedType = prop.GetElementTypeString();
            string referencedCollectionEntry = prop.GetCollectionEntryFullName();
            string referencedCollectionEntryImpl = referencedCollectionEntry + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string referencedCollectionEntryProxy = referencedCollectionEntryImpl + "." + prop.GetCollectionEntryClassName() + "Proxy";

            string providerCollectionType = "ICollection<" + referencedCollectionEntryImpl + ">";
            string underlyingCollectionName = name + "Collection";
            string underlyingCollectionBackingName = backingName + "Collection";
            string moduleNamespace = prop.Module.Namespace;

            string backingCollectionType = (hasPersistentOrder ? "ClientValueListWrapper" : "ClientValueCollectionWrapper")
                + String.Format("<{0}, {1}, {2}, {3}, {4}>",
                    thisInterface,
                    referencedType,
                    referencedCollectionEntry,
                    referencedCollectionEntryImpl,
                    providerCollectionType);

            Call(
                host, ctx, serializationList,
                name, backingName, backingCollectionType, exposedCollectionInterface,
                thisInterface, referencedType, referencedCollectionEntry, referencedCollectionEntryImpl, referencedCollectionEntryProxy,
                providerCollectionType, underlyingCollectionName, underlyingCollectionBackingName,
                orderByValue, moduleNamespace, prop.DisableExport == true);
        }
示例#16
0
        // NHibernate has different structure, accesses Proxy directly
        protected override void ApplyCase(Templates.ObjectClasses.UpdateParentTemplateParams prop)
        {
            string implType = prop.IfType+ ImplementationSuffix;

            this.WriteObjects("                case \"", prop.PropertyName, "\":");
            this.WriteLine();
            this.WriteObjects("                    {");
            this.WriteLine();
            this.WriteObjects("                        var __oldValue = (", implType, ")OurContext.AttachAndWrap(this.Proxy.", prop.PropertyName, ");");
            this.WriteLine();
            this.WriteObjects("                        var __newValue = (", implType, ")parentObj;");
            this.WriteLine();
            this.WriteObjects("                        NotifyPropertyChanging(\"", prop.PropertyName, "\", __oldValue, __newValue);");
            this.WriteLine();
            this.WriteObjects("                        this.Proxy.", prop.PropertyName, " = __newValue == null ? null : __newValue.Proxy;");
            this.WriteLine();
            this.WriteObjects("                        NotifyPropertyChanged(\"", prop.PropertyName, "\", __oldValue, __newValue);");
            this.WriteLine();
            this.WriteObjects("                    }");
            this.WriteLine();
            this.WriteObjects("                    break;");
            this.WriteLine();
        }
示例#17
0
 protected virtual void AddSerialization(
     Templates.Serialization.SerializationMembersList list,
     string memberName,
     string fkBackingName)
 {
     if (list != null)
     {
         if (hasDefaultValue)
         {
             Templates.Serialization.SimplePropertyWithDefaultSerialization
                 .AddToSerializers(list,
                     disableExport ? Templates.Serialization.SerializerType.Binary : Templates.Serialization.SerializerType.All,
                     moduleNamespace, propertyName, propertyType, "Proxy." + propertyName, isSetFlagName);
         }
         else
         {
             Templates.Serialization.SimplePropertySerialization
                 .AddToSerializers(list,
                     disableExport ? Templates.Serialization.SerializerType.Binary : Templates.Serialization.SerializerType.All,
                     moduleNamespace, propertyName, propertyType, "Proxy." + propertyName);
         }
     }
 }
示例#18
0
 public NotifyingValueProperty(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList serializationList, string type, string name, string modulenamespace, string backingName, bool isCalculated, bool disableExport)
     : base(_host, ctx, serializationList, type, name, modulenamespace, "Proxy." + name, isCalculated, disableExport)
 {
 }
示例#19
0
 public EagerLoadingSerialization(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, Templates.Serialization.SerializerDirection direction, string streamName, string xmlnamespace, string xmlname, string collectionName, bool serializeIds, bool serializeRelationEntries, string relationEntryCollectionName)
     : base(_host, ctx, direction, streamName, xmlnamespace, xmlname, collectionName, serializeIds, serializeRelationEntries)
 {
     this.relationEntryCollectionName = relationEntryCollectionName;
 }
示例#20
0
 public NotifyingDataProperty(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList list, Property prop)
     : base(_host, ctx, list, prop)
 {
 }
示例#21
0
 public ListProperty(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, Templates.Serialization.SerializationMembersList list, DataType containingType, String name, Property property)
     : base(_host, ctx, list, containingType, name, property)
 {
 }
 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, false, serializeRelationEntries, "this.Proxy." + memberName);
     }
 }
示例#23
0
 public ExportGuidProperty(Arebis.CodeGeneration.IGenerationHost _host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList list, string backingName)
     : base(_host, ctx, list, backingName)
 {
 }
示例#24
0
 public NotifyingEnumProperty(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList serializationList, Property prop)
     : base(host, ctx, serializationList, prop)
 {
     efName = name + ImplementationPropertySuffix;
 }