当前位置: 首页>>代码示例>>C#>>正文


C# SubRecord.GetStrData方法代码示例

本文整理汇总了C#中SubRecord.GetStrData方法的典型用法代码示例。如果您正苦于以下问题:C# SubRecord.GetStrData方法的具体用法?C# SubRecord.GetStrData怎么用?C# SubRecord.GetStrData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SubRecord的用法示例。


在下文中一共展示了SubRecord.GetStrData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompileResultScript

        public static bool CompileResultScript(SubRecord sr, out Record r2, out string msg)
        {
            msg=null;
            r2=null;
            r=new Record();
            string script=sr.GetStrData();
            locals.Clear();
            localList.Clear();
            edidRefs.Clear();
            refcount=0;
            errors.Clear();

            ts=new TokenStream(script, errors);
            if(errors.Count>0) return OutputErrors(out msg);
            schr=new SubRecord();
            schr.Name="SCHR";
            r.AddRecord(schr);
            scda=new SubRecord();
            scda.Name="SCDA";
            r.AddRecord(scda);
            sr=(SubRecord)sr.Clone();
            r.AddRecord(sr);

            bw=new BinaryWriter(new MemoryStream());

            while(ts.PeekNextStatement().Length>0) {
                try {
                    HandleResultsBlock();
                } catch(Exception ex) {
                    return ReturnError(ex.Message, out msg);
                }
            }

            if(errors.Count>0) {
                return OutputErrors(out msg);
            }

            byte[] header=new byte[20];
            TypeConverter.si2h(refcount, header, 4);
            TypeConverter.i2h((uint)bw.BaseStream.Length, header, 8);
            TypeConverter.si2h(localList.Count, header, 12);
            TypeConverter.si2h(0x10000, header, 16);
            schr.SetData(header);
            byte[] compileddata=((MemoryStream)bw.BaseStream).GetBuffer();
            if(compileddata.Length!=bw.BaseStream.Length) Array.Resize<byte>(ref compileddata, (int)bw.BaseStream.Length);
            scda.SetData(compileddata);
            bw.Close();
            r2=r;
            return true;
        }
开发者ID:robjer,项目名称:tesvsnip,代码行数:50,代码来源:ScriptCompiler.cs

示例2: MatchRecordAddConditionals

 private static void MatchRecordAddConditionals(Dictionary<int, Conditional> conditions, SubRecord sr, ElementStructure[] ess)
 {
     int offset = 0;
     byte[] data = sr.GetReadonlyData();
     for (int j = 0; j < ess.Length; j++)
     {
         if (ess[j].CondID != 0)
         {
             switch (ess[j].type)
             {
                 case ElementValueType.Int:
                 case ElementValueType.FormID:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.Int, TypeConverter.h2si(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]));
                     offset += 4;
                     break;
                 case ElementValueType.UInt:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.UInt, (uint)TypeConverter.h2i(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]));
                     offset += 4;
                     break;
                 case ElementValueType.Float:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.Float, TypeConverter.h2f(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]));
                     offset += 4;
                     break;
                 case ElementValueType.Short:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.Short, (int)TypeConverter.h2ss(data[offset], data[offset + 1]));
                     offset += 2;
                     break;
                 case ElementValueType.UShort:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.UShort, TypeConverter.h2s(data[offset], data[offset + 1]));
                     offset += 2;
                     break;
                 case ElementValueType.SByte:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.SByte, (sbyte)data[offset]);
                     offset++;
                     break;
                 case ElementValueType.Byte:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.Byte, (int)data[offset]);
                     offset++;
                     break;
                 case ElementValueType.String:
                     {
                         string s = "";
                         while (data[offset] != 0) s += (char)data[offset++];
                         offset++;
                         conditions[ess[j].CondID] = new Conditional(ElementValueType.String, s);
                     }
                     break;
                 case ElementValueType.fstring:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.String, sr.GetStrData());
                     break;
                 case ElementValueType.BString:
                     {
                         int len = TypeConverter.h2s(data[offset], data[offset + 1]);
                         string s = System.Text.Encoding.ASCII.GetString(data, offset + 2, len);
                         offset = offset + (2 + len);
                         conditions[ess[j].CondID] = new Conditional(ElementValueType.String, s);
                     } break;
                 case ElementValueType.LString:
                     conditions[ess[j].CondID] = new Conditional(ElementValueType.Int, TypeConverter.h2si(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]));
                     offset += 4;
                     break;
                 default:
                     throw new ApplicationException();
             }
         }
         else
         {
             switch (ess[j].type)
             {
                 case ElementValueType.Int:
                 case ElementValueType.UInt:
                 case ElementValueType.FormID:
                 case ElementValueType.Float:
                     offset += 4;
                     break;
                 case ElementValueType.UShort:
                 case ElementValueType.Short:
                     offset += 2;
                     break;
                 case ElementValueType.SByte:
                 case ElementValueType.Byte:
                     offset++;
                     break;
                 case ElementValueType.String:
                     while (data[offset] != 0) offset++;
                     offset++;
                     break;
                 case ElementValueType.fstring:
                     break;
                 case ElementValueType.LString:
                     break;
                 case ElementValueType.BString:
                     int len = TypeConverter.h2s(data[offset], data[offset + 1]);
                     offset += 2 + len;
                     break;
                 default:
                     throw new ApplicationException();
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:robjer,项目名称:tesvsnip,代码行数:101,代码来源:MainView.cs


注:本文中的SubRecord.GetStrData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。