/// <summary>
 /// Constructor that takes a FileInfo and, if the file exists, triggers the load.
 /// </summary>
 /// <param name="passedFileInfo">The FileInfo representing the file to be loaded.</param>
 public StructureDefinitions_File(IParent_Json_File passedParent, FileInfo passedFileInfo) : base(passedParent, passedFileInfo)
 {
     //File = passedFileInfo ?? throw new NullReferenceException("passedFileInfo was null.");
     //// RootNode = new Blueprint_TN(this, nodeName: File.Name, newNodeType: Base_TN_NodeType.DataFile, nodeToolTipText: File.FullName);
     //if (File.Exists) LoadFile();
     //else Debug.Print("Structure definitions initialised but file {0} doesn't exist.", passedFileInfo.FullName);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Basic constructor.
 /// </summary>
 /// <param name="ownerObject"></param>
 public Json_File_UI(IParent_Json_File ownerObject) : base(ownerObject)
 {
     if (RootNode == null)
     {
         ReGenerateRootNode();
     }
     RootNode.OwnerObject = this;
 }
        /// <summary>
        /// General use constructor - takes a FileInfo and, if the file exists, triggers the load.
        /// </summary>
        /// <param name="passedFileInfo">The FileInfo representing the file to be loaded.</param>
        public StationBlueprint_File(IParent_Json_File passedParent, FileInfo stationBlueprintFileInfo)
            : base(passedParent, stationBlueprintFileInfo, autoDeserialise: true)
        {
            Debug.Print("StationBlueprint_File.ctor(FileInfo) called {0}", stationBlueprintFileInfo.FullName);

            // Re-assign the OwnerStructure (the base class stores this as an object,
            // we ideally need it in its native type to work with its methods.
            OwnerObject = passedParent; // ?? throw new NullReferenceException();

            // Create a new Blueprint object - possibly not required when opening from file.
            if (BlueprintObject == null)
            {
                BlueprintObject = new StationBlueprint(this, null);
            }
        }
        /// <summary>
        /// A constructor for creating a new file in memory using a JToken.
        /// </summary>
        /// <param name="passedParent"></param>
        /// <param name="jdata"></param>
        public StationBlueprint_File(IParent_Json_File passedParent, JToken jdata)
            : base(passedParent, jdata, autoDeserialise: true)
        {
            Debug.Print("StationBlueprint_File.ctor(JToken) called - HasValues [{0}]",
                        jdata != null ? jdata.HasValues.ToString() : "null");

            // Re-assign the OwnerStructure (the base class stores this as an object,
            // we ideally need it in its native type to work with its methods.
            OwnerObject = passedParent; // ?? throw new NullReferenceException();

            // Create a new Blueprint object - possibly not required when creating from JData.
            if (BlueprintObject == null)
            {
                BlueprintObject = new StationBlueprint(this, null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor that takes a FileInfo and, if the file exists, triggers the load.
        /// </summary>
        /// <param name="PassedFileInfo">The FileInfo representing the file to be loaded.</param>
        public Json_File_UI(IParent_Json_File ownerObject, FileInfo passedFileInfo, int populateDepth = 1)
            : base(ownerObject, passedFileInfo, autoDeserialise: false)
        {
            // Set the auto-population depth.
            PopulateDepth = populateDepth;

            // Create the root node for the file
            if (RootNode == null)
            {
                ReGenerateRootNode();
            }
            else
            {
                RootNode.Name = File.Name;
            }
            RootNode.OwnerObject = this;
        }
        /// <summary>
        /// Constructor that takes a DirectoryInfo and if valid, triggers the load
        /// </summary>
        /// <param name="passedDirectoryInfo"></param>
        /// <param name="autoPopulateTree"></param>
        public Json_FileCollection(IParent_Json_File passedParent, DirectoryInfo passedDirectoryInfo, int populateDepth = 0)
        {
            // Set up the data dictionary
            DataDictionary = new Dictionary <string, Json_File_UI>();

            // Check validity - if good load the data set
            OwnerObject       = passedParent ?? throw new InvalidOperationException("passedParent was null.");
            DataDirectoryInfo = passedDirectoryInfo ?? throw new NullReferenceException("passedDirectoryInfo was null.");
            if (!DataDirectoryInfo.Exists)
            {
                throw new DirectoryNotFoundException("DataDirectoryInfo reports the passed folder doesn't exist.");
            }

            RootNode = new Base_TN(ownerObject: this, nodeType: Base_TN_NodeType.DataFolder,
                                   nodeName: DataDirectoryInfo.Name);

            Load(populateDepth: populateDepth);
        }
 /// <summary>
 /// Constructor that takes a FileInfo and, if the file exists, triggers the load.
 /// </summary>
 /// <param name="passedFileInfo">The FileInfo representing the file to be loaded.</param>
 public GameSave_Json_File(IParent_Json_File passedParentObject, FileInfo passedFileInfo, int populateDepth)
     : base(passedParentObject, passedFileInfo, populateDepth)
 {
     RootNode.Name     = File.Name;
     RootNode.NodeType = Base_TN_NodeType.SaveFile;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Default constructor, not used directly but used by derived classes.
 /// </summary>
 public Json_File(IParent_Json_File ownerObject) => OwnerObject = ownerObject;