Esempio n. 1
0
        public async Task ConfigureAsync(string configFile)
        {
            var serializer = new XmlSerializer(typeof(Configuration));

            await using var fs = File.OpenRead(configFile);

            Logger.Config = Config = (Configuration)serializer.Deserialize(fs);

            if (!File.Exists(configFile))
            {
                throw new ArgumentException($"{configFile} config file does not exist.");
            }

            if (!string.IsNullOrWhiteSpace(Config.ResourcesConfiguration?.GameResourceFolder))
            {
                Resources = new LocalResources(Config);
            }

            ServerSpecification specification;

            await using (var ctx = new NovaContext())
            {
                specification = await ctx.Specifications.FirstAsync(s => s.Id == Id);
            }

            Port = specification.Port;

            _server = new RakNetServer(Port, "3.25 ND1");
        }
Esempio n. 2
0
        /// <summary>
        /// Factory method to apply memcache required configuration based on the installed SDK version.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        /// <param name="sdkVersion">The current SDK version</param>
        private void CachingConfigurationFactoryMethod(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings,
            string sdkVersion)
        {
            switch (sdkVersion)
            {
            case SDKVersion.Version180:
                Version180Configuration(
                    azureService,
                    roleName,
                    isWebRole,
                    cacheWorkerRole,
                    startup,
                    endpoints,
                    localResources,
                    ref configurationSettings);
                break;

            default:
                throw new Exception(string.Format(Resources.AzureSdkVersionNotSupported,
                                                  Resources.MinSupportAzureSdkVersion, Resources.MaxSupportAzureSdkVersion));
            }
        }
Esempio n. 3
0
    public Sprite GetImage()
    {
        Texture2D texture = null;
        Sprite    sprite  = null;

        if (GameObject.Find("LocalResources") == null)
        {
            texture = Resources.Load <Texture>("Music/" + path + "/image") as Texture2D;
            if (texture != null)
            {
                sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            }
        }
        else
        {
            Debug.Log("aclip:" + path + "/image");
            GameObject     gameObject     = GameObject.Find("LocalResources");
            LocalResources localResources = gameObject.GetComponent <LocalResources>();

            Debug.Log("local" + localResources);
            texture = (UnityEngine.Texture)localResources.GetLoadFile(path + "/image") as Texture2D;
            Debug.Log("texture" + texture);
            sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
        }
        return(sprite);
    }
Esempio n. 4
0
        public virtual async Task ConfigureAsync(string configFile)
        {
            MasterPath = Path.GetDirectoryName(configFile);

            var serializer = new XmlSerializer(typeof(Configuration));

            if (!File.Exists(configFile))
            {
                throw new ArgumentException($"{configFile} config file does not exist.");
            }

            await using (var fs = File.OpenRead(configFile))
            {
                Logger.Config = Config = (Configuration)serializer.Deserialize(fs);

                UchuContextBase.Config = Config;
            }

            await SetupApiAsync().ConfigureAwait(false);

            if (!string.IsNullOrWhiteSpace(Config.ResourcesConfiguration?.GameResourceFolder))
            {
                Resources = new LocalResources(Config);
            }

            var certificateFilePath = Path.Combine(MasterPath, Config.Networking.Certificate);

            if (Config.Networking?.Certificate != default && File.Exists(certificateFilePath))
            {
                var cert = new X509Certificate2(certificateFilePath);

                Logger.Information($"PRIVATE KEY: {cert.HasPrivateKey} {cert.PrivateKey}");

                Certificate = cert;

                RakNetServer = new TcpUdpServer(Port, "3.25 ND1", Certificate, 150);
            }
            else
            {
                RakNetServer = new TcpUdpServer(Port, "3.25 ND1");
            }

            SsoService = new SsoService(Config.SsoConfig?.Domain ?? "");

            try
            {
                SessionCache = new RedisSessionCache();
            }
            catch (RedisConnectionException)
            {
                Logger.Error("Failed to establish Redis connection, falling back to database.");

                SessionCache = new DatabaseCache();
            }

            Logger.Information($"Server {Id} configured on port: {Port}");
        }
Esempio n. 5
0
        private void setLocalResources(ActionExecutedContext filterContext)
        {
            // Get csv file name as Controller name + actionResult
            string page =
                (
                    filterContext.ActionDescriptor.ControllerDescriptor.ControllerName
                    + filterContext.ActionDescriptor.ActionName
                ).ToUpper();

            // Get resources from IOC and get csv.
            LocalResources.getResources(page);
        }
Esempio n. 6
0
        public static IResources InResources(this IResources resources)
        {
            if (resources is LocalResources)
            {
                return(resources);
            }

            if (localResources == null)
            {
                localResources = new LocalResources();
            }

            return(localResources);
        }
Esempio n. 7
0
        void Start()
        {
            /* Loads a text. Path:Resources/test.txt */
            ApplicationContext context   = Context.GetApplicationContext();
            IResources         resources = context.GetService <IResources>();
            TextAsset          text      = resources.InResources().LoadAsset <TextAsset>("test.txt");

            Debug.Log(text.text);

            // or

            LocalResources localResources = new LocalResources();

            text = localResources.LoadAsset <TextAsset>("test.txt");
            Debug.Log(text.text);
        }
Esempio n. 8
0
    public AudioClip GetAudioClip()
    {
        AudioClip aClip;

        if (GameObject.Find("LocalResources") == null)
        {
            aClip = Resources.Load <AudioClip>("Music/" + path + "/music");
        }
        else
        {
            Debug.Log("aclip:" + path + "/music");
            GameObject     gameObject     = GameObject.Find("LocalResources");
            LocalResources localResources = gameObject.GetComponent <LocalResources>();
            aClip = (AudioClip)localResources.GetLoadFile(path + "/music");
            Debug.Log(aClip);
        }
        return(aClip);
    }
Esempio n. 9
0
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                                                 roleName, new Dictionary <string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath      = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                                                 roleName, parameters);
            }

            // Add startup task to install memcache shim on the client side.
            string cacheRuntimeUri = CloudRuntimeCollection.GetRuntimeUrl(Resources.CacheRuntimeValue, CacheRuntimeVersion);

            Debug.Assert(!string.IsNullOrEmpty(cacheRuntimeUri));
            Variable emulated = new Variable {
                name = Resources.EmulatedKey, RoleInstanceValue = new RoleInstanceValueElement {
                    xpath = "/RoleEnvironment/Deployment/@emulated"
                }
            };

            Variable[] env = { emulated, new Variable {
                                   name = Resources.CacheRuntimeUrl,value = cacheRuntimeUri
                               } };
            Task       shimStartupTask = new Task {
                Environment = env, commandLine = Resources.CacheStartupCommand, executionContext = ExecutionContext.elevated
            };

            startup.Task = General.ExtendArray <Task>(startup.Task, shimStartupTask);

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name     = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port     = Resources.MemcacheEndpointPort
            };

            endpoints.InternalEndpoint = General.ExtendArray <InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };

            localResources.LocalStorage = General.ExtendArray <LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                name = Resources.CacheClientDiagnosticLevelAssemblyName
            };

            configurationSettings = General.ExtendArray <DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(azureService.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(azureService.Components.GetLocalConfigRole(roleName));
        }
Esempio n. 10
0
        /// <summary>
        /// Configures the server by parsing config files and setting up certificates.
        /// </summary>
        /// <param name="configFile">The config file to use as configuration</param>
        /// <exception cref="ArgumentException">If the provided config file can't be found</exception>
        public virtual async Task ConfigureAsync(string configFile)
        {
            if (configFile == null)
            {
                throw new ArgumentNullException(nameof(configFile),
                                                ResourceStrings.Server_ConfigureAsync_ConfigFileNullException);
            }

            MasterPath = Path.GetDirectoryName(configFile);
            Config     = UchuConfiguration.Load(configFile);
            if (!Config.DebugConfig.StartInstancesAsThreads)
            {
                Logger.SetConfiguration(Config);
            }
            UchuContextBase.Config = Config;

            if (!File.Exists(configFile))
            {
                throw new ArgumentException($"{configFile} config file does not exist.");
            }

            await SetupApiAsync().ConfigureAwait(false);

            if (!string.IsNullOrWhiteSpace(Config.ResourcesConfiguration?.GameResourceFolder))
            {
                Resources = new LocalResources(Config);
            }

            // Setup the RakNet server and possible certificate
            var certificateFilePath = Path.Combine(MasterPath, Config.Networking.Certificate);

            if (Config.Networking?.Certificate != default && File.Exists(certificateFilePath))
            {
                var cert = new X509Certificate2(certificateFilePath);
                Logger.Information($"PRIVATE KEY: {cert.HasPrivateKey} {cert.PrivateKey}");
                Certificate  = cert;
                RakNetServer = new TcpUdpServer(Port, "3.25 ND1", Certificate, 150);
            }
            else
            {
                RakNetServer = new TcpUdpServer(Port, "3.25 ND1");
            }

            SsoService = new SsoService(Config.SsoConfig?.Domain ?? "");

            // Try to connect to Redis, otherwise fallback to DB caching
            if (Config.CacheConfig.UseService)
            {
                try
                {
                    SessionCache = new RedisSessionCache(Config.CacheConfig);
                    Logger.Information($"Established Redis connection at {Config.CacheConfig.Host}:{Config.CacheConfig.Port}");
                }
                catch (RedisConnectionException)
                {
                    Logger.Error("Failed to establish Redis connection, falling back to database.");
                    SessionCache = new DatabaseCache();
                }
            }
            else
            {
                Logger.Information("Caching service is disabled, falling back to database.");
                SessionCache = new DatabaseCache();
            }

            HeartBeatsPerInterval      = Config.Networking.WorldServerHeartBeatsPerInterval;
            HeartBeatIntervalInMinutes = Config.Networking.WorldServerHeartBeatIntervalInMinutes;

            Logger.Information($"Server {Id} configured on port: {Port}");
        }
Esempio n. 11
0
 public void SetLocalResources(LocalResources localResources)
 {
     this.localResources = localResources;
 }
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                    roleName, new Dictionary<string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                    roleName, parameters);
            }

            // Add startup task to install memcache shim on the client side.
            string cacheRuntimeUri = CloudRuntimeCollection.GetRuntimeUrl(Resources.CacheRuntimeValue, CacheRuntimeVersion);
            Debug.Assert(!string.IsNullOrEmpty(cacheRuntimeUri));
            Variable emulated = new Variable { name = Resources.EmulatedKey, RoleInstanceValue = new RoleInstanceValueElement { xpath = "/RoleEnvironment/Deployment/@emulated" } };
            Variable[] env = { emulated, new Variable { name = Resources.CacheRuntimeUrl, value = cacheRuntimeUri } };
            Task shimStartupTask = new Task { Environment = env, commandLine = Resources.CacheStartupCommand, executionContext = ExecutionContext.elevated };
            startup.Task = CloudServiceUtilities.ExtendArray<Task>(startup.Task, shimStartupTask);

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port = Resources.MemcacheEndpointPort
            };
            endpoints.InternalEndpoint = CloudServiceUtilities.ExtendArray<InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };
            localResources.LocalStorage = CloudServiceUtilities.ExtendArray<LocalStore>(localResources.LocalStorage, localStore);

            DefConfigurationSetting diagnosticLevel = new DefConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName };
            configurationSettings = CloudServiceUtilities.ExtendArray<DefConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(azureService.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(azureService.Components.GetLocalConfigRole(roleName));
        }
        /// <summary>
        /// Factory method to apply memcache required configuration based on the installed SDK version.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        /// <param name="sdkVersion">The current SDK version</param>
        private void CachingConfigurationFactoryMethod(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefConfigurationSetting[] configurationSettings,
            string sdkVersion)
        {
            switch (sdkVersion)
            {
                case SDKVersion.Version180:
                    Version180Configuration(
                        azureService,
                        roleName,
                        isWebRole,
                        cacheWorkerRole,
                        startup,
                        endpoints,
                        localResources,
                        ref configurationSettings);
                    break;

                default:
                    throw new Exception(string.Format(Resources.AzureSdkVersionNotSupported,
                        Resources.MinSupportAzureSdkVersion, Resources.MaxSupportAzureSdkVersion));
            }
        }
        private static void CacheClientCommonConfiguration(
            CloudServiceProject cloudServiceProject,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                    roleName, new Dictionary<string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                    roleName, parameters);
            }

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port = Resources.MemcacheEndpointPort
            };
            endpoints.InternalEndpoint = GeneralUtilities.ExtendArray<InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };
            localResources.LocalStorage = GeneralUtilities.ExtendArray<LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName };
            configurationSettings = GeneralUtilities.ExtendArray<DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetLocalConfigRole(roleName));
        }
Esempio n. 15
0
 public static void LocalResourcesLocalStoreExists(LocalStore expected, LocalResources actual)
 {
     Assert.IsTrue(Array.Exists <LocalStore>(actual.LocalStorage, l => l.name.Equals(expected.name) &&
                                             l.cleanOnRoleRecycle.Equals(expected.cleanOnRoleRecycle) && l.sizeInMB.Equals(expected.sizeInMB)));
 }
Esempio n. 16
0
 public static void LocalResourcesLocalStoreExists(LocalStore expected, LocalResources actual)
 {
     Assert.IsTrue(Array.Exists<LocalStore>(actual.LocalStorage, l => l.name.Equals(expected.name) &&
         l.cleanOnRoleRecycle.Equals(expected.cleanOnRoleRecycle) && l.sizeInMB.Equals(expected.sizeInMB)));
 }
Esempio n. 17
0
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="cloudServiceProject">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            CloudServiceProject cloudServiceProject,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                                                        roleName, new Dictionary <string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath      = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                                                        roleName, parameters);
            }

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name     = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port     = Resources.MemcacheEndpointPort
            };

            endpoints.InternalEndpoint = General.ExtendArray <InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };

            localResources.LocalStorage = General.ExtendArray <LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                name = Resources.CacheClientDiagnosticLevelAssemblyName
            };

            configurationSettings = General.ExtendArray <DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetLocalConfigRole(roleName));
        }
Esempio n. 18
0
    protected override void Load()
    {
        SimpleMusicData musicData;
        MusicInf        inf;

        MusicDTO.EditData data;
        MusicOldDTO       oldData;
        GameObject        gameObject     = GameObject.Find("LocalResources");
        LocalResources    localResources = gameObject.GetComponent <LocalResources>();
        string            folder         = "/music";

#if UNITY_EDITOR
        folder = "/resources/music";
#endif

        if (System.IO.Directory.Exists(@Application.dataPath + folder))
        {
            string[] directories = System.IO.Directory.GetDirectories(@Application.dataPath + "/resources/music", "*");
            string   json;
            for (int i = 0; i < directories.Length; i++)
            {
                // id,pathを読み込む
                MusicListItemJson item;
                item    = new MusicListItemJson();
                item.id = startId + i;

                if (System.IO.Directory.Exists(directories[i]))
                {
                    if (System.IO.File.Exists(directories[i] + "/info.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/info");
                        inf  = JsonUtility.FromJson <MusicInf>(json);
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/music.wav"))
                    {
                        item.path = directories[i];
                    }
                    else if (System.IO.File.Exists(directories[i] + "/music.mp3"))
                    {
                        item.path = directories[i];
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/score.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/score");

                        // 譜面情報を読み込む
                        if (inf.score_ver == 1)
                        {
                            data = JsonUtility.FromJson <MusicDTO.EditData>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, data);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else if (inf.score_ver == 0)
                        {
                            oldData = JsonUtility.FromJson <MusicOldDTO>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, oldData);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    musicDataList.Add(musicData);
                }
            }
        }
    }