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


C# Marshaller.GetSizeTag方法代码示例

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


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

示例1: ToHost

 internal virtual void ToHost(Marshaller m)
 {
     var members = GetFieldsToMarshal(true);
     dbg.Indent();
     for (int i = 0; i < members.Length; ++i)
     {
         TpmStructMemberInfo memInfo = members[i];
         Type memType = Globs.GetMemberType(memInfo);
         var wt = members[i].WireType;
         switch(wt)
         {
             case MarshalType.Union:
             {
                 dbg.Trace("Union " + memType.Name + " with selector " + memInfo.Tag.Value);
                 memInfo.Value = m.Get(UnionElementFromSelector(memType, memInfo.Tag.Value), memType.Name);
                 break;
             }
             case MarshalType.FixedLengthArray:
             {
                 object arr = Globs.GetMember(memInfo, this);
                 memInfo.Value = m.GetArray(memType.GetElementType(), (arr as Array).Length, memInfo.Name);
                 break;
             }
             case MarshalType.VariableLengthArray:
             {
                 int size = m.GetSizeTag(memInfo.SizeLength, memInfo.SizeName);
                 memInfo.Value = m.GetArray(memType.GetElementType(), size, memInfo.Name);
                 Debug.Assert(size == ((Array)memInfo.Value).Length);
                 dbg.Trace("Received Array " + memInfo.Name + " of size " + size);
                 break;
             }
             case MarshalType.SizedStruct:
             {
                 int size = m.GetSizeTag(memInfo.SizeLength, memInfo.SizeName);
                 if (size != 0)
                 {
                     memInfo.Value = m.Get(memType, memInfo.Name);
                     Debug.Assert(size == Marshaller.GetTpmRepresentation(memInfo.Value).Length);
                 }
                 dbg.Trace("Received Struct " + memInfo.Name + " of size " + size);
                 break;
             }
             default:
                 // Only attempt unmarshaling a field, if it is not sized or
                 // if its size is non-zero.
                 if (memInfo.Tag == null ||
                     memInfo.Tag.GetValueAsUInt() != 0)
                 {
                     memInfo.Value = m.Get(memType, memInfo.Name);
                 }
                 break;
         }
         dbg.Trace((i + 1) + ": " + memInfo.Name +  " = " + memInfo.Value);
         // Some property values are dynamically obtained from their linked fields.
         // Correspondingly, they do not have a setter, so we bypass them here.
         Debug.Assert(wt != MarshalType.LengthOfStruct && wt != MarshalType.ArrayCount);
         if (wt != MarshalType.UnionSelector)
         {
             Globs.SetMember(memInfo, this, memInfo.Value);
         }
     }
     dbg.Unindent();
 }
开发者ID:Microsoft,项目名称:TSS.MSR,代码行数:63,代码来源:TpmBaseClasses.cs


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