コード例 #1
0
        public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry)
        {
            var inContext = new Context();

            inContext.TemplateRegistry.RegisterAll(inboundRegistry);
            var outContext = new Context();

            outContext.TemplateRegistry.RegisterAll(outboundRegistry);
            inContext.ErrorHandler = this;

            this.connection = connection;
            this.protocol   = protocol;
            try
            {
                in_stream  = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                out_stream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (System.IO.IOException e)
            {
                errorHandler.Error(null, "Error occurred in connection.", e);
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }
コード例 #2
0
ファイル: ScalarConverter.cs プロジェクト: radtek/Gradual
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var  type         = (Type)TEMPLATE_TYPE_MAP[fieldDef.GetGroup()];
            bool optional     = fieldDef.GetBool("Optional");
            var  initialValue = ScalarValue.UNDEFINED;

            if (fieldDef.IsDefined("InitialValue"))
            {
                initialValue = (ScalarValue)fieldDef.GetValue("InitialValue");
            }

            if (fieldDef.IsDefined("Operator"))
            {
                GroupValue operatorGroup    = fieldDef.GetGroup("Operator").GetGroup(0);
                Operator   operator_Renamed = GetOperator(operatorGroup.GetGroup());
                var        scalar           = new Scalar(fieldDef.GetString("Name"), type, operator_Renamed, initialValue, optional);
                if (operatorGroup.IsDefined("Dictionary"))
                {
                    scalar.Dictionary = operatorGroup.GetString("Dictionary");
                }
                if (operatorGroup.IsDefined("Key"))
                {
                    string name = operatorGroup.GetGroup("Key").GetString("Name");
                    string ns   = operatorGroup.GetGroup("Key").GetString("Ns");
                    scalar.Key = new QName(name, ns);
                }
                return(scalar);
            }
            return(new Scalar(fieldDef.GetString("Name"), type, Operator.NONE, initialValue, optional));
        }
コード例 #3
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string ns = fieldDef.GetString("Ns");
            var qname = new QName(name, ns);
            var fields = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            Scalar length = null;
            if (fieldDef.IsDefined("Length"))
            {
                var lengthDef = fieldDef.GetGroup("Length");
                QName lengthName;
                string id = null;
                if (lengthDef.IsDefined("Name"))
                {
                    var nameDef = lengthDef.GetGroup("Name");
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    if (nameDef.IsDefined("AuxId"))
                        id = nameDef.GetString("AuxId");
                }
                else
                    lengthName = Global.CreateImplicitName(qname);
                var operator_Renamed = Operator.NONE;
                if (lengthDef.IsDefined("Operator"))
                    operator_Renamed = GetOperator(lengthDef.GetGroup("Operator").GetGroup(0).GetGroup());
                var initialValue = ScalarValue.UNDEFINED;
                if (lengthDef.IsDefined("InitialValue"))
                    initialValue = (ScalarValue) lengthDef.GetValue("InitialValue");
                length = new Scalar(lengthName, Type.U32, operator_Renamed, initialValue, optional) {Id = id};
            }

            return new Sequence(qname, length, fields, optional);
        }
 public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
 {
     var scalar = (Scalar) base.Convert(fieldDef, templateRegistry, context);
     if (fieldDef.IsDefined("Length"))
     {
         scalar.AddAttribute(Error.FastConstants.LENGTH_FIELD, fieldDef.GetGroup("Length").GetString("Name"));
     }
     return scalar;
 }
コード例 #5
0
 public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
 {
     var name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
     if (!templateRegistry.IsDefined(name))
     {
         throw new System.SystemException("Referenced template " + name + " not defined.");
     }
     return new StaticTemplateReference(templateRegistry.get_Renamed(name));
 }
コード例 #6
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");

            Field[] fields   = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool    optional = fieldDef.GetBool("Optional");

            return(new Group(name, fields, optional));
        }
コード例 #7
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));

            if (!templateRegistry.IsDefined(name))
            {
                throw new System.SystemException("Referenced template " + name + " not defined.");
            }
            return(new StaticTemplateReference(templateRegistry.get_Renamed(name)));
        }
コード例 #8
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var scalar = (Scalar)base.Convert(fieldDef, templateRegistry, context);

            if (fieldDef.IsDefined("Length"))
            {
                scalar.AddAttribute(Error.FastConstants.LENGTH_FIELD, fieldDef.GetGroup("Length").GetString("Name"));
            }
            return(scalar);
        }
コード例 #9
0
 public static Field[] ParseFieldInstructions(GroupValue groupDef, TemplateRegistry registry, ConversionContext context)
 {
     var instructions = groupDef.GetSequence("Instructions");
     var fields = new Field[instructions.Length];
     for (int i = 0; i < fields.Length; i++)
     {
         var fieldDef = instructions[i].GetGroup(0);
         var converter = context.GetConverter(fieldDef.GetGroup());
         if (converter == null)
         {
             throw new System.SystemException("Encountered unknown group " + fieldDef.GetGroup() + "while processing field instructions " + groupDef.GetGroup());
         }
         fields[i] = converter.Convert(fieldDef, registry, context);
     }
     return fields;
 }
コード例 #10
0
        public static Field[] ParseFieldInstructions(GroupValue groupDef, TemplateRegistry registry, ConversionContext context)
        {
            var instructions = groupDef.GetSequence("Instructions");
            var fields       = new Field[instructions.Length];

            for (int i = 0; i < fields.Length; i++)
            {
                var fieldDef  = instructions[i].GetGroup(0);
                var converter = context.GetConverter(fieldDef.GetGroup());
                if (converter == null)
                {
                    throw new System.SystemException("Encountered unknown group " + fieldDef.GetGroup() + "while processing field instructions " + groupDef.GetGroup());
                }
                fields[i] = converter.Convert(fieldDef, registry, context);
            }
            return(fields);
        }
コード例 #11
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name     = fieldDef.GetString("Name");
            string ns       = fieldDef.GetString("Ns");
            var    qname    = new QName(name, ns);
            var    fields   = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool   optional = fieldDef.GetBool("Optional");
            Scalar length   = null;

            if (fieldDef.IsDefined("Length"))
            {
                var    lengthDef = fieldDef.GetGroup("Length");
                QName  lengthName;
                string id = null;
                if (lengthDef.IsDefined("Name"))
                {
                    var nameDef = lengthDef.GetGroup("Name");
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    if (nameDef.IsDefined("AuxId"))
                    {
                        id = nameDef.GetString("AuxId");
                    }
                }
                else
                {
                    lengthName = Global.CreateImplicitName(qname);
                }
                var operator_Renamed = Operator.NONE;
                if (lengthDef.IsDefined("Operator"))
                {
                    operator_Renamed = GetOperator(lengthDef.GetGroup("Operator").GetGroup(0).GetGroup());
                }
                var initialValue = ScalarValue.UNDEFINED;
                if (lengthDef.IsDefined("InitialValue"))
                {
                    initialValue = (ScalarValue)lengthDef.GetValue("InitialValue");
                }
                length = new Scalar(lengthName, Type.U32, operator_Renamed, initialValue, optional)
                {
                    Id = id
                };
            }

            return(new Sequence(qname, length, fields, optional));
        }
コード例 #12
0
 public virtual void  SendTemplates(TemplateRegistry registry)
 {
     if (!protocol.SupportsTemplateExchange())
     {
         throw new System.NotSupportedException("The procotol " + protocol + " does not support template exchange.");
     }
     MessageTemplate[] templates = registry.Templates;
     for (int i = 0; i < templates.Length; i++)
     {
         MessageTemplate template = templates[i];
         out_stream.WriteMessage(protocol.CreateTemplateDefinitionMessage(template));
         out_stream.WriteMessage(protocol.CreateTemplateDeclarationMessage(template, registry.GetId(template)));
         if (!out_stream.GetTemplateRegistry().IsRegistered(template))
         {
             out_stream.RegisterTemplate(registry.GetId(template), template);
         }
     }
 }
コード例 #13
0
 public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
 {
     var name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
     bool optional = fieldDef.GetBool("Optional");
     var exponentDef = fieldDef.GetGroup("Exponent");
     var exponentOperatorDef = exponentDef.GetGroup("Operator").GetGroup(0);
     var exponentOperator = GetOperator(exponentOperatorDef.GetGroup());
     var exponentDefaultValue = ScalarValue.UNDEFINED;
     if (exponentDef.IsDefined("InitialValue"))
         exponentDefaultValue = new IntegerValue(exponentDef.GetInt("InitialValue"));
     var mantissaDef = fieldDef.GetGroup("Mantissa");
     var mantissaOperatorDef = mantissaDef.GetGroup("Operator").GetGroup(0);
     var mantissaOperator = GetOperator(mantissaOperatorDef.GetGroup());
     var mantissaDefaultValue = ScalarValue.UNDEFINED;
     if (mantissaDef.IsDefined("InitialValue"))
         mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
     return Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue, mantissaOperator, mantissaDefaultValue, optional);
 }
コード例 #14
0
        public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry)
        {
            var inContext = new Context();
            inContext.TemplateRegistry.RegisterAll(inboundRegistry);
            var outContext = new Context();
            outContext.TemplateRegistry.RegisterAll(outboundRegistry);
            inContext.ErrorHandler = this;

            this.connection = connection;
            this.protocol = protocol;
            try
            {
                in_stream = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                out_stream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (System.IO.IOException e)
            {
                errorHandler.Error(null, "Error occurred in connection.", e);
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }
コード例 #15
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var  name                 = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            bool optional             = fieldDef.GetBool("Optional");
            var  exponentDef          = fieldDef.GetGroup("Exponent");
            var  exponentOperatorDef  = exponentDef.GetGroup("Operator").GetGroup(0);
            var  exponentOperator     = GetOperator(exponentOperatorDef.GetGroup());
            var  exponentDefaultValue = ScalarValue.UNDEFINED;

            if (exponentDef.IsDefined("InitialValue"))
            {
                exponentDefaultValue = new IntegerValue(exponentDef.GetInt("InitialValue"));
            }
            var mantissaDef          = fieldDef.GetGroup("Mantissa");
            var mantissaOperatorDef  = mantissaDef.GetGroup("Operator").GetGroup(0);
            var mantissaOperator     = GetOperator(mantissaOperatorDef.GetGroup());
            var mantissaDefaultValue = ScalarValue.UNDEFINED;

            if (mantissaDef.IsDefined("InitialValue"))
            {
                mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
            }
            return(Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue, mantissaOperator, mantissaDefaultValue, optional));
        }
コード例 #16
0
 public void SetTemplateRegistry(TemplateRegistry registry)
 {
     context.TemplateRegistry = registry;
 }
コード例 #17
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var type = (Type) TEMPLATE_TYPE_MAP[fieldDef.GetGroup()];
            bool optional = fieldDef.GetBool("Optional");
            var initialValue = ScalarValue.UNDEFINED;
            if (fieldDef.IsDefined("InitialValue"))
                initialValue = (ScalarValue) fieldDef.GetValue("InitialValue");

            if (fieldDef.IsDefined("Operator"))
            {
                GroupValue operatorGroup = fieldDef.GetGroup("Operator").GetGroup(0);
                Operator operator_Renamed = GetOperator(operatorGroup.GetGroup());
                var scalar = new Scalar(fieldDef.GetString("Name"), type, operator_Renamed, initialValue, optional);
                if (operatorGroup.IsDefined("Dictionary"))
                    scalar.Dictionary = operatorGroup.GetString("Dictionary");
                if (operatorGroup.IsDefined("Key"))
                {
                    string name = operatorGroup.GetGroup("Key").GetString("Name");
                    string ns = operatorGroup.GetGroup("Key").GetString("Ns");
                    scalar.Key = new QName(name, ns);
                }
                return scalar;
            }
            return new Scalar(fieldDef.GetString("Name"), type, Operator.NONE, initialValue, optional);
        }
コード例 #18
0
 public virtual Field Convert(GroupValue groupValue, TemplateRegistry templateRegistry, ConversionContext context)
 {
     return DynamicTemplateReference.INSTANCE;
 }
コード例 #19
0
ファイル: MessageInputStream.cs プロジェクト: radtek/Gradual
 public void  SetTemplateRegistry(TemplateRegistry registry)
 {
     context.TemplateRegistry = registry;
 }
コード例 #20
0
 public virtual Field Convert(GroupValue groupValue, TemplateRegistry templateRegistry, ConversionContext context)
 {
     return(DynamicTemplateReference.INSTANCE);
 }
コード例 #21
0
 public virtual void SendTemplates(TemplateRegistry registry)
 {
     if (!protocol.SupportsTemplateExchange())
     {
         throw new System.NotSupportedException("The procotol " + protocol + " does not support template exchange.");
     }
     MessageTemplate[] templates = registry.Templates;
     for (int i = 0; i < templates.Length; i++)
     {
         MessageTemplate template = templates[i];
         out_stream.WriteMessage(protocol.CreateTemplateDefinitionMessage(template));
         out_stream.WriteMessage(protocol.CreateTemplateDeclarationMessage(template, registry.GetId(template)));
         if (!out_stream.GetTemplateRegistry().IsRegistered(template))
             out_stream.RegisterTemplate(registry.GetId(template), template);
     }
 }
コード例 #22
0
 public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
 {
     string name = fieldDef.GetString("Name");
     Field[] fields = ParseFieldInstructions(fieldDef, templateRegistry, context);
     bool optional = fieldDef.GetBool("Optional");
     return new Group(name, fields, optional);
 }
コード例 #23
0
 public abstract Field Convert(GroupValue param1, OpenFAST.Template.TemplateRegistry param2, ConversionContext param3);