Esempio n. 1
0
        private string GetProcessedItem(ISubstitutionContext context, string input, MessageFieldType itemType)
        {
            Logger.WriteTrace(string.Format("{0} processing ", itemType), SeverityEnum.Trace);
            var worker         = SubstitutionManager.GetWorker(context, itemType);
            var res            = worker.PreProcess(input, context);
            var transformation = TransformationManager.GetTransformation(itemType, context);

            res = transformation.Transform(input, context, worker.OnPartLoaded);
            res = worker.PostProcess(input, context);
            Logger.WriteTrace(string.Format("{0} result: {1}", itemType, res), SeverityEnum.Trace);
            return(res);
        }
Esempio n. 2
0
        private static CodeTypeReference GetCodeTypeReference(MessageFieldType fieldType, Type type, IDictionary <MessageDefinitions.Data.Enum, TypeInfo> typeInfoByEnum)
        {
            if (fieldType.FieldType == FieldType.Enum)
            {
                TypeInfo enumTypeInfo = typeInfoByEnum[fieldType.Enum];
                return(new CodeTypeReference(enumTypeInfo.FullName));
            }

            CodeTypeReference codeTypeReference = new CodeTypeReference(type);

            if (fieldType.FieldType == FieldType.Array)
            {
                codeTypeReference.ArrayRank = 1;
            }

            return(codeTypeReference);
        }
Esempio n. 3
0
        public ISubstitutionWorker GetWorker(ISubstitutionContext context, MessageFieldType type)
        {
            switch (type)
            {
            case MessageFieldType.ForBody:
                return(new SubstitutionWorker(ClassContainer.Instance.Resolve <ILogger>(), new List <ISubstitution>
                {
                    new ResourceSubstitution(),
                    new FieldSubstitution(),
                    new ComplexSubstitution(),
                    new ContextVarsSubstitution(),
                },
                                              new List <ISubstitution>
                {
                }));

            case MessageFieldType.ForSubject:
                return(new SubstitutionWorker(ClassContainer.Instance.Resolve <ILogger>(), new List <ISubstitution>
                {
                    new ResourceSubstitution(),
                    new FieldSubstitution(),
                    new ContextVarsSubstitution(),
                },
                                              new List <ISubstitution>
                {
                    new RemoveXmlTagsSubstitution(),
                    new OneLineSubstitution()
                }));

            case MessageFieldType.ForFrom:
            case MessageFieldType.ForReplay:
                return(new SubstitutionWorker(ClassContainer.Instance.Resolve <ILogger>(), new List <ISubstitution>
                {
                    new ResourceSubstitution(),
                    new FieldSubstitution(),
                    new ContextVarsSubstitution(),
                },
                                              new List <ISubstitution>
                {
                    new RemoveXmlTagsSubstitution(),
                    new OneLineSubstitution()
                }));

            default: return(new SubstitutionWorker(ClassContainer.Instance.Resolve <ILogger>(), new List <ISubstitution>(), new List <ISubstitution>()));
            }
        }
Esempio n. 4
0
        private string ConvertTypeName(MessageFieldType fieldType)
        {
            switch (fieldType)
            {
            case MessageFieldType.Int8:
                return("sbyte");

            case MessageFieldType.Int16:
                return("short");

            case MessageFieldType.Int32:
                return("int");

            case MessageFieldType.Int64:
                return("long");

            case MessageFieldType.Uint8:
                return("byte");

            case MessageFieldType.Uint16:
                return("ushort");

            case MessageFieldType.Uint32:
                return("uint");

            case MessageFieldType.Float32:
                return("float");

            case MessageFieldType.Uint64:
                return("ulong");

            case MessageFieldType.Char:
                return("char");

            case MessageFieldType.Double:
                return("double");

            default:
                throw new ArgumentOutOfRangeException(nameof(fieldType), fieldType, null);
            }
        }
Esempio n. 5
0
        public static int GetFieldTypeByteSize(this MessageFieldType type)
        {
            switch (type)
            {
            case MessageFieldType.Int8:
                return(1);

            case MessageFieldType.Int16:
                return(2);

            case MessageFieldType.Int32:
                return(4);

            case MessageFieldType.Int64:
                return(8);

            case MessageFieldType.Uint8:
                return(1);

            case MessageFieldType.Uint16:
                return(2);

            case MessageFieldType.Uint32:
                return(4);

            case MessageFieldType.Float32:
                return(4);

            case MessageFieldType.Uint64:
                return(8);

            case MessageFieldType.Char:
                return(1);

            case MessageFieldType.Double:
                return(8);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Esempio n. 6
0
        private static string FieldTypeToString(MessageFieldType type)
        {
            switch (type)
            {
            case MessageFieldType.Int8:
                return("int8_t");

            case MessageFieldType.Int16:
                return("int16_t");

            case MessageFieldType.Int32:
                return("int32_t");

            case MessageFieldType.Int64:
                return("int64_t");

            case MessageFieldType.Uint8:
                return("uint8_t");

            case MessageFieldType.Uint16:
                return("uint16_t");

            case MessageFieldType.Uint32:
                return("uint32_t");

            case MessageFieldType.Float32:
                return("float");

            case MessageFieldType.Uint64:
                return("uint64_t");

            case MessageFieldType.Char:
                return("char");

            case MessageFieldType.Double:
                return("double");

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Esempio n. 7
0
 public IMianTemplateTransformation GetTransformation(MessageFieldType type, ISubstitutionContext context)
 {
     return(new XsltTransformation());
 }
        private static void AddEnumReadCodeStatements(CodeStatementCollection codeStatementCollection, string readerParamName, MessageFieldType type, CodePropertyReferenceExpression propertyExpression, string enumFullname)
        {
            String readMethodName = GetReadMethodName(type.DataType);

            var codeMethodInvokeExpression = new CodeMethodInvokeExpression(new CodeVariableReferenceExpression(readerParamName), readMethodName);

            CodeAssignStatement propertyAssignStatement = new CodeAssignStatement(propertyExpression,
                                                                                  new CodeCastExpression(enumFullname, codeMethodInvokeExpression));

            codeStatementCollection.Add(propertyAssignStatement);
        }
        private static void AddArrayWriteCodeStatements(CodeStatementCollection statements, string writerParamName, MessageFieldType type, CodePropertyReferenceExpression propertyExpression)
        {
            for (int i = 0; i < type.ArrayLength; i++)
            {
                CodeArrayIndexerExpression codeArrayIndexerExpression =
                    new CodeArrayIndexerExpression(propertyExpression, new CodePrimitiveExpression(i));

                CodeMethodInvokeExpression writeInvoke =
                    new CodeMethodInvokeExpression(
                        new CodeVariableReferenceExpression(writerParamName), "Write", codeArrayIndexerExpression);

                statements.Add(writeInvoke);
            }
        }
        private static void AddEnumWriteCodeStatements(CodeStatementCollection statements, string writerParamName, MessageFieldType fieldType, CodePropertyReferenceExpression propertyExpression)
        {
            Type type = SystemTypeHelper.GetType(fieldType.DataType);
            CodeCastExpression castExpression = new CodeCastExpression(type, propertyExpression);

            CodeMethodInvokeExpression writeInvoke =
                new CodeMethodInvokeExpression(
                    new CodeVariableReferenceExpression(writerParamName), "Write", castExpression);

            statements.Add(writeInvoke);
        }