Exemplo n.º 1
0
        public async Task <SwaggerService> RunAsync()
        {
            return(await Task.Run(() =>
            {
                var generator = new WebApiAssemblyToSwaggerGenerator(Settings);

                var controllerNames = ControllerNames.ToList();
                if (!string.IsNullOrEmpty(ControllerName))
                {
                    controllerNames.Add(ControllerName);
                }

                controllerNames = controllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
                if (!controllerNames.Any() && Settings.AssemblyPaths?.Length > 0)
                {
                    controllerNames = generator.GetControllerClasses().ToList();
                }

                var service = generator.GenerateForControllers(controllerNames);

                if (!string.IsNullOrEmpty(ServiceHost))
                {
                    service.Host = ServiceHost;
                }
                if (ServiceSchemes != null && ServiceSchemes.Any())
                {
                    service.Schemes = ServiceSchemes.Select(s => (SwaggerSchema)Enum.Parse(typeof(SwaggerSchema), s, true)).ToList();
                }

                return service;
            }));
        }
Exemplo n.º 2
0
 public void ToView()
 {
     if (!string.IsNullOrEmpty(ControllerNames))
     {
         Controllers = ControllerNames.Split(";");
     }
 }
Exemplo n.º 3
0
        private Task LoadAssembliesAsync()
        {
            return(RunTaskAsync(async() =>
            {
                AllControllerNames = await Task.Run(async() =>
                {
                    if (Command.AssemblyPaths?.Length > 0)
                    {
                        return await Document.GetControllersFromCommandLineAsync();
                    }
                    else
                    {
                        return new string[] { }
                    };
                });

                if (ControllerNames != null)
                {
                    var newControllerNames = ControllerNames.ToList();
                    foreach (var controller in newControllerNames.ToArray())
                    {
                        if (!AllControllerNames.Contains(controller))
                        {
                            newControllerNames.Remove(controller);
                        }
                    }
                    ControllerNames = newControllerNames.ToArray();
                }
                else
                {
                    ControllerNames = new string[] { }
                };
            }));
        }
Exemplo n.º 4
0
 internal static string GetRoles(ControllerNames controllerName)
 {
     return(controllerName switch
     {
         ControllerNames.Competencia => AppRoles.Generate(AppRoles.ADMINISTRADOR),
         _ => AppRoles.ADMINISTRADOR
     });
Exemplo n.º 5
0
 protected void ChangeController(ControllerNames name)
 {
     if (OnChangeController != null)
     {
         OnChangeController(name);
     }
 }
        private Task LoadAssembliesAsync()
        {
            return(RunTaskAsync(async() =>
            {
                AllControllerNames = await Task.Run(() =>
                {
                    if (Command.Settings.AssemblyPaths?.Length > 0)
                    {
                        var generator = new WebApiAssemblyToSwaggerGenerator(Command.Settings);
                        return generator.GetControllerClasses();
                    }
                    else
                    {
                        return new string[] { }
                    };
                });

                if (ControllerNames != null)
                {
                    var newControllerNames = ControllerNames.ToList();
                    foreach (var controller in newControllerNames.ToArray())
                    {
                        if (!AllControllerNames.Contains(controller))
                        {
                            newControllerNames.Remove(controller);
                        }
                    }
                    ControllerNames = newControllerNames.ToArray();
                }
                else
                {
                    ControllerNames = new string[] { }
                };
            }));
        }
Exemplo n.º 7
0
        public static bool AllowedAccess(ControllerNames controllerName, ClaimsPrincipal user)
        {
            var perfil = user.Claims.Where(c => c.Type == ClaimTypes.Role).Select(c => c.Value).FirstOrDefault();

            if (string.IsNullOrWhiteSpace(perfil))
            {
                return(false);
            }

            perfil = perfil.ToLower();

            if (perfil == AppRoles.ADMINISTRADOR.ToLower())
            {
                return(true);
            }

            var controllerRoles = AccessManager.GetRoles(controllerName);

            if (string.IsNullOrWhiteSpace(controllerRoles))
            {
                return(true);
            }

            return(controllerRoles.ToLower().Contains(perfil));
        }
        static ModernController()
        {
            List <string> namesToRegister = ControllerNames.ControllerName("Modern");

            for (int i = 0; i < namesToRegister.Count; i++)
            {
                InputSystem.RegisterLayout <ModernController> (
                    matches: new InputDeviceMatcher()
                    .WithProduct(namesToRegister [i]));
            }
        }
        static XBoxControllerBluetooth()
        {
            List <string> namesToRegister = ControllerNames.ControllerName("XboxBluetooth");

            for (int i = 0; i < namesToRegister.Count; i++)
            {
                InputSystem.RegisterLayout <XBoxControllerBluetooth> (
                    matches: new InputDeviceMatcher()
                    .WithProduct(namesToRegister [i]));
            }
        }
Exemplo n.º 10
0
        static ClassicJoystick()
        {
            List <string> namesToRegister = ControllerNames.ControllerName("Classic");

            for (int i = 0; i < namesToRegister.Count; i++)
            {
                InputSystem.RegisterLayout <ClassicJoystick> (
                    matches: new InputDeviceMatcher()
                    .WithProduct(namesToRegister [i]));
            }
        }
Exemplo n.º 11
0
        protected override async Task <string> RunIsolatedAsync(AssemblyLoader.AssemblyLoader assemblyLoader)
        {
            await TransformAsync(assemblyLoader);

            var controllerNames = ControllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            if (!controllerNames.Any() && AssemblyPaths?.Length > 0)
            {
                controllerNames = GetControllerNames(assemblyLoader).ToList();
            }

            var controllerTypes = await GetControllerTypesAsync(controllerNames, assemblyLoader);

            var generator = new WebApiToSwaggerGenerator(Settings);
            var document  = await generator.GenerateForControllersAsync(controllerTypes).ConfigureAwait(false);

            if (ServiceHost == ".")
            {
                document.Host = string.Empty;
            }
            else if (!string.IsNullOrEmpty(ServiceHost))
            {
                document.Host = ServiceHost;
            }

            if (string.IsNullOrEmpty(DocumentTemplate))
            {
                if (!string.IsNullOrEmpty(InfoTitle))
                {
                    document.Info.Title = InfoTitle;
                }
                if (!string.IsNullOrEmpty(InfoVersion))
                {
                    document.Info.Version = InfoVersion;
                }
                if (!string.IsNullOrEmpty(InfoDescription))
                {
                    document.Info.Description = InfoDescription;
                }
            }

            if (ServiceSchemes != null && ServiceSchemes.Any())
            {
                document.Schemes = ServiceSchemes.Select(s => (SwaggerSchema)Enum.Parse(typeof(SwaggerSchema), s, true)).ToList();
            }

            if (!string.IsNullOrEmpty(ServiceBasePath))
            {
                document.BasePath = ServiceBasePath;
            }

            return(document.ToJson());
        }
Exemplo n.º 12
0
        public async Task <SwaggerDocument> RunAsync()
        {
            return(await Task.Run(() =>
            {
                if (!string.IsNullOrEmpty(DocumentTemplate))
                {
                    if (DynamicApis.FileExists(DocumentTemplate))
                    {
                        Settings.DocumentTemplate = DynamicApis.FileReadAllText(DocumentTemplate);
                    }
                    else
                    {
                        Settings.DocumentTemplate = DocumentTemplate;
                    }
                }
                else
                {
                    Settings.DocumentTemplate = null;
                }

                var generator = CreateGenerator();
                var controllerNames = ControllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
                if (!controllerNames.Any() && Settings.AssemblyPaths?.Length > 0)
                {
                    controllerNames = generator.GetControllerClasses().ToList();
                }

                var document = generator.GenerateForControllers(controllerNames);

                if (ServiceHost == ".")
                {
                    document.Host = string.Empty;
                }
                else if (!string.IsNullOrEmpty(ServiceHost))
                {
                    document.Host = ServiceHost;
                }

                if (ServiceSchemes != null && ServiceSchemes.Any())
                {
                    document.Schemes = ServiceSchemes.Select(s => (SwaggerSchema)Enum.Parse(typeof(SwaggerSchema), s, true)).ToList();
                }

                if (!string.IsNullOrEmpty(ServiceBasePath))
                {
                    document.BasePath = ServiceBasePath;
                }

                return document;
            }));
        }
Exemplo n.º 13
0
        public async Task <SwaggerService> RunAsync()
        {
            return(await Task.Run(() =>
            {
                var generator = new WebApiAssemblyToSwaggerGenerator(Settings);

                var controllerNames = ControllerNames.ToList();
                if (!string.IsNullOrEmpty(ControllerName))
                {
                    controllerNames.Add(ControllerName);
                }

                controllerNames = controllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
                if (!controllerNames.Any() && Settings.AssemblyPaths?.Length > 0)
                {
                    controllerNames = generator.GetControllerClasses().ToList();
                }

                return generator.GenerateForControllers(controllerNames);
            }));
        }
Exemplo n.º 14
0
        public async Task <string> RunAsync()
        {
            var generator = new WebApiAssemblyToSwaggerGenerator(Settings);

            var controllerNames = ControllerNames.ToList();

            if (!string.IsNullOrEmpty(ControllerName))
            {
                controllerNames.Add(ControllerName);
            }

            controllerNames = controllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
            if (!controllerNames.Any())
            {
                controllerNames = generator.GetControllerClasses().ToList();
            }

            var service = generator.GenerateForControllers(controllerNames);

            return(service.ToJson());
        }
Exemplo n.º 15
0
        public ABaseController(IConfiguration config, IDbSettingsReader settings, ILogger logger) : base()
        {
            this.Settings    = settings;
            this.Config      = config;
            this.Views       = new ViewNames();
            this.Logger      = logger;
            this.Controllers = new ControllerNames
            {
                DashboardController = Settings.GetAppDashboardControllerName(),
                MyProfileController = Settings.GetAppMyProfileControllerName(),
                AccountController   = Settings.GetAccountControllerName(),
                UninstallController = Settings.GetAppUninstallControllerName()
            };

            this.VersionInfo = new Versions()
            {
                AppVersion                 = settings.GetAppVersion(),
                FrameWorkVersion           = AppSettingsAccessor.GetFrameWorkBuildNumber(),
                DataSeederFrameworkVersion = Settings.GetDataSeederFrameworkVersion()
            };
        }
Exemplo n.º 16
0
        private void changeController(ControllerNames name)
        {
            switch (name)
            {
            case ControllerNames.Play:
                currentController = new PlayController();
                break;

            case ControllerNames.Start:
                currentController = new StartController();
                break;

            case ControllerNames.GameOver:
                currentController = new GameOverController();
                break;
            }

            currentController.OnChangeController += (n) =>
            {
                changeController(n);
            };
        }
Exemplo n.º 17
0
        private InputSource GetInputSource(InputAction.CallbackContext context)
        {
            if (context.control == null)
            {
                Debug.LogErrorFormat("<UnityInputSystem/GetInputSource> Context.Control ({0})", "Null");

                return(InputSource.NONE);
            }
            else if (context.control.device == null)
            {
                Debug.LogErrorFormat("<UnityInputSystem/GetInputSource> Context.Control.Device ({0})", "Null");

                return(InputSource.NONE);
            }

            string current = context.control.device.description.product;

            if (context.control.device.deviceId > 2)
            {
                if (string.IsNullOrEmpty(current))
                {
                    Debug.LogErrorFormat("<UnityInputSystem/GetInputSource> Context.Control.Device.Description.Product ({0})", "Null");

                    return(InputSource.NONE);
                }

                for (int i = 0; i < ControllerNames.ControllerName("Modern").Count; i++)
                {
                    if (current.Equals(ControllerNames.ControllerName("Modern")[i]))
                    {
                        return(InputSource.MODERN_CONTROLLER);
                    }
                }

                for (int i = 0; i < ControllerNames.ControllerName("Classic").Count; i++)
                {
                    if (current.Equals(ControllerNames.ControllerName("Classic")[i]))
                    {
                        return(InputSource.CLASSIC_JOYSTICK);
                    }
                }

                for (int i = 0; i < ControllerNames.ControllerName("Xbox").Count; i++)
                {
                    if (current.Equals(ControllerNames.ControllerName("Xbox")[i]))
                    {
                        return(InputSource.XBOX_CONTROLLER);
                    }
                }

                for (int i = 0; i < ControllerNames.ControllerName("XboxBluetooth").Count; i++)
                {
                    if (current.Equals(ControllerNames.ControllerName("XboxBluetooth")[i]))
                    {
                        return(InputSource.XBOX_CONTROLLER);
                    }
                }

                return(InputSource.GENERIC);
            }
            else
            {
                return(InputSource.KEYBOARD_AND_MOUSE);
            }
        }
Exemplo n.º 18
0
 public Controller(ControllerNames name)
 {
     CName = name;
 }
Exemplo n.º 19
0
 public DisableUser(ActionNames redirectToAction = ActionNames.ForceLogoffUser, ControllerNames redirectToController = ControllerNames.Account)
 {
     _redirectToResult     = redirectToAction;
     _redirectToController = redirectToController;
 }
Exemplo n.º 20
0
        public async Task <SwaggerDocument> RunAsync()
        {
            return(await Task.Run(async() =>
            {
                if (!string.IsNullOrEmpty(DocumentTemplate))
                {
                    if (await DynamicApis.FileExistsAsync(DocumentTemplate).ConfigureAwait(false))
                    {
                        Settings.DocumentTemplate = await DynamicApis.FileReadAllTextAsync(DocumentTemplate).ConfigureAwait(false);
                    }
                    else
                    {
                        Settings.DocumentTemplate = DocumentTemplate;
                    }

                    if (!string.IsNullOrEmpty(Settings.DocumentTemplate) && !Settings.DocumentTemplate.StartsWith("{"))
                    {
                        Settings.DocumentTemplate = (await SwaggerYamlDocument.FromYamlAsync(Settings.DocumentTemplate)).ToJson();
                    }
                }
                else
                {
                    Settings.DocumentTemplate = null;
                }

                var generator = new WebApiAssemblyToSwaggerGenerator(Settings);

                var controllerNames = ControllerNames.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
                if (!controllerNames.Any() && Settings.AssemblySettings.AssemblyPaths?.Length > 0)
                {
                    controllerNames = generator.GetExportedControllerClassNames().ToList();
                }

                var document = await generator.GenerateForControllersAsync(controllerNames).ConfigureAwait(false);
                if (ServiceHost == ".")
                {
                    document.Host = string.Empty;
                }
                else if (!string.IsNullOrEmpty(ServiceHost))
                {
                    document.Host = ServiceHost;
                }

                if (!string.IsNullOrEmpty(InfoTitle))
                {
                    document.Info.Title = InfoTitle;
                }
                if (!string.IsNullOrEmpty(InfoVersion))
                {
                    document.Info.Version = InfoVersion;
                }
                if (!string.IsNullOrEmpty(InfoDescription))
                {
                    document.Info.Description = InfoDescription;
                }

                if (ServiceSchemes != null && ServiceSchemes.Any())
                {
                    document.Schemes = ServiceSchemes.Select(s => (SwaggerSchema)Enum.Parse(typeof(SwaggerSchema), s, true)).ToList();
                }

                if (!string.IsNullOrEmpty(ServiceBasePath))
                {
                    document.BasePath = ServiceBasePath;
                }

                return document;
            }));
        }