Ejemplo n.º 1
0
        private Dictionary <string, string> DeserializeCustomPropertiesDictionary(out bool isTruncatedResult)
        {
            byte[] valueOrDefault = this.propertyBag.GetValueOrDefault <byte[]>(ActivitySchema.CustomProperties, null);
            if (valueOrDefault == null || valueOrDefault.Length == 0)
            {
                isTruncatedResult = false;
                return(new Dictionary <string, string>());
            }
            AbstractCustomPropertySerializer deserializer = CustomPropertySerializerFactory.GetDeserializer(valueOrDefault);

            if (deserializer == null)
            {
                isTruncatedResult = false;
                return(new Dictionary <string, string>());
            }
            return(deserializer.Deserialize(valueOrDefault, out isTruncatedResult));
        }
Ejemplo n.º 2
0
        private void SerializeCustomPropertiesDictionary(IDictionary <string, string> data, out bool isTruncatedResult)
        {
            if (data == null || data.Count == 0)
            {
                isTruncatedResult = false;
                return;
            }
            AbstractCustomPropertySerializer serializer = CustomPropertySerializerFactory.GetSerializer();

            if (serializer == null)
            {
                isTruncatedResult = false;
                return;
            }
            byte[] array = serializer.Serialize(data, out isTruncatedResult);
            if (array != null)
            {
                this.propertyBag.SetProperty(ActivitySchema.CustomProperties, array);
            }
        }
Ejemplo n.º 3
0
        public static AbstractCustomPropertySerializer GetDeserializer(byte[] bytes)
        {
            ArgumentValidator.ThrowIfNull("bytes", bytes);
            if (bytes.Length < 3)
            {
                InferenceDiagnosticsLog.Log("CustomPropertySerializerFactory.GetDeserializer", string.Format("Cannot deserialize a byte array that does not have a header. Length of bytes: '{0}'", bytes.Length));
                return(null);
            }
            int num  = (int)bytes[0];
            int num2 = (int)bytes[1];

            if (num <= CustomPropertySerializerFactory.maxVersion)
            {
                return(CustomPropertySerializerFactory.GetSerializer(num));
            }
            if (num2 <= CustomPropertySerializerFactory.maxVersion)
            {
                return(CustomPropertySerializerFactory.GetSerializer(CustomPropertySerializerFactory.maxVersion));
            }
            InferenceDiagnosticsLog.Log("Activity.DeserializeCustomPropertiesDictionary", string.Format("Unable to find a serializer for deserializing. Version used for serializing '{0}', MinVersion supported '{1}', MaxVersion understood by factory '{2}'", num, num2, CustomPropertySerializerFactory.maxVersion));
            return(null);
        }
Ejemplo n.º 4
0
 public static AbstractCustomPropertySerializer GetSerializer()
 {
     return(CustomPropertySerializerFactory.GetSerializer(CustomPropertySerializerFactory.maxVersion));
 }