public RawEntry(CacheBase Cache, int Address)
            {
                EndianReader Reader = Cache.Reader;

                Reader.SeekTo(Address);

                Reader.SeekTo(Address + 12);
                TagID = Reader.ReadInt32();

                Reader.ReadInt16();
                Reader.ReadInt16();
                Reader.ReadInt32();

                FixupOffset = Reader.ReadInt32();
                FixupSize   = Reader.ReadInt32();

                Reader.ReadInt32();

                CacheIndex     = Reader.ReadInt32();
                RequiredOffset = Reader.ReadInt32();
                RequiredSize   = Reader.ReadInt32();

                Reader.ReadInt32();

                CacheIndex2    = Reader.ReadInt32();
                OptionalOffset = Reader.ReadInt32();
                OptionalSize   = Reader.ReadInt32();

                Reader.ReadInt32();
                Reader.ReadInt32();

                #region Resource Fixups
                int iCount  = Reader.ReadInt32();
                int iOffset = Reader.ReadInt32() - Cache.Magic;
                for (int i = 0; i < iCount; i++)
                {
                    Fixups.Add(new ResourceFixup(Cache, iOffset + 8 * i));
                }
                #endregion

                #region Resource Definition Fixups
                Reader.SeekTo(Address + 84);
                iCount  = Reader.ReadInt32();
                iOffset = Reader.ReadInt32() - Cache.Magic;
                for (int i = 0; i < iCount; i++)
                {
                    DefinitionFixups.Add(new ResourceDefinitionFixup(Cache, iOffset + 8 * i));
                }
                #endregion
            }
Example #2
0
        /// <summary>
        /// Convert this object to a JSON string of itself
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var i in Items)
            {
                sb.AppendLine(Resource1.enum_value_template_csharp
                              .Replace("@@COMMENT@@", Fixups.Comment(i.Comment))
                              .Replace("@@VALUE@@", i.Value));
            }

            return(Resource1.enum_class_template_csharp
                   .Replace("@@ENUMCLASS@@", EnumDataType)
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@VALUELIST@@", sb.ToString()));
        }
            public RawEntry(CacheBase Cache, int Address)
            {
                EndianReader Reader = Cache.Reader;

                Reader.SeekTo(Address);

                Reader.SeekTo(Address + 12);
                TagID = Reader.ReadInt32();
                Reader.ReadInt16();
                Reader.ReadByte();
                Reader.ReadByte();
                FixupSize = Reader.ReadInt32();
                Reader.ReadInt16();
                SegmentIndex = Reader.ReadInt16();
                Reader.ReadInt32();

                #region Resources
                Reader.SeekTo(Address + 32);
                int iCount  = Reader.ReadInt32();
                int iOffset = Reader.ReadInt32() - Cache.Magic;
                for (int i = 0; i < iCount; i++)
                {
                    Fixups.Add(new ResourceFixup(Cache, iOffset + 8 * i));
                }
                #endregion

                #region Resource Definitions
                Reader.SeekTo(Address + 44);
                iCount  = Reader.ReadInt32();
                iOffset = Reader.ReadInt32() - Cache.Magic;
                for (int i = 0; i < iCount; i++)
                {
                    DefinitionFixups.Add(new ResourceDefinitionFixup(Cache, iOffset + 8 * i));
                }
                #endregion

                #region Fixup Location
                Reader.SeekTo(Address + 56);
                iCount  = Reader.ReadInt32();
                iOffset = Reader.ReadInt32() - Cache.Magic;
                if (iCount > 0)
                {
                    Reader.SeekTo(iOffset);
                    FixupOffset = Reader.ReadInt32();
                }
                #endregion
            }
Example #4
0
        void ReadFixups(NomadObject obj)
        {
            var offsetsAttr = obj.GetAttribute("offsetsArray");
            var hashesAttr  = obj.GetAttribute("hashesArray");

            if ((offsetsAttr != null) && (hashesAttr != null))
            {
                var offsets = Utils.UnpackArray(offsetsAttr, BitConverter.ToInt32, 4, out int nOffsets);
                var hashes  = Utils.UnpackArray(hashesAttr, BitConverter.ToInt32, 4, out int nHashes);

                if (nOffsets != nHashes)
                {
                    throw new InvalidDataException("Yikes!");
                }

                // doesn't matter which one we use
                // but we'll be verbose anyways :)
                var count = (nOffsets & nHashes);

                Fixups = new List <FixupInfo>(count);

                for (int i = 0; i < count; i++)
                {
                    var offset = offsets[i];
                    var hash   = hashes[i];

                    var fixup = new FixupInfo(hash, offset);

                    Fixups.Add(fixup);
                }
            }
            else
            {
                foreach (var child in obj.Children)
                {
                    if (child.Id != "FIXUP")
                    {
                        throw new InvalidDataException($"Expected a FIXUP but got '{child.Id}' instead.");
                    }

                    var fixup = ParseFixup(child);

                    Fixups.Add(fixup);
                }
            }
        }
Example #5
0
        void ProcessFixups(ProjectState state, IO.XmlStream s)
        {
            foreach (XmlNode n in s.Cursor.ChildNodes)
            {
                if (n.Name != "fixup")
                {
                    continue;
                }

                s.SaveCursor(n);
                var fu = new Fixup(state, s);
                s.RestoreCursor();
                string name_str = fu.ToString();

                try { Fixups.Add(name_str, fu); }
                catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "fix-up definition", name_str); }
            }
        }
        /// <summary>
        /// Serialize this as a file string
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var prop in Properties)
            {
                sb.AppendLine(Resource1.model_property_template_csharp
                              .Replace("@@PROPERTYNAME@@", prop.CSharpParamName)
                              .Replace("@@COMMENT@@", Fixups.Comment(prop.Comment))
                              .Replace("@@PROPERTYTYPE@@", prop.TypeName));
            }

            // Produce the full file
            return(Resource1.model_class_template_csharp
                   .Replace("@@PROPERTYLIST@@", sb.ToString())
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@MODELCLASS@@", SchemaName));
        }
        public override string ToString()
        {
            // Assemble parameter comments and list
            StringBuilder paramcomments = new StringBuilder();
            StringBuilder paramlist     = new StringBuilder();
            StringBuilder parambuilder  = new StringBuilder();

            foreach (var p in Params)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", p.CSharpParamName, p.Comment);
                paramlist.AppendFormat("{0} {1}, ", p.TypeName, p.ParamName.Replace("$", ""));
                parambuilder.AppendFormat("\r\n            path.ApplyField(\"{0}\", {1});", p.ParamName, p.CSharpParamName);
            }
            foreach (var p in QueryParams)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", p.CSharpParamName, p.Comment);
                paramlist.AppendFormat("{0} {1}, ", p.TypeName, p.ParamName.Replace("$", ""));
                parambuilder.AppendFormat("\r\n            path.AddQuery(\"{0}\", {1});", p.ParamName, p.CSharpParamName);
            }
            if (BodyParam != null)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", BodyParam.CSharpParamName, BodyParam.Comment);
                paramlist.AppendFormat("{0} {1}, ", BodyParam.TypeName, BodyParam.ParamName.Replace("$", ""));
            }
            paramcomments.Append("        /// <returns></returns>");
            if (paramlist.Length > 0)
            {
                paramlist.Length -= 2;
            }

            // Here's your template
            return(Resource1.api_template_csharp
                   .Replace("@@CATEGORY@@", Category)
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@TYPENAME@@", TypeName)
                   .Replace("@@APINAME@@", OperationId)
                   .Replace("@@HTTPVERB@@", HttpVerb)
                   .Replace("@@PARAMCOMMENTS@@", paramcomments.ToString())
                   .Replace("@@PARAMBUILDER@@", parambuilder.ToString())
                   .Replace("@@PARAMS@@", paramlist.ToString())
                   .Replace("@@URI@@", URI)
                   .Replace("@@PAYLOAD@@", BodyParam == null ? "null" : "model"));
        }