public unsafe void ReadObject(BinSerializer bs)
        {
            WaitHandle = new IntPtr(bs.ReadInt64());
            TxnPtr     = new IntPtr(bs.ReadInt64());

            var req = new ClrUpdateRequire();

            req.RaftGroupId   = bs.ReadUInt64();
            req.SchemaVersion = bs.ReadUInt32();
            req.DataCF        = (sbyte)bs.ReadByte();
            req.Merge         = bs.ReadBoolean();
            req.ReturnExists  = bs.ReadBoolean();

            req.KeySize = new IntPtr(bs.ReadInt32());
            req.KeyPtr  = Marshal.AllocHGlobal(req.KeySize.ToInt32());
            var span = new Span <byte>(req.KeyPtr.ToPointer(), req.KeySize.ToInt32());

            bs.Stream.Read(span);

            req.RefsSize = new IntPtr(bs.ReadInt32());
            if (req.RefsSize.ToInt32() > 0)
            {
                req.RefsPtr = Marshal.AllocHGlobal(req.RefsSize.ToInt32());
                span        = new Span <byte>(req.RefsPtr.ToPointer(), req.RefsSize.ToInt32());
                bs.Stream.Read(span);
            }

            int dataSize = bs.ReadInt32();

            req.DataPtr = NativeApi.NewNativeString(dataSize, out byte *dp);
            span        = new Span <byte>(dp, dataSize);
            bs.Stream.Read(span);

            Require = req;
        }
        public void ReadObject(BinSerializer bs)
        {
            Source      = (InvokeSource)bs.ReadByte();
            ContentType = (InvokeProtocol)bs.ReadByte();
            WaitHandle  = new IntPtr(bs.ReadInt64());
            SourceMsgId = bs.ReadInt32();
            Service     = bs.ReadString();
            //注意统一转换为RoutedSession
            if (bs.ReadBoolean())
            {
                ulong id     = bs.ReadUInt64();
                int   levels = bs.ReadInt32();
                var   path   = new TreeNodePath(levels);
                for (int i = 0; i < levels; i++)
                {
                    path[i] = new TreeNodeInfo {
                        ID = bs.ReadGuid(), Text = bs.ReadString()
                    };
                }
                Guid?empID      = null;
                bool isExternal = bs.ReadBoolean();
                if (!isExternal)
                {
                    empID = bs.ReadGuid();
                }
                string tag = bs.ReadString();
                Session = new RoutedSession(id, path, empID, tag);
            }
            var args = new InvokeArgs();

            args.ReadObject(bs);
            Args = args; //Don't use Args.ReadObject(bs)
        }
        public void ReadObject(BinSerializer bs)
        {
            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: _storeType = (EntityStoreType)bs.ReadByte(); break;

                case 2: OrderByDesc = bs.ReadBoolean(); break;

                case 3: SchemaVersion = bs.ReadUInt32(); break;

                case 4:
                {
                    int count = bs.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        var idx = (EntityIndexModel)bs.Deserialize();
                        Indexes.Add(idx);
                    }
                }
                break;

                case 5:
                {
                    int count = bs.ReadInt32();
                    PartitionKeys = new PartitionKey[count];
                    for (int i = 0; i < count; i++)
                    {
                        PartitionKeys[i].MemberId     = bs.ReadUInt16();
                        PartitionKeys[i].OrderByDesc  = bs.ReadBoolean();
                        PartitionKeys[i].Rule         = (PartitionKeyRule)bs.ReadByte();
                        PartitionKeys[i].RuleArgument = bs.ReadInt32();
                    }
                }
                break;

                case 6: _devIndexIdSeq = bs.ReadByte(); break;

                case 7: _usrIndexIdSeq = bs.ReadByte(); break;

                case 8: _oldSchemaVersion = bs.ReadUInt32(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name} at {propIndex} ");
                }
            } while (propIndex != 0);
        }
Exemple #4
0
        public void ReadObject(BinSerializer cf)
        {
            uint propIndex;

            do
            {
                propIndex = cf.ReadUInt32();
                switch (propIndex)
                {
                case 1: Id = cf.ReadGuid(); break;

                case 2: Name = cf.ReadString(); break;

                case 3: Version = cf.ReadUInt32(); break;

                case 4: Parent = (ModelFolder)cf.Deserialize(); break;

                case 5: _childs = cf.ReadList <ModelFolder>(); break;

                case 6: AppId = cf.ReadUInt32(); break;

                case 7: TargetModelType = (ModelType)cf.ReadByte(); break;

                case 8: SortNum = cf.ReadInt32(); break;

                case 9: IsDeleted = cf.ReadBoolean(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name}");
                }
            } while (propIndex != 0);
        }
Exemple #5
0
        public virtual void ReadObject(BinSerializer bs)
        {
            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: Owner = (EntityModel)bs.Deserialize(); break;

                case 2: AllowNull = bs.ReadBoolean(); break;

                case 3: Name = bs.ReadString(); break;

                case 4: MemberId = bs.ReadUInt16(); break;

                case 5: _originalName = bs.ReadString(); break;

                case 6: PersistentState = (PersistentState)bs.ReadByte(); break;

                case 7: Comment = bs.ReadString(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name}");
                }
            } while (propIndex != 0);
        }
Exemple #6
0
        public static WebSession LoadWebSession(this ISession session)
        {
            var data = session.Get(WebSession.UserSessionKey);

            if (data == null)
            {
                return(null);
            }

            ulong        id;
            Guid?        empID = null;
            TreeNodePath path;
            string       tag = null;

            using (var ms = new MemoryStream(data))
            {
                var bs = new BinSerializer(ms); //TODO:使用ThreadCache或参照RoutedSessionReader
                id   = bs.ReadUInt64();
                path = (TreeNodePath)bs.Deserialize();
                bool isExternal = bs.ReadBoolean();
                if (!isExternal)
                {
                    empID = bs.ReadGuid();
                }
                tag = bs.ReadString();
                bs.Clear();
            }

            return(new WebSession(id, path, empID, tag));
        }
Exemple #7
0
        public virtual void ReadObject(BinSerializer bs)
        {
            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: Id = bs.ReadUInt64(); break;

                case 2: Name = bs.ReadString(); break;

                case 3: DesignMode = bs.ReadBoolean(); break;

                case 4: Version = bs.ReadUInt32(); break;

                case 5: PersistentState = (PersistentState)bs.ReadByte(); break;

                case 6: FolderId = bs.ReadGuid(); break;

                case 7: _originalName = bs.ReadString(); break;

                case 0: break;

                default: throw new Exception("Deserialize_ObjectUnknownFieldIndex: " + GetType().Name);
                }
            } while (propIndex != 0);
        }
        public unsafe void ReadObject(BinSerializer bs)
        {
            WaitHandle = new IntPtr(bs.ReadInt64());
            TxnPtr     = new IntPtr(bs.ReadInt64());

            var req = new ClrDeleteRequire();

            req.RaftGroupId   = bs.ReadUInt64();
            req.SchemaVersion = bs.ReadUInt32();
            req.DataCF        = (sbyte)bs.ReadByte();
            req.ReturnExists  = bs.ReadBoolean();

            req.KeySize = new IntPtr(bs.ReadInt32());
            req.KeyPtr  = Marshal.AllocHGlobal(req.KeySize.ToInt32());
            var span = new Span <byte>(req.KeyPtr.ToPointer(), req.KeySize.ToInt32());

            bs.Stream.Read(span);

            req.RefsSize = new IntPtr(bs.ReadInt32());
            if (req.RefsSize.ToInt32() > 0)
            {
                req.RefsPtr = Marshal.AllocHGlobal(req.RefsSize.ToInt32());
                span        = new Span <byte>(req.RefsPtr.ToPointer(), req.RefsSize.ToInt32());
                bs.Stream.Read(span);
            }

            Require = req;
        }
        internal void ReadObject(BinSerializer bs)
        {
            PartitionKeys = bs.ReadUInt16Array();
            int count = bs.ReadInt32();

            if (count > 0)
            {
                ClusteringColumns = new FieldWithOrder[count];
                for (int i = 0; i < count; i++)
                {
                    ClusteringColumns[i] = new FieldWithOrder()
                    {
                        MemberId    = bs.ReadUInt16(),
                        OrderByDesc = bs.ReadBoolean()
                    };
                }
            }
        }
Exemple #10
0
        internal void ReadObject(BinSerializer bs)
        {
            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: MemberId = bs.ReadUInt16(); break;

                case 2: OrderByDesc = bs.ReadBoolean(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name} at {propIndex} ");
                }
            } while (propIndex != 0);
        }
Exemple #11
0
        public override void ReadObject(BinSerializer bs)
        {
            base.ReadObject(bs);

            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: Global = bs.ReadBoolean(); break;

                case 2: State = (EntityIndexState)bs.ReadByte(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name} at {propIndex} ");
                }
            } while (propIndex != 0);
        }
Exemple #12
0
        public override void ReadObject(BinSerializer bs)
        {
            base.ReadObject(bs);

            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: IsFlag = bs.ReadBoolean(); break;

                case 2: Comment = bs.ReadString(); break;

                case 3: Items = bs.ReadList <EnumModelItem>(); break;

                case 0: break;

                default: throw new Exception($"Deserialize_ObjectUnknownFieldIndex: {GetType().Name}");
                }
            } while (propIndex != 0);
        }
Exemple #13
0
        public override void ReadObject(BinSerializer cf)
        {
            base.ReadObject(cf);

            uint propIndex;

            do
            {
                propIndex = cf.ReadUInt32();
                switch (propIndex)
                {
                case 1: cf.ReadBoolean(); break;     //todo: 待全部转换完后移除

                case 2: ModelID = cf.ReadUInt64(); break;

                case 3: _user = cf.Deserialize(); break;

                case 0: break;

                default: throw new Exception("Deserialize_ObjectUnknownFieldIndex: " + GetType().Name);
                }
            } while (propIndex != 0);
        }
        public virtual void ReadObject(BinSerializer bs)
        {
            uint propIndex;

            do
            {
                propIndex = bs.ReadUInt32();
                switch (propIndex)
                {
                case 1: Owner = (EntityModel)bs.Deserialize(); break;

                case 2: IndexId = bs.ReadByte(); break;

                case 3: Name = bs.ReadString(); break;

                case 4: Unique = bs.ReadBoolean(); break;

                case 6:
                    int count = bs.ReadInt32();
                    Fields = new FieldWithOrder[count];
                    for (int i = 0; i < count; i++)
                    {
                        Fields[i].ReadObject(bs);
                    }
                    break;

                case 7: StoringFields = bs.ReadUInt16Array(); break;

                case 9: PersistentState = (PersistentState)bs.ReadByte(); break;

                case 0: break;

                default: throw new Exception(string.Format("Deserialize_ObjectUnknownFieldIndex: {0} at {1} ", GetType().Name, propIndex));
                }
            } while (propIndex != 0);
        }
Exemple #15
0
        public unsafe void ReadObject(BinSerializer bs)
        {
            WaitHandle = new IntPtr(bs.ReadInt64());

            var req = new ClrScanRequire();

            req.RaftGroupId   = bs.ReadUInt64();
            req.DataCF        = bs.ReadInt32();
            req.Skip          = bs.ReadUInt32();
            req.Take          = bs.ReadUInt32();
            req.ToIndexTarget = bs.ReadBoolean();

            req.BeginKeySize = new IntPtr(bs.ReadInt32());
            req.BeginKeyPtr  = Marshal.AllocHGlobal(req.BeginKeySize.ToInt32());
            var span = new Span <byte>(req.BeginKeyPtr.ToPointer(), req.BeginKeySize.ToInt32());

            bs.Stream.Read(span);

            req.EndKeySize = new IntPtr(bs.ReadInt32());
            if (req.EndKeySize.ToInt32() > 0)
            {
                req.EndKeyPtr = Marshal.AllocHGlobal(req.EndKeySize.ToInt32());
                span          = new Span <byte>(req.EndKeyPtr.ToPointer(), req.EndKeySize.ToInt32());
                bs.Stream.Read(span);
            }

            var filterSize = bs.ReadInt32();

            if (filterSize > 0)
            {
                req.FilterPtr = NativeApi.NewNativeString(filterSize, out byte *dp); //注意转换
                span          = new Span <byte>(dp, filterSize);
                bs.Stream.Read(span);
            }
            Require = req;
        }
Exemple #16
0
        internal void Read(BinSerializer bs)
        {
            Id         = bs.ReadUInt16();
            MemberType = (EntityMemberType)bs.ReadByte();
            ValueType  = (EntityFieldType)bs.ReadByte();
            Flag.Data  = bs.ReadByte();

            switch (MemberType)
            {
            case EntityMemberType.DataField:
                switch (ValueType)
                {
                case EntityFieldType.Boolean: BooleanValue = bs.ReadBoolean(); break;

                case EntityFieldType.Byte: ByteValue = bs.ReadByte(); break;

                case EntityFieldType.Float: FloatValue = bs.ReadFloat(); break;

                case EntityFieldType.Double: DoubleValue = bs.ReadDouble(); break;

                case EntityFieldType.Enum: Int32Value = bs.ReadInt32(); break;

                case EntityFieldType.Int16: Int16Value = bs.ReadInt16(); break;

                case EntityFieldType.UInt16: UInt16Value = bs.ReadUInt16(); break;

                case EntityFieldType.Int32: Int32Value = bs.ReadInt32(); break;

                case EntityFieldType.UInt32: UInt32Value = bs.ReadUInt32(); break;

                case EntityFieldType.Int64: Int64Value = bs.ReadInt64(); break;

                case EntityFieldType.UInt64: UInt64Value = bs.ReadUInt64(); break;

                case EntityFieldType.DateTime: DateTimeValue = bs.ReadDateTime(); break;

                case EntityFieldType.Guid: GuidValue = bs.ReadGuid(); break;

                case EntityFieldType.Decimal: DecimalValue = bs.ReadDecimal(); break;

                case EntityFieldType.String: ObjectValue = bs.ReadString(); break;

                case EntityFieldType.Binary: ObjectValue = bs.ReadByteArray(); break;

                default: throw new NotSupportedException();
                }
                break;

            case EntityMemberType.EntityRef:
            case EntityMemberType.EntitySet: ObjectValue = bs.Deserialize(); break;

            //case EntityMemberType.ImageRef: this.ObjectValue = bs.Deserialize(); break;
            //case EntityMemberType.FieldSet:
            //switch (this.ValueType)
            //{
            //    case EntityFieldType.String:
            //        {
            //            var array = bs.ReadStringArray();
            //            this.ObjectValue = array == null ? null : new HashSet<string>(array);
            //        }
            //        break;
            //    case EntityFieldType.Integer:
            //        {
            //            var array = bs.ReadInt32Array();
            //            this.ObjectValue = array == null ? null : new HashSet<int>(array);
            //        }
            //        break;
            //    case EntityFieldType.Guid:
            //        {
            //            var array = bs.ReadGuidArray();
            //            this.ObjectValue = array == null ? null : new HashSet<Guid>(array);
            //        }
            //        break;
            //    case EntityFieldType.Float:
            //        {
            //            var array = bs.ReadFloatArray();
            //            this.ObjectValue = array == null ? null : new HashSet<float>(array);
            //        }
            //        break;
            //    case EntityFieldType.Double:
            //        {
            //            var array = bs.ReadDoubleArray();
            //            this.ObjectValue = array == null ? null : new HashSet<double>(array);
            //        }
            //        break;
            //    case EntityFieldType.Decimal:
            //        {
            //            var array = bs.ReadDecimalArray();
            //            this.ObjectValue = array == null ? null : new HashSet<Decimal>(array);
            //        }
            //        break;
            //    case EntityFieldType.DateTime:
            //        {
            //            var array = bs.ReadDateTimeArray();
            //            this.ObjectValue = array == null ? null : new HashSet<DateTime>(array);
            //        }
            //        break;
            //    case EntityFieldType.Byte:
            //        {
            //            var array = bs.ReadByteArray();
            //            this.ObjectValue = array == null ? null : new HashSet<byte>(array);
            //        }
            //        break;
            //    default: throw new NotSupportedException($"不支持二进制反序列化FieldSet: {ValueType}");
            //}
            //break;
            default:
                GuidValue   = bs.ReadGuid();
                ObjectValue = bs.Deserialize();
                break;
            }
        }