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


C# MemoryHolder.ReadUnicodeString方法代码示例

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


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

示例1: GetRawValue

            internal string GetRawValue(MemoryHolder owner, int offset) {
                Debug.Assert(IsStringType);
                SimpleType st = (SimpleType)_type;
                string str;
                if (st._type == SimpleTypeKind.Char) {
                    str = owner.ReadAnsiString(offset, _length);
                } else {
                    str = owner.ReadUnicodeString(offset, _length);
                }

                return str;
            }
开发者ID:techarch,项目名称:ironruby,代码行数:12,代码来源:ArrayType.cs

示例2: switch

            object INativeType.GetValue(MemoryHolder/*!*/ owner, int offset, bool raw) {
                object res;
                switch (_type) {
                    case SimpleTypeKind.Boolean: res = owner.ReadByte(offset) != 0 ? ScriptingRuntimeHelpers.True : ScriptingRuntimeHelpers.False; break;
                    case SimpleTypeKind.Char: res = new string((char)owner.ReadByte(offset), 1); break;
                    case SimpleTypeKind.SignedByte: res = GetIntReturn((int)(sbyte)owner.ReadByte(offset)); break;
                    case SimpleTypeKind.UnsignedByte: res = GetIntReturn((int)owner.ReadByte(offset)); break;
                    case SimpleTypeKind.SignedShort: res = GetIntReturn((int)owner.ReadInt16(offset)); break;
                    case SimpleTypeKind.WChar: res = new string((char)owner.ReadInt16(offset), 1); break;
                    case SimpleTypeKind.UnsignedShort: res = GetIntReturn((int)(ushort)owner.ReadInt16(offset)); break;
                    case SimpleTypeKind.SignedInt: res = GetIntReturn((int)owner.ReadInt32(offset)); break;
                    case SimpleTypeKind.UnsignedInt: res = GetIntReturn((uint)owner.ReadInt32(offset)); break;
                    case SimpleTypeKind.UnsignedLong: res = GetIntReturn((uint)owner.ReadInt32(offset)); break;
                    case SimpleTypeKind.SignedLong: res = GetIntReturn(owner.ReadInt32(offset)); break;
                    case SimpleTypeKind.Single: res = GetSingleReturn(owner.ReadInt32(offset)); break;
                    case SimpleTypeKind.Double: res = GetDoubleReturn(owner.ReadInt64(offset)); break;
                    case SimpleTypeKind.UnsignedLongLong: res = GetIntReturn((ulong)owner.ReadInt64(offset)); break;
                    case SimpleTypeKind.SignedLongLong: res = GetIntReturn(owner.ReadInt64(offset)); break;
                    case SimpleTypeKind.Object: res = GetObjectReturn(owner.ReadIntPtr(offset)); break;
                    case SimpleTypeKind.Pointer: res = ToPython(owner.ReadIntPtr(offset)); break;
                    case SimpleTypeKind.CharPointer: res = owner.ReadAnsiString(offset); break;
                    case SimpleTypeKind.WCharPointer: res = owner.ReadUnicodeString(offset); break;
                    default:
                        throw new InvalidOperationException();
                }

                if (!raw && IsSubClass) {
                    res = PythonCalls.Call(this, res);
                }

                return res;
            }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:32,代码来源:SimpleType.cs

示例3: MemoryHolder

            object INativeType.GetValue(MemoryHolder owner, object readingFrom, int offset, bool raw) {
                if (IsStringType) {
                    SimpleType st = (SimpleType)_type;
                    string str;
                    if (st._type == SimpleTypeKind.Char) {
                        str = owner.ReadAnsiString(offset, _length);
                    } else {
                        str = owner.ReadUnicodeString(offset, _length);
                    }

                    // remove any trailing nulls
                    for (int i = 0; i < str.Length; i++) {
                        if (str[i] == '\x00') {
                            return str.Substring(0, i);
                        }
                    }

                    return str;
                }

                _Array arr = (_Array)CreateInstance(Context.SharedContext);
                arr._memHolder = new MemoryHolder(owner.UnsafeAddress.Add(offset), ((INativeType)this).Size, owner);
                return arr;
            }
开发者ID:techarch,项目名称:ironruby,代码行数:24,代码来源:ArrayType.cs

示例4: checked

            object INativeType.GetValue(MemoryHolder owner, int offset, bool raw) {
                if (IsStringType) {
                    SimpleType st = (SimpleType)_type;
                    string str;
                    if (st._type == SimpleTypeKind.Char) {
                        str = owner.ReadAnsiString(offset, _length);
                    } else {
                        str = owner.ReadUnicodeString(offset, _length);
                    }

                    // remove any trailing nulls
                    for (int i = 0; i < str.Length; i++) {
                        if (str[i] == '\x00') {
                            return str.Substring(0, i);
                        }
                    }

                    return str;
                }

                object[] res = new object[_length];
                for (int i = 0; i < res.Length; i++) {
                    res[i] = _type.GetValue(owner, checked(offset + _type.Size * i), raw);
                }

                return List.FromArrayNoCopy(res);
            }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:27,代码来源:ArrayType.cs


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