Example #1
0
    public static UIBlocker Create(Transform requester)
    {
        // Make sure the requester is not null
        if (!requester)
        {
            throw new System.ArgumentNullException(nameof(requester));
        }

        Canvas canvas = requester.GetComponentInParent <Canvas>();

        // If there is no canvas in the parent then throw exception
        if (!canvas)
        {
            throw new System.ArgumentException(
                      $"Cannot request a UIBlocker for object {requester} " +
                      $"because it is not a canvas or a child of a canvas!");
        }

        // Make sure we have the root canvas
        canvas = canvas.rootCanvas;

        // Create a UI blocker from resources
        UIBlocker instance = ResourcesExtensions.InstantiateFromResources <UIBlocker>(nameof(UIBlocker), canvas.transform);

        instance.transform.SetAsLastSibling();

        return(instance);
    }
        private IEnumerable <string> GetmainResxKeys(FileInfo file)
        {
            var relativeDirectory = _routesManager.GetRelativeDirectoryFromSource(file.Directory);
            var mainFile          = _routesManager.GetFileFromDestination(Path.Combine(relativeDirectory, Routes.ResourcesFilePath));

            return(ResourcesExtensions.GetResourcesByFile(mainFile.FullName).Keys);
        }
Example #3
0
    public static void StartMusic()
    {
        MusicManager managerInstance = ResourcesExtensions.InstantiateFromResources <MusicManager>(prefabPath, null);

        instance = managerInstance;
        DontDestroyOnLoad(managerInstance);
    }
Example #4
0
 public static TutorialUI InstantiateFromResources(Transform parent, string resourcePath = null)
 {
     if (string.IsNullOrWhiteSpace(resourcePath))
     {
         resourcePath = defaultResourcePath;
     }
     return(ResourcesExtensions.InstantiateFromResources <TutorialUI>(resourcePath, parent));
 }
 public static GenericYesNoWindow InstantiateFromResource(Transform parent, string prefabPath = null)
 {
     if (string.IsNullOrWhiteSpace(prefabPath))
     {
         prefabPath = defaultPrefabPath;
     }
     return(ResourcesExtensions.InstantiateFromResources <GenericYesNoWindow>(prefabPath, parent));
 }
Example #6
0
 public static UnlockUI InstantiateFromResources(Transform parent, string prefabPath = null)
 {
     if (string.IsNullOrWhiteSpace(prefabPath))
     {
         prefabPath = defaultResourcePath;
     }
     return(ResourcesExtensions.InstantiateFromResources <UnlockUI>(prefabPath, parent));
 }
        public Task <GeoAddress> GetAddressDetailAsync(string id)
        {
            var client   = GetClient(PlaceDetailsServiceUrl);
            var resource = GetPlaceDetailRequest(id);

            Func <PlaceDetailResponse, GeoAddress> selector = response => ResourcesExtensions.ConvertGeoObjectToAddress(response.Result);

            return(HandleGoogleResultAsync(() => client.GetAsync <PlaceDetailResponse>(resource), selector, new GeoAddress()));
        }
Example #8
0
    public static void Initialize()
    {
        // Instantiate the effects manager from the resources and make it not destroy on load
        instance = ResourcesExtensions.InstantiateFromResources <OutlineManager>(nameof(OutlineManager), null);
        DontDestroyOnLoad(instance);

        // Re-initialize the pools on scene loaded
        SceneManager.sceneLoaded += instance.OnSceneLoaded;
    }
Example #9
0
        // TODO: this method should not be in this class, since it is not a validating method,
        // but the _routesManager contains the necessary paths
        internal Dictionary <string, ResxItem> GetResourcesWithChanges(string resPath)
        {
            var originalResxPath = _routesManager.GetFileFromSource(resPath);
            var originalValues   = ResourcesExtensions.GetResourcesByFile(originalResxPath.FullName);

            var actualResxPath = _routesManager.GetFileFromDestination(resPath);
            var newValues      = ResourcesExtensions.GetResourcesByFile(actualResxPath.FullName);

            return(newValues.GetChangesFrom(originalValues));
        }
 /// <summary>
 /// Convert a SDK TagsResource object to PS PSTagResource
 /// </summary>
 /// <param name="tagsResource">SDK TagsResource extension method</param>
 /// <returns>PS object PSTagResource</returns>
 public static PSTagResource ToPSTagResource(this TagsResource tagsResource)
 {
     return(new PSTagResource
     {
         Id = tagsResource?.Id,
         Name = tagsResource?.Name,
         Type = tagsResource?.Type,
         Properties = new PSTagsObject(tagsResource?.Properties?.TagsProperty),
         PropertiesTable = ResourcesExtensions.ConstructTagsTable(TagsConversionHelper.CreateTagHashtable(tagsResource?.Properties?.TagsProperty))
     });
 }
        public void ConcatFile()
        {
            var root   = "SiCo.Utilities.Generics.Test.Resources.";
            var result = "FILE1CONTENTFILE2CONTENT";
            var text   = ResourcesExtensions.ConcatFile(
                typeof(StringExtensionsTest),
                root + "File1.txt",
                root + "File2.txt");

            Assert.Equal(result, text);
        }
Example #12
0
    public static void CreateDebuggingUI()
    {
        if (!instance)
        {
            instance = ResourcesExtensions.InstantiateFromResources <DebuggingUI>(prefabPath, null);
            DontDestroyOnLoad(instance.gameObject);

            // Update the ui each time that a new scene is loaded
            SceneManager.sceneLoaded += instance.UpdateUI;
        }
    }
Example #13
0
    public static void CreateInstance()
    {
        if (!instance)
        {
            // Try to instantiate the component from the resources folder
            string typename = typeof(BehaviourType).Name;
            instance = ResourcesExtensions.InstantiateFromResources <BehaviourType>(typename, null);

            // Make the instance not destroyed on load
            DontDestroyOnLoad(instance);
        }
    }
        public async Task <GeoPlace> GetPlaceDetailAsync(string id)
        {
            var client   = GetClient(PlaceDetailsServiceUrl);
            var resource = GetPlaceDetailRequest(id);

            Func <PlaceDetailResponse, GeoPlace> selector = response => new GeoPlace
            {
                Id      = id,
                Name    = response.Result.Formatted_address,
                Address = ResourcesExtensions.ConvertGeoObjectToAddress(response.Result)
            };

            return(await HandleGoogleResultAsync(() => client.GetAsync <PlaceDetailResponse>(resource), selector, new GeoPlace()).ConfigureAwait(false));
        }
Example #15
0
        internal bool HasResourceChanges(string resPath)
        {
            if (!_routesManager.ExistInSourceAndDestination(resPath))
            {
                return(true);
            }

            var originalResxPath = _routesManager.GetFileFromSource(resPath);
            var originalResx     = ResourcesExtensions.GetResourcesByFile(originalResxPath.FullName);

            var actualResxPath = _routesManager.GetFileFromDestination(resPath);
            var actualResx     = ResourcesExtensions.GetResourcesByFile(actualResxPath.FullName);

            return(!originalResx.AreEquals(actualResx));
        }
Example #16
0
        private void VerifyResourceContent(string directory, string fileName)
        {
            var resxFile  = Path.Combine(_sourceDir.FullName, directory, fileName);
            var resources = ResourcesExtensions.GetResourcesByFile(resxFile);

            foreach (var culture in _cultures)
            {
                var cultureFile = new FileInfo(Path.Combine(_sourceDir.FullName, directory, string.Format(Routes.ResourcesFilePathPattern, culture)));

                if (cultureFile.Exists)
                {
                    var cultureResources = ResourcesExtensions.GetResourcesByFile(cultureFile.FullName);
                    VerifyResourceValues(resources.Keys, cultureResources.Keys, resxFile, cultureFile.FullName);
                    VerifyResourcesFormat(resources, cultureResources, resxFile, cultureFile.FullName);
                }
            }
        }
        private void MergeResxFile(FileInfo file)
        {
            var mainKeys     = GetmainResxKeys(file);
            var relativePath = _routesManager.GetRelativePathFromSourceFile(file);
            var destFile     = _routesManager.GetFileFromDestination(relativePath);

            var newResxItems    = ResourcesExtensions.GetResourcesByFile(file.FullName);
            var sourceResxItems = ResourcesExtensions.GetResourcesByFile(destFile.FullName)
                                  .Where(item => mainKeys.Contains(item.Key) && !newResxItems.Keys.Contains(item.Key));

            foreach (var item in sourceResxItems)
            {
                newResxItems.Add(item.Key, item.Value);
            }

            ResourcesExtensions.CreateResxFile(destFile.FullName, newResxItems);
        }
        internal void ExtractResourceFiles()
        {
            foreach (string directory in Routes.ResoureceDirectories)
            {
                var srcResFile    = Path.Combine(directory, Routes.ResourcesFilePath);
                var newResxValues = _validator.GetResourcesWithChanges(srcResFile);

                if (newResxValues.Any())
                {
                    var desDirectory = _routesManager.GetOrCreateDestDirectory(directory).FullName;
                    var resourceFile = ResourcesExtensions.CreateResxFile(Path.Combine(desDirectory, Routes.ResourcesFilePath), newResxValues);

                    foreach (string culture in _cultures)
                    {
                        string destResFile = Path.Combine(desDirectory, string.Format(Routes.ResourcesFilePathPattern, culture));
                        resourceFile.CopyTo(destResFile, true);
                    }

                    resourceFile.Delete();
                }
            }
        }
        public Common()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Environment.CurrentDirectory)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();
            var config = builder.Build();

            this.ConnectionString = config.GetConnectionString("TestConnection");

            // db
            this.QueryDrop   = "DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public; ALTER SCHEMA public OWNER TO admin;";
            this.QueryCreate = ResourcesExtensions.ConcatFile(typeof(Common), "SiCo.Utilities.Pgsql.Test.Resources.db_raw.sql");
            this.QueryClean  = @"
    TRUNCATE public.enum CASCADE;
    TRUNCATE public.log CASCADE;
    TRUNCATE public.sample CASCADE";

            // log
            this.InsertLog = @"INSERT INTO log (membership_id, path, section, action, status, message, created, triggered_by) VALUES
('3004fbb1-da84-426a-a669-0cbc111dcc97', 'Log.Sample', 'Manual', 0, 0, 'Add sample log 1', '2016-04-06 20:39:33.66683', NULL),
('3004fbb1-da84-426a-a669-0cbc111dcc97', 'Log.Sample', 'Manual', 1, 1, 'Add sample log 2', '2016-04-06 21:20:33.66683', NULL),
('3004fbb1-da84-426a-a669-0cbc111dcc97', 'Log.Sample', 'Manual', 2, 2, 'Add sample log 3', '2016-04-06 22:41:33.66683', NULL);";
        }
Example #20
0
 public Player(PlayerColour colour, string name, ResourceSet resources = null)
 {
     Colour    = colour;
     Name      = name;
     Resources = resources ?? new ResourceSet(ResourcesExtensions.CreateEach());
 }
Example #21
0
 public static void Initialize()
 {
     instance = ResourcesExtensions.InstantiateFromResources <AudioPanel>(nameof(AudioPanel), null);
     DontDestroyOnLoad(instance);
 }