Exemplo n.º 1
0
        /// <summary>
        /// Merges schemas from two binary types.
        /// </summary>
        private static BinaryObjectSchema MergeSchemas(BinaryType a, BinaryType b)
        {
            if (a == null || a.Schema == null)
            {
                return(b.Schema);
            }

            if (b == null || b.Schema == null)
            {
                return(a.Schema);
            }

            var res = new BinaryObjectSchema();

            foreach (var schema in a.Schema.GetAll())
            {
                res.Add(schema.Key, schema.Value);
            }

            foreach (var schema in b.Schema.GetAll())
            {
                res.Add(schema.Key, schema.Value);
            }

            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="typeId">Type ID.</param>
        /// <param name="typeName">Type name.</param>
        /// <param name="fields">Fields.</param>
        /// <param name="affKeyFieldName">Affinity key field name.</param>
        /// <param name="isEnum">Enum flag.</param>
        /// <param name="enumValues">Enum values.</param>
        /// <param name="marshaller">Marshaller.</param>
        /// <param name="schema"></param>
        public BinaryType(int typeId, string typeName, IDictionary <string, BinaryField> fields,
                          string affKeyFieldName, bool isEnum, IDictionary <string, int> enumValues, Marshaller marshaller,
                          BinaryObjectSchema schema)
        {
            _typeId               = typeId;
            _typeName             = typeName;
            _affinityKeyFieldName = affKeyFieldName;
            _fields               = fields;
            _isEnum               = isEnum;
            _enumNameToValue      = enumValues;

            if (_enumNameToValue != null)
            {
                _enumValueToName = _enumNameToValue.ToDictionary(x => x.Value, x => x.Key);
            }

            _marshaller = marshaller;
            _schema     = schema;
        }