コード例 #1
0
        /// <summary>
        /// Constructs a ModuleDescriptor from a Json object
        /// </summary>
        /// <param name="InObject"></param>
        /// <returns>The new module descriptor</returns>
        public static ModuleDescriptor FromJsonObject(JsonObject InObject)
        {
            ModuleDescriptor Module = new ModuleDescriptor(InObject.GetStringField("Name"), InObject.GetEnumField <ModuleHostType>("Type"));

            ModuleLoadingPhase LoadingPhase;

            if (InObject.TryGetEnumField <ModuleLoadingPhase>("LoadingPhase", out LoadingPhase))
            {
                Module.LoadingPhase = LoadingPhase;
            }

            try
            {
                string[] WhitelistPlatforms;
                if (InObject.TryGetStringArrayField("WhitelistPlatforms", out WhitelistPlatforms))
                {
                    Module.WhitelistPlatforms = Array.ConvertAll(WhitelistPlatforms, x => UnrealTargetPlatform.Parse(x));
                }

                string[] BlacklistPlatforms;
                if (InObject.TryGetStringArrayField("BlacklistPlatforms", out BlacklistPlatforms))
                {
                    Module.BlacklistPlatforms = Array.ConvertAll(BlacklistPlatforms, x => UnrealTargetPlatform.Parse(x));
                }
            }
            catch (BuildException Ex)
            {
                ExceptionUtils.AddContext(Ex, "while parsing module descriptor '{0}'", Module.Name);
                throw;
            }

            TargetType[] WhitelistTargets;
            if (InObject.TryGetEnumArrayField <TargetType>("WhitelistTargets", out WhitelistTargets))
            {
                Module.WhitelistTargets = WhitelistTargets;
            }

            TargetType[] BlacklistTargets;
            if (InObject.TryGetEnumArrayField <TargetType>("BlacklistTargets", out BlacklistTargets))
            {
                Module.BlacklistTargets = BlacklistTargets;
            }

            UnrealTargetConfiguration[] WhitelistTargetConfigurations;
            if (InObject.TryGetEnumArrayField <UnrealTargetConfiguration>("WhitelistTargetConfigurations", out WhitelistTargetConfigurations))
            {
                Module.WhitelistTargetConfigurations = WhitelistTargetConfigurations;
            }

            UnrealTargetConfiguration[] BlacklistTargetConfigurations;
            if (InObject.TryGetEnumArrayField <UnrealTargetConfiguration>("BlacklistTargetConfigurations", out BlacklistTargetConfigurations))
            {
                Module.BlacklistTargetConfigurations = BlacklistTargetConfigurations;
            }

            string[] WhitelistPrograms;
            if (InObject.TryGetStringArrayField("WhitelistPrograms", out WhitelistPrograms))
            {
                Module.WhitelistPrograms = WhitelistPrograms;
            }

            string[] BlacklistPrograms;
            if (InObject.TryGetStringArrayField("BlacklistPrograms", out BlacklistPrograms))
            {
                Module.BlacklistPrograms = BlacklistPrograms;
            }

            string[] AdditionalDependencies;
            if (InObject.TryGetStringArrayField("AdditionalDependencies", out AdditionalDependencies))
            {
                Module.AdditionalDependencies = AdditionalDependencies;
            }

            return(Module);
        }