コード例 #1
0
 public ProblemGatherer(BehaviorGraph graph, IViewProblemStoreCache cache, ITemplateRegistry<ITemplate> sparkTemplates, IParsingRegistrations<ITemplate> parsings)
 {
     _graph = graph;
     _cache = cache;
     _sparkTemplates = sparkTemplates;
     _parsings = parsings;
 }
コード例 #2
0
 public Context(ITemplateRegistry templateRegistry)
 {
     _dictionaries[DictionaryFields.Global]   = _globalDictionary;
     _dictionaries[DictionaryFields.Template] = _templateDictionary;
     _dictionaries[DictionaryFields.Type]     = _applicationTypeDictionary;
     _templateRegistry = templateRegistry ?? new BasicTemplateRegistry();
 }
コード例 #3
0
ファイル: Context.cs プロジェクト: shariqkudcs/openfastdotnet
 public Context(ITemplateRegistry templateRegistry)
 {
     _dictionaries[DictionaryFields.Global] = _globalDictionary;
     _dictionaries[DictionaryFields.Template] = _templateDictionary;
     _dictionaries[DictionaryFields.Type] = _applicationTypeDictionary;
     _templateRegistry = templateRegistry ?? new BasicTemplateRegistry();
 }
コード例 #4
0
        protected override void beforeEach()
        {
            const string viewPath    = "/_Package1_/Handlers/Models/SerieSL.spark";
            var          appRoot     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates");
            var          packageRoot = Path.Combine(appRoot, "App", "fubu-packages", "Package1", "WebContent");

            var binding1       = new Template(Path.Combine(packageRoot, "Handlers", "Shared", "bindings.xml"), packageRoot, "Package1");
            var binding2       = new Template(Path.Combine(appRoot, "Shared", "bindings.xml"), appRoot, FubuSparkConstants.HostOrigin);
            var viewPathPolicy = new ViewPathPolicy();

            viewPathPolicy.Apply(binding1);
            viewPathPolicy.Apply(binding2);

            _viewFolder = MockFor <IViewFolder>();
            _viewFolder.Expect(x => x.GetViewSource(binding1.ViewPath)).Return(new FileSystemViewFile(binding1.FilePath));
            _viewFolder.Expect(x => x.GetViewSource(binding2.ViewPath)).Return(new FileSystemViewFile(binding2.FilePath));

            _request = new BindingRequest(_viewFolder)
            {
                ViewPath = viewPath
            };

            _templateRegistry = MockFor <ITemplateRegistry>();
            _templateRegistry.Expect(x => x.BindingsForView(viewPath)).Return(new[] { binding1, binding2 });
        }
コード例 #5
0
        private IEnumerable<string> getDirectories(ITemplate template, ITemplateRegistry templateRegistry, bool includeDirectAncestor)
        {
            foreach (var directory in _builder.BuildBy(template.FilePath, template.RootPath, includeDirectAncestor))
            {
                yield return directory;
            }

            if (template.FromHost())
            {
                yield break;
            }

            var hostTemplate = templateRegistry.FromHost().FirstOrDefault();
            if (hostTemplate == null)
            {
                yield break;
            }

            var hostRoot = hostTemplate.RootPath;
            if (includeDirectAncestor)
            {
                yield return hostRoot;
            }

            foreach (var sharedFolder in _builder.SharedFolderNames)
            {
                yield return Path.Combine(hostRoot, sharedFolder);
            }
        }
コード例 #6
0
        public Session(IConnection connection, ISessionProtocol protocol, ITemplateRegistry inboundRegistry,
                       ITemplateRegistry outboundRegistry)
        {
            var inContext = new Context();

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

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

            _connection = connection;
            _protocol   = protocol;
            try
            {
                _inStream  = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                _outStream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (IOException e)
            {
                _errorHandler.OnError(e, DynError.Undefined, "Error occurred in connection.");
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }
コード例 #7
0
        private IEnumerable <string> getDirectories(ITemplate template, ITemplateRegistry templateRegistry, bool includeDirectAncestor)
        {
            foreach (var directory in _builder.BuildBy(template.FilePath, template.RootPath, includeDirectAncestor))
            {
                yield return(directory);
            }

            if (template.FromHost())
            {
                yield break;
            }

            var hostTemplate = templateRegistry.FromHost().FirstOrDefault();

            if (hostTemplate == null)
            {
                yield break;
            }

            var hostRoot = hostTemplate.RootPath;

            if (includeDirectAncestor)
            {
                yield return(hostRoot);
            }

            foreach (var sharedFolder in _builder.SharedFolderNames)
            {
                yield return(Path.Combine(hostRoot, sharedFolder));
            }
        }
コード例 #8
0
 public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
 {
     var name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
     bool optional = fieldDef.GetBool("Optional");
     GroupValue exponentDef = fieldDef.GetGroup("Exponent");
     GroupValue exponentOperatorDef = exponentDef.GetGroup("Operator").GetGroup(0);
     Operator exponentOperator = GetOperator(exponentOperatorDef.Group);
     ScalarValue exponentDefaultValue = ScalarValue.Undefined;
     if (exponentDef.IsDefined("InitialValue"))
         exponentDefaultValue = new IntegerValue(exponentDef.GetInt("InitialValue"));
     GroupValue mantissaDef = fieldDef.GetGroup("Mantissa");
     GroupValue mantissaOperatorDef = mantissaDef.GetGroup("Operator").GetGroup(0);
     Operator mantissaOperator = GetOperator(mantissaOperatorDef.Group);
     ScalarValue mantissaDefaultValue = ScalarValue.Undefined;
     if (mantissaDef.IsDefined("InitialValue"))
         mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
     ComposedScalar composedDecimal = Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue,
                                                           mantissaOperator, mantissaDefaultValue, optional);
     IFieldValue retAuxId;
     if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId!=null)
     {
         composedDecimal.Id = retAuxId.ToString();
     }
     return composedDecimal;
 }
コード例 #9
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            var         name                 = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            bool        optional             = fieldDef.GetBool("Optional");
            GroupValue  exponentDef          = fieldDef.GetGroup("Exponent");
            GroupValue  exponentOperatorDef  = exponentDef.GetGroup("Operator").GetGroup(0);
            Operator    exponentOperator     = GetOperator(exponentOperatorDef.Group);
            ScalarValue exponentDefaultValue = ScalarValue.Undefined;

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

            if (mantissaDef.IsDefined("InitialValue"))
            {
                mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
            }
            ComposedScalar composedDecimal = Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue,
                                                                  mantissaOperator, mantissaDefaultValue, optional);
            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                composedDecimal.Id = retAuxId.ToString();
            }
            return(composedDecimal);
        }
コード例 #10
0
 public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
 {
     var scalar = (Scalar) base.Convert(fieldDef, templateRegistry, context);
     IFieldValue retLength;
     if (fieldDef.TryGetValue("Length", out retLength) && retLength != null)
         scalar.AddAttribute(FastConstants.LengthField, ((GroupValue) retLength).GetString("Name"));
     return scalar;
 }
コード例 #11
0
        private IEnumerable<ITemplate> locateTemplates(string name, ITemplate fromTemplate, ITemplateRegistry templateRegistry, bool sharedsOnly)
        {
            var directories = sharedsOnly 
                ? _provider.SharedPathsOf(fromTemplate, templateRegistry) 
                : _provider.ReachablesOf(fromTemplate, templateRegistry);

            return templateRegistry.ByNameUnderDirectories(name, directories);
        }
コード例 #12
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            var name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            MessageTemplate template;
            if (templateRegistry.TryGetTemplate(name, out template))
                return new StaticTemplateReference(template);

            throw new ArgumentOutOfRangeException("fieldDef", name, "Referenced template name not defined.");
        }
コード例 #13
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            var         scalar = (Scalar)base.Convert(fieldDef, templateRegistry, context);
            IFieldValue retLength;

            if (fieldDef.TryGetValue("Length", out retLength) && retLength != null)
            {
                scalar.AddAttribute(FastConstants.LengthField, ((GroupValue)retLength).GetString("Name"));
            }
            return(scalar);
        }
コード例 #14
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            var             name = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            MessageTemplate template;

            if (templateRegistry.TryGetTemplate(name, out template))
            {
                return(new StaticTemplateReference(template));
            }

            throw new ArgumentOutOfRangeException("fieldDef", name, "Referenced template name not defined.");
        }
コード例 #15
0
        public void Compose(ITemplateRegistry templates)
        {
            templates.AllTemplates().Each(t =>
            {
                var bindRequest = createBindRequest(t, templates);

                var binders  = _binders.Where(x => x.CanBind(bindRequest));
                var policies = _policies.Where(x => x.Matches(t));

                binders.Each(binder => binder.Bind(bindRequest));
                policies.Each(policy => policy.Apply(t));
            });
        }
コード例 #16
0
        public override Session Connect(string senderName, IConnection connection, ITemplateRegistry inboundRegistry,
                                        ITemplateRegistry outboundRegistry, IMessageListener messageListener,
                                        ISessionListener sessionListener)
        {
            var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.Null);

            session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName));
            Message message    = session.MessageInputStream.ReadMessage();
            string  serverName = message.GetString(1);

            session.Client = new BasicClient(serverName, "unknown");
            return(session);
        }
コード例 #17
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string ns = fieldDef.GetString("Ns");
            var qname = new QName(name, ns);
            Field[] fields = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            Scalar length = null;
            IFieldValue retLength;
            if (fieldDef.TryGetValue("Length", out retLength) && retLength!=null)
            {
                GroupValue lengthDef = (GroupValue)retLength;
                QName lengthName;
                string id = null;
                IFieldValue retName;
                if (lengthDef.TryGetValue("Name", out retName) && retName != null)
                {
                    GroupValue nameDef = (GroupValue)retName;
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    IFieldValue retAuxId;
                    if (nameDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                        id = retAuxId.ToString();
                }
                else
                    lengthName = Global.CreateImplicitName(qname);
                Operator op = Operator.None;
                IFieldValue retOperator;
                if (lengthDef.TryGetValue("Operator", out retOperator) && retOperator != null)
                    op = GetOperator(((GroupValue)retOperator).GetGroup(0).Group);
                ScalarValue initialValue = ScalarValue.Undefined;
                IFieldValue retInitialValue;
                if (lengthDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null)
                    initialValue = (ScalarValue) retInitialValue;
                length = new Scalar(lengthName, FastType.U32, op, initialValue, optional) {Id = id};
            }

            var sequence = new Sequence(qname, length, fields, optional);
            IFieldValue retTypeRef;
            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                GroupValue typeRef = (GroupValue)retTypeRef;
                string typeRefName = typeRef.GetString("Name");
                string typeRefNs = ""; // context.getNamespace();
                IFieldValue rettypeRefNs;
                if (typeRef.TryGetValue("Ns", out rettypeRefNs) && rettypeRefNs!=null)
                    typeRefNs = rettypeRefNs.ToString();
                sequence.TypeReference = new QName(typeRefName, typeRefNs);
            }
            return sequence;
        }
コード例 #18
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            FastType    type     = _templateTypeMap[fieldDef.Group];
            bool        optional = fieldDef.GetBool("Optional");
            IFieldValue retInitialValue;
            ScalarValue initialValue = fieldDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null
                                           ? (ScalarValue)retInitialValue
                                           : ScalarValue.Undefined;

            string      name = fieldDef.GetString("Name");
            IFieldValue rettempNs;
            string      tempNs = fieldDef.TryGetValue("Ns", out rettempNs) && rettempNs != null?rettempNs.ToString() : "";

            var qname = new QName(name, tempNs);

            Scalar      scalar;
            IFieldValue retOperator;

            if (fieldDef.TryGetValue("Operator", out retOperator) && retOperator != null)
            {
                GroupValue operatorGroup = ((GroupValue)retOperator).GetGroup(0);
                Operator   operatortemp  = GetOperator(operatorGroup.Group);
                scalar = new Scalar(qname, type, operatortemp, initialValue, optional);
                IFieldValue retDictionary;
                if (operatorGroup.TryGetValue("Dictionary", out retDictionary) && retDictionary != null)
                {
                    scalar.Dictionary = retDictionary.ToString();
                }
                IFieldValue retKey;
                if (operatorGroup.TryGetValue("Key", out retKey) && retKey != null)
                {
                    GroupValue retOperatorGroup = (GroupValue)retKey;
                    string     keyName          = retOperatorGroup.GetString("Name");
                    string     ns = retOperatorGroup.GetString("Ns");
                    scalar.Key = new QName(keyName, ns);
                }
            }
            else
            {
                scalar = new Scalar(qname, type, Operator.None, initialValue, optional);
            }
            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                scalar.Id = retAuxId.ToString();
            }
            return(scalar);
        }
コード例 #19
0
        private BindRequest createBindRequest(ITemplate template, ITemplateRegistry templateRegistry)
        {
            var chunks = _chunkLoader.Load(template);

            return(new BindRequest
            {
                Target = template,
                Types = _types,
                TemplateRegistry = templateRegistry,
                Master = chunks.Master(),
                ViewModelType = chunks.ViewModel(),
                Namespaces = chunks.Namespaces(),
                Logger = SparkLogger.Default()
            });
        }
コード例 #20
0
        public override void RegisterAll(ITemplateRegistry registry)
        {
            if (registry == null)
            {
                return;
            }

            MessageTemplate[] templatesp = registry.Templates;
            if (templatesp != null)
            {
                foreach (MessageTemplate t in templatesp)
                {
                    Add(registry.GetId(t), t);
                }
            }
        }
コード例 #21
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            FastType type = _templateTypeMap[fieldDef.Group];
            bool optional = fieldDef.GetBool("Optional");
            IFieldValue retInitialValue;
            ScalarValue initialValue = fieldDef.TryGetValue("InitialValue",out retInitialValue) && retInitialValue!=null
                                           ? (ScalarValue)retInitialValue
                                           : ScalarValue.Undefined;

            string name = fieldDef.GetString("Name");
            IFieldValue rettempNs;
            string tempNs = fieldDef.TryGetValue("Ns", out rettempNs) && rettempNs != null ? rettempNs.ToString() : "";
            var qname = new QName(name, tempNs);

            Scalar scalar;
            IFieldValue retOperator;
            if (fieldDef.TryGetValue("Operator", out retOperator) && retOperator!=null)
            {
                GroupValue operatorGroup = ((GroupValue)retOperator).GetGroup(0);
                Operator operatortemp = GetOperator(operatorGroup.Group);
                scalar = new Scalar(qname, type, operatortemp, initialValue, optional);
                IFieldValue retDictionary;
                if (operatorGroup.TryGetValue("Dictionary", out retDictionary) && retDictionary != null)
                    scalar.Dictionary = retDictionary.ToString();
                IFieldValue retKey;
                if (operatorGroup.TryGetValue("Key", out retKey) && retKey != null)
                {
                    GroupValue retOperatorGroup = (GroupValue) retKey;
                    string keyName = retOperatorGroup.GetString("Name");
                    string ns = retOperatorGroup.GetString("Ns");
                    scalar.Key = new QName(keyName, ns);
                }
            }
            else
            {
                scalar = new Scalar(qname, type, Operator.None, initialValue, optional);
            }
            IFieldValue retAuxId;
            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId!=null)
            {
                scalar.Id = retAuxId.ToString();
            }
            return scalar;
        }
コード例 #22
0
        protected override void beforeEach()
        {
            _template1        = new Template("tmpl1.spark", "x", "o1");
            _template2        = new Template("tmpl2.spark", "z", "o2");
            _templateRegistry = new TemplateRegistry <ITemplate>(new[] { _template1, _template2 });

            var parsingRegistrations = MockFor <IParsingRegistrations <ITemplate> >();

            parsingRegistrations.Stub(x => x.ParsingFor(Arg <Template> .Is.Anything)).Return(new Parsing());

            Services.Inject(_types);
            configurePolicies();
            configureBinders();

            registerBindersAndPolicies();

            OtherTemplateBinder.Reset();
            OtherTemplatePolicy.Reset();
        }
コード例 #23
0
        public void Compose(ITemplateRegistry templates)
        {
            templates.AllTemplates().Each(t =>
            {
                var bindRequest = new BindRequest
                {
                    Target           = t,
                    Parsing          = _parsings.ParsingFor(t),
                    Types            = _types,
                    TemplateRegistry = templates,
                    Logger           = SparkLogger.Default()
                };

                var binders  = _binders.Where(x => x.CanBind(bindRequest));
                var policies = _policies.Where(x => x.Matches(t));

                binders.Each(binder => binder.Bind(bindRequest));
                policies.Each(policy => policy.Apply(t));
            });
        }
コード例 #24
0
        static SessionControlProtocol11()
        {
            FastResetTemplate.AddAttribute(ResetProperty, "yes");

            TemplateRegistry = new BasicTemplateRegistry
            {
                { HelloTemplateId, HelloTemplate },
                { AlertTemplateId, AlertTemplate },
                { ResetTemplateId, FastResetTemplate },
                { TemplateDeclId, TemplateDeclaration },
                { TemplateDefId, TemplateDefinition },
                { Int32InstrId, Int32Instr },
                { Uint32InstrId, Uint32Instr },
                { Int64InstrId, Int64Instr },
                { Uint64InstrId, Uint64Instr },
                { DecimalInstrId, DecimalInstr },
                { CompDecimalInstrId, CompDecimalInstr },
                { AsciiInstrId, AsciiInstr },
                { UnicodeInstrId, UnicodeInstr },
                { ByteVectorInstrId, ByteVectorInstr },
                { StatTempRefInstrId, StatTempRefInstr },
                { DynTempRefInstrId, DynTempRefInstr },
                { SequenceInstrId, SequenceInstr },
                { GroupInstrId, GroupInstr },
                { ConstantOpId, ConstantOp },
                { DefaultOpId, DefaultOp },
                { CopyOpId, CopyOp },
                { IncrementOpId, IncrementOp },
                { DeltaOpId, DeltaOp },
                { TailOpId, TailOp },
                { ForeignInstrId, ForeignInstr },
                { ElementId, Element },
                { TextId, Text }
            };

            // TODO: move this into a unit test
            foreach (MessageTemplate t in TemplateRegistry.Templates)
            {
                VerifyChildNamespaces(t);
            }
        }
コード例 #25
0
        public static Field[] ParseFieldInstructions(GroupValue groupDef, ITemplateRegistry registry,
                                                     ConversionContext context)
        {
            SequenceValue instructions = groupDef.GetSequence("Instructions");
            var           fields       = new Field[instructions.Length];

            for (int i = 0; i < fields.Length; i++)
            {
                GroupValue fieldDef = instructions[i].GetGroup(0);
                IFieldInstructionConverter converter = context.GetConverter(fieldDef.Group);
                if (converter == null)
                {
                    throw new SystemException(
                              string.Format("Encountered unknown group {0} while processing field instructions {1}",
                                            fieldDef.Group, groupDef.Group));
                }

                fields[i] = converter.Convert(fieldDef, registry, context);
            }
            return(fields);
        }
コード例 #26
0
        protected override void beforeEach()
        {
            _template1        = new Template("tmpl1.spark", "x", "o1");
            _template2        = new Template("tmpl2.spark", "z", "o2");
            _templateRegistry = new TemplateRegistry {
                _template1, _template2
            };

            var chunkLoader = MockFor <IChunkLoader>();

            chunkLoader.Stub(x => x.Load(Arg <Template> .Is.Anything)).Return(Enumerable.Empty <Chunk>());

            Services.Inject(_types);
            configurePolicies();
            configureBinders();

            registerBindersAndPolicies();

            OtherTemplateBinder.Reset();
            OtherTemplatePolicy.Reset();
        }
コード例 #27
0
        public override Session Connect(string senderName, IConnection connection, ITemplateRegistry inboundRegistry,
                                        ITemplateRegistry outboundRegistry, IMessageListener messageListener,
                                        ISessionListener sessionListener)
        {
            var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.Null);

            session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName));
            try
            {
                Thread.Sleep(new TimeSpan((Int64)10000 * 20));
            }
            catch (ThreadInterruptedException)
            {
            }

            Message message    = session.MessageInputStream.ReadMessage();
            string  serverName = message.GetString(1);
            string  vendorId   = message.IsDefined(2) ? message.GetString(2) : "unknown";

            session.Client = new BasicClient(serverName, vendorId);
            return(session);
        }
コード例 #28
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string      name          = fieldDef.GetString("Name");
            string      namespacetemp = "";
            IFieldValue retns;

            if (fieldDef.TryGetValue("Ns", out retns) && retns != null)
            {
                namespacetemp = retns.ToString();
            }

            Field[] fields   = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool    optional = fieldDef.GetBool("Optional");
            var     group    = new Group(new QName(name, namespacetemp), fields, optional);

            IFieldValue retTypeRef;

            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                var         typeRef     = (GroupValue)retTypeRef;
                String      typeRefName = typeRef.GetString("Name");
                String      typeRefNs   = ""; // context.getNamespace();
                IFieldValue retNsTypeRef;
                if (typeRef.TryGetValue("Ns", out retNsTypeRef) && retNsTypeRef != null)
                {
                    typeRefNs = retNsTypeRef.ToString();
                }
                group.TypeReference = new QName(typeRefName, typeRefNs);
            }

            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                group.Id = retAuxId.ToString();
            }

            return(group);
        }
コード例 #29
0
        public void SendTemplates(ITemplateRegistry registry)
        {
            if (!_protocol.SupportsTemplateExchange)
            {
                throw new NotSupportedException("The procotol " + _protocol +
                                                " does not support template exchange.");
            }
            foreach (MessageTemplate template in registry.Templates)
            {
                _outStream.WriteMessage(_protocol.CreateTemplateDefinitionMessage(template));

                int templateId = registry.GetId(template);

                _outStream.WriteMessage(_protocol.CreateTemplateDeclarationMessage(template, templateId));

                // BUG? double check if IsRegister() done on the same object as RegisterTemplate
                if (!_outStream.TemplateRegistry.IsRegistered(template))
                {
                    _outStream.RegisterTemplate(templateId, template);
                }
            }
        }
コード例 #30
0
        protected override void beforeEach()
        {
            _template1        = new Template("tmpl1.cshtml", "x", "o1");
            _template2        = new Template("tmpl2.cshtml", "z", "o2");
            _templateRegistry = new TemplateRegistry <IRazorTemplate>(new[] { _template1, _template2 });

            var viewParser = MockFor <IViewParser>();

            //null here probably won't work
            viewParser.Stub(x => x.Parse(null)).Return(Enumerable.Empty <Span>());

            Func <string, IViewParser> parser = file => viewParser;

            Services.Inject(parser);
            Services.Inject(_types);
            configurePolicies();
            configureBinders();

            registerBindersAndPolicies();

            OtherTemplateBinder.Reset();
            OtherTemplatePolicy.Reset();
        }
コード例 #31
0
ファイル: Session.cs プロジェクト: shariqkudcs/openfastdotnet
        public Session(IConnection connection, ISessionProtocol protocol, ITemplateRegistry inboundRegistry,
                       ITemplateRegistry outboundRegistry)
        {
            var inContext = new Context();
            inContext.TemplateRegistry.RegisterAll(inboundRegistry);
            var outContext = new Context();
            outContext.TemplateRegistry.RegisterAll(outboundRegistry);
            inContext.ErrorHandler = this;

            _connection = connection;
            _protocol = protocol;
            try
            {
                _inStream = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                _outStream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (IOException e)
            {
                _errorHandler.OnError(e, DynError.Undefined, "Error occurred in connection.");
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }
コード例 #32
0
 public SharedTemplateLocator(ITemplateDirectoryProvider provider, ITemplateRegistry templates)
 {
     _provider = provider;
     _templates = templates;
 }
コード例 #33
0
 public virtual void RegisterSessionTemplates(ITemplateRegistry registry)
 {
     registry.Add(HelloTemplateId, HelloTemplate);
     registry.Add(AlertTemplateId, AlertTemplate);
     registry.Add(ResetTemplateId, FastResetTemplate);
 }
コード例 #34
0
ファイル: RazorViewFacility.cs プロジェクト: roend83/fubumvc
 public RazorViewFacility(ITemplateRegistry<IRazorTemplate> templateRegistry)
 {
     _templateRegistry = templateRegistry;
 }
コード例 #35
0
 public FubuBindingProvider(ITemplateRegistry templateRegistry)
 {
     _templateRegistry = templateRegistry;
 }
コード例 #36
0
 public FubuBindingProvider(ITemplateRegistry templateRegistry)
 {
     _templateRegistry = templateRegistry;
 }
コード例 #37
0
        public static Field[] ParseFieldInstructions(GroupValue groupDef, ITemplateRegistry registry,
                                                     ConversionContext context)
        {
            SequenceValue instructions = groupDef.GetSequence("Instructions");
            var fields = new Field[instructions.Length];
            for (int i = 0; i < fields.Length; i++)
            {
                GroupValue fieldDef = instructions[i].GetGroup(0);
                IFieldInstructionConverter converter = context.GetConverter(fieldDef.Group);
                if (converter == null)
                    throw new SystemException(
                        string.Format("Encountered unknown group {0} while processing field instructions {1}",
                                      fieldDef.Group, groupDef.Group));

                fields[i] = converter.Convert(fieldDef, registry, context);
            }
            return fields;
        }
コード例 #38
0
 public MessageInputStream(Stream inputStream, ITemplateRegistry templateRegistry)
     : this(inputStream, new Context(templateRegistry))
 {
 }
コード例 #39
0
 public IEnumerable<ITemplate> LocateBindings(string bindingName, ITemplate fromTemplate, ITemplateRegistry templateRegistry)
 {
     return locateTemplates(bindingName, fromTemplate, templateRegistry, false)
         .Where(x => x.IsXml());
 }
コード例 #40
0
 public ITemplate LocateMaster(string masterName, ITemplate fromTemplate, ITemplateRegistry templateRegistry)
 {
     return locateTemplates(masterName, fromTemplate, templateRegistry, true)
         .Where(x => x.IsSparkView())
         .FirstOrDefault();
 }
コード例 #41
0
ファイル: SparkActivator.cs プロジェクト: GunioRobot/fubumvc
 public SparkActivator(ITemplateRegistry templateRegistry, ISparkViewEngine engine)
 {
     _templateRegistry = templateRegistry;
     _engine = engine;
 }
コード例 #42
0
 public abstract Field Convert(GroupValue param1, ITemplateRegistry param2,
                               ConversionContext param3);
コード例 #43
0
 public abstract Session Connect(string param1, IConnection param2, ITemplateRegistry inboundRegistry,
                                 ITemplateRegistry outboundRegistry, IMessageListener messageListener,
                                 ISessionListener sessionListener);
コード例 #44
0
 public virtual Field Convert(GroupValue groupValue, ITemplateRegistry templateRegistry,
                              ConversionContext context)
 {
     return DynamicTemplateReference.Instance;
 }
コード例 #45
0
        private IEnumerable <ITemplate> locateTemplates(string name, ITemplate fromTemplate, ITemplateRegistry templateRegistry, bool sharedsOnly)
        {
            var directories = sharedsOnly
                ? _provider.SharedPathsOf(fromTemplate, templateRegistry)
                : _provider.ReachablesOf(fromTemplate, templateRegistry);

            return(templateRegistry.ByNameUnderDirectories(name, directories));
        }
コード例 #46
0
 public SharingAttacherActivator(ITemplateRegistry <T> templates, IEnumerable <ISharingAttacher <T> > attachers)
 {
     _templates = templates;
     _attachers = attachers;
 }
コード例 #47
0
 public void RegisterAll(ITemplateRegistry registry)
 {
 }
コード例 #48
0
ファイル: SparkActivator.cs プロジェクト: henninga/fubumvc
 public SparkActivator(ITemplateRegistry templateRegistry, ISparkViewEngine engine)
 {
     _templateRegistry = templateRegistry;
     _engine = engine;
     _logger = PackageRegistry.Diagnostics.LogFor(this);
 }
コード例 #49
0
 public TemplateDirectoryProvider(ISharedPathBuilder builder, ITemplateRegistry <T> templates, ISharingGraph graph)
 {
     _builder   = builder;
     _templates = templates;
     _graph     = graph;
 }
コード例 #50
0
ファイル: Session.cs プロジェクト: shariqkudcs/openfastdotnet
        public void SendTemplates(ITemplateRegistry registry)
        {
            if (!_protocol.SupportsTemplateExchange)
            {
                throw new NotSupportedException("The procotol " + _protocol +
                                                " does not support template exchange.");
            }
            foreach (MessageTemplate template in registry.Templates)
            {
                _outStream.WriteMessage(_protocol.CreateTemplateDefinitionMessage(template));

                int templateId = registry.GetId(template);

                _outStream.WriteMessage(_protocol.CreateTemplateDeclarationMessage(template, templateId));

                // BUG? double check if IsRegister() done on the same object as RegisterTemplate
                if (!_outStream.TemplateRegistry.IsRegistered(template))
                    _outStream.RegisterTemplate(templateId, template);
            }
        }
コード例 #51
0
ファイル: SparkViewFacility.cs プロジェクト: jemacom/fubumvc
 public SparkViewFacility(ITemplateRegistry templateRegistry)
 {
     _templateRegistry = templateRegistry;
 }
コード例 #52
0
ファイル: SparkViewFacility.cs プロジェクト: rmueller/fubumvc
 public SparkViewFacility(ITemplateRegistry templateRegistry)
 {
     _templateRegistry = templateRegistry;
 }
コード例 #53
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string namespacetemp = "";
            IFieldValue retns;

            if (fieldDef.TryGetValue("Ns", out retns) && retns != null)
                namespacetemp = retns.ToString();

            Field[] fields = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            var group = new Group(new QName(name, namespacetemp), fields, optional);

            IFieldValue retTypeRef;
            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                var typeRef = (GroupValue) retTypeRef;
                String typeRefName = typeRef.GetString("Name");
                String typeRefNs = ""; // context.getNamespace();
                IFieldValue retNsTypeRef;
                if (typeRef.TryGetValue("Ns", out retNsTypeRef) && retNsTypeRef != null)
                    typeRefNs = retNsTypeRef.ToString();
                group.TypeReference = new QName(typeRefName, typeRefNs);
            }

            IFieldValue retAuxId;
            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                group.Id = retAuxId.ToString();

            return group;
        }
コード例 #54
0
 public virtual Field Convert(GroupValue groupValue, ITemplateRegistry templateRegistry,
                              ConversionContext context)
 {
     return(DynamicTemplateReference.Instance);
 }
コード例 #55
0
 public override Session Connect(string senderName, IConnection connection, ITemplateRegistry inboundRegistry,
                                 ITemplateRegistry outboundRegistry, IMessageListener messageListener,
                                 ISessionListener sessionListener)
 {
     var session = new Session(connection, this, TemplateRegistryFields.Null, TemplateRegistryFields.Null);
     session.MessageOutputStream.WriteMessage(CreateHelloMessage(senderName));
     Message message = session.MessageInputStream.ReadMessage();
     string serverName = message.GetString(1);
     session.Client = new BasicClient(serverName, "unknown");
     return session;
 }
コード例 #56
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name  = fieldDef.GetString("Name");
            string ns    = fieldDef.GetString("Ns");
            var    qname = new QName(name, ns);

            Field[]     fields   = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool        optional = fieldDef.GetBool("Optional");
            Scalar      length   = null;
            IFieldValue retLength;

            if (fieldDef.TryGetValue("Length", out retLength) && retLength != null)
            {
                GroupValue  lengthDef = (GroupValue)retLength;
                QName       lengthName;
                string      id = null;
                IFieldValue retName;
                if (lengthDef.TryGetValue("Name", out retName) && retName != null)
                {
                    GroupValue nameDef = (GroupValue)retName;
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    IFieldValue retAuxId;
                    if (nameDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                    {
                        id = retAuxId.ToString();
                    }
                }
                else
                {
                    lengthName = Global.CreateImplicitName(qname);
                }
                Operator    op = Operator.None;
                IFieldValue retOperator;
                if (lengthDef.TryGetValue("Operator", out retOperator) && retOperator != null)
                {
                    op = GetOperator(((GroupValue)retOperator).GetGroup(0).Group);
                }
                ScalarValue initialValue = ScalarValue.Undefined;
                IFieldValue retInitialValue;
                if (lengthDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null)
                {
                    initialValue = (ScalarValue)retInitialValue;
                }
                length = new Scalar(lengthName, FastType.U32, op, initialValue, optional)
                {
                    Id = id
                };
            }

            var         sequence = new Sequence(qname, length, fields, optional);
            IFieldValue retTypeRef;

            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                GroupValue  typeRef     = (GroupValue)retTypeRef;
                string      typeRefName = typeRef.GetString("Name");
                string      typeRefNs   = ""; // context.getNamespace();
                IFieldValue rettypeRefNs;
                if (typeRef.TryGetValue("Ns", out rettypeRefNs) && rettypeRefNs != null)
                {
                    typeRefNs = rettypeRefNs.ToString();
                }
                sequence.TypeReference = new QName(typeRefName, typeRefNs);
            }
            return(sequence);
        }
コード例 #57
0
 public IEnumerable<string> SharedPathsOf(ITemplate template, ITemplateRegistry templateRegistry)
 {
     return getDirectories(template, templateRegistry, false);
 }
コード例 #58
0
 public SharedTemplateLocator(ITemplateDirectoryProvider <T> provider, ITemplateRegistry <T> templates, ITemplateSelector <T> templateSelector)
 {
     _provider         = provider;
     _templates        = templates;
     _templateSelector = templateSelector;
 }
コード例 #59
0
 public SparkActivator(ITemplateRegistry templateRegistry, ISparkViewEngine engine)
 {
     _templateRegistry = templateRegistry;
     _engine           = engine;
 }
コード例 #60
0
 public IEnumerable<string> ReachablesOf(ITemplate template, ITemplateRegistry templateRegistry)
 {
     return getDirectories(template, templateRegistry, true);
 }