コード例 #1
0
ファイル: Network_Server.cs プロジェクト: monsajem/Incs
        private static async Task I_SendUpdate <ValueType, KeyType>
            (this IAsyncOprations Client,
            Table <ValueType, KeyType> Table,
            UpdateAble <KeyType>[] UpdateCodes,
            Func <KeyType, Task <ValueType> > GetItem,
            bool IsPartOfTable)
            where KeyType : IComparable <KeyType>
        {
            var LastUpdateCode = await Client.GetData <ulong>();      //1

            await Client.SendData(Table.UpdateAble.UpdateCode.Value); //2

            if (Table.UpdateAble.UpdateCode < LastUpdateCode)
            {
                LastUpdateCode = 0;
            }
            if (Table.UpdateAble.UpdateCode != LastUpdateCode)
            {
                await Client.SendData(Table.UpdateAble.UpdateCodes.Length);//3

                var Remote = new IRemoteUpdateSender <ValueType, KeyType>(
                    Client, Table, UpdateCodes, GetItem, IsPartOfTable);
                await Client.Remote(Remote);
            }
        }
コード例 #2
0
        private static async Task <bool> I_GetUpdate <ValueType, KeyType>(
            this IAsyncOprations Client,
            Table <ValueType, KeyType> Table,
            Action <ValueType> MakeingUpdate,
            Action <KeyType> Deleted,
            bool IsPartOfTable)
            where KeyType : IComparable <KeyType>
        {
            if (Table._UpdateAble == null)
            {
                Table._UpdateAble = new UpdateAbles <KeyType>(
                    Table.BasicActions.UpdateCode,
                    Table.BasicActions.Items.Select((c) => (Table.GetKey(c.Value), c.UpdateCode)));
            }
            var Result = false;

            await Client.SendData(Table.UpdateAble.UpdateCode.Value); //1

            var LastUpdateCode = await Client.GetData <ulong>();      //2

            if (Table.UpdateAble.UpdateCode.Value != LastUpdateCode)
            {
                var ServerItemsCount = await Client.GetData <int>();//3

                var Remote = new IRemoteUpdateReciver <ValueType, KeyType>(
                    Client, Table, null, null, IsPartOfTable, ServerItemsCount);
                await Client.Remote(Remote,
                                    async (Remote) => await Remote.MakeUpdate(LastUpdateCode));
            }
            return(Result);
        }