Ejemplo n.º 1
0
        /// <summary>
        /// insecure if you not realy sure it is a controllertype
        /// </summary>
        /// <param name="controllerType"></param>
        /// <returns></returns>
        internal static ControllerObject CreateController(Type controllerType, Session session, HttpListenerContext context)
        {
            int    indexQuestion = context.Request.RawUrl.IndexOf('?');
            int    indexHastag   = context.Request.RawUrl.IndexOf('#');
            string parameterpart = string.Empty;
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (indexQuestion != -1)
            {
                if (indexQuestion > indexHastag)
                {
                    parameterpart = context.Request.RawUrl.Split('?')[1];
                }
                else
                {
                    parameterpart = context.Request.RawUrl.Split('?', '#')[1];
                }

                foreach (string part in parameterpart.Split('&'))
                {
                    parameters.Add(WebUtility.UrlDecode(part.Split('=')[0]), WebUtility.UrlDecode(part.Split('=')[1]));
                }
            }



            ControllerObject o = Activator.CreateInstance(controllerType) as ControllerObject;

            o.Session = session;
            o.AfterConstruct();
            o.Parameters = parameters;
            return(o);
        }
Ejemplo n.º 2
0
 public IdentityUserController(ControllerObject controller) : base(controller)
 {
     Constructing();
     oneEntityController     = new QnSProjectAward.Logic.Controllers.Persistence.Account.IdentityController(this);
     anotherEntityController = new QnSProjectAward.Logic.Controllers.Persistence.Account.UserController(this);
     Constructed();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Создать контроллер для движения
        /// </summary>
        private static void CreateController()
        {
            GameObject go = new GameObject("MoveBehaviour");

            go.AddComponent(typeof(ControllerObject));
            controller = go.GetComponent <ControllerObject>();
        }
 public GenericOneToManyController(ControllerObject controller) : base(controller)
 {
     Constructing();
     OneEntityController  = CreateFirstEntityController(this);
     ManyEntityController = CreateSecondEntityController(this);
     ChangedSessionToken += GenericOneToManyController_ChangedSessionToken;
     Constructed();
 }
Ejemplo n.º 5
0
        internal static async Task <IEnumerable <Role> > QueryIdentityRolesAsync(ControllerObject controllerObject, int identityId)
        {
            controllerObject.CheckArgument(nameof(controllerObject));

            var result = new List <Role>();

            using var identityXRoleCtrl = new Controllers.Persistence.Account.IdentityXRoleController(controllerObject);
            var roles = await identityXRoleCtrl.QueryIdentityRolesAsync(identityId)
                        .ConfigureAwait(false);

            result.AddRange(roles);
            return(result);
        }
Ejemplo n.º 6
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 7
0
    private void CreateButton <T>(MenuSettings <T> settings) where T : UnityEngine.Object
    {
        EditorGUILayout.BeginHorizontal();
        T[]      objs  = FindObjectsOfType <T>();
        string[] names = objs.Select(x => x.name).ToArray();
        string   msg   = "";

        if (ArrayUtility.Contains(names, settings.name))
        {
            msg = "Duplicate name"; GUI.enabled = false;
        }
        if (settings.name == "")
        {
            msg = "Empty Name"; GUI.enabled = false;
        }
        EditorGUILayout.LabelField(msg, GUILayout.Width(197));
        if (GUILayout.Button("Create", LayoutSettings.buttonOp))
        {
            GameObject obj = new GameObject(settings.name);
            //Controller.
            if (typeof(T) == typeof(ControllerOutput))
            {
                //Create Controller.
                ControllerObject cont = (ControllerObject)obj.AddComponent(System.Type.GetType(string.Format("Gimbl.{0}", contType.ToString())));
                cont.InitiateController();
                //Create general Output Object and link.
                ControllerOutput contOut = obj.AddComponent <ControllerOutput>();
                contOut.master = cont;
                // Select created.
                settings.selectedObj = contOut as T;
            }
            //Actor.
            if (typeof(T) == typeof(ActorObject))
            {
                ActorObject act = obj.AddComponent <ActorObject>();
                act.InitiateActor(actorModels[selectedModel], trackCam);
                settings.selectedObj = act as T;
            }
            //Path.
            if (typeof(T) == typeof(PathCreator))
            {
                CreatePath(settings as MenuSettings <PathCreator>, obj);
            }
            settings.name = "";
        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 8
0
        static partial void CreateController <C>(ControllerObject controllerObject, ref IControllerAccess <C> controller) where C : IIdentifiable
        {
            controllerObject.CheckArgument(nameof(controllerObject));

            if (typeof(C) == typeof(SmartNQuick.Contracts.Persistence.MusicStore.IGenre))
            {
                controller = new Controllers.Persistence.MusicStore.GenreController(controllerObject) as IControllerAccess <C>;
            }
            else if (typeof(C) == typeof(SmartNQuick.Contracts.Persistence.MusicStore.IArtist))
            {
                controller = new Controllers.Persistence.MusicStore.ArtistController(controllerObject) as IControllerAccess <C>;
            }
            else if (typeof(C) == typeof(SmartNQuick.Contracts.Persistence.MusicStore.IAlbum))
            {
                controller = new Controllers.Persistence.MusicStore.AlbumController(controllerObject) as IControllerAccess <C>;
            }
        }
Ejemplo n.º 9
0
    public void Setup(Vector3[] new_points, ControllerObject new_controller)
    {
        this.points      = new_points;
        lr.positionCount = points.Length;
        lr.SetPositions(points);

        controller = new_controller;
        if (controller == controllers.leftHand)
        {
            otherController = controllers.rightHand;
        }
        if (controller == controllers.rightHand)
        {
            otherController = controllers.rightHand;
        }

        StartCoroutine(CheckCollisions());
    }
Ejemplo n.º 10
0
        internal static Func <ViewObject> GetView(HttpListenerContext context, ControllerObject controller, List <string> urlParts)
        {
            return(() =>
            {
                controller._requestContext = context;
                var HttpMethod = context.Request.HttpMethod.ToLower();

                var controllerType = controller.GetType();


                MethodInfo method;
                if (urlParts.Count > 0)
                {
                    method = controllerType.GetMethods()
                             .FirstOrDefault(mi => mi.Name.ToLower() == $"{HttpMethod}{urlParts[0]}");
                }
                else
                {
                    method = controllerType.GetMethods()
                             .FirstOrDefault(mi => mi.Name.ToLower() == $"{HttpMethod}");
                }
                var result = method?.Invoke(controller, new object[] { });

                if (result != null && result is ViewObject)
                {
                    return (result as ViewObject);
                }
                else if (method == null)
                {
                    return new NotFoundView("action not found");
                }
                else
                {
                    return new RawObjectView(result);
                }
            });
        }
Ejemplo n.º 11
0
 public ImageController(ControllerObject controller) : base(controller)
 {
 }
Ejemplo n.º 12
0
 public HolidayEntryController(ControllerObject controller) : base(controller)
 {
     Constructing();
     Constructed();
 }
Ejemplo n.º 13
0
 public AppAccessController(ControllerObject controller) : base(controller)
 {
     Constructing();
     Constructed();
 }
Ejemplo n.º 14
0
 protected QuickNSmartController(ControllerObject controller)
     : base(controller)
 {
 }
Ejemplo n.º 15
0
 protected GenericPersistenceController(ControllerObject controllerObject)
     : base(controllerObject)
 {
     Constructing();
     Constructed();
 }
Ejemplo n.º 16
0
 public UserProjectController(ControllerObject controllerObject) : base(controllerObject)
 {
 }
 public TravelExpenseController(ControllerObject controller)
     : base(controller)
 {
     travelController  = new TravelController(this);
     expenseController = new ExpenseController(this);
 }
Ejemplo n.º 18
0
 protected BillShareController(ControllerObject controller)
     : base(controller)
 {
 }
Ejemplo n.º 19
0
        static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                errorLevel = 3;
                Usage();
                return(errorLevel);
            }

            try {
                string    path = null;
                Hashtable commandLineProperties = new Hashtable();

                ProcessCommandLineArguments(args, ref path, commandLineProperties);

                LibraryManifest libraryInfo = new LibraryManifest(path);

                // default to Development profile
                string profileName            = "Development (Public)";
                string commandLineProfileName = (string)commandLineProperties["BuildProfileName"];
                profileName = (commandLineProfileName != null) ? commandLineProfileName : profileName;

                ProductBuildDataSet pbDataSet = ProductBuildDataSet.GetProductBuildDataSetWithoutComplist(
                    profileName,
                    libraryInfo.GetName(),
                    libraryInfo.GetVersion(),
                    libraryInfo.GetPlatform(),
                    libraryInfo.GetBranchOrTrunkName(),
                    libraryInfo.GetDirectory(),
                    path,
                    libraryInfo.GetDate());

                pbDataSet.ApplyCommandLineProperties(commandLineProperties);
                pbDataSet.LoadComplist();
                pbDataSet.FinalizeProperties();
                pbDataSet.WriteBuildConfigurationFile(pbDataSet.GetBuildConfigurationFilename());

                string           buildPath        = pbDataSet.GetBuildProperty("BuildPath");
                VmsProduct       currProduct      = new VmsProduct(libraryInfo.GetName(), libraryInfo.GetVersion(), libraryInfo.GetPlatform());
                VmsLibrary       currLibrary      = new VmsLibrary(currProduct, libraryInfo.GetBranchOrTrunkName());
                ControllerObject controllerObject = new ControllerObject();
                string           currentKey       = Util.GetServiceKey();
                bool             actionSucceeded  = false;
                string           errorMessage     = null;
                if (controllerObject.BuildLibrary(currLibrary, currentKey, buildPath, out errorMessage, false))
                {
                    NewMessage.ProcessMessages(currentKey, ref errorMessage, ref actionSucceeded, false, ref errorLevel);
                    if (actionSucceeded)
                    {
                        Console.WriteLine("    Successfully built " + currLibrary.ShortLibraryName);
                    }
                    else
                    {
                        Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                    }
                }
                else
                {
                    Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                }
            }
            catch (Exception e) {
                errorLevel = 3;
                Console.Error.WriteLine("An error occurred in ProductBuilder:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }
            return(errorLevel);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Callback method for any commands the player sends to the controller
        /// </summary>
        /// <param name="sock">The socketstate the connection is on</param>
        static void CommandRequestHandler(SocketState sock)
        {
            Tank main;

            //If the tank is not currently connected, don't listen to any commands from that client
            if (tanks.ContainsKey((int)sock.ID))
            {
                main = tanks[(int)sock.ID];
            }
            else
            {
                return;
            }

            // Split the command by its \n's
            string[] commands = Regex.Split(sock.GetData(), @"(?<=[\n])");
            if (commands.Length == 1)
            {
                return;
            }

            //Deserialize the command
            ControllerObject command = JsonConvert.DeserializeObject <ControllerObject>(commands[commands.Length - 2]);

            //If there is nothing in command then ignore it
            if (command == null)
            {
                return;
            }

            //If the tank is currently alive and has made it this far, listen to its commands
            if (main.hitPoints != 0)
            {
                //Process the fire status of the tank and either fire a projectile, beam, or do nothing
                switch (command.getFireStatus())
                {
                case "none":
                    break;

                case "main":
                    if (main.shotTimer > 0)
                    {
                        break;
                    }
                    Projectile shot = new Projectile();
                    main.tankTotalShots++;
                    shot.orientation = main.aiming;
                    shot.location    = main.location;
                    shot.tankID      = main.ID;
                    shot.ID          = shotCount;
                    shotCount++;
                    lock (projectiles)
                    {
                        projectiles.Add(shot.ID, shot);
                    }
                    main.shotTimer = FramesPerShot;
                    break;

                case "alt":
                    if (main.railgunShots > 0)
                    {
                        main.railgunShots--;
                        Beam railBeam = new Beam();
                        main.tankTotalShots++;
                        railBeam.direction = main.aiming;
                        railBeam.origin    = main.location;
                        railBeam.tankID    = main.ID;
                        railBeam.ID        = shotCount;
                        lock (beams)
                        {
                            beams.Add(railBeam.ID, railBeam);
                        }
                        shotCount++;
                    }

                    break;
                }

                //Variables used to track where the tank will be after the command is implemented
                double tankLocAfterMoveY;
                double tankLocAfterMoveX;

                //Process the tank's move command and update it's location based on the button that was pressed
                switch (command.getMoveDirection())
                {
                case "none":
                    main.tankVelocity = new Vector2D(0, 0);
                    break;

                case "up":
                    main.tankVelocity = new Vector2D(0, -EngineStrength);
                    tankLocAfterMoveY = main.location.GetY() + main.tankVelocity.GetY();
                    tankLocAfterMoveX = main.location.GetX() + main.tankVelocity.GetX();

                    //If the tank will hit a wall with this move, don't move it
                    if (collisionCheck(tankLocAfterMoveX, tankLocAfterMoveY))
                    {
                        main.tankVelocity = new Vector2D(0, 0);
                    }
                    //If the tank is at the edge of the world after this move, teleport it to the other side
                    else if (tankLocAfterMoveY < -serverWorld.worldSize / 2)
                    {
                        tankLocAfterMoveY = serverWorld.worldSize / 2 - 5;
                        main.location     = new Vector2D(main.location.GetX(), tankLocAfterMoveY);
                        main.orientation  = new Vector2D(0, -1);
                    }
                    //If the tank won't hit a wall or the edge, move it
                    else
                    {
                        main.location    = main.location + main.tankVelocity;
                        main.orientation = new Vector2D(0, -1);
                    }
                    break;

                case "down":
                    main.tankVelocity = new Vector2D(0, EngineStrength);
                    tankLocAfterMoveY = main.location.GetY() + main.tankVelocity.GetY();
                    tankLocAfterMoveX = main.location.GetX() + main.tankVelocity.GetX();

                    //If the tank will hit a wall with this move, don't move it
                    if (collisionCheck(tankLocAfterMoveX, tankLocAfterMoveY))
                    {
                        main.tankVelocity = new Vector2D(0, 0);
                    }
                    //If the tank is at the edge of the world after this move, teleport it to the other side
                    else if (tankLocAfterMoveY > serverWorld.worldSize / 2)
                    {
                        tankLocAfterMoveY = -serverWorld.worldSize / 2 + 5;
                        main.location     = new Vector2D(main.location.GetX(), tankLocAfterMoveY);
                        main.orientation  = new Vector2D(0, 1);
                    }
                    //If the tank won't hit a wall or the edge, move it
                    else
                    {
                        main.location    = main.location + main.tankVelocity;
                        main.orientation = new Vector2D(0, 1);
                    }
                    break;

                case "left":
                    main.tankVelocity = new Vector2D(-EngineStrength, 0);
                    tankLocAfterMoveY = main.location.GetY() + main.tankVelocity.GetY();
                    tankLocAfterMoveX = main.location.GetX() + main.tankVelocity.GetX();

                    //If the tank will hit a wall with this move, don't move it
                    if (collisionCheck(tankLocAfterMoveX, tankLocAfterMoveY))
                    {
                        main.tankVelocity = new Vector2D(0, 0);
                    }
                    //If the tank is at the edge of the world after this move, teleport it to the other side
                    else if (tankLocAfterMoveX < -serverWorld.worldSize / 2)
                    {
                        tankLocAfterMoveX = serverWorld.worldSize / 2 - 5;
                        main.location     = new Vector2D(tankLocAfterMoveX, main.location.GetY());
                        main.orientation  = new Vector2D(-1, 0);
                    }
                    //If the tank won't hit a wall or the edge, move it
                    else
                    {
                        main.location    = main.location + main.tankVelocity;
                        main.orientation = new Vector2D(-1, 0);
                    }
                    break;

                case "right":
                    main.tankVelocity = new Vector2D(EngineStrength, 0);
                    tankLocAfterMoveY = main.location.GetY() + main.tankVelocity.GetY();
                    tankLocAfterMoveX = main.location.GetX() + main.tankVelocity.GetX();

                    //If the tank will hit a wall with this move, don't move it
                    if (collisionCheck(tankLocAfterMoveX, tankLocAfterMoveY))
                    {
                        main.tankVelocity = new Vector2D(0, 0);
                    }
                    //If the tank is at the edge of the world after this move, teleport it to the other side
                    else if (tankLocAfterMoveX > serverWorld.worldSize / 2)
                    {
                        tankLocAfterMoveX = -serverWorld.worldSize / 2 + 5;
                        main.location     = new Vector2D(tankLocAfterMoveX, main.location.GetY());
                        main.orientation  = new Vector2D(1, 0);
                    }
                    //If the tank won't hit a wall or the edge, move it
                    else
                    {
                        main.location    = main.location + main.tankVelocity;
                        main.orientation = new Vector2D(1, 0);
                    }
                    break;
                }
                //Aim the turret the direction it should be facing
                main.aiming = command.getTurretDirection();
            }

            //Remove the data that has been processed and ask for more data
            sock.RemoveData(0, sock.GetData().Length);
            Networking.GetData(sock);
        }
 protected QnSTravelCountController(ControllerObject controller)
     : base(controller)
 {
 }
Ejemplo n.º 22
0
 public AlbumController(ControllerObject controller)
     : base(controller)
 {
 }
 public ProjectController(ControllerObject controller) : base(controller)
 {
 }
 public GenericShadowController(ControllerObject controller) : base(controller)
 {
     Constructing();
     ChangedSessionToken += GenericViewController_ChangedSessionToken;
     Constructed();
 }
        private ControllerMethod BuildControllerMethod(string url, Method method, Resource resource, ControllerObject parent, IDictionary <string, Parameter> parentUriParameters)
        {
            var relativeUri = UrlGeneratorHelper.GetRelativeUri(url, parent.PrefixUri);

            var parentUrl = UrlGeneratorHelper.GetParentUri(url, resource.RelativeUri);

            return(new ControllerMethod
            {
                Name = NetNamingMapper.GetMethodName(method.Verb ?? "Get" + resource.RelativeUri),
                Parameter = GetParameter(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url),
                UriParameters = uriParametersGenerator.GetUriParameters(resource, url, parentUriParameters),
                ReturnType = GetReturnType(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url),
                Comment = GetComment(resource, method),
                Url = relativeUri,
                Verb = NetNamingMapper.Capitalize(method.Verb),
                Parent = null,
                UseSecurity =
                    raml.SecuredBy != null && raml.SecuredBy.Any() ||
                    resource.Methods.Any(m => m.Verb == method.Verb && m.SecuredBy != null && m.SecuredBy.Any()),
                SecurityParameters = GetSecurityParameters(raml, method)
            });
        }
        public IEnumerable <ControllerMethod> GetMethods(Resource resource, string url, ControllerObject parent, string objectName, IDictionary <string, Parameter> parentUriParameters)
        {
            var methodsNames = new List <string>();

            if (parent != null && parent.Methods != null)
            {
                methodsNames = parent.Methods.Select(m => m.Name).ToList();
            }

            var generatorMethods = new Collection <ControllerMethod>();

            if (resource.Methods == null)
            {
                return(generatorMethods);
            }

            foreach (var method in resource.Methods)
            {
                var generatedMethod = BuildControllerMethod(url, method, resource, parent, parentUriParameters);

                if (IsVerbForMethod(method))
                {
                    if (methodsNames.Contains(generatedMethod.Name))
                    {
                        generatedMethod.Name = GetUniqueName(methodsNames, generatedMethod.Name, resource.RelativeUri);
                    }

                    if (method.QueryParameters != null && method.QueryParameters.Any())
                    {
                        var queryParameters = QueryParametersParser.ParseParameters(method);
                        generatedMethod.QueryParameters = queryParameters;
                    }

                    generatorMethods.Add(generatedMethod);
                    methodsNames.Add(generatedMethod.Name);
                }
            }

            return(generatorMethods);
        }
Ejemplo n.º 27
0
 public LabelController(ControllerObject controller) : base(controller)
 {
 }
 protected abstract GenericController <TSecond, TSecondEntity> CreateSecondEntityController(ControllerObject controller);
 protected GenericPersistenceController(ControllerObject other) : base(other)
 {
 }
 protected abstract GenericController <TFirst, TFirstEntity> CreateFirstEntityController(ControllerObject controller);