public void SetUp()
 {
     Context.firstContext = null;
     view   = new object();
     Parent = new CrossContext(view, true);
     Child  = new TestCrossContextSubclass(view, true);
 }
Example #2
0
        public async Task <T> Query <T>(CrossContext ctx, QueryHandler <T> handler)
        {
            var logger = _loggerFactory.CreateLogger($"QueryProcessor[{nameof(handler)}][{ctx.CorrelationUuid}]");

            logger.LogInformation($"Started at {DateTime.Now}");

            try
            {
                using (var uow = _uowFactory.CreateUnitOfWork(null, ctx.Token))
                {
                    handler.Logger = logger;
                    var result = await handler.Query(uow, ctx.Token);

                    return(result);
                }
            }
            catch (Exception e)
            {
                logger.LogError("{0}\n{1}", e.Message, e.StackTrace);
                throw;
            }
            finally
            {
                logger.LogInformation($"Done at: {DateTime.Now}");
            }
        }
Example #3
0
 public void SetUp()
 {
     Context.firstContext = null;
     view     = new object();
     Parent   = new CrossContext(view, true);
     ChildOne = new CrossContext(view, true);             //Ctr will automatically add to Context.firstcontext. No need to call it manually (and you should not).
     ChildTwo = new CrossContext(view, true);
 }
Example #4
0
 public void SetUp()
 {
     Context.firstContext = null;
     view     = new object();
     Parent   = new CrossContext(view, true);
     ChildOne = new CrossContext(view, true);
     ChildTwo = new CrossContext(view, true);
 }
Example #5
0
 public override void Update()
 {
     if (Input.GetKeyUp(KeyCode.T))
     {
         var crossSys = GameModuleFeature.Instance.ReflectField <PlaybackSystem>("_playbackSystem")
                        .ReflectField <List <IPlaybackSystem> >("_systems").First(a => a.GetType() == typeof(CrossSpreadUpdateSystem));
         cross = crossSys.ReflectField <CrossContext>("_crossContext");
     }
 }
Example #6
0
 public CommandProcessorBuilder(CrossContext ctx, IExternalServiceProvider externalServiceProvider,
                                IUowFactory uowFactory,
                                ILoggerFactory loggerFactory)
 {
     _ctx = ctx ?? throw new ArgumentNullException(nameof(ctx), "Correlation unreachable");
     _externalServiceProvider = externalServiceProvider ?? throw new ArgumentNullException(nameof(externalServiceProvider));
     _uowFactory    = uowFactory ?? throw new ArgumentNullException(nameof(uowFactory));
     _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
 }
Example #7
0
        public async Task <int> CreatePerson(CreatePersonCommandModel command, CrossContext ctx, CancellationToken token)
        {
            var events = await _processor
                         .Command <CreatePersonDomainCommand>(command, ctx)
                         .UseDomain(_mapper.Map <CreatePersonDomainCommand>(command))
                         .UseValidator(new CreatePersonCommandValidator())
                         .RunWithEvents(() => new CreatePersonCommandHandler(), token);

            return(events.MapSingleEvent <PersonCreatedDomainEvent, int>(x => x.PersonId));
        }
Example #8
0
 public void AddUser()
 {
     var db = new CrossContext();
     db.Users.Add(new IdentityUser<int>
     {
         NormalizedUserName="******",
         NormalizedEmail="*****@*****.**",
         PasswordHash=EncryptTool.Encrypt("123456")
     });
     db.SaveChanges();
 }
Example #9
0
        public void AddUser()
        {
            var db = new CrossContext();

            db.Users.Add(new IdentityUser <int>
            {
                NormalizedUserName = "******",
                NormalizedEmail    = "*****@*****.**",
                PasswordHash       = EncryptTool.Encrypt("123456")
            });
            db.SaveChanges();
        }
Example #10
0
        public async Task <PersonRemovedIntegrationEvent> RemovePerson(int personId, CrossContext ctx, CancellationToken token)
        {
            var events = await _processor
                         .Command <RemovePersonDomainCommand>(personId, ctx)
                         .UseTransaction()
                         .UseDomain(new RemovePersonDomainCommand {
                Id = personId
            })
                         .RunWithEvents(() => new RemovePersonCommandHandler(), token);

            return(events.MapOptionalSingleEvent <PersonRemovedDomainEvent, PersonRemovedIntegrationEvent>(
                       x => _mapper.Map <PersonRemovedIntegrationEvent>(x)));
        }
Example #11
0
        public void SetUp()
        {
            testValue = 0;

            Context.firstContext = null;
            view   = new object();
            Parent = new CrossContextTestClass(view, true);
            Parent.Start();

            ChildOne = new CrossContextTestClass(view, true);
            ChildOne.Start();

            ChildTwo = new CrossContextTestClass(view, true);
            ChildTwo.Start();
        }
Example #12
0
        public async Task <DomainEvent[]> ProcessWithEvents(TCommand command, CrossContext ctx)
        {
            var  logger = _loggerFactory.CreateLogger($"CommandProcessor[{nameof(command)}][{ctx.CorrelationUuid}]");
            IUow uow    = null;

            try
            {
                logger.LogInformation($"Started at {DateTime.Now}");
                var handler = _handlerBuilder();
                handler.Logger = _loggerFactory.CreateLogger(nameof(handler));
                handler.ExternalServiceProvider = _externalServiceProvider;
                handler.CancellationToken       = ctx.Token;

                await handler.BeforeExecute(async func =>
                {
                    using (var nonTransactionalUow = _uowfactory.CreateUnitOfWork(null, ctx.Token))
                    {
                        await func(nonTransactionalUow);
                    }
                }, command);

                var transactionUuid = UseTransaction ? Guid.NewGuid() : (Guid?)null;
                uow = _uowfactory.CreateUnitOfWork(transactionUuid, ctx.Token);

                await handler.Execute(uow, command);

                await uow.Commit();

                return(handler.EventList.ToArray());
            }
            catch (Exception e)
            {
                var t = uow?.Rollback();
                if (t != null)
                {
                    await t;
                }

                logger.LogError("{0}\n{1}", e.Message, e.StackTrace);
                throw;
            }
            finally
            {
                uow?.Dispose();

                logger.LogInformation($"Done at {DateTime.Now}");
            }
        }
Example #13
0
 public Task <ComplexModel> GetComplexModel(CrossContext ctx, CancellationToken token)
 {
     return(Task.FromResult(new ComplexModel {
         Encoding = Encoding.UTF8.BodyName,
         Dates = new Dictionary <DateTimeKind, DateTime>
         {
             { DateTimeKind.Local, DateTime.Now },
             { DateTimeKind.Utc, DateTime.UtcNow },
             { DateTimeKind.Unspecified, DateTime.UnixEpoch }
         },
         Files = new List <byte[]>
         {
             Encoding.UTF8.GetBytes("2dcf2b49-87b8-451e-8f70-dd8b0ba5d610"),
             Encoding.UTF8.GetBytes("Совет. По этому запросу вы можете найти сайты на русском языке. Указать языки для результатов поиска можно в разделе Настройки."),
             Encoding.UTF8.GetBytes("enough for me to be able to correlate the generated error with an HTTP request")
         },
         NullableEnumNull = null,
         NullableEnumValue = EventResetMode.ManualReset
     }));
 }
Example #14
0
 public Task <CrossContext> ProcessComplexModel(ComplexModel file, CrossContext ctx, CancellationToken token)
 {
     return(Task.FromResult(ctx));
 }
Example #15
0
        public async Task <bool> UpdatePerson(int personId, CreatePersonCommandModel command, CrossContext ctx, CancellationToken token)
        {
            var domainCommand = _mapper.Map <UpdatePersonDomainCommand>(command);

            domainCommand.Id = personId;

            var events = await _processor
                         .Command <UpdatePersonDomainCommand>(command, ctx)
                         .UseTransaction()
                         .UseDomain(domainCommand)
                         .UseValidator(new UpdatePersonCommandValidator())
                         .RunWithEvents(() => new UpdatePersonCommandHandler(), token);

            return(events.MapOptionalSingleEvent <PersonUpdatedDomainEvent, bool>(x => x != null));
        }
Example #16
0
 public Task Process(TCommand command, CrossContext ctx)
 => ProcessWithEvents(command, ctx);
Example #17
0
 internal AccountBLL(CrossContext db)
 {
     _db = db;
 }
        public override void Execute()
        {
            HashSet <object> instanceSet = new HashSet <object>();

            RichMVCContextRoot[] roots = GameObject.FindObjectsOfType <RichMVCContextRoot>();

            foreach (RichMVCContextRoot root in roots)
            {
                Debug.Log("Adding models of " + root + " to SRDebugger");

                FieldInfo fieldInfo = typeof(CrossContextInjectionBinder).BaseType.GetField("bindings", BindingFlags.Instance | BindingFlags.NonPublic);

                if (fieldInfo == null)
                {
                    return;
                }

                CrossContext context = root.context as CrossContext;

                InjectionBinder injectionBinder = context.injectionBinder as CrossContextInjectionBinder;

                if (injectionBinder == null)
                {
                    return;
                }

                object bindings = fieldInfo.GetValue(injectionBinder);
                Dictionary <object, Dictionary <object, IBinding> > bindingDictionaries = (Dictionary <object, Dictionary <object, IBinding> >)bindings;
                if (bindingDictionaries == null)
                {
                    return;
                }

                foreach (object mainKey in bindingDictionaries.Keys)
                {
                    string typeName;
                    if (!(mainKey is Type))
                    {
                        continue;
                    }

                    Type mainKeyType = mainKey as Type;

                    if (_ignoredTypeList.Contains(mainKeyType))
                    {
                        continue;
                    }

                    IBinding binding = injectionBinder.GetBinding(mainKeyType);

                    if (binding == null)
                    {
                        continue;
                    }

                    typeName = mainKey.ToString();

                    object instance = injectionBinder.GetInstance(mainKeyType);

                    if (instanceSet.Contains(instance))
                    {
                        continue;
                    }

                    Debug.Log("Adding " + instance.ToString());
                    SRDebug.Instance.AddOptionContainer(instance);
                    instanceSet.Add(instance);
                }
            }
        }
Example #19
0
        public CommandProcessorBuilder <TDomainMessage> Command <TDomainMessage>(object model, CrossContext ctx) where TDomainMessage : DomainMessage
        {
            _loggerFactory.CreateLogger($"ProcessorFactory[{ctx.CorrelationUuid}]")
            .LogInformation($"Prepare processing for '{nameof(model)}'");

            return(new CommandProcessorBuilder <TDomainMessage>(ctx, _externalServiceProvider, _uowFactory, _loggerFactory));
        }
Example #20
0
    private void DrawModels()
    {
        if (!Application.isPlaying)
        {
            EditorGUILayout.LabelField("Enter Play Mode to view Models.");
            return;
        }

        if (Selection.activeObject == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        GameObject rootGameObject = Selection.activeObject as GameObject;

        if (rootGameObject == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        _inspectedRoot = rootGameObject.GetComponent <RichMVCContextRoot>();
        if (_inspectedRoot == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        SirenixEditorFields.UnityObjectField("Inspecting", _inspectedRoot, typeof(RichMVCContextRoot), true);
        SirenixEditorGUI.DrawThickHorizontalSeperator(5f, 5f, 5f);

        CrossContext context = _inspectedRoot.context as CrossContext;

        EditorGUILayout.Toggle("Context Found", context != null);
        if (context == null)
        {
            return;
        }

        FieldInfo fieldInfo = typeof(CrossContextInjectionBinder).BaseType.GetField("bindings", BindingFlags.Instance | BindingFlags.NonPublic);

        EditorGUILayout.Toggle("Bindings Found", fieldInfo != null);
        if (fieldInfo == null)
        {
            return;
        }

        InjectionBinder injectionBinder = context.injectionBinder as CrossContextInjectionBinder;

        EditorGUILayout.Toggle("InjectionBinder Casted", injectionBinder != null);
        if (injectionBinder == null)
        {
            return;
        }

        SirenixEditorGUI.DrawThickHorizontalSeperator(5f, 5f, 5f);
        SirenixEditorGUI.Title("Bindings", "", TextAlignment.Center, false);
        SirenixEditorGUI.BeginBox();

        object bindings = fieldInfo.GetValue(injectionBinder);
        Dictionary <object, Dictionary <object, IBinding> > bindingDictionaries = (Dictionary <object, Dictionary <object, IBinding> >)bindings;

        if (bindingDictionaries == null)
        {
            return;
        }

        foreach (object mainKey in bindingDictionaries.Keys)
        {
            string typeName;
            if (!(mainKey is Type))
            {
                continue;
            }

            Type mainKeyType = mainKey as Type;

            if (_ignoredTypeList.Contains(mainKeyType))
            {
                continue;
            }

            IBinding binding = injectionBinder.GetBinding(mainKeyType);

            if (binding == null)
            {
                continue;
            }
            SirenixEditorGUI.BeginBox();

            typeName = mainKey.ToString();
            SirenixEditorGUI.Title(mainKeyType.Name, "", TextAlignment.Center, false);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            object instance = injectionBinder.GetInstance(mainKeyType);
            if (GUILayout.Button("Inspect", GUILayout.Height(20), GUILayout.Width(80)))
            {
                OdinEditorWindow.InspectObject(instance);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();

            SirenixEditorGUI.EndBox();
            SirenixEditorGUI.DrawHorizontalLineSeperator(2f, 2f, 2f);
        }
        SirenixEditorGUI.EndBox();
    }
Example #21
0
 public Task <string> ProcessByteArray(byte[] file, CrossContext ctx, CancellationToken token)
 {
     return(Task.FromResult(Encoding.UTF8.GetString(file)));
 }
        protected override void Awake()
        {
            context = new CrossContext(this);

            DontDestroyOnLoad(gameObject);
        }
Example #23
0
 internal AccountBLL(CrossContext db)
 {
     _db = db;
 }
        public async Task <PagedResult <SearchPersonResultPrj> > SearchPerson(SearchPersonFilterPrj model, CrossContext ctx, CancellationToken token)
        {
            var filter = _mapper.Map <SearchPersonFilter>(model);
            var query  = new SearchPersonFilterQuery(filter);
            var result = await _processor.Query(ctx, token, query);

            return(new PagedResult <SearchPersonResultPrj>(result.PageSize, result.PageNumber, result.TotalCount,
                                                           _mapper.Map <List <SearchPersonResultPrj> >(result.Items)));
        }
Example #25
0
 public Task <string> ProcessArrayOfByteArray(IReadOnlyCollection <byte[]> file, CrossContext ctx, CancellationToken token)
 {
     return(Task.FromResult(Tools.Json.Serializer.Serialize(file.Select(x => Encoding.UTF8.GetString(x)))));
 }