예제 #1
0
        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);
        }
예제 #3
0
        public async Task Request(AddressType ServiceAddress)
        {
            await Link.SendCondition(true);

            await Link.SendData(ServiceAddress);
        }
예제 #4
0
            public IRemoteUpdateSender(
                IAsyncOprations Client,
                Table <ValueType, KeyType> Table,
                UpdateAble <KeyType>[] UpdateCodes,
                Func <KeyType, Task <ValueType> > GetItem,
                bool IsPartOfTable)
            {
                this.Client        = Client;
                this.Table         = Table;
                this.UpdateCodes   = UpdateCodes;
                this.GetItem       = GetItem;
                this.IsPartOfTable = IsPartOfTable;
                if (IsPartOfTable)
                {
                    PartTable           = (PartOfTable <ValueType, KeyType>)Table;
                    ParentTable         = PartTable.Parent;
                    Table.MoveRelations = ParentTable.MoveRelations;
                }

                GetUpdateCodeAtPos = async(c) => UpdateCodes[c].UpdateCode;
                IsExistAtParent    = async(c) => ParentTable.IsExist(c);

                Func <UpdateAble <KeyType>[], Task> SendUpdate = async(MyUpCodes) =>
                {
                    var IsPartOfTable = this.IsPartOfTable;
                    var len           = MyUpCodes.Length;
                    await Client.SendData(len);

                    for (int i = 0; i < len; i++)
                    {
                        var MyUpCode = MyUpCodes[i];
                        await Client.SendData(MyUpCode.UpdateCode);

                        if (IsPartOfTable)
                        {
                            await Client.SendData(ParentTable.UpdateAble[MyUpCode.Key].UpdateCode);
                        }
                    }
                    for (int i = 0; i < len; i++)
                    {
                        if (await Client.GetData <bool>())
                        {
                            await Client.SendData(await GetItem(MyUpCodes[i].Key));
                        }
                    }
                };

                UpdateFromPosToUpCode = async(Pos, ClientUpCode) =>
                {
                    var MyUpCodes = UpdateCodes.
                                    Skip(Pos).
                                    TakeWhile((c) => ClientUpCode >= c.UpdateCode).ToArray();
                    await SendUpdate(MyUpCodes);
                };
                UpdateFromPosToEnd = async(Pos) =>
                {
                    var MyUpCodes = UpdateCodes.Skip(Pos).ToArray();
                    await SendUpdate(MyUpCodes);
                };

#if DEBUG_UpdateAble
                Debuger = async() =>
                {
                    await Client.SendData(Table.UpdateAble.UpdateCodes);  //1

                    await Client.SendData(Table.KeysInfo.Keys.ToArray()); //2
                };
#endif
            }
예제 #5
0
 public async Task Request(AddressType ServiceAddress)
 {
     await Link.SendData(ServiceAddress);
 }