TryGetUnsignedIntegerField() public method

public TryGetUnsignedIntegerField ( string FieldName, uint &Result ) : bool
FieldName string
Result uint
return bool
コード例 #1
0
        /// <summary>
        /// Creates a plugin descriptor from a file on disk
        /// </summary>
        /// <param name="FileName">The filename to read</param>
        /// <returns>New plugin descriptor</returns>
        public static ProjectDescriptor FromFile(string FileName)
        {
            JsonObject RawObject = JsonObject.Read(FileName);

            try
            {
                ProjectDescriptor Descriptor = new ProjectDescriptor();

                // Read the version
                if (!RawObject.TryGetIntegerField("FileVersion", out Descriptor.FileVersion))
                {
                    if (!RawObject.TryGetIntegerField("ProjectFileVersion", out Descriptor.FileVersion))
                    {
                        throw new BuildException("Project descriptor '{0}' does not contain a valid FileVersion entry", FileName);
                    }
                }

                // Check it's not newer than the latest version we can parse
                if (Descriptor.FileVersion > (int)PluginDescriptorVersion.Latest)
                {
                    throw new BuildException("Project descriptor '{0}' appears to be in a newer version ({1}) of the file format that we can load (max version: {2}).", FileName, Descriptor.FileVersion, (int)ProjectDescriptorVersion.Latest);
                }

                // Read simple fields
                RawObject.TryGetStringField("EngineAssociation", out Descriptor.EngineAssociation);
                RawObject.TryGetStringField("Category", out Descriptor.Category);
                RawObject.TryGetStringField("Description", out Descriptor.Description);

                // Read the modules
                JsonObject[] ModulesArray;
                if (RawObject.TryGetObjectArrayField("Modules", out ModulesArray))
                {
                    Descriptor.Modules = Array.ConvertAll(ModulesArray, x => ModuleDescriptor.FromJsonObject(x));
                }

                // Read the plugins
                JsonObject[] PluginsArray;
                if (RawObject.TryGetObjectArrayField("Plugins", out PluginsArray))
                {
                    Descriptor.Plugins = Array.ConvertAll(PluginsArray, x => PluginReferenceDescriptor.FromJsonObject(x));
                }

                // Read the target platforms
                RawObject.TryGetStringArrayField("TargetPlatforms", out Descriptor.TargetPlatforms);

                // Get the sample name hash
                RawObject.TryGetUnsignedIntegerField("EpicSampleNameHash", out Descriptor.EpicSampleNameHash);

                // Read the pre and post-build steps
                CustomBuildSteps.TryRead(RawObject, "PreBuildSteps", out Descriptor.PreBuildSteps);
                CustomBuildSteps.TryRead(RawObject, "PostBuildSteps", out Descriptor.PostBuildSteps);

                return(Descriptor);
            }
            catch (JsonParseException ParseException)
            {
                throw new JsonParseException("{0} (in {1})", ParseException.Message, FileName);
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="RawObject">Raw JSON object to parse</param>
        public ProjectDescriptor(JsonObject RawObject)
        {
            // Read the version
            if (!RawObject.TryGetIntegerField("FileVersion", out FileVersion))
            {
                if (!RawObject.TryGetIntegerField("ProjectFileVersion", out FileVersion))
                {
                    throw new BuildException("Project does not contain a valid FileVersion entry");
                }
            }

            // Check it's not newer than the latest version we can parse
            if (FileVersion > (int)PluginDescriptorVersion.Latest)
            {
                throw new BuildException("Project descriptor appears to be in a newer version ({0}) of the file format that we can load (max version: {1}).", FileVersion, (int)ProjectDescriptorVersion.Latest);
            }

            // Read simple fields
            RawObject.TryGetStringField("EngineAssociation", out EngineAssociation);
            RawObject.TryGetStringField("Category", out Category);
            RawObject.TryGetStringField("Description", out Description);
            RawObject.TryGetBoolField("Enterprise", out IsEnterpriseProject);

            // Read the modules
            JsonObject[] ModulesArray;
            if (RawObject.TryGetObjectArrayField("Modules", out ModulesArray))
            {
                Modules = Array.ConvertAll(ModulesArray, x => ModuleDescriptor.FromJsonObject(x));
            }

            // Read the plugins
            JsonObject[] PluginsArray;
            if (RawObject.TryGetObjectArrayField("Plugins", out PluginsArray))
            {
                Plugins = Array.ConvertAll(PluginsArray, x => PluginReferenceDescriptor.FromJsonObject(x));
            }

            // Read the additional plugin directories
            RawObject.TryGetStringArrayField("AdditionalPluginDirectories", out AdditionalPluginDirectories);

            // Read the target platforms
            RawObject.TryGetStringArrayField("TargetPlatforms", out TargetPlatforms);

            // Get the sample name hash
            RawObject.TryGetUnsignedIntegerField("EpicSampleNameHash", out EpicSampleNameHash);

            // Read the pre and post-build steps
            CustomBuildSteps.TryRead(RawObject, "PreBuildSteps", out PreBuildSteps);
            CustomBuildSteps.TryRead(RawObject, "PostBuildSteps", out PostBuildSteps);
        }
        /// <summary>
        /// Creates a plugin descriptor from a file on disk
        /// </summary>
        /// <param name="FileName">The filename to read</param>
        /// <returns>New plugin descriptor</returns>
        public static ProjectDescriptor FromFile(string FileName)
        {
            JsonObject RawObject = JsonObject.Read(FileName);

            try
            {
                ProjectDescriptor Descriptor = new ProjectDescriptor();

                // Read the version
                if (!RawObject.TryGetIntegerField("FileVersion", out Descriptor.FileVersion))
                {
                    if (!RawObject.TryGetIntegerField("ProjectFileVersion", out Descriptor.FileVersion))
                    {
                        throw new BuildException("Project descriptor '{0}' does not contain a valid FileVersion entry", FileName);
                    }
                }

                // Check it's not newer than the latest version we can parse
                if (Descriptor.FileVersion > (int)PluginDescriptorVersion.Latest)
                {
                    throw new BuildException("Project descriptor '{0}' appears to be in a newer version ({1}) of the file format that we can load (max version: {2}).", FileName, Descriptor.FileVersion, (int)ProjectDescriptorVersion.Latest);
                }

                // Read simple fields
                RawObject.TryGetStringField("EngineAssociation", out Descriptor.EngineAssociation);
                RawObject.TryGetStringField("Category", out Descriptor.Category);
                RawObject.TryGetStringField("Description", out Descriptor.Description);

                // Read the modules
                JsonObject[] ModulesArray;
                if (RawObject.TryGetObjectArrayField("Modules", out ModulesArray))
                {
                    Descriptor.Modules = Array.ConvertAll(ModulesArray, x => ModuleDescriptor.FromJsonObject(x));
                }

                // Read the plugins
                JsonObject[] PluginsArray;
                if (RawObject.TryGetObjectArrayField("Plugins", out PluginsArray))
                {
                    Descriptor.Plugins = Array.ConvertAll(PluginsArray, x => PluginReferenceDescriptor.FromJsonObject(x));
                }

                string[] Dirs;
                Descriptor.AdditionalPluginDirectories = new List <DirectoryReference>();
                // Read the additional plugin directories
                if (RawObject.TryGetStringArrayField("AdditionalPluginDirectories", out Dirs))
                {
                    for (int Index = 0; Index < Dirs.Length; Index++)
                    {
                        if (Path.IsPathRooted(Dirs[Index]))
                        {
                            // Absolute path so create in place
                            Descriptor.AdditionalPluginDirectories.Add(new DirectoryReference(Dirs[Index]));
                            Log.TraceVerbose("Project ({0}) : Added additional absolute plugin directory ({1})", FileName, Dirs[Index]);
                        }
                        else
                        {
                            // This path is relative to the project path so build that out
                            string RelativePath = Path.Combine(Path.GetDirectoryName(FileName), Dirs[Index]);
                            Descriptor.AdditionalPluginDirectories.Add(new DirectoryReference(RelativePath));
                            Log.TraceVerbose("Project ({0}) : Added additional relative plugin directory ({1})", FileName, Dirs[Index]);
                        }
                    }
                }

                // Read the target platforms
                RawObject.TryGetStringArrayField("TargetPlatforms", out Descriptor.TargetPlatforms);

                // Get the sample name hash
                RawObject.TryGetUnsignedIntegerField("EpicSampleNameHash", out Descriptor.EpicSampleNameHash);

                // Read the pre and post-build steps
                CustomBuildSteps.TryRead(RawObject, "PreBuildSteps", out Descriptor.PreBuildSteps);
                CustomBuildSteps.TryRead(RawObject, "PostBuildSteps", out Descriptor.PostBuildSteps);

                return(Descriptor);
            }
            catch (JsonParseException ParseException)
            {
                throw new JsonParseException("{0} (in {1})", ParseException.Message, FileName);
            }
        }