Пример #1
0
        public void ServiceTest()
        {
            Stream      serverPeerStream = new Regulus.Remote.Standalone.Stream();
            IStreamable serverStream     = serverPeerStream;
            IStreamable clientStream     = new ReverseStream(serverPeerStream);

            IBinderProvider entry = NSubstitute.Substitute.For <IBinderProvider>();
            IGpiA           gpia  = new SoulGpiA();

            entry.AssignBinder(NSubstitute.Arg.Do <IBinder>(binder => binder.Bind <IGpiA>(gpia)), NSubstitute.Arg.Any <object>());

            Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer();
            IProtocol protocol = ProtocolHelper.CreateProtocol(serializer);

            Soul.IService service   = new Regulus.Remote.Soul.Service(entry, protocol);
            IAgent        agent     = new Regulus.Remote.Ghost.Agent(protocol) as Ghost.IAgent;
            IGpiA         ghostGpia = null;


            service.Join(serverStream);
            agent.Start(clientStream);
            agent.QueryNotifier <IGpiA>().Supply += gpi => ghostGpia = gpi;

            while (ghostGpia == null)
            {
                agent.Update();
            }

            agent.Stop();
            service.Leave(serverStream);

            IDisposable disposable = service;

            disposable.Dispose();
        }
Пример #2
0
        private static void _TestService(IBinderProvider entry, ref bool bind, IProtocol protocol)
        {
            bind = false;
            var service = Regulus.Remote.Standalone.Provider.CreateService(protocol, entry);

            Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol);
            service.Join(agent, null);
            IGpiA retGpiA = null;
            bool  ret     = false;

            agent.QueryNotifier <IGpiA>().Supply += gpi => {
                ret     = true;
                retGpiA = gpi;
            };
            var timer = new Regulus.Utility.TimeCounter();
            var apr   = new Regulus.Utility.AutoPowerRegulator(new Utility.PowerRegulator());

            while (retGpiA == null)
            {
                apr.Operate();
                agent.Update();
                if (timer.Second > 10)
                {
                    throw new System.Exception($"debug agent:{agent.Active} bind:{bind} ");
                }
            }

            service.Leave(agent);
            service.Dispose();

            Assert.AreNotEqual(null, retGpiA);
            Assert.AreEqual(true, bind);
            Assert.AreEqual(true, ret);
        }
Пример #3
0
 public Service(IBinderProvider entry, IProtocol protocol)
 {
     _Service           = new Regulus.Remote.Soul.Service(entry, protocol);
     _Agents            = new List <Ghost.IAgent>();
     _Streams           = new Dictionary <IAgent, IStreamable>();
     _ServiceDisposable = _Service;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Enum" /> class.
 /// </summary>
 /// <param name="node">The node associated with the symbol.</param>
 /// <param name="parent">The document that contains this enum.</param>
 /// <param name="name">The name of the enum.</param>
 /// <param name="binderProvider">Used to get binders for nodes.</param>
 public Enum(
     EnumDefinitionContext node,
     IDocument parent,
     string name,
     IBinderProvider binderProvider)
     : base(node, parent, name)
 {
     this.binderProvider = binderProvider;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Union" /> class.
 /// </summary>
 /// <param name="node">The union parse tree node.</param>
 /// <param name="binderProvider">Used to get binders.</param>
 /// <param name="parent">The document that contains this union.</param>
 /// <param name="name">The name of the union.</param>
 public Union(
     UnionDefinitionContext node,
     IBinderProvider binderProvider,
     IDocument parent,
     string name)
     : base(node, parent, name)
 {
     this.binderProvider = binderProvider;
 }
Пример #6
0
 public Service(IBinderProvider entry, IProtocol protocol)
 {
     _Users             = new System.Collections.Generic.List <User>();
     this._Entry        = entry;
     this._Protocol     = protocol;
     _Updater           = new Utility.Updater();
     _Updater.AddEvent += (user) => _Entry.AssignBinder(((User)user).Binder, ((User)user).State);
     _ThreadUpdater     = new ThreadUpdater(_Update);
     _ThreadUpdater.Start();
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ListOrSetType{TNode}" /> class.
 /// </summary>
 /// <param name="node">The node this symbol is bound to.</param>
 /// <param name="parent">The parent symbol.</param>
 /// <param name="binderProvider">Used to get binders for nodes.</param>
 /// <param name="csharpCollectionTypeName">The name of the C# type that will be generated from this type.</param>
 protected ListOrSetType(
     TNode node,
     ISymbol parent,
     IBinderProvider binderProvider,
     string csharpCollectionTypeName)
     : base(node, parent)
 {
     this.binderProvider           = binderProvider;
     this.csharpCollectionTypeName = csharpCollectionTypeName;
 }
Пример #8
0
        public Server()
        {
            this._LogRecorder = new LogFileRecorder("Storage");
            this._DefaultAdministratorName = "itisnotagame";
            this._Ip      = "mongodb://127.0.0.1:27017";
            this._Name    = "ItIsNotAGame1";
            this._Updater = new Updater();

            this._Center = new Game.Storage.Center(this);

            _BinderProvider = _Center;
        }
Пример #9
0
        public void Test()
        {
            IBinderProvider entry = NSubstitute.Substitute.For <IBinderProvider>();
            IGpiA           gpia  = new SoulGpiA();
            bool            bind  = false;

            entry.AssignBinder(NSubstitute.Arg.Do <IBinder>(binder =>
            {
                bind = true;
                binder.Bind <IGpiA>(gpia);
            }), NSubstitute.Arg.Any <object>());

            Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer();
            IProtocol protocol = ProtocolHelper.CreateProtocol(serializer);

            _TestService(entry, ref bind, protocol);
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Field" /> class.
 /// </summary>
 /// <param name="node">The node associated with the symbol.</param>
 /// <param name="parent">The struct that contains this field.</param>
 /// <param name="fieldId">The field's Id.</param>
 /// <param name="rawFieldId">The raw text representing the field Id.</param>
 /// <param name="requiredness">The level of requiredness of the field.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="isFieldIdImplicit">
 /// Indicates whether the field Id was generated automatically by the
 /// compiler rather than being explicitly defined in the IDL.
 /// </param>
 /// <param name="binderProvider">Used to get binders.</param>
 public Field(
     FieldContext node,
     IStruct parent,
     int?fieldId,
     string rawFieldId,
     FieldRequiredness requiredness,
     string name,
     bool isFieldIdImplicit,
     IBinderProvider binderProvider)
     : base(node, parent)
 {
     this.FieldId           = fieldId;
     this.RawFieldId        = rawFieldId;
     this.Requiredness      = requiredness;
     this.Name              = name;
     this.IsFieldIdImplicit = isFieldIdImplicit;
     this.binderProvider    = binderProvider;
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SetTypeBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">Used to get binders.</param>
 public SetTypeBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExceptionBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">
 /// Used to get the correct binder for a particular node.
 /// </param>
 public ExceptionBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #13
0
 public StandaloneFactory(IBinderProvider core, IProtocol provider)
 {
     this._Core = core;
     _Protocol  = provider;
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StructBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">
 /// Used to get the correct binder for a particular node.
 /// </param>
 public StructBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">Used to get other binders.</param>
 public DocumentBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldTypeBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">Used to get binders for nodes.</param>
 public FieldTypeBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnumBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">The binder provider.</param>
 public EnumBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapType" /> class.
 /// </summary>
 /// <param name="node">The node the symbol is bound to.</param>
 /// <param name="parent">The parent symbol.</param>
 /// <param name="binderProvider">Used to get binders.</param>
 public MapType(MapTypeContext node, ISymbol parent, IBinderProvider binderProvider)
     : base(node, parent)
 {
     this.binderProvider = binderProvider;
 }
Пример #19
0
 public static Standalone.IService CreateService(IProtocol protocol, IBinderProvider entry)
 {
     return(new Standalone.Service(entry, protocol));
 }
Пример #20
0
 public Service(IBinderProvider entry, IProtocol protocol)
 {
     _Users         = new System.Collections.Generic.List <User>();
     this._Entry    = entry;
     this._Protocol = protocol;
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldBinder" /> class.
 /// </summary>
 /// <param name="containerBinder">The container binder.</param>
 /// <param name="binderProvider">Used to find binders for child nodes.</param>
 public FieldBinder(
     IFieldContainerBinder containerBinder, IBinderProvider binderProvider)
 {
     this.containerBinder = containerBinder;
     this.binderProvider  = binderProvider;
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Document" /> class.
 /// </summary>
 /// <param name="node">The document node.</param>
 /// <param name="parent">The parent symbol.</param>
 /// <param name="binderProvider">Used to get binders for nodes.</param>
 public Document(DocumentContext node, ISymbol parent, IBinderProvider binderProvider)
     : base(node, parent)
 {
     this.binderProvider = binderProvider;
 }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnionBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">
 /// Used to get the correct binder for a particular node.
 /// </param>
 public UnionBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamespaceBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">Used to get binders for nodes.</param>
 public NamespaceBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }
Пример #25
0
        /// <summary>
        /// Sets the binder provider.
        /// </summary>
        /// <param name="binderProvider">The binder provider.</param>
        /// <returns>The builder.</returns>
        public TBuilder SetBinderProvider(IBinderProvider binderProvider)
        {
            this.BinderProvider = binderProvider;

            return((TBuilder)this);
        }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ListType" /> class.
 /// </summary>
 /// <param name="node">The node the symbol was created from.</param>
 /// <param name="parent">The parent of this type.</param>
 /// <param name="binderProvider">Used to get binders.</param>
 public ListType(ListTypeContext node, ISymbol parent, IBinderProvider binderProvider)
     : base(node, parent, binderProvider, CSharpTypeName)
 {
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstantBinder" /> class.
 /// </summary>
 /// <param name="binderProvider">Used to get binders.</param>
 public ConstantBinder(IBinderProvider binderProvider)
 {
     this.binderProvider = binderProvider;
 }