示例#1
0
        private void InitPersistors()
        {
            m_fields     = new IDataField[m_Def.Fields.Values.Count];
            m_persistors = new IBinaryPersistor[m_fields.Length];
            var i = 0;

            if (m_Def.DependingField != null)
            {
                // depending field comes first
                m_persistors[0] = BinaryPersistors.GetPersistor(m_Def.DependingField);
                m_fields[0]     = m_Def.DependingField;
                i++;
            }

            foreach (var field in m_Def.Fields.Values)
            {
                if (field == m_Def.DependingField)
                {
                    continue;
                }
                var persistor = BinaryPersistors.GetPersistor(field);
                m_persistors[i] = persistor;
                m_fields[i]     = field;
                i++;
            }
        }
示例#2
0
 /// <summary>Returns null if its a String field</summary>
 /// <param name="field"></param>
 /// <returns></returns>
 public static IBinaryPersistor GetPersistor(IDataField field)
 {
     if (field.DataFieldType == DataFieldType.FlatArray || field.DataFieldType == DataFieldType.NestedArray)
     {
         return((IBinaryPersistor) new ArrayPersistor((ArrayDataField)field));
     }
     return(BinaryPersistors.GetPersistorNoArray(field));
 }
示例#3
0
        public NestedPersistor(INestedDataField dataField)
        {
            this.m_DataField            = dataField;
            this.m_UnderlyingPersistors = new IBinaryPersistor[this.m_DataField.InnerFields.Count];
            this.m_accessors            = new IGetterSetter[this.m_DataField.InnerFields.Count];
            int index = 0;

            foreach (IDataField field in this.m_DataField.InnerFields.Values)
            {
                IBinaryPersistor persistor = BinaryPersistors.GetPersistor(field);
                this.m_UnderlyingPersistors[index] = persistor;
                this.m_accessors[index]            = field.Accessor;
                ++index;
            }
        }
示例#4
0
        public NestedPersistor(
            INestedDataField dataField)
        {
            m_DataField            = dataField;
            m_UnderlyingPersistors = new IBinaryPersistor[m_DataField.InnerFields.Count];
            m_accessors            = new IGetterSetter[m_DataField.InnerFields.Count];
            var i = 0;

            foreach (var field in m_DataField.InnerFields.Values)
            {
                var persistor = BinaryPersistors.GetPersistor(field);
                m_UnderlyingPersistors[i] = persistor;
                m_accessors[i]            = field.Accessor;
                i++;
            }
        }
示例#5
0
        public static IBinaryPersistor GetPersistorNoArray(IDataField field)
        {
            Type actualType = field.MappedMember.GetActualType();

            if (field is INestedDataField)
            {
                return((IBinaryPersistor) new NestedPersistor((INestedDataField)field));
            }
            ISimpleBinaryPersistor simplePersistor = BinaryPersistors.GetSimplePersistor(actualType);

            if (simplePersistor == null)
            {
                throw new DataHolderException("Simple Type did not have a binary Persistor: " + actualType.FullName,
                                              new object[0]);
            }
            return((IBinaryPersistor)simplePersistor);
        }
示例#6
0
        private void InitPersistors()
        {
            this.m_fields     = new IDataField[this.m_Def.Fields.Values.Count];
            this.m_persistors = new IBinaryPersistor[this.m_fields.Length];
            int index = 0;

            if (this.m_Def.DependingField != null)
            {
                this.m_persistors[0] = BinaryPersistors.GetPersistor((IDataField)this.m_Def.DependingField);
                this.m_fields[0]     = (IDataField)this.m_Def.DependingField;
                ++index;
            }

            foreach (IDataField field in this.m_Def.Fields.Values)
            {
                if (field != this.m_Def.DependingField)
                {
                    IBinaryPersistor persistor = BinaryPersistors.GetPersistor(field);
                    this.m_persistors[index] = persistor;
                    this.m_fields[index]     = field;
                    ++index;
                }
            }
        }
示例#7
0
 public ArrayPersistor(ArrayDataField field)
 {
     m_DataField           = field;
     m_UnderlyingPersistor = BinaryPersistors.GetPersistorNoArray(m_DataField);
 }
示例#8
0
 public ArrayPersistor(ArrayDataField field)
 {
     this.m_DataField           = field;
     this.m_UnderlyingPersistor = BinaryPersistors.GetPersistorNoArray((IDataField)this.m_DataField);
 }