public static Task SendUpdate <DataType, KeyType>
     (this IAsyncOprations Client,
     PartOfTable <DataType, KeyType> Table)
     where KeyType : IComparable <KeyType>
 => Client.I_SendUpdate(
     Table,
     Table.UpdateAble.UpdateCodes,
     async(key) => Table[key].Value, true);
Exemple #2
0
 public static bool GetUpdate <DataType, KeyType>(
     this ISyncOprations Client,
     PartOfTable <DataType, KeyType> RelationTable,
     Action <DataType> MakeingUpdate = null)
     where KeyType : IComparable <KeyType>
 => Client.I_GetUpdate(RelationTable, MakeingUpdate, true).GetAwaiter().GetResult();
Exemple #3
0
 public static void SendUpdate <DataType, KeyType>
     (this ISyncOprations Client,
     PartOfTable <DataType, KeyType> Table)
     where KeyType : IComparable <KeyType>
 => ((IAsyncOprations)Client).SendUpdate(Table).Wait();
 public static Task <bool> GetUpdate <DataType, KeyType>(
     this IAsyncOprations Client,
     PartOfTable <DataType, KeyType> RelationTable,
     Action <DataType> MakeingUpdate = null)
     where KeyType : IComparable <KeyType>
 => Client.I_GetUpdate(RelationTable, MakeingUpdate, true);
Exemple #5
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
            }