Ejemplo n.º 1
0
        internal Protocol([NotNull] string name, [NotNull] ISerializers serializers, [NotNull] IIdentities identities, [NotNull] IScheduler scheduler,
                          [NotNull] IWire wire, Lifetime lifetime, SerializationCtx?serializationCtx = null, [CanBeNull] ProtocolContexts parentContexts = null, params RdContextBase[] initialContexts)
        {
            Name     = name ?? throw new ArgumentNullException(nameof(name));
            Location = new RName(name);

            Serializers          = serializers ?? throw new ArgumentNullException(nameof(serializers));
            Identities           = identities ?? throw new ArgumentNullException(nameof(identities));
            Scheduler            = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
            Wire                 = wire ?? throw new ArgumentNullException(nameof(wire));
            SerializationContext = serializationCtx ?? new SerializationCtx(this, new Dictionary <string, IInternRoot <object> >()
            {
                { ProtocolInternScopeStringId, CreateProtocolInternRoot(lifetime) }
            });
            Contexts      = parentContexts ?? new ProtocolContexts(SerializationContext);
            wire.Contexts = Contexts;
            if (serializationCtx == null)
            {
                SerializationContext.InternRoots[ProtocolInternScopeStringId].Bind(lifetime, this, ProtocolInternRootRdId);
            }
            foreach (var rdContextBase in initialContexts)
            {
                rdContextBase.RegisterOn(Contexts);
            }
            if (parentContexts == null)
            {
                BindContexts(lifetime);
            }
            OutOfSyncModels = new ViewableSet <RdExtBase>();
        }
Ejemplo n.º 2
0
        public Protocol([NotNull] string name, [NotNull] ISerializers serializers, [NotNull] IIdentities identities, [NotNull] IScheduler scheduler,
                        [NotNull] IWire wire, Lifetime lifetime, SerializationCtx?serializationCtx = null)
        {
            Name     = name ?? throw new ArgumentNullException(nameof(name));
            Location = new RName(name);

            Serializers          = serializers ?? throw new ArgumentNullException(nameof(serializers));
            Identities           = identities ?? throw new ArgumentNullException(nameof(identities));
            Scheduler            = scheduler ?? throw new ArgumentNullException(nameof(scheduler));
            Wire                 = wire ?? throw new ArgumentNullException(nameof(wire));
            SerializationContext = serializationCtx ?? new SerializationCtx(this, new Dictionary <string, IInternRoot>()
            {
                { ProtocolInternScopeStringId, CreateProtocolInternRoot(lifetime) }
            });
            OutOfSyncModels = new ViewableSet <RdExtBase>();
        }