コード例 #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
 public static Task SendUpdate <DataType, KeyType>
     (this IAsyncOprations Client, Table <DataType, KeyType> Table)
     where KeyType : IComparable <KeyType>
 => Client.I_SendUpdate(
     Table,
     Table.UpdateAble.UpdateCodes,
     async(key) => Table[key].Value, false);
コード例 #3
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);
        }
コード例 #4
0
ファイル: Service.cs プロジェクト: gitter-badger/Incs
 public Service(IAsyncOprations link)
 {
     this.Link = link;
 }
コード例 #5
0
 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);
コード例 #6
0
 public static Task <bool> GetUpdate <DataType, KeyType>(
     this IAsyncOprations Client,
     Table <DataType, KeyType> Table,
     Action <DataType> MakeingUpdate = null)
     where KeyType : IComparable <KeyType>
 => Client.I_GetUpdate(Table, MakeingUpdate, false);
コード例 #7
0
ファイル: TableActions.cs プロジェクト: monsajem/Incs
 public Task GetUpdate(IAsyncOprations Client);
コード例 #8
0
ファイル: TableActions.cs プロジェクト: monsajem/Incs
 public Task SendUpdate(IAsyncOprations Client);
コード例 #9
0
ファイル: Network_Server.cs プロジェクト: monsajem/Incs
            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
            }
コード例 #10
0
            public IRemoteUpdateReciver(
                IAsyncOprations Client,
                Table <ValueType, KeyType> Table,
                UpdateAble <KeyType>[] UpdateCodes,
                Func <KeyType, Task <ValueType> > GetItem,
                bool IsPartOfTable,
                int ServerItemsCount) :
                base(Client, Table, UpdateCodes, GetItem, IsPartOfTable)
            {
                this.ServerItemsCount = ServerItemsCount;
                EndPos = Math.Min(Table.UpdateAble.UpdateCodes.Length, ServerItemsCount) - 1;

                UpdateFromPosToUpCode = async(Pos, ClientUpCode) =>
                {
                    await UpdateNextItems();
                };
                UpdateFromPosToEnd = async(Pos) =>
                {
                    await UpdateNextItems();
                };

#if DEBUG_UpdateAble
                Debuger = async() =>
                {
                    {
                        var ClientUpdates = Table.UpdateAble.UpdateCodes;
                        var ServerUpdates = await Client.GetData(ClientUpdates);//1

                        if (ServerUpdates.Length != ClientUpdates.Length)
                        {
                            throw new FormatException("Updates are wrong. Count is Wrong.");
                        }
                        for (int i = 0; i < ServerUpdates.Length; i++)
                        {
                            var ClientUpdate = ClientUpdates[i];
                            var ServerUpdate = ServerUpdates[i];
                            if (ClientUpdate.Key.CompareTo(ServerUpdate.Key) != 0)
                            {
                                throw new FormatException("Updates are wrong. key is wrong.");
                            }
                            if (ClientUpdate.UpdateCode != ServerUpdate.UpdateCode)
                            {
                                throw new FormatException("Updates are wrong. Update Code is wrong.");
                            }
                        }
                    }

                    {
                        var ClientDatas = Table.KeysInfo.Keys.ToArray();
                        var ServerDatas = await Client.GetData(ClientDatas);//2

                        if (ServerDatas.Length != ClientDatas.Length)
                        {
                            throw new FormatException("Updates are wrong. Count is Wrong.");
                        }
                        for (int i = 0; i < ServerDatas.Length; i++)
                        {
                            var ClientData = ClientDatas[i];
                            var ServerData = ServerDatas[i];
                            if (ClientData.CompareTo(ServerData) != 0)
                            {
                                throw new FormatException("Updates are wrong. key is wrong.");
                            }
                        }
                    }
                };
#endif
            }
コード例 #11
0
ファイル: FindTable.cs プロジェクト: monsajem/Incs
 public virtual Task GetUpdate(object HolderKey, IAsyncOprations Client) =>
 throw new Exception("Not impelemented.");
コード例 #12
0
ファイル: FindTable.cs プロジェクト: monsajem/Incs
 public virtual Task GetUpdate(IAsyncOprations Client) =>
 throw new Exception("GetUpdate not implemented in table finder!");