Exemplo n.º 1
0
            public void Check(MessageSerializedPropertyInfo messageSerializedPropertyInfo, SerializationDefaults serializationDefaults, MessageClassAttribute classAttribute)
            {
                if (!messageSerializedPropertyInfo.ContainsAuthenticationAttribute &&
                    messageSerializedPropertyInfo.PropertyInfo.Name.Equals("Hash", StringComparison.InvariantCultureIgnoreCase))
                {
                    messageSerializedPropertyInfo.CalculatedFieldAttributes.Add(new CalculatedAuthenticationResultAttribute(typeof(CalculatorAuthenticationSha256)));

                    // Since we know the result of the hash is going to be 32 bytes if the Length property hasn't been set we'll set it.
                    if (!messageSerializedPropertyInfo.MessagePropertyAttribute.IsLengthSpecified)
                    {
                        messageSerializedPropertyInfo.MessagePropertyAttribute.Length = 32;
                    }
                }
            }
Exemplo n.º 2
0
 public void Check(MessageSerializedPropertyInfo messageSerializedPropertyInfo, SerializationDefaults serializationDefaults, MessageClassAttribute classAttribute)
 {
     if (!messageSerializedPropertyInfo.ContainsLengthAttribute &&
         messageSerializedPropertyInfo.PropertyInfo.Name == "Length")
     {
         messageSerializedPropertyInfo.CalculatedFieldAttributes.Add(new CalculatedLengthResultAttribute());
     }
 }
Exemplo n.º 3
0
        public void Check(MessageSerializedPropertyInfo messageSerializedPropertyInfo, SerializationDefaults serializationDefaults, MessageClassAttribute classAttribute)
        {
            if (!messageSerializedPropertyInfo.CalculatedFieldAttributes.Any(item => item is CalculatedChecksum5555ResultAttribute || item is CalculatedChecksum5555Attribute))
            {
                if (messageSerializedPropertyInfo.PropertyInfo.Name == "Checksum")
                {
                    messageSerializedPropertyInfo.CalculatedFieldAttributes.Add(new CalculatedChecksum5555ResultAttribute());
                }

                if (messageSerializedPropertyInfo.PropertyInfo.Name == "NumberNotIncludedInChecksum")
                {
                    CalculatedChecksum5555Attribute attribute = new CalculatedChecksum5555Attribute();
                    attribute.Exclude = true;
                    messageSerializedPropertyInfo.CalculatedFieldAttributes.Add(attribute);
                }
            }
        }
Exemplo n.º 4
0
 void VerifyMessageSerializedClassAttribute(MessageClassAttribute classInfoToVerify, MessageClassAttribute classInfoExpected, string infoPrefix)
 {
     Assert.That(classInfoToVerify.DefaultExcludeProperty, Is.EqualTo(classInfoExpected.DefaultExcludeProperty), infoPrefix + "::DefaultExcludeProperty");
     Assert.That(classInfoToVerify.PutInheritedPropertiesLast, Is.EqualTo(classInfoExpected.PutInheritedPropertiesLast), infoPrefix + "::PutInheritedPropertiesLast");
 }
Exemplo n.º 5
0
 public void Check(MessageSerializedPropertyInfo messageSerializedPropertyInfo, SerializationDefaults serializationDefaults, MessageClassAttribute classAttribute)
 {
     if (!messageSerializedPropertyInfo.MessagePropertyAttribute.IsPrepadCharacterSpecified)
     {
         messageSerializedPropertyInfo.MessagePropertyAttribute.PrepadCharacter = '0';
     }
 }
Exemplo n.º 6
0
        public void Check(MessageSerializedPropertyInfo messageSerializedPropertyInfo, SerializationDefaults serializationDefaults, MessageClassAttribute classAttribute)
        {
            var messagePropertyAttribute = messageSerializedPropertyInfo.MessagePropertyAttribute;

            if (!messagePropertyAttribute.IsEndiannessSpecified)
            {
                if (classAttribute.EndiannessExplicitlySpecified)
                {
                    messagePropertyAttribute.Endianness = classAttribute.Endianness;
                }
                else if (serializationDefaults != null)
                {
                    messagePropertyAttribute.Endianness = serializationDefaults.Endianness;
                }
                else
                {
                    messagePropertyAttribute.Endianness = Endiannesses.System;
                }
            }
        }