public void Remove(RootTag tag)
        {
            int index = (int)tag;

            if (_tag2go.ContainsKey(index))
            {
                _tag2go[index].DestroySelf();
                _tag2go.Remove(index);
            }
        }
        private GameObject InitRoot(RootTag tag)
        {
            var go = Root.GetChild(tag.ToString());

            if (!go)
            {
                go = Root.AddNewChildTo(tag.ToString());
            }
            int index = (int)tag;

            _tag2go[index] = go;
            return(_tag2go[index]);
        }
        public GameObject AddTo(RootTag tag, GameObject child)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return(child);
            }
#endif
            //#if UNITY_EDITOR
            child.transform.SetParent(GetRoot(tag).transform);
//#endif
            return(child);
        }
        public GameObject GetRoot(RootTag tag)
        {
            int index = (int)tag;

            if (_tag2go.ContainsKey(index))
            {
                return(_tag2go[index]);
            }
            else
            {
                return(InitRoot(tag));
            }
        }
Ejemplo n.º 5
0
 public string ToString([NotNull] string indentString)
 {
     return(RootTag.ToString(indentString));
 }
Ejemplo n.º 6
0
 /// <summary> Prints contents of the root tag, and any child tags, to a string. </summary>
 public override string ToString()
 {
     return(RootTag.ToString(NbtTag.DefaultIndentString));
 }
Ejemplo n.º 7
0
        /// <summary> Saves this NBT file to a stream. Nothing is written to stream if RootTag is <c>null</c>. </summary>
        /// <param name="stream"> Stream to write data to. May not be <c>null</c>. </param>
        /// <param name="compression"> Compression mode to use for saving. May not be AutoDetect. </param>
        /// <returns> Number of bytes written to the stream. </returns>
        /// <exception cref="ArgumentNullException"> <paramref name="stream"/> is <c>null</c>. </exception>
        /// <exception cref="ArgumentException"> If AutoDetect was given as the <paramref name="compression"/> mode. </exception>
        /// <exception cref="ArgumentOutOfRangeException"> If an unrecognized/unsupported value was given for <paramref name="compression"/>. </exception>
        /// <exception cref="InvalidDataException"> If given stream does not support writing. </exception>
        /// <exception cref="NbtFormatException"> If RootTag is null;
        /// or if RootTag is unnamed;
        /// or if one of the NbtCompound tags contained unnamed tags;
        /// or if an NbtList tag had Unknown list type and no elements. </exception>
        public long SaveToStream([NotNull] Stream stream, NbtCompression compression)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            switch (compression)
            {
            case NbtCompression.AutoDetect:
                throw new ArgumentException("AutoDetect is not a valid NbtCompression value for saving.");

            case NbtCompression.ZLib:
            case NbtCompression.GZip:
            case NbtCompression.None:
                break;

            default:
                throw new ArgumentOutOfRangeException("compression");
            }

            if (rootTag.Name == null)
            {
                // This may trigger if root tag has been renamed
                throw new NbtFormatException(
                          "Cannot save NbtFile: Root tag is not named. Its name may be an empty string, but not null.");
            }

            long startOffset = 0;

            if (stream.CanSeek)
            {
                startOffset = stream.Position;
            }
            else
            {
                stream = new ByteCountingStream(stream);
            }

            switch (compression)
            {
            case NbtCompression.ZLib:
                stream.WriteByte(0x78);
                stream.WriteByte(0x01);
                int checksum;
                using (var compressStream = new ZLibStream(stream, CompressionMode.Compress, true)) {
                    var bufferedStream = new BufferedStream(compressStream, WriteBufferSize);
                    RootTag.WriteTag(new NbtBinaryWriter(bufferedStream, BigEndian)
                    {
                        UseVarInt = UseVarInt
                    });
                    bufferedStream.Flush();
                    checksum = compressStream.Checksum;
                }
                byte[] checksumBytes = BitConverter.GetBytes(checksum);
                if (BitConverter.IsLittleEndian)
                {
                    // Adler32 checksum is big-endian
                    Array.Reverse(checksumBytes);
                }
                stream.Write(checksumBytes, 0, checksumBytes.Length);
                break;

            case NbtCompression.GZip:
                using (var compressStream = new GZipStream(stream, CompressionMode.Compress, true)) {
                    // use a buffered stream to avoid GZipping in small increments (which has a lot of overhead)
                    var bufferedStream = new BufferedStream(compressStream, WriteBufferSize);
                    RootTag.WriteTag(new NbtBinaryWriter(bufferedStream, BigEndian)
                    {
                        UseVarInt = UseVarInt
                    });
                    bufferedStream.Flush();
                }
                break;

            case NbtCompression.None:
                var writer = new NbtBinaryWriter(stream, BigEndian)
                {
                    UseVarInt = UseVarInt
                };
                RootTag.WriteTag(writer);
                break;

            default:
                throw new ArgumentOutOfRangeException("compression");
            }

            if (stream.CanSeek)
            {
                return(stream.Position - startOffset);
            }
            else
            {
                return(((ByteCountingStream)stream).BytesWritten);
            }
        }
 public T AddComp <T>(RootTag tag) where T : MonoBehaviour
 {
     return(GetRoot(tag).AddComponent <T>());
 }
Ejemplo n.º 9
0
        /// <summary> Saves this NBT file to a stream. Nothing is written to stream if RootTag is <c>null</c>. </summary>
        /// <param name="stream"> Stream to write data to. May not be <c>null</c>. </param>
        /// <param name="compression"> Compression mode to use for saving. May not be AutoDetect. </param>
        /// <returns> Number of bytes written to the stream. </returns>
        /// <exception cref="ArgumentNullException"> <paramref name="stream"/> is <c>null</c>. </exception>
        /// <exception cref="ArgumentException"> If AutoDetect was given as the <paramref name="compression"/> mode. </exception>
        /// <exception cref="ArgumentOutOfRangeException"> If an unrecognized/unsupported value was given for <paramref name="compression"/>. </exception>
        /// <exception cref="InvalidDataException"> If given stream does not support writing. </exception>
        /// <exception cref="NbtFormatException"> If RootTag is null;
        /// or if RootTag is unnamed;
        /// or if one of the NbtCompound tags contained unnamed tags;
        /// or if an NbtList tag had Unknown list type and no elements. </exception>
        public int SaveToStream([NotNull] Stream stream, NbtCompression compression)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            switch (compression)
            {
            case NbtCompression.AutoDetect:
                throw new ArgumentException("AutoDetect is not a valid NbtCompression value for saving.");

            case NbtCompression.ZLib:
            case NbtCompression.GZip:
            case NbtCompression.None:
                break;

            default:
                throw new ArgumentOutOfRangeException("compression");
            }

            if (rootTag == null)
            {
                throw new NbtFormatException("Cannot save NbtFile: No root tag.");
            }

            if (rootTag.Name == null)
            {
                throw new NbtFormatException(
                          "Cannot save NbtFile: Root tag is not named. Its name may be an empty string, but not null.");
            }

            long startPosition = stream.Position;

            switch (compression)
            {
            case NbtCompression.ZLib:
                stream.WriteByte(0x78);
                stream.WriteByte(0x01);
                int checksum;
                using (var compressStream = new ZLibStream(stream, CompressionMode.Compress, true)) {
                    BufferedStream bufferedStream = new BufferedStream(compressStream, WriteBufferSize);
                    RootTag.WriteTag(new NbtBinaryWriter(bufferedStream, BigEndian), true);
                    bufferedStream.Flush();
                    checksum = compressStream.Checksum;
                }
                byte[] checksumBytes = BitConverter.GetBytes(checksum);
                if (BitConverter.IsLittleEndian)
                {
                    // Adler32 checksum is big-endian
                    Array.Reverse(checksumBytes);
                }
                stream.Write(checksumBytes, 0, checksumBytes.Length);
                break;

            case NbtCompression.GZip:
                using (var compressStream = new GZipStream(stream, CompressionMode.Compress, true)) {
                    // use a buffered stream to avoid gzipping in small increments (which has a lot of overhead)
                    BufferedStream bufferedStream = new BufferedStream(compressStream, WriteBufferSize);
                    RootTag.WriteTag(new NbtBinaryWriter(bufferedStream, BigEndian), true);
                    bufferedStream.Flush();
                }
                break;

            case NbtCompression.None:
                RootTag.WriteTag(new NbtBinaryWriter(stream, BigEndian), true);
                break;
            }

            return((int)(stream.Position - startPosition));
        }
        public static DataTable ReadXML(string folderPath)
        {
            List <Jscape_UserDetail>    lstUserDetails = new List <Jscape_UserDetail>();
            Dictionary <string, string> dctUserDetail  = new Dictionary <string, string>();
            int tagCounter = 0;

            //string folderPath = @"E:\Nishant_Backup_Mar2020\Nishant\Project\Fiserv\JscapeToSFG\POC\Users\Fiserv_CUSolutions";

            foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
            {
                // var updatedFile = Path.ChangeExtension(file, ".xml");
                // File.Move(file, Path.ChangeExtension(file, ".xml"));

                // XElement xelement = XElement.Load(updatedFile);

                XElement xelement           = XElement.Load(file);
                IEnumerable <XElement> tags = xelement.Elements();

                foreach (var RootTag in tags)
                {
                    IEnumerable <XElement> childElements = RootTag.Elements();
                    foreach (var element in childElements)
                    {
                        if (element.Name.LocalName.ToUpper().Equals("STRING") && tagCounter == 0)
                        {
                            dctUserDetail.Add("Name", element.Value);
                        }

                        if (element.Name.LocalName.ToUpper().Equals("STRING") && tagCounter == 1)
                        {
                            dctUserDetail.Add("LoginID", element.Value);
                            tagCounter++;
                        }

                        if (element.Attributes().Count() > 0)
                        {
                            var attributeName = element.Attributes().First().Name.LocalName;

                            if (!string.IsNullOrEmpty(attributeName) && attributeName.ToUpper().Equals("PROPERTY"))
                            {
                                var PropertyName   = element.Attribute(attributeName).Value;
                                var PeropertyValue = element.Value;

                                dctUserDetail.Add(PropertyName, PeropertyValue);
                            }
                        }

                        IEnumerable <XElement> lstTags = element.Descendants("void");
                        foreach (var tag in lstTags)
                        {
                            if (tag.Attributes().First().Name.LocalName.Equals("property"))
                            {
                                var attributeName = tag.Attributes().First().Name.LocalName;
                                var PropertyName  = tag.Attribute(attributeName).Value;

                                if (PropertyName.ToUpper().Equals("REALPATH"))
                                {
                                    var PeropertyValue = tag.Value;
                                    dctUserDetail.Add(PropertyName, PeropertyValue);
                                }
                            }
                        }

                        if (tagCounter == 0)
                        {
                            tagCounter++;
                        }
                    }
                }

                CreateUserRecord(lstUserDetails, dctUserDetail);
                dctUserDetail.Clear();
                tagCounter = 0;
            }

            //Push the data into Excel
            return(SaveDataInExcel(lstUserDetails));
        }
Ejemplo n.º 11
0
 /// <summary> Prints contents of the root tag, and any child tags, to a string.
 /// Indents the string using multiples of the given indentation string. </summary>
 /// <param name="indentString"> String to be used for indentation. </param>
 /// <returns> A string representing contents of this tag, and all child tags (if any). </returns>
 /// <exception cref="ArgumentNullException"> <paramref name="indentString"/> is <c>null</c>. </exception>
 public string ToString(string indentString)
 {
     return(RootTag.ToString(indentString));
 }