Пример #1
0
        public static void Main()
        {
            MainWindow mainWindow = new MainWindow();

            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;

            try { doc.Load("notesShabbos.xml"); }
            catch (System.IO.FileNotFoundException)
            {
                doc.LoadXml("<?xml version=\"1.0\"?> \n" +
                            "<books xmlns=\"http://www.contoso.com/books\"> \n" +
                            "  <book genre=\"novel\" ISBN=\"1-861001-57-8\" publicationdate=\"1823-01-28\"> \n" +
                            "    <title>Pride And Prejudice</title> \n" +
                            "    <price>24.95</price> \n" +
                            "  </book> \n" +
                            "  <book genre=\"novel\" ISBN=\"1-861002-30-1\" publicationdate=\"1985-01-01\"> \n" +
                            "    <title>The Handmaid's Tale</title> \n" +
                            "    <price>29.95</price> \n" +
                            "  </book> \n" +
                            "</books>");
            }

            SimpleFlow simpleFlow = new SimpleFlow(doc);

            //parse simpleflow and display
            mainWindow.LoadText(simpleFlow.Content);

            new Application().Run(mainWindow);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            AttributeFlowReader flowReader = new AttributeFlowReader(typeof(GuessTheNumberFlow));
            var flow = flowReader.GetFlatFlow();
            var activityDiagramBuilder = new ActivityDiagramBuilder();
            var activityDiagram        = activityDiagramBuilder.GetActivityDiagram(flow, true);

            SimpleFlow simpleFlow = new SimpleFlow(new InMemoryEventStore());

            simpleFlow.Start();


            GuessTheNumberFlow guessTheNumber = new GuessTheNumberFlow(new InMemoryEventStore());

            guessTheNumber.Start();
        }
Пример #3
0
        /// <summary>
        /// Builds a new flow that will be returned by <see cref="Build"/>.
        /// </summary>
        /// <returns>A new <see cref="SimpleFlow"/>.</returns>
        protected IFlow Flow()
        {
            if (!_dirty)
            {
                // optimization in case this method is called consecutively
                return(_flow);
            }
            _flow = new SimpleFlow(_name);
            // optimization for flows that only have one state that itself is a flow:
            var state = _currentState as FlowState;

            if (state != null && _states.Count() == 1)
            {
                return(state.GetFlows().First());
            }
            AddDanglingEndStates();
            _flow.StateTransitions = _transitions;
            _dirty = false;
            return(_flow);
        }
Пример #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            var moduleRepo              = new ModuleRepository();
            var elementMapper           = new ElementTypeTemplateMapper();
            var controlMapper           = new ControlTypeTemplateMapper();
            var validationMapper        = new ValidationAttributeJsConverterMapper();
            var moduleBuilder           = new ModuleBuilder(moduleRepo, elementMapper, controlMapper, validationMapper);
            var inMemoryFlowPersistance = new InMemoryFlowPersistance();

            services.AddSingleton <IElementTypeTemplateMapper>(elementMapper);
            services.AddSingleton <IControlTypeTemplateMapper>(controlMapper);
            services.AddSingleton <IValidationAttributeJsConverterMapper>(validationMapper);
            services.AddSingleton <IModuleRepository>(moduleRepo);
            services.AddSingleton <IFlowPersistance>(inMemoryFlowPersistance);

            validationMapper.AddValidator("MaxLengthAttribute", CustomAttribuesJsConverters.MaxLengthJsConverter);
            controlMapper.AddTemplate("defaultButton", ControlType.Button, true);

            UserRegistrationFlow.RegisterFlow(moduleBuilder);
            UserLoginFlow.RegisterFlow(moduleBuilder);
            UserEditFlow.RegisterFlow(moduleBuilder);

            A1Flow.RegisterFlow(moduleBuilder);
            A2A3A4Flow.RegisterFlow(moduleBuilder);
            A7Flow.RegisterFlow(moduleBuilder);

            TestFlow.RegisterFlow(moduleBuilder);
            SimpleFlow.RegisterFlow(moduleBuilder);

            MainReportFlow.RegisterFlow(moduleBuilder);

            services.AddControllers(c =>
            {
                c.EnableEndpointRouting = false;
            }).ConfigureApplicationPartManager(apm =>
            {
                apm.FeatureProviders.Add(new FlowControllerFeatureProvider(moduleRepo));
            }).AddNewtonsoftJson(j =>
            {
                j.SerializerSettings.ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                };
                j.SerializerSettings.Converters.Add(new StringEnumConverter
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                });
                j.SerializerSettings.Converters.Add(new BaseCollectionConverter());
                j.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                j.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            var symmetricKey = Encoding.ASCII.GetBytes(Configuration.GetSection("Jwt").GetValue <string>("SymmetricKey"));

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(symmetricKey),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });
            services.AddAuthorization(a =>
            {
                a.AddPolicy("IsAccountEnabled", policy => policy.RequireClaim("account_enabled", "True", "true"));
            });

            services.AddSwaggerGen(s =>
            {
                s.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Core Dui Example API", Version = "v1"
                });
                s.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    In          = ParameterLocation.Header,
                    Description = "Please insert JWT with Bearer into field",
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.ApiKey
                });
                s.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] { }
                    }
                });
            });

            services.AddDbContext <DbLabCalcContext>(o =>
            {
                o.UseLazyLoadingProxies().UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            });

            services.Configure <LdapConfig>(Configuration.GetSection("Ldap"));
            services.Configure <JwtConfig>(Configuration.GetSection("Jwt"));
            services.Configure <SmtpConfig>(Configuration.GetSection("Smtp"));
            services.Configure <AppConfig>(Configuration.GetSection("App"));

            services.AddScoped <IEmailClient, GmailEmailClient>();
            services.AddScoped <IAuthenticationService <LdapUser>, LdapAuthenticationService>();
            services.AddScoped <IAuthenticationService <DbUserClient>, DbAuthenticationService>();
            services.AddScoped <IEmailTemplates, EmailTemplates>();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
        }