Beispiel #1
0
        public async Task SignIn(string key)
        {
            var authenticationResult = await App.PublicClientApp.AcquireTokenSilentAsync(App.Scopes,
                                                                                         App.PublicClientApp.Users.FirstOrDefault(user => user.DisplayableId == key));

            Token = authenticationResult.AccessToken;
            using (var stream = await GetDataStream("https://graph.microsoft.com/v1.0/me"))
            {
                DeserializedAccount        deserializedAccount = new DeserializedAccount();
                DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedAccount.GetType());
                deserializedAccount = ser.ReadObject(stream) as DeserializedAccount;
                if (deserializedAccount == null)
                {
                    throw new NullReferenceException("Couldn't deserialized the data");
                }
                Login = deserializedAccount.UserPrincipalName;
                Id    = deserializedAccount.Id;
            }
            using (var stream = await GetDataStream("https://graph.microsoft.com/v1.0/me/drive"))
            {
                DeserializedAccount        deserializedAccount = new DeserializedAccount();
                DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedAccount.GetType());
                deserializedAccount = ser.ReadObject(stream) as DeserializedAccount;
                if (deserializedAccount == null)
                {
                    throw new NullReferenceException("Couldn't deserialized the data");
                }
                Size           = new SpaceSize();
                Size.TotalSize = deserializedAccount.Quota.Total;
                Size.UsedSize  = deserializedAccount.Quota.Used;
                Size.FreeSize  = deserializedAccount.Quota.Remaining;
            }

            Status = ConnectionStatusEnum.Connected;
        }
Beispiel #2
0
        public async Task <IActionResult> PutSpaceSize(int id, SpaceSize spaceSize)
        {
            if (id != spaceSize.Id)
            {
                return(BadRequest());
            }

            _context.Entry(spaceSize).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpaceSizeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public void GetEmtpy(SpaceSize size)
        {
            int empty = 0;

            foreach (KeyValuePair <int, Space> pair in lotSpaces)
            {
                if (pair.Value.Size == size && pair.Value.Taken == false)
                {
                    empty++;
                }
            }

            switch (size)
            {
            case SpaceSize.COMPACT:
                EmptyCompactSpaces = empty;
                break;

            case SpaceSize.LARGE:
                EmptyLargeSpaces = empty;
                break;

            case SpaceSize.MOTOR_SIZE:
                EmptyMotorSpaces = empty;
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        public async Task <ActionResult <SpaceSize> > PostSpaceSize(SpaceSize spaceSize)
        {
            _context.SpaceSize.Add(spaceSize);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSpaceSize", new { id = spaceSize.Id }, spaceSize));
        }
Beispiel #5
0
        public void Add(IList <string> path, IGroupTreeItem item)
        {
            string     fullCurrentPath = String.Empty;
            IContainer itemDirectory   = FindItemDirectory(path);

            if (NameScan(itemDirectory, item.Name, item.Type))
            {
                throw new ArgumentException("Element has already been");
            }

            item.Parent = itemDirectory;
            itemDirectory.Items.Add(item);

            switch (item)
            {
            case IContainer container:
                _settings.Add(path, new GroupSettingsContainer(container));
                break;

            case IGroup group:
                _settings.Add(path, new GroupSettingsGroup(group));
                break;

            default:
                throw new ArgumentException("Unknown type");
            }

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(item, path, RegistryActionEnum.Added);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemMoved);
        }
Beispiel #6
0
 public Space(int row, int number, SpaceSize size)
 {
     Row    = row;
     Number = number;
     Size   = size;
     Taken  = false;
 }
Beispiel #7
0
        public void Copy(IList <string> path, string name, GroupTreeTypeEnum type, IList <string> otherPath)
        {
            string     fullCurrentPath   = String.Empty;
            IContainer itemDirectoryFrom = FindItemDirectory(path);
            IContainer itemDirectoryTo   = FindItemDirectory(otherPath);

            IGroupTreeItem itemForCopy =
                itemDirectoryFrom.Items.FirstOrDefault(it => it.Name == name && it.Type == type);

            if (itemForCopy == null)
            {
                throw new DirectoryNotFoundException();
            }

            if (NameScan(itemDirectoryTo, itemForCopy.Name, itemForCopy.Type))
            {
                throw new ArgumentException("Element has already been");
            }

            IGroupTreeItem newItem = itemForCopy.Clone();

            newItem.Parent = itemDirectoryTo;
            itemDirectoryTo.Items.Add(newItem);

            _settings.Copy(path, name, type, otherPath);

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(newItem, otherPath, RegistryActionEnum.Added);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemCopied);
        }
Beispiel #8
0
        public void Clone_RequestForClone_GetCloneObject()
        {
            string expectedToken = "simpleToken";
            string expectedLogin = "******";
            DateTime expectedCreaDate = new DateTime(2018, 4, 22, 2, 7, 0);
            string expectedServerName = "OneDrive";
            SpaceSize expectedSize = new SpaceSize() { TotalSize = 1000, FreeSize = 300, UsedSize = 700 };
            List<string> expectedGroups=new List<string>(){"Group1","Group2"};

            ConnectionStatusEnum expectedStatus = ConnectionStatusEnum.Connected;

            _mockService.SetupGet(account => account.Token).Returns(expectedToken);
            _mockService.SetupGet(account => account.Login).Returns(expectedLogin);
            _mockService.SetupGet(account => account.ServerName).Returns(expectedServerName);
            _mockService.SetupGet(account => account.Status).Returns(expectedStatus);
            _mockService.SetupGet(account => account.Size).Returns(expectedSize);
            _mockService.SetupGet(account => account.Clone()).Returns(_mockService.Object);
            _account.Groups.Add("Group1");
            _account.Groups.Add("Group2");

            var accountClone = _account.Clone();

            CollectionAssert.AreEqual((List<string>)_account.Groups, expectedGroups);
            Assert.AreEqual(accountClone.Token, expectedToken);
            Assert.AreEqual(accountClone.Login, expectedLogin);
            Assert.AreEqual(accountClone.ServerName, expectedServerName);
            Assert.AreEqual(accountClone.Size, expectedSize);
            Assert.AreEqual(accountClone.Status, expectedStatus);
        }
Beispiel #9
0
 void Start()
 {
     halfSize = GetComponent <Collider>().bounds.extents;
     //Debug.Log(halfSize);
     spaceSize    = new SpaceSize();
     rb           = GetComponent <Rigidbody>();
     currentSpeed = rb.velocity.z;
     StartCoroutine(Evade());
 }
        public void Add_RequestForAddItem_AddNewItem()
        {
            GroupSettingsContainer groupSettingsStub = null;

            SpaceSize expectedSize = new SpaceSize()
            {
                TotalSize = 100, FreeSize = 30, UsedSize = 70
            };

            var forAdd = new Container()
            {
                Name     = "Container1",
                IsActive = true,
                Items    = new List <IGroupTreeItem>()
                {
                    new Container()
                    {
                        Name = "Container2", Size = new SpaceSize()
                    },
                    new Group()
                    {
                        Name = "Group2", Size = expectedSize
                    }
                },
                Size = expectedSize
            };

            var expectedContainer = new ContainerProjection(new Container()
            {
                Name  = "Root",
                Size  = expectedSize,
                Items = new List <IGroupTreeItem>()
                {
                    forAdd
                }
            });

            _mockService.Setup(settings => settings.LoadGroupTree()).Returns(groupSettingsStub);
            _groupContainerStub = new UnityContainer();
            _groupContainerStub.RegisterInstance <IGroupSettings>(_mockService.Object);
            _groupContainerStub.RegisterInstance <IAccountRegistry>(_accountRegistryStub.Object);
            _groupContainerStub.RegisterType <IContainer, Container>(new InjectionConstructor());
            _groupContainerStub.RegisterType <IGroup, Group>(new InjectionConstructor());

            GroupTreeRegistry registry = new GroupTreeRegistry(_groupContainerStub);

            registry.Initialization();
            registry.Add(new List <string>(), forAdd);

            IContainerProjection rootProjection = registry.GetContainerProjection(new List <string>(), null);

            Assert.IsTrue(expectedContainer.Equals(rootProjection));
        }
Beispiel #11
0
    private SpaceSize spaceSize; // Класс отвечает за определение размеров области отображения

    void Start()
    {
        spaceSize   = new SpaceSize();
        rb          = GetComponent <Rigidbody>();
        audioSource = GetComponent <AudioSource>();

        if (useLasers)
        {
            StartCoroutine(Fire(delayLaser, fireRateLaser, shotSpawns, shot));
        }

        if (useRockets)
        {
            StartCoroutine(Fire(delayRocket, fireRateRocket, rocketSpawns, rocket));
        }
    }
Beispiel #12
0
 public async Task Update()
 {
     using (var stream = await GetDataStream("https://graph.microsoft.com/v1.0/me/drive"))
     {
         DeserializedAccount        deserializedAccount = new DeserializedAccount();
         DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedAccount.GetType());
         deserializedAccount = ser.ReadObject(stream) as DeserializedAccount;
         if (deserializedAccount == null)
         {
             throw new NullReferenceException("Couldn't deserialized the data");
         }
         Size           = new SpaceSize();
         Size.TotalSize = deserializedAccount.Quota.Total;
         Size.UsedSize  = deserializedAccount.Quota.Used;
         Size.FreeSize  = deserializedAccount.Quota.Remaining;
     }
     Status = ConnectionStatusEnum.Connected;
 }
Beispiel #13
0
        public void LoadSizeInfo()
        {
            if (Size == null)
            {
                Size = new SpaceSize();
            }
            else
            {
                Size.TotalSize = Size.UsedSize = Size.FreeSize = 0;
            }

            foreach (var item in Items)
            {
                Size.TotalSize += item.Size.TotalSize;
                Size.UsedSize  += item.Size.UsedSize;
                Size.FreeSize  += item.Size.FreeSize;
            }
        }
Beispiel #14
0
 void Start()
 {
     isShuttingDown  = false;
     audioController = FindObjectOfType <AudioController>();
     sceneController = FindObjectOfType <SceneController>();
     pause           = false;
     CanvasGroupActivation(pauseCanvasGroup, false);
     CanvasGroupActivation(gameOverCanvasGroup, false);
     CanvasGroupActivation(winCanvasGroup, false);
     SetSoundsToggle();
     SetMusicToggle();
     player    = GameObject.FindWithTag("Player");
     spaceSize = new SpaceSize();
     gameOver  = false;
     score     = PlayerPrefs.GetInt("currentScore", 0);
     UpdateScore();
     StartCoroutine(SpawnWaves());
     StartCoroutine(DestroyLevelNumberText());
 }
Beispiel #15
0
        public void BindingParameters_ChangeFileStorageAccount_GetChangeInAccount()
        {
            string expectedToken = "simpleToken";
            string expectedLogin = "******";
            DateTime expectedCreaDate = new DateTime(2018, 4, 22, 2, 7, 0);
            string expectedServerName = "OneDrive";
            SpaceSize expectedSize = new SpaceSize() { TotalSize = 1000, FreeSize = 300, UsedSize = 700 };
            ConnectionStatusEnum expectedStatus = ConnectionStatusEnum.Connected;

            _mockService.SetupGet(account => account.Token).Returns(expectedToken);
            _mockService.SetupGet(account => account.Login).Returns(expectedLogin);
            _mockService.SetupGet(account => account.ServerName).Returns(expectedServerName);
            _mockService.SetupGet(account => account.Status).Returns(expectedStatus);
            _mockService.SetupGet(account => account.Size).Returns(expectedSize);

            Assert.AreEqual(_account.Token, expectedToken);
            Assert.AreEqual(_account.Login, expectedLogin);
            Assert.AreEqual(_account.ServerName, expectedServerName);
            Assert.AreEqual(_account.Size, expectedSize);
            Assert.AreEqual(_account.Status, expectedStatus);

        }
Beispiel #16
0
        public void Delete(IList <string> path, string name, GroupTreeTypeEnum type)
        {
            string     fullCurrentPath = String.Empty;
            IContainer itemDirectory   = FindItemDirectory(path);

            IGroupTreeItem itemForDelete = itemDirectory.Items.FirstOrDefault(it => it.Name == name && it.Type == type);

            if (itemForDelete == null)
            {
                throw new DirectoryNotFoundException();
            }

            itemDirectory.Items.Remove(itemForDelete);
            _settings.Delete(path, name, type);

            SpaceSize oldSize = new SpaceSize(_groupTree.Size);

            _groupTree.LoadSizeInfo();
            SpaceSize newSize = new SpaceSize(_groupTree.Size);

            OnChangedStructureEvent(itemForDelete, path, RegistryActionEnum.Removed);
            OnChangedSizeEvent(oldSize, newSize, GroupTreeSizeChangedEnum.ItemDeleted);
        }
Beispiel #17
0
        public void LoadSizeInfo()
        {
            var accounts = GetAccountProjections();

            if (Size == null)
            {
                Size = new SpaceSize();
            }
            else
            {
                Size.TotalSize = Size.UsedSize = Size.FreeSize = 0;
            }

            foreach (var item in Items)
            {
                item.LoadSizeInfo();
            }
            foreach (var item in accounts)
            {
                Size.TotalSize += item.Size.TotalSize;
                Size.UsedSize  += item.Size.UsedSize;
                Size.FreeSize  += item.Size.FreeSize;
            }
        }
Beispiel #18
0
    private SpaceSize spaceSize; // Класс отвечает за определение размеров области отображения

    void Start()
    {
        spaceSize = new SpaceSize();
        StartCoroutine(InstantiateSecondObj());
        InstantiateSecondObj();
    }
 public GroupTreeSizeChangedEventArg(SpaceSize oldSize, SpaceSize newSize, GroupTreeSizeChangedEnum action)
 {
     OldSize = oldSize;
     NewSize = newSize;
     Action  = action;
 }
Beispiel #20
0
 void OnChangedSizeEvent(SpaceSize oldSize, SpaceSize newSize,
                         GroupTreeSizeChangedEnum action)
 {
     ChangedSizeEvent?.Invoke(this,
                              new GroupTreeSizeChangedEventArg(oldSize, newSize, action));
 }
Beispiel #21
0
    private SpaceSize spaceSize; // Класс отвечает за определение размеров области отображения

    void Start()
    {
        spaceSize = new SpaceSize();
        StartCoroutine(SpawnAttackingObjects());
    }
Beispiel #22
0
 public Space(int row, int number, SpaceSize size)
 {
     this.row    = row;
     this.number = number;
     this.size   = size;
 }
Beispiel #23
0
 void Start()
 {
     //halfSize = GetComponent<MeshFilter>().mesh.bounds.extents;
     halfSize  = GetComponent <Collider>().bounds.extents;
     spaceSize = new SpaceSize();
 }
Beispiel #24
0
 void Start()
 {
     halfSize  = GetComponent <Collider>().bounds.extents;
     spaceSize = new SpaceSize();
 }
Beispiel #25
0
        public static IEnumerator EditorPlay(string rootObjectName, SpaceSize spaceSize)
        {
            EditorApplication.isPlaying = true;

            if (EditorApplication.isPaused)
            {
                EditorApplication.isPaused = false;
            }

            string progressTitle = "SetPassCalls and Batches Check.";
            float  progress      = 0;

            EditorUtility.DisplayProgressBar(progressTitle, "Initializing...", progress);
            double time = EditorApplication.timeSinceStartup;

            while (EditorApplication.timeSinceStartup - time < 1.84f)
            {
                Debug.Log(3);
                yield return(null);

                Debug.Log(4);
            }

            if (!EditorApplication.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", LocalizedMessage.Get("PerformanceCalculator.NotPlayMode"), "OK");
                EditorApplication.isPlaying = false;
                EditorUtility.ClearProgressBar();
                yield break;
            }

            Scene scene = SceneManager.GetActiveScene();

            if (EditorApplication.isPaused)
            {
                EditorApplication.isPaused = false;
            }

            AssetUtility.TemporaryDestroyObjectsOutsideOfRootObjectAndRunCallback(rootObjectName);

            if (EditorApplication.isPaused)
            {
                EditorApplication.isPaused = false;
            }

            foreach (Camera cam in Camera.allCameras.Union(SceneView.sceneViews.ToArray().Select(s => ((SceneView)s).camera)))
            {
                cam.enabled = false;
            }

            int space = spaceSize == SpaceSize.Small ? -4 : 8;

            GameObject checkParentObj = new GameObject("SetPassCheck");

            checkParentObj.transform.position = new Vector3(0, 0, 0);
            GameObject cameraObj = new GameObject("CheckCamera");
            Camera     checkCam  = cameraObj.AddComponent <Camera>();

            cameraObj.AddComponent <AudioListener>();
            checkCam.depth = 100;
            cameraObj.transform.SetParent(checkParentObj.transform);
            float rate = spaceSize == SpaceSize.Small ? 0.5f : 2;

            cameraObj.transform.position = new Vector3(0, 2.5f * rate, -(10 + space));

#if VRC_SDK_VRCSDK3
            scene.GetRootGameObjects()[0]?.transform.Find("Dynamic")?.gameObject.SetActive(true);
#endif

            List <int> setPassCallsList = new List <int>();
            List <int> batchesList      = new List <int>();
            float      rotation         = 0;
            for (int i = 0; i < 360; i++)
            {
                if (EditorApplication.isPaused)
                {
                    EditorApplication.isPaused = false;
                }
                progress = (float)i / 360;
                if (EditorUtility.DisplayCancelableProgressBar(progressTitle, (progress * 100).ToString("F2") + "%", progress))
                {
                    EditorApplication.isPlaying = false;
                    EditorUtility.ClearProgressBar();
                    yield break;
                }
                checkParentObj.transform.rotation = Quaternion.Euler(0, rotation, 0);
                setPassCallsList.Add(UnityStats.setPassCalls);
                batchesList.Add(UnityStats.batches);
                rotation++;
                yield return(null);
            }

            Object.DestroyImmediate(cameraObj);
            Object.DestroyImmediate(checkParentObj);

            int setPassCalls = (int)setPassCallsList.Average();
            int batches      = (int)batchesList.Average();

            EditorUtility.ClearProgressBar();

            EditorApplication.isPlaying = false;

            yield return(setPassCalls, batches);
        }
Beispiel #26
0
 void Start()
 {
     spaceSize = new SpaceSize();
     halfSize  = GetComponent <Collider>().bounds.extents;
     StartCoroutine(Jump());
 }
        public void SetActive_RequestForSetActive_SetActiveState()
        {
            var groupSettingsStub = new GroupSettingsContainer()
            {
                Name  = "Root",
                Items = new List <GroupSettingsItem>()
                {
                    new GroupSettingsContainer()
                    {
                        Name  = "Container1",
                        Items = new List <GroupSettingsItem>()
                        {
                            new GroupSettingsContainer()
                            {
                                Name = "Container2"
                            },
                            new GroupSettingsGroup()
                            {
                                Name = "Group2", Items = new List <string>()
                                {
                                    "Account1"
                                }
                            }
                        },
                        IsActive = true
                    },
                    new GroupSettingsGroup()
                    {
                        Name = "Group", Items = new List <string>()
                        {
                            "Account1"
                        }
                    }
                }
            };
            SpaceSize expectedSize = new SpaceSize()
            {
                TotalSize = 100, FreeSize = 80, UsedSize = 20
            };

            var expectedContainer = new ContainerProjection(new Container()
            {
                Name  = "Root",
                Size  = expectedSize,
                Items = new List <IGroupTreeItem>()
                {
                    new Container()
                    {
                        Name     = "Container1",
                        IsActive = false,
                        Items    = new List <IGroupTreeItem>()
                        {
                            new Container()
                            {
                                Name = "Container2", Size = new SpaceSize()
                            },
                            new Group()
                            {
                                Name = "Group2", Size = expectedSize, Items = new List <IAccountProjection>()
                                {
                                    _accountStub.Object
                                }
                            }
                        },
                        Size = expectedSize
                    },
                    new Group()
                    {
                        Name = "Group", Size = expectedSize, Items = new List <IAccountProjection>()
                        {
                            _accountStub.Object
                        }
                    },
                }
            });

            _mockService.Setup(settings => settings.LoadGroupTree()).Returns(groupSettingsStub);
            _accountRegistryStub.Setup(accountRegistry => accountRegistry.Find("Account1")).Returns(_accountStub.Object);
            _accountStub.SetupGet(accountProjection => accountProjection.Size).Returns(() => expectedSize);
            _accountStub.SetupGet(accountProjection => accountProjection.Login).Returns(() => "Account1");

            _groupContainerStub = new UnityContainer();
            _groupContainerStub.RegisterInstance <IGroupSettings>(_mockService.Object);
            _groupContainerStub.RegisterInstance <IAccountRegistry>(_accountRegistryStub.Object);
            _groupContainerStub.RegisterType <IContainer, Container>(new InjectionConstructor());
            _groupContainerStub.RegisterType <IGroup, Group>(new InjectionConstructor());

            GroupTreeRegistry registry = new GroupTreeRegistry(_groupContainerStub);

            registry.Initialization();
            registry.SetActive(new List <string>(), "Container1", false);

            IContainerProjection rootProjection = registry.GetContainerProjection(new List <string>(), null);

            Assert.IsTrue(expectedContainer.Equals(rootProjection));
        }
Beispiel #28
0
        public static IEnumerator Calculate(string rootObjectName, SpaceSize spaceSize)
        {
            float progress = 0;

            Scene scene = SceneManager.GetActiveScene();

            if (EditorApplication.isPaused)
            {
                EditorApplication.isPaused = false;
            }

            AssetUtility.TemporaryDestroyObjectsOutsideOfRootObjectAndRunCallback(rootObjectName);

            if (EditorApplication.isPaused)
            {
                EditorApplication.isPaused = false;
            }

            foreach (Camera cam in Camera.allCameras.Union(SceneView.sceneViews.ToArray().Select(s => ((SceneView)s).camera)))
            {
                cam.enabled = false;
            }

            int space = spaceSize == SpaceSize.Small ? -4 : 8;

            GameObject checkParentObj = new GameObject("SetPassCheck");

            checkParentObj.transform.position = new Vector3(0, 0, 0);
            GameObject cameraObj = new GameObject("CheckCamera");
            Camera     checkCam  = cameraObj.AddComponent <Camera>();

            cameraObj.AddComponent <AudioListener>();
            checkCam.depth = 100;
            cameraObj.transform.SetParent(checkParentObj.transform);
            float rate = spaceSize == SpaceSize.Small ? 0.5f : 2;

            cameraObj.transform.position = new Vector3(0, 2.5f * rate, -(10 + space));

            List <int> setPassCallsList = new List <int>();
            List <int> batchesList      = new List <int>();
            float      rotation         = 0;

            for (int i = 0; i < 360; i++)
            {
                if (EditorApplication.isPaused)
                {
                    EditorApplication.isPaused = false;
                }
                progress = (float)i / 360;
                if (EditorUtility.DisplayCancelableProgressBar(ProgressTitle, (progress * 100).ToString("F2") + "%", progress))
                {
                    EditorApplication.isPlaying = false;
                    EditorUtility.ClearProgressBar();
                    yield break;
                }
                checkParentObj.transform.rotation = Quaternion.Euler(0, rotation, 0);
                setPassCallsList.Add(UnityStats.setPassCalls);
                batchesList.Add(UnityStats.batches);
                rotation++;
                yield return(null);
            }

            Object.DestroyImmediate(cameraObj);
            Object.DestroyImmediate(checkParentObj);

            int setPassCalls = (int)setPassCallsList.Average();
            int batches      = (int)batchesList.Average();

            EditorUtility.ClearProgressBar();

            yield return(setPassCalls, batches);
        }