Exemple #1
0
 /// <summary>Construct the serializer.</summary>
 /// <param name="settings">Database settings.</param>
 /// <param name="typesToAdd">Record types to add.</param>
 public EseSerializer(EsentDatabase.Settings settings, int cursorsPerSession, IEnumerable <Type> typesToAdd) :
     this(settings, cursorsPerSession)
 {
     if (null != typesToAdd)
     {
         foreach (Type t in typesToAdd)
         {
             EseTableAttribute a = t.getTableAttribute();
             if (null == a)
             {
                 continue;
             }
             m_tables.Add(new TypeSerializer(t, a));
         }
     }
     Api.JetInit(ref m_idInstance);
 }
Exemple #2
0
        /// <summary>Add the record type to serializer.</summary>
        /// <param name="t">The record type to add.</param>
        /// <returns>False if the type was already added.</returns>
        public bool AddSerializedType(Type t)
        {
            EseTableAttribute a = t.getTableAttribute();

            if (null == a)
            {
                throw new SerializationException("The type must have [EseTable] attribute applied.");
            }

            lock ( syncRoot )
            {
                if (m_tables.FindIndex(ts => ts.recordType.Equals(t)) >= 0)
                {
                    return(false);                      // the type is already added.
                }
                m_tables.Add(new TypeSerializer(t, a));
                return(true);
            }
        }
Exemple #3
0
        internal TypeSerializer serializerForType(Type t)
        {
            TypeSerializer ser;

            if (serializers.TryGetValue(t, out ser))
            {
                return(ser);
            }

            EseTableAttribute attrTable = t.getTableAttribute();

            if (null == attrTable)
            {
                throw new SerializationException("The [EseTable] attribute is not applied to '" + t.Name + "' type more then once.");
            }

            ser = new TypeSerializer(t, attrTable);
            serializers.Add(t, ser);
            return(ser);
        }