コード例 #1
0
    public static void MessageProperty_Name_Sets(string name)
    {
        MessagePropertyAttribute attribute = new MessagePropertyAttribute();

        attribute.Name = name;
        Assert.True(String.Equals(name, attribute.Name),
                    String.Format("Set Name to '{0}' but getter returned '{1}'", name, attribute.Name));
    }
コード例 #2
0
        // Some example code: https://docs.microsoft.com/en-us/dotnet/standard/serialization/examples-of-xml-serialization
        ConfigMessageSerializerClass CreateClassInfo()
        {
            ConfigMessageSerializerClass messageSerializerClassInfo = new ConfigMessageSerializerClass();
            ConfigClassInfo classInfo = new ConfigClassInfo();

            classInfo.AssemblyName  = Assembly.GetExecutingAssembly().FullName;
            classInfo.ClassFullName = typeof(SimpleXmlTestClass).FullName;

            ConfigPropertyInfo propertyInfo1 = new ConfigPropertyInfo();

            propertyInfo1.Name = "Property1";
            propertyInfo1.Attributes.Add(new MessagePropertyAttribute()
            {
                PrepadCharacter = 'T'
            });
            propertyInfo1.Attributes.Add(new CalculatedLengthResultAttribute());
            //propertyInfo1._messagePropertyAttribute.MessageLengthType = MessageLengthTypes.RestOfMessage;
            //propertyInfo1._messagePropertyAttribute.PrepadCharacter = 'T';
            //propertyInfo1.AuthenticationClass = typeof(int);
            classInfo.Properties.Add(propertyInfo1);

            ConfigPropertyInfo propertyInfo2 = new ConfigPropertyInfo();

            propertyInfo2.Name = "Property2";
            classInfo.Properties.Add(propertyInfo2);

            ConfigPropertyInfo propertyInfo3 = new ConfigPropertyInfo();

            propertyInfo3.Name = "Property3";
            var property3MessagePropertyAttribute = new MessagePropertyAttribute();

            property3MessagePropertyAttribute.IsBcd = true;
            //property3MessagePropertyAttribute.IsAuthenticationField = false;
            //property3MessagePropertyAttribute.ExcludeFromAuthentication = true;
            property3MessagePropertyAttribute.Length                 = 20;
            property3MessagePropertyAttribute.Format                 = "YYYYMMDDHHMMSS";
            property3MessagePropertyAttribute.BlobType               = BlobTypes.None;
            property3MessagePropertyAttribute.VariableLength         = true;
            property3MessagePropertyAttribute.MinLength              = 1;
            property3MessagePropertyAttribute.MaxLength              = 18;
            property3MessagePropertyAttribute.MinimizeVariableLength = true;
            //property3MessagePropertyAttribute.ExcludeFromLength = false;
            property3MessagePropertyAttribute.PrepadCharacter = ' ';
            //property3MessagePropertyAttribute.MessageLengthType = MessageLengthTypes.RestOfMessage;
            //property3MessagePropertyAttribute.AuthenticationClass = typeof(AuthenticationCrc32);
            propertyInfo3.Attributes.Add(property3MessagePropertyAttribute);
            propertyInfo3.Attributes.Add(new CalculatedLengthResultAttribute()
            {
                Exclude = false
            });
            propertyInfo3.Attributes.Add(new CalculatedAuthenticationResultAttribute(typeof(CalculatorAuthenticationCrc32)));
            classInfo.Properties.Add(propertyInfo3);

            messageSerializerClassInfo.ClassInfo = classInfo;

            return(messageSerializerClassInfo);
        }
コード例 #3
0
 void VerifyMessageSerializedPropertyAttribute(MessagePropertyAttribute propertyInfoToVerify, MessagePropertyAttribute propertyInfoExpected, string infoPrefix)
 {
     Assert.That(propertyInfoToVerify.Exclude, Is.EqualTo(propertyInfoExpected.Exclude), infoPrefix + "::Exclude");
     //Assert.That(propertyInfoToVerify.ExcludeFromLength, Is.EqualTo(propertyInfoExpected.ExcludeFromLength), infoPrefix + "::ExcludeFromLength");
     Assert.That(propertyInfoToVerify.Prepad, Is.EqualTo(propertyInfoExpected.Prepad), infoPrefix + "::Prepad");
     Assert.That(propertyInfoToVerify.PrepadCharacter, Is.EqualTo(propertyInfoExpected.PrepadCharacter), infoPrefix + "::PrepadCharacter");
     //Assert.That(propertyInfoToVerify.MessageLengthType, Is.EqualTo(propertyInfoExpected.MessageLengthType), infoPrefix + "::MessageLengthType");
     Assert.That(propertyInfoToVerify.BlobType, Is.EqualTo(propertyInfoExpected.BlobType), infoPrefix + "::BlobType");
     Assert.That(propertyInfoToVerify.AssociatedBlobProperty, Is.EqualTo(propertyInfoExpected.AssociatedBlobProperty), infoPrefix + "::AssociatedBlobProperty");
     Assert.That(propertyInfoToVerify.IsBcd, Is.EqualTo(propertyInfoExpected.IsBcd), infoPrefix + "::IsBcd");
     //Assert.That(propertyInfoToVerify.IsAuthenticationField, Is.EqualTo(propertyInfoExpected.IsAuthenticationField), infoPrefix + "::IsAuthenticationField");
     //Assert.That(propertyInfoToVerify.AuthenticationClass, Is.EqualTo(propertyInfoExpected.AuthenticationClass), infoPrefix + "::AuthenticationClass");
     //Assert.That(propertyInfoToVerify.ExcludeFromAuthentication, Is.EqualTo(propertyInfoExpected.ExcludeFromAuthentication), infoPrefix + "::ExcludeFromAuthentication");
     Assert.That(propertyInfoToVerify.Length, Is.EqualTo(propertyInfoExpected.Length), infoPrefix + "::Length");
     Assert.That(propertyInfoToVerify.VariableLength, Is.EqualTo(propertyInfoExpected.VariableLength), infoPrefix + "::VariableLength");
     Assert.That(propertyInfoToVerify.MinLength, Is.EqualTo(propertyInfoExpected.MinLength), infoPrefix + "::MinLength");
     Assert.That(propertyInfoToVerify.MaxLength, Is.EqualTo(propertyInfoExpected.MaxLength), infoPrefix + "::MaxLength");
     Assert.That(propertyInfoToVerify.MinimizeVariableLength, Is.EqualTo(propertyInfoExpected.MinimizeVariableLength), infoPrefix + "::MinimizeVariableLength");
     Assert.That(propertyInfoToVerify.Format, Is.EqualTo(propertyInfoExpected.Format), infoPrefix + "::Format");
 }