System.Collections.Generic.List.ForEach(System.Action)

Here are the examples of the csharp api System.Collections.Generic.List.ForEach(System.Action) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6344 Examples 7

19 View Source File : UIBuilder.Gauges.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public void HideAllGauges() {
            Bars.ForEach(x => x.Hide());
            Arrows.ForEach(x => x.Hide());
            Diamonds.ForEach(x => x.Hide());
        }

19 View Source File : UIBuilder.Buffs.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

private void DisposeBuffs() {
            Buffs.ForEach(x => x.Dispose());
            Buffs = null;

            BuffRoot->Destroy(true);
            BuffRoot = null;

            // ========= PARTYLIST =============

            var partyListAddon = UIHelper.PartyListAddon;

            for (var i = 0; i < PartyListBuffs.Count; i++) {
                if (partyListAddon != null) {
                    var partyMember = partyListAddon->PartyMember[i];
                    PartyListBuffs[i].DetachFrom(partyMember.TargetGlowContainer);
                    partyMember.PartyMemberComponent->UldManager.UpdateDrawNodeList();
                }
                PartyListBuffs[i].Dispose();
            }
            PartyListBuffs = null;
        }

19 View Source File : UIBuilder.Buffs.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public void HideAllBuffs() => Buffs.ForEach(x => x.Hide());

19 View Source File : UIBuilder.Gauges.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

private void DisposeGauges() {
            Bars.ForEach(x => x.Dispose());
            Bars = null;

            Arrows.ForEach(x => x.Dispose());
            Arrows = null;

            Diamonds.ForEach(x => x.Dispose());
            Diamonds = null;

            GaugeRoot->Destroy(true);
            GaugeRoot = null;
        }

19 View Source File : UIIconManager.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public void Reset() {
            IconConfigs.Clear();
            Icons.ForEach(x => x.Dispose());
            Icons.Clear();
        }

19 View Source File : QueryParameters.cs
License : MIT License
Project Creator : 17MKH

public DynamicParameters ToDynamicParameters()
    {
        var dynParams = new DynamicParameters();

        _parameters.ForEach(m =>
        {
            if (m.Value == null)
            {
                dynParams.Add(m.Key, null, DbType.String);
            }
            else
            {
                var t = m.Value.GetType();
                if (t.IsEnum)
                {
                    dynParams.Add(m.Key, m.Value, DbType.Int32);
                }
                else
                {
                    var dbType = TypeMap[m.Value.GetType()];
                    dynParams.Add(m.Key, m.Value, dbType);
                }
            }
        });

        return dynParams;
    }

19 View Source File : ObjectPool.cs
License : MIT License
Project Creator : 2881099

private void RestoreToAvailable()
        {

            bool isRestored = false;
            if (UnavailableException != null)
            {

                lock (UnavailableLock)
                {

                    if (UnavailableException != null)
                    {

                        UnavailableException = null;
                        UnavailableTime = null;
                        isRestored = true;
                    }
                }
            }

            if (isRestored)
            {

                lock (_allObjectsLock)
                    _allObjects.ForEach(a => a.LastGetTime = a.LastReturnTime = new DateTime(2000, 1, 1));

                Policy.OnAvailable();

                var bgcolor = Console.BackgroundColor;
                var forecolor = Console.ForegroundColor;
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write($"【{Policy.Name}】已恢复工作");
                Console.BackgroundColor = bgcolor;
                Console.ForegroundColor = forecolor;
                Console.WriteLine();
            }
        }

19 View Source File : ObjectPool.cs
License : MIT License
Project Creator : 2881099

private void RestoreToAvailable()
        {

            bool isRestored = false;
            if (UnavailableException != null)
            {

                lock (UnavailableLock)
                {

                    if (UnavailableException != null)
                    {

                        UnavailableException = null;
                        UnavailableTime = null;
                        isRestored = true;
                    }
                }
            }

            if (isRestored)
            {

                lock (_allObjectsLock)
                    _allObjects.ForEach(a => a.LastGetTime = a.LastReturnTime = new DateTime(2000, 1, 1));

                Policy.OnAvailable();

                TestTrace.WriteLine($"【{Policy.Name}】Recovered", ConsoleColor.DarkGreen);
            }
        }

19 View Source File : UserControlBase.cs
License : MIT License
Project Creator : 2881099

protected List<TextBoxX> InitLostFocus(Control control, Highlighter highlighter)
        {
            textBoxs = control.Controls.Cast<Control>().Where(a => (a is TextBoxX textBox))
            .OrderBy(a => a.Name).Select(a => a as TextBoxX).ToList();
            textBoxs.ForEach(a =>
            {
                a.LostFocus += (s, e) =>
                {
                    if (!string.IsNullOrEmpty(((TextBoxX)s).Text))
                    {
                        highlighter.SetHighlightColor(a, eHighlightColor.Green);
                    }
                };

            });
            return textBoxs;
        }

19 View Source File : Program.cs
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec

public static void PrintWarnings()
        {
            if (mismatchWarnings.Any())
            {
                Console.WriteLine(" ");
                Console.WriteLine("Attention - mismatch between technique and tactic has been detected!");
            }
            mismatchWarnings.ForEach(Console.WriteLine);
        }

19 View Source File : Function.cs
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec

private void initConfig()
        {
            _alerts = new List<ISender>();
            config = JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json"));
            if (string.IsNullOrEmpty(config.SlackPath))
                config.SlackPath = Environment.GetEnvironmentVariable("SLACKPATH");
            if (string.IsNullOrEmpty(config.WebhookChannel))
                config.WebhookChannel = Environment.GetEnvironmentVariable("WEBHOOKCHANNEL");
            if (string.IsNullOrEmpty(config.WebHookToken))
                config.WebHookToken = Environment.GetEnvironmentVariable("WEBHOOKTOKEN");
            if (string.IsNullOrEmpty(config.PostUrl))
                config.PostUrl = Environment.GetEnvironmentVariable("POSTURL");
            var type = typeof(ISender);
            var types = AppDomain.CurrentDomain.Getreplacedemblies()
                .SelectMany(s => s.GetTypes())
                .Where(p => type.IsreplacedignableFrom(p) && !p.IsInterface && !p.IsAbstract);
            types.ToList().ForEach(type => {
                ConstructorInfo ctor = type.GetConstructor(new[] { typeof(Storage<SessionLog>), typeof(Config), typeof(IMemoryCache) });
                ISender instance = ctor.Invoke(new object[] { _storage, config, memoryCache }) as ISender;
                _alerts.Add(instance);
            });
        }

19 View Source File : PlyHandler.cs
License : MIT License
Project Creator : 3DBear

private static PlyResult ParseAscii(List<string> plyFile, PlyHeader header)
        {
            var vertices = new List<Vector3>();
            var triangles = new List<int>();
            var colors = new List<Color>();
            var headerEndIndex = plyFile.IndexOf("end_header");
            var vertexStartIndex = headerEndIndex + 1;
            var faceStartIndex = vertexStartIndex + header.VertexCount + 1;
            plyFile.GetRange(vertexStartIndex, header.VertexCount).ForEach(vertex =>
            {
                var xyzrgb = vertex.Split(' ');
                vertices.Add(ParseVertex(xyzrgb, header));
                colors.Add(ParseColor(xyzrgb, header));
            });

            plyFile.GetRange(faceStartIndex, header.FaceCount).ForEach(face =>
            {
                triangles.AddRange(GetTriangles(face, header));
            });
            return new PlyResult(vertices, triangles, colors);
        }

19 View Source File : ProjectReferences.cs
License : MIT License
Project Creator : 3F

protected void InitMap()
        {
            foreach(var r in References)
            {
                if(!map.ContainsKey(r.Key)) {
                    map[r.Key] = new HashSet<string>();
                }
                r.Value.ForEach(i => ExtarctProjectGuid(i)?.E(g => map[r.Key].Add(FormatGuid(g))));
            }
            BuildOrder();
        }

19 View Source File : WNestedProjectsTest.cs
License : MIT License
Project Creator : 3F

protected void ResetData()
        {
            folders.ForEach(f => f.header.parent.Value = null);
            projects.ForEach(p => p.parent.Value = null);
        }

19 View Source File : TestController.cs
License : MIT License
Project Creator : a3geek

private void Update()
        {
            if(this.spawned == false)
            {
                return;
            }

            if(Input.GetKeyDown(KeyCode.Space))
            {
                this.collisions[LayersManager.UnityLayerCount]
                    .ForEach(coll => coll.GetComponent<Rigidbody2D>().simulated = !coll.GetComponent<Rigidbody2D>().simulated);
            }

            if(Input.GetKeyDown(KeyCode.V))
            {
                this.collisions[LayersManager.UnityLayerCount]
                    .ForEach(coll => coll.gameObject.SetActive(!coll.gameObject.activeSelf));
            }

            if(Input.GetKeyDown(KeyCode.A))
            {
                var colls = this.collisions[LayersManager.UnityLayerCount];

                for(var i = 0; i < colls.Count; i++)
                {
                    colls[i].Layer.ChangeLayer(LayersManager.UnityLayerCount + 1);
                    colls[i].UpdateIgnoreLayers();
                }
            }

            if(this.autoRespawn == false || Random.value > this.respawnRate)
            {
                return;
            }

            var keys = this.collisions.Keys.ToList();
            var layerID = keys[Random.Range(0, keys.Count)];

            if(Random.value <= 0.5f)
            {
                Debug.Log("Destroy");
                var colls = this.collisions[layerID];
                var coll = colls[Random.Range(0, colls.Count)];

                this.collisions[layerID].Remove(coll);
                Destroy(coll.gameObject);
            }
            else
            {
                Debug.Log("Create");
                var info = this.fieldInfo.Infos.FirstOrDefault(e => e.Prefab.LayerID == layerID);
                this.Create(info.Prefab, info.Parent, info.Color);
            }
        }

19 View Source File : TestController.cs
License : MIT License
Project Creator : a3geek

private void Update()
        {
            if(this.spawned == false)
            {
                return;
            }

            if(Input.GetKeyDown(KeyCode.Space))
            {
                this.collisions[LayersManager.UnityLayerCount]
                    .ForEach(coll => coll.GetComponent<Rigidbody2D>().simulated = !coll.GetComponent<Rigidbody2D>().simulated);
            }

            if(Input.GetKeyDown(KeyCode.V))
            {
                this.collisions[LayersManager.UnityLayerCount]
                    .ForEach(coll => coll.gameObject.SetActive(!coll.gameObject.activeSelf));
            }

            if(Input.GetKeyDown(KeyCode.A))
            {
                var colls = this.collisions[LayersManager.UnityLayerCount];

                for(var i = 0; i < colls.Count; i++)
                {
                    colls[i].Layer.ChangeLayer(LayersManager.UnityLayerCount + 1);
                    colls[i].UpdateIgnoreLayers();
                }
            }

            if(this.autoRespawn == false || Random.value > this.respawnRate)
            {
                return;
            }

            var keys = this.collisions.Keys.ToList();
            var layerID = keys[Random.Range(0, keys.Count)];

            if(Random.value <= 0.5f)
            {
                Debug.Log("Destroy");
                var colls = this.collisions[layerID];
                var coll = colls[Random.Range(0, colls.Count)];

                this.collisions[layerID].Remove(coll);
                Destroy(coll.gameObject);
            }
            else
            {
                Debug.Log("Create");
                var info = this.fieldInfo.Infos.FirstOrDefault(e => e.Prefab.LayerID == layerID);
                this.Create(info.Prefab, info.Parent, info.Color);
            }
        }

19 View Source File : PhysicsLayer.cs
License : MIT License
Project Creator : a3geek

private void Update(IEnumerable<int> layerIDs, Func<LayerCollision, bool> collGetter)
        {
            var ids = this.collisions.ConvertAll(coll => coll.LayerID);

            foreach(var layerID in layerIDs)
            {
                ids.Remove(layerID);

                var coll = this[layerID] ?? this.AddLayerCollision(layerID);
                coll.Collision = collGetter(coll);
            }

            ids.ForEach(id => this.DeleteLayerCollision(id));
        }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static Formula ConvertStringToMacroFormula(string formula, int frmRow, int frmCol)
        {
            Stack<AbstractPtg> ptgStack = new Stack<AbstractPtg>();
            int charactersPushed = 0;
            foreach (char c in formula)
            {
                PtgConcat ptgConcat = new PtgConcat();
                
                Stack<AbstractPtg> charStack = GetCharSubroutineWithArgsForInt(Convert.ToUInt16(c), 1);
                charStack.Reverse().ToList().ForEach(item => ptgStack.Push(item));
                charactersPushed += 1;
                if (charactersPushed > 1)
                {
                    ptgStack.Push(ptgConcat);
                }
            }
            
            Formula f = new Formula(new Cell(frmRow, frmCol), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));
            return f;
        }

19 View Source File : AuditTrailRepository.cs
License : Apache License 2.0
Project Creator : aadreja

public List<IAuditTrail> ReadAllAuditTrail(object id)
        {
            var lstAudit = ReadAll("*", $"[email protected] AND [email protected]", 
                new { TableName = enreplacedyTableInfo.Name, RecordId = id.ToString() }, 
                Config.CreatedOnColumnName + " ASC");

            var result = lstAudit.ToList();

            result.ForEach(p => p.Split());

            return result.Cast<IAuditTrail>().ToList();

        }

19 View Source File : VxFormRow.cs
License : MIT License
Project Creator : Aaltuj

internal static void AddColumn(VxFormRow foundRow, VxFormElementDefinition formColumn, VxFormLayoutOptions options)
        {
            foundRow.Columns.Add(formColumn);

            var layoutAttr = formColumn.RenderOptions;
            // Turn off all Labels for the elements
            switch (options.LabelOrientation)
            {
                case LabelOrientation.LEFT: layoutAttr.ShowLabel = false; break;
                case LabelOrientation.NONE: layoutAttr.ShowLabel = false; break;
                case LabelOrientation.TOP: layoutAttr.ShowLabel = true; break;
            }


            if (options.ShowPlaceholder == PlaceholderPolicy.EXPLICIT_LABEL_FALLBACK)
                layoutAttr.Placeholder = layoutAttr.Placeholder != null ? layoutAttr.Placeholder : layoutAttr.Label;
            else if (
                (options.ShowPlaceholder == PlaceholderPolicy.IMPLICIT || options.ShowPlaceholder == PlaceholderPolicy.IMPLICIT_LABEL_FALLBACK)
                && foundRow.Columns.Count > 1)
            {
                foundRow.Columns.ForEach(x =>
                {
                    x.RenderOptions.Placeholder = x.RenderOptions.Label;
                });
            }
            else if (options.ShowPlaceholder == PlaceholderPolicy.IMPLICIT_LABEL_FALLBACK && foundRow.Columns.Count == 1)
            {
                layoutAttr.Placeholder = layoutAttr.Label;
            }
            else if (options.ShowPlaceholder == PlaceholderPolicy.NONE)
                layoutAttr.Placeholder = null;

        }

19 View Source File : RandomWeaponGeneratorWindow.cs
License : MIT License
Project Creator : Abdelfattah-Radwan

private void SavereplacedetReferences()
		{
			List<int> templatesInstanceIDs = new List<int>();
			List<int> weaponBasesInstanceIDs = new List<int>();
			List<int> stocksInstanceIDs = new List<int>();
			List<int> handlesInstanceIDs = new List<int>();
			List<int> magazinesInstanceIDs = new List<int>();
			List<int> scopesInstanceIDs = new List<int>();
			List<int> barrelsInstanceIDs = new List<int>();

			templates?.ForEach(template =>
			{
				if (template != null)
				{
					templatesInstanceIDs.Add(template.GetInstanceID());
				}
			});

			weaponBases?.ForEach(weaponBase =>
			{
				if (weaponBase != null)
				{
					weaponBasesInstanceIDs.Add(weaponBase.GetInstanceID());
				}
			});

			stocks?.ForEach(stock =>
			{
				if (stock != null)
				{
					stocksInstanceIDs.Add(stock.GetInstanceID());
				}
			});

			grips?.ForEach(handle =>
			{
				if (handle != null)
				{
					handlesInstanceIDs.Add(handle.GetInstanceID());
				}
			});

			magazines?.ForEach(magazine =>
			{
				if (magazine != null)
				{
					magazinesInstanceIDs.Add(magazine.GetInstanceID());
				}
			});

			scopes?.ForEach(scope =>
			{
				if (scope != null)
				{
					scopesInstanceIDs.Add(scope.GetInstanceID());
				}
			});

			barrels?.ForEach(barrel =>
			{
				if (barrel != null)
				{
					barrelsInstanceIDs.Add(barrel.GetInstanceID());
				}
			});

			List<int>[] lists = new List<int>[7]
			{
				templatesInstanceIDs,
				weaponBasesInstanceIDs,
				stocksInstanceIDs,
				handlesInstanceIDs,
				magazinesInstanceIDs,
				scopesInstanceIDs,
				barrelsInstanceIDs,
			};

			using (FileStream fileStream = new FileStream(Path.Combine("Temp", replacedET_REFERENCES_INSTANCE_IDS_FILE_NAME), FileMode.Create))
			{
				new BinaryFormatter().Serialize(fileStream, lists);
			}
		}

19 View Source File : RandomWeaponGeneratorWindow.cs
License : MIT License
Project Creator : Abdelfattah-Radwan

private void LoadreplacedetReferences()
		{
			templates?.Clear();
			weaponBases?.Clear();
			stocks?.Clear();
			grips?.Clear();
			magazines?.Clear();
			scopes?.Clear();
			barrels?.Clear();

			string filePath = Path.Combine("Temp", replacedET_REFERENCES_INSTANCE_IDS_FILE_NAME);

			if (File.Exists(filePath))
			{
				List<int>[] lists = new List<int>[0];

				using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
				{
					lists = new BinaryFormatter().Deserialize(fileStream) as List<int>[];
				}

				lists[0].ForEach(id => templates?.Add(replacedetDatabase.LoadreplacedetAtPath<WeaponPropertiesTemplate>(replacedetDatabase.GetreplacedetPath(id))));
				lists[1].ForEach(id => weaponBases?.Add(replacedetDatabase.LoadreplacedetAtPath<WeaponBase>(replacedetDatabase.GetreplacedetPath(id))));
				lists[2].ForEach(id => stocks?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
				lists[3].ForEach(id => grips?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
				lists[4].ForEach(id => magazines?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
				lists[5].ForEach(id => scopes?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
				lists[6].ForEach(id => barrels?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
			}
		}

19 View Source File : ObjectService.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<TransactionObjectDto>> GetObjectsByIds(List<int> objectsIds)
        {

            var objectsIdsModel = new ObjectsIdsModel();
            objectsIds.ForEach(oid => objectsIdsModel.ObjectsIds.Add(oid));

            var upstreamModel = await _objectsClient.GetObjectsDataAsync(objectsIdsModel);

            var objects = upstreamModel.Objects.Select(om => new TransactionObjectDto
            {
                Description = om.Description,
                Id = om.Id,
                Name = om.Name,
                PhotoUrl = om.PhotoUrl
            }).ToList();

            return objects;
        }

19 View Source File : UserService.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<UserDto>> GetUsersAsync(List<string> usersIds)
        {
            if (usersIds.IsNullOrEmpty())
            {
                return new List<UserDto>();
            }
            var usersIdsModel = new UsersIdsModel();
            usersIds.ForEach(uid => usersIdsModel.UsersIds.Add(uid));

            var users = await _grpcClient.GetUsersDataV1_1Async(usersIdsModel);

            var usersDtos = users.Users.Select(umodel => new UserDto
            {
                Email = umodel.Email,
                Id = umodel.Id,
                Name = umodel.Name,
                PictureUrl = umodel.PictureUrl,
                Username = umodel.Username, PhoneNumber = umodel.PhoneNumber
            }).ToList();

            return usersDtos;
        }

19 View Source File : ObjectService.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<TransactionObjectDto>> GetObjectsByIds(List<int> objectsIds)
        {

            var objectsIdsModel = new ObjectsIdsModel();
            objectsIds.ForEach(oid => objectsIdsModel.ObjectsIds.Add(oid));

            var upstreamModel = await _objectsClient.GetObjectsDataAsync(objectsIdsModel);

            var objects = upstreamModel.Objects.Select(om => new TransactionObjectDto
            {
                Description = om.Description,
                Id = om.Id,
                Name = om.Name
            }).ToList();

            return objects;
        }

19 View Source File : UserService.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<UserDto>> GetUsersAsync(List<string> usersIds)
        {
            if (usersIds.IsNullOrEmpty())
            {
                return new List<UserDto>();
            }
            var usersIdsModel = new UsersIdsModel();
            usersIds.ForEach(uid => usersIdsModel.UsersIds.Add(uid));

            var users = await _grpcClient.GetUsersDataAsync(usersIdsModel);

            var usersDtos = users.Users.Select(umodel => new UserDto
            {
                Email = umodel.Email,
                Id = umodel.Id,
                Name = umodel.Name,
                PictureUrl = umodel.PictureUrl,
                Username = umodel.Username
            }).ToList();

            return usersDtos;
        }

19 View Source File : UserService.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<(double? distance, string userId)>> CalculateUsersDistances(string theUserId, List<string> usersIds)
        {
            var request = new CalculateDistanceRequest();
            request.TheUserId = theUserId;
            usersIds.ForEach(uid => request.UserIds.Add(uid));

            var result = await _grpcClient.CalculateDistanceAsync(request);

            return result.Distances.Select(d => (d.Distance, d.UserId)).ToList();
        }

19 View Source File : UserStatsGetter.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<UserMonthlyCountStats>> GetUsersCountOverMonth()
        {
            var startDate = DateTime.UtcNow.AddDays(-31);
            var endDate = DateTime.UtcNow;

            var users = (from u in _usersRepo.Table.Where(uu => uu.CreatedAt >= startDate && uu.CreatedAt <= endDate)
                         group u by u.CreatedAt.Date into g
                         orderby g.Key
                         select new UserMonthlyCountStats
                         {
                             Count = g.Count(),
                             Day = g.Key
                         }).ToList();
            var days = Enumerable.Range(0, 31).Select(offset => endDate.AddDays(-offset)).ToList();

            days.ForEach(day =>
            {
                if (!users.Any(u => u.Day.Date == day.Date))
                {
                    users.Add(new UserMonthlyCountStats
                    {
                        Day = day.Date,
                        Count = 0
                    });
                }
            });

            users = users.OrderBy(u => u.Day.Date).ToList();

            return users;
        }

19 View Source File : UserStatsGetter.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<int>> GetUsersCountOverToday()
        {
            // This will resolve to MM/DD/YYYY 00:00:00
            var startDate = DateTime.UtcNow.Date;

            // This will resolve to MM/DD+1/YYYY 00:00:00
            var endDate = DateTime.UtcNow.Date.AddDays(1);

            var usersHourly = (from u in _usersRepo.Table
                               where u.CreatedAt >= startDate && u.CreatedAt <= endDate
                               group u by new
                               {
                                   u.CreatedAt.Date,
                                   u.CreatedAt.Hour
                               } into g
                               select new
                               {
                                   Count = g.Count(),
                                   Date = g.Key.Date,
                                   Hour = g.Key.Hour
                               }).ToList();
            var usersHourlyFormated = usersHourly.Select(u => new
            {
                Count = u.Count,
                DateTime = new DateTime(u.Date.Year, u.Date.Month, u.Date.Day, u.Hour, 0, 0)
            }).ToList();

            var hours = Enumerable.Range(0, 24).Select(offset =>
            {

                var dateTime = startDate.AddHours(offset);
                return dateTime;
            }).ToList();

            hours.ForEach(hour =>
            {
                if (!usersHourlyFormated.Any(u => u.DateTime == hour))
                {
                    usersHourlyFormated.Add(new
                    {
                        Count = 0,
                        DateTime = hour
                    });
                }
            });
            usersHourlyFormated = usersHourlyFormated.OrderBy(u => u.DateTime).ToList();

            var stats = usersHourlyFormated.Select(u => u.Count).ToList();
            return stats;
        }

19 View Source File : UserStatsGetter.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<UserYearlyCountListStats> GetUsersCountOverTwoYears()
        {
            // end Date 6/4/ 2020
            // start date 1/1/2019
            // the stats will
            // CurrentYear : 1/1/20, 1/2/20, 1/3/20, 1/4/20, 1/5/20 = 0, 1/6/20 = 0, 1/7/20 = 0, ...
            // PreviousYear: 1/1/19, 1/2/19, 1/3/19, 1/4/19, 1/5/19 = x, 1/6/20 = y, 1/7/19 = z, ...
            var startDate = DateTime.UtcNow.AddYears(-1).AddMonths(-DateTime.UtcNow.Month + 1).AddDays(-DateTime.UtcNow.Day + 1).Date;
            var endDate = DateTime.UtcNow.Date;

            var usersMonthly = (from u in _usersRepo.Table
                                where u.CreatedAt >= startDate && u.CreatedAt <= endDate
                                group u by new
                                {
                                    u.CreatedAt.Year,
                                    u.CreatedAt.Month
                                } into g
                                select new
                                {
                                    Count = g.Count(),
                                    MonthYear = new DateTime(g.Key.Year, g.Key.Month, 1)
                                }).ToList();

            var months = Enumerable.Range(0, 24).Select(offset => startDate.AddMonths(offset)).ToList();

            months.ForEach(month =>
            {
                if (!usersMonthly.Any(u => u.MonthYear.Year == month.Year && u.MonthYear.Month == month.Month))
                {
                    usersMonthly.Add(new
                    {
                        Count = 0,
                        MonthYear = month,
                    });
                }
            });

            return new UserYearlyCountListStats()
            {
                CurrentYear = usersMonthly.Where(um => um.MonthYear.Year == DateTime.UtcNow.Year).OrderBy(c => c.MonthYear).Select(c => c.Count).ToList(),
                PreviousYear = usersMonthly.Where(um => um.MonthYear.Year == DateTime.UtcNow.Year - 1).OrderBy(c => c.MonthYear).Select(c => c.Count).ToList()
            };
        }

19 View Source File : TransactionStatsQueriesHandler.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<TransactionTodayStatsDto> Handle(TransactionStatsOverTodayQuery request, CancellationToken cancellationToken)
        {
            // This will resolve to MM/DD/YYYY 00:00:00
            var startDate = DateTime.UtcNow.Date;

            // This will resolve to MM/DD+1/YYYY 00:00:00
            var endDate = DateTime.UtcNow.Date.AddDays(1);

            var transesHourly = (from r in _receivingsRepo.Table
                                 where r.ReceivedAtUtc >= startDate && r.ReceivedAtUtc <= endDate
                                 group r by new
                                 {
                                     r.ReceivedAtUtc.Date,
                                     r.ReceivedAtUtc.Hour,
                                 } into g
                                 select new
                                 {
                                     Count = g.Count(),
                                     Date = g.Key.Date,
                                     Hour = g.Key.Hour
                                 });
            var transesHourlyFormated = transesHourly.Select(r => new
            {
                r.Count,
                DateTime = new DateTime(r.Date.Year, r.Date.Month, r.Date.Day, r.Hour, 0, 0)
            }).ToList();

            var hours = Enumerable.Range(0, 24).Select(offset =>
            {

                var dateTime = startDate.AddHours(offset);
                return dateTime;
            }).ToList();

            hours.ForEach(hour =>
            {
                if (!transesHourlyFormated.Any(t => t.DateTime == hour))
                {
                    transesHourlyFormated.Add(new
                    {
                        Count = 0,
                        DateTime = hour
                    });
                }
            });

            transesHourlyFormated = transesHourlyFormated.OrderBy(t => t.DateTime).ToList();
            var stats = transesHourlyFormated.Select(t => t.Count).ToList();

            var transactions = from r in _registrationsRepo.Table
                               where r.ShouldReturnItAfter.HasValue && r.Status == ObjectRegistrationStatus.OK
                               select r;
            var late = transactions
                .AsEnumerable()
                .Count(r => r.ObjectReceiving != null &&
                    r.ObjectReceiving.ObjectReturning != null &&
                    (r.ObjectReceiving.ReceivedAtUtc + r.ShouldReturnItAfter.Value) > r.ObjectReceiving.ObjectReturning.ReturnedAtUtc.AddMinutes(30));
            var notReturned = transactions.Count(r => r.ObjectReceiving != null && r.ObjectReceiving.ObjectReturning == null);
            var onTime = transactions
                .AsEnumerable()
                .Count(r => r.ObjectReceiving != null &&
                    r.ObjectReceiving.ObjectReturning != null &&
                    r.ObjectReceiving.ReceivedAtUtc.Add(r.ShouldReturnItAfter.Value) <= r.ObjectReceiving.ObjectReturning.ReturnedAtUtc.AddMinutes(30));

            return new TransactionTodayStatsDto
            {
                LateReturn = late,
                NotReturnedYet = notReturned,
                OnTimeReturn = onTime,
                TransactionsOverToday = stats
            };
        }

19 View Source File : TransactionStatsQueriesHandler.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<TransactionMonthlyStatsDto>> Handle(TransactionStatsOverMonthQuery request, CancellationToken cancellationToken)
        {
            var startDate = DateTime.UtcNow.Date.AddDays(-31);
            var endDate = DateTime.UtcNow.Date;

            var transes = (from r in _receivingsRepo.Table
                           where
                              r.ReceivedAtUtc.Date >= startDate && r.ReceivedAtUtc.Date <= endDate
                           group r by r.ReceivedAtUtc.Date into g
                           orderby g.Key
                           select new TransactionMonthlyStatsDto
                           {
                               Count = g.Count(),
                               Day = g.Key
                           }).ToList();
            var days = Enumerable.Range(0, 31).Select(offset => endDate.AddDays(-offset)).ToList();

            days.ForEach(day =>
            {
                if (!transes.Any(t => t.Day.Date == day.Date))
                {
                    transes.Add(new TransactionMonthlyStatsDto
                    {
                        Count = 0,
                        Day = day.Date,
                    });
                }
            });

            return transes.OrderBy(t => t.Day.Date).ToList();
        }

19 View Source File : TransactionStatsQueriesHandler.cs
License : MIT License
Project Creator : Abdulrhman5

public async Task<List<int>> Handle(TransactionStatsOverYearQuery request, CancellationToken cancellationToken)
        {
            // end Date 6/4/ 2020
            // start date 1/1/2019
            // the stats will
            // CurrentYear : 1/1/20, 1/2/20, 1/3/20, 1/4/20, 1/5/20 = 0, 1/6/20 = 0, 1/7/20 = 0, ...
            var startDate = DateTime.UtcNow.AddMonths(-DateTime.UtcNow.Month + 1).AddDays(-DateTime.UtcNow.Day + 1).Date;
            var endDate = DateTime.UtcNow.Date.AddDays(1);

            var transesMonthly = (from r in _receivingsRepo.Table
                                  where
                                     r.ReceivedAtUtc >= startDate && r.ReceivedAtUtc <= endDate
                                  group r by new
                                  {
                                      r.ReceivedAtUtc.Year,
                                      r.ReceivedAtUtc.Month
                                  } into g
                                  select new
                                  {
                                      Count = g.Count(),
                                      MonthYear = new DateTime(g.Key.Year, g.Key.Month, 1)
                                  }).ToList();

            var months = Enumerable.Range(0, 12).Select(offset => startDate.AddMonths(offset)).ToList();

            months.ForEach(month =>
            {
                if (!transesMonthly.Any(u => u.MonthYear.Year == month.Year && u.MonthYear.Month == month.Month))
                {
                    transesMonthly.Add(new
                    {
                        Count = 0,
                        MonthYear = month,
                    });
                }
            });

            return transesMonthly.Select(m => m.Count).ToList();
        }

19 View Source File : EndlessItemsControl.cs
License : MIT License
Project Creator : ABTSoftware

private void AddMoreItems()
        {
            var isBusy = (bool)GetValue(IsBusyProperty);
            if (!isBusy)
            {
                SetValue(IsBusyProperty, true);
                SetValue(IsBusyProperty, false);
                SetValue(IsBusyProperty, true);
                var delay = (TimeSpan)GetValue(PreLoadingDelayProperty);
                
                Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(delay);

                    var items = _allItems.Take(10).ToList();
                    items.ForEach(item =>
                    {
                        Dispatcher.BeginInvoke(new Action(() => Currenreplacedems.Add(item)));
                        _allItems.Remove(item);
                    });
                }).ContinueWith(_ =>
                {
                    Dispatcher.BeginInvoke(new Action(() => SetValue(IsBusyProperty, false)));
                });
            }
        }

19 View Source File : EndlessItemsControl.cs
License : MIT License
Project Creator : ABTSoftware

private void RefhrereplacedemsSource(List<object> newItems)
        {
            var startCapacity = (int)GetValue(StartCapacityProperty);

            _allItems = newItems;
            Currenreplacedems = new ObservableCollection<object>(_allItems.Take(startCapacity));
            _allItems.Take(startCapacity).ToList().ForEach(item => _allItems.Remove(item));

            var binding = new Binding
            {
                Path = new PropertyPath("Currenreplacedems"),
                Source = this,
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };
            SetBinding(ItemsSourceProperty, binding);
        }

19 View Source File : Example.cs
License : MIT License
Project Creator : ABTSoftware

private void LoadCode()
        {
            try
            {
                _sourceFilePaths.ForEach(file =>
                {
                    var index = file.LastIndexOf('/') + 1;
                    var fileName = file.Substring(index).Replace(".txt", String.Empty);
                    _sourceFiles[fileName] = ExampleLoader.LoadSourceFile(file);
                });
            }
            catch (Exception ex)
            {                
                throw new Exception(string.Format("An error occurred when parsing the source-code files for Example '{0}'", replacedle), ex);
            }
        }

19 View Source File : DigitalAnalyzerExampleViewModel.cs
License : MIT License
Project Creator : ABTSoftware

private async Task GenerateData(List<byte[]> digitalChannels, List<float[]> replacedogChannels)
        {
            var digitalChannelsCount = digitalChannels.Count;
            var replacedogChannelsCount = replacedogChannels.Count;

            var totalChannelCount = digitalChannelsCount + replacedogChannelsCount;
            var channelList = new List<ChannelViewModel>(totalChannelCount);
            var channelIndex = ChannelViewModels.Count;

            await Task.Run(async () =>
            {
                var xStart = 0d;
                var xStep = 1d;

                var digital = new List<Task<ChannelViewModel>>(digitalChannelsCount);
                var replacedog = new List<Task<ChannelViewModel>>(replacedogChannelsCount);

                foreach (var channel in digitalChannels)
                {
                    var id = channelIndex++;
                    digital.Add(Task.Run(() => ChannelGenerationHelper.Instance.GenerateDigitalChannel(xStart, xStep, channel, id)));
                }
                foreach (var channel in replacedogChannels)
                {
                    var id = channelIndex++;
                    replacedog.Add(Task.Run(() => ChannelGenerationHelper.Instance.GeneratereplacedogChannel(xStart, xStep, channel, id)));
                }

                await Task.WhenAll(digital.Union(replacedog));

                foreach (var p in digital.Union(replacedog))
                {
                    channelList.Add(p.Result);
                }
            });

            channelList.ForEach(ch => ChannelViewModels.Add(ch));
        }

19 View Source File : DigitalAnalyzerExampleViewModel.cs
License : MIT License
Project Creator : ABTSoftware

private async Task GenerateData(List<byte[]> digitalChannels)
        {
            var digitalChannelsCount = digitalChannels.Count;

            var channelList = new List<ChannelViewModel>(digitalChannelsCount);
            var channelIndex = ChannelViewModels.Count;

            await Task.Run(async () =>
            {
                var xStart = 0d;
                var xStep = 1d;

                var channels = new List<Task<ChannelViewModel>>(digitalChannelsCount);

                foreach (var channel in digitalChannels)
                {
                    var id = channelIndex++;
                    channels.Add(Task.Run(() => ChannelGenerationHelper.Instance.GenerateDigitalChannel(xStart, xStep, channel, id)));
                }

                await Task.WhenAll(channels);

                foreach (var p in channels)
                {
                    channelList.Add(p.Result);
                }
            });

            channelList.ForEach(ch => ChannelViewModels.Add(ch));
        }

19 View Source File : SurfaceMeshSelectionModifier.cs
License : MIT License
Project Creator : ABTSoftware

public override void OnModifierMouseUp(ModifierMouseArgs e)
        {
            base.OnModifierMouseUp(e);

            ClearAll();

            if (!IsDragging || Viewport3D == null || Viewport3D.RootEnreplacedy == null) return;

            var endPoint = e.MousePoint;
            var distanceDragged = PointUtil.Distance(StartPoint, endPoint);
            var isAreaSelection = distanceDragged > MinDragSensitivity;

            IList<EnreplacedyVertexId> hitEnreplacedyVertexIds;
            if (isAreaSelection)
            {
                // Drag select
                hitEnreplacedyVertexIds = Viewport3D.PickScene(new Rect(StartPoint, e.MousePoint));
            }
            else
            {
                // Point select
                var vertexId = Viewport3D.PickScene(e.MousePoint);
                hitEnreplacedyVertexIds = vertexId.HasValue ? new[] { vertexId.Value } : new EnreplacedyVertexId[0];
            }
            if (!hitEnreplacedyVertexIds.IsNullOrEmpty())
            {
                var hitEnreplacedyGroups = hitEnreplacedyVertexIds
                    .GroupBy(x => x.EnreplacedyId)
                    .ToDictionary(x => x.Key, x => x.Select(i => new VertexId { Id = i.VertexId }).ToList());

                var xSize = BoundedPaletteProvider.XSize - 1;

                //Visit enreplacedies to perform selection or deselection
                Viewport3D.RootEnreplacedy.VisitEnreplacedies(enreplacedy =>
                {
                    var enreplacedyId = enreplacedy.EnreplacedyId;
                    var hitVertexIds = new List<VertexId>();

                    if (hitEnreplacedyGroups.ContainsKey(enreplacedyId))
                    {
                        hitVertexIds = hitEnreplacedyGroups[enreplacedyId];
                    }

                    if (hitVertexIds.Any())
                    {
                        if (!_selectedVertices.ContainsKey(enreplacedyId))
                            _selectedVertices.Add(enreplacedyId, new HashSet<ulong>());


                        var selectedVertices = _selectedVertices[enreplacedyId];
                        hitVertexIds.ForEach(x => selectedVertices.Add(x.Id));

                        BoundedPaletteProvider.SelectedIndexes.Clear();
                        foreach (var hitEnreplacedyVertexId in hitEnreplacedyVertexIds)
                        {
                            var id = Convert.ToInt32(hitEnreplacedyVertexId.VertexId) - 1;
                            var vertexIndexInfo = new SurfaceMeshVertexInfo();
                            if (id < xSize)
                            {
                                vertexIndexInfo.XIndex = id;
                            }
                            else
                            {
                                vertexIndexInfo.ZIndex = id / xSize;
                                vertexIndexInfo.XIndex = id - (vertexIndexInfo.ZIndex * xSize);
                            }

                            BoundedPaletteProvider.SelectedIndexes.Add(vertexIndexInfo);
                        }
                    }
                    else
                    {
                        _selectedVertices.Remove(enreplacedyId);
                        BoundedPaletteProvider.SelectedIndexes.Clear();
                    }
                });
            }

            IsDragging = false;
            ReleaseMouseCapture();
            BoundedPaletteProvider.DataSeries.IsDirty = true;
            BoundedPaletteProvider.DataSeries.OnDataSeriesChanged(DataSeriesUpdate.SelectionChanged,
                DataSeriesAction.None);
        }

19 View Source File : DataBuilder.cs
License : MIT License
Project Creator : abvogel

public XmlDoreplacedent BuildSchemaXML()
        {
            this._Enreplacedies.Keys.ToList().ForEach(logicalName =>
            {
                this.AppendData(GetStubRecords(logicalName));
            });

            this._Enreplacedies.Keys.ToList().ForEach(logicalName =>
            {
                // Commit global plugin disable state if it was set
                if (_PluginsDisabled != null)
                    this._Enreplacedies[logicalName].PluginsDisabled = (bool)_PluginsDisabled;
                this.FinalizeEnreplacedy(logicalName);
            });

            return XmlSchemaBuilder.ToXmlDoreplacedent(_Enreplacedies);
        }

19 View Source File : DataBuilder.cs
License : MIT License
Project Creator : abvogel

public XmlDoreplacedent BuildDataXML()
        {
            this._Enreplacedies.Keys.ToList().ForEach(logicalName =>
            {
                this.AppendData(GetStubRecords(logicalName));
            });

            this._Enreplacedies.Keys.ToList().ForEach(logicalName =>
            {
                this.FinalizeEnreplacedy(logicalName);
            });

            return XmlDataBuilder.ToXmlDoreplacedent(_Enreplacedies);
        }

19 View Source File : DataBuilder.cs
License : MIT License
Project Creator : abvogel

private List<Enreplacedy> GetStubRecordsForM2MRelationships(string logicalName)
        {
            var stubRecords = new List<Enreplacedy>();
            foreach (var Relationship in this._Enreplacedies[logicalName].RelatedEnreplacedies)
            {
                var targetLogicalName = this._Enreplacedies[logicalName].Metadata.ManyToManyRelationships.Where(x => x.SchemaName == Relationship.Key || x.IntersectEnreplacedyName == Relationship.Key).Select(x => x.Enreplacedy2LogicalName).FirstOrDefault();

                foreach (var RelatedEnreplacedyPair in Relationship.Value)
                {
                    stubRecords.Add(new Enreplacedy(logicalName, RelatedEnreplacedyPair.Key));
                    RelatedEnreplacedyPair.Value.ToList<Guid>().ForEach(stubRecordId => stubRecords.Add(new Enreplacedy(targetLogicalName, stubRecordId)));
                }
            }
            return stubRecords;
        }

19 View Source File : BuilderEntityMetadata.cs
License : MIT License
Project Creator : abvogel

private void ReduceEnreplacediesBasedOnIdentifier()
        {
            Dictionary<String, Enreplacedy> DistinctEnreplacedies = new Dictionary<String, Enreplacedy>();

            while (Enreplacedies.Count > 0)
            {
                var enreplacedy = Enreplacedies.Dequeue();
                String EnreplacedyIdentifier = GetIdentifierFromEnreplacedy(enreplacedy);
                if (DistinctEnreplacedies.ContainsKey(EnreplacedyIdentifier))
                {
                    Enreplacedy priorEnreplacedy = DistinctEnreplacedies[EnreplacedyIdentifier];
                    foreach (var attribute in enreplacedy.Attributes)
                    {
                        priorEnreplacedy[attribute.Key] = attribute.Value;
                    }
                    DistinctEnreplacedies[EnreplacedyIdentifier] = priorEnreplacedy;
                }
                else
                {
                    DistinctEnreplacedies.Add(EnreplacedyIdentifier, enreplacedy);
                }
            }

            // Rebuild list of enreplacedies based on an enforced identifier
            DistinctEnreplacedies.Keys.ToList<String>().ForEach(key => Enreplacedies.Enqueue(DistinctEnreplacedies[key]));
        }

19 View Source File : BuilderEntityMetadata.cs
License : MIT License
Project Creator : abvogel

private String GetIdentifierFromEnreplacedy(Enreplacedy enreplacedy)
        {
            List<Object> EnreplacedyIdentifier = new List<Object>();

            Identifiers.ForEach(identifier =>
            {
                if (enreplacedy.Contains(identifier))
                {
                    EnreplacedyIdentifier.Add(enreplacedy[identifier]);
                }
            });

            return String.Join("|", EnreplacedyIdentifier);
        }

19 View Source File : UnitTests_SpecialLogic.cs
License : MIT License
Project Creator : abvogel

[TestMethod]
        public void ReflexiveM2MRelationship_Data()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.AgentScriptActionLogicalName,
                SupportMethods.AgentScriptActionDisplayName,
                SupportMethods.Getm2mReflexiveRelationshipTypeEnreplacedies());
            fakedContext.AddRelationship("msdyusd_subactioncalls", new XrmFakedRelationship
            {
                IntersectEnreplacedy = "msdyusd_subactioncalls",
                Enreplacedy1LogicalName = "msdyusd_agentscriptaction",
                Enreplacedy1Attribute = "msdyusd_agentscriptactionidone",
                Enreplacedy2LogicalName = "msdyusd_agentscriptaction",
                Enreplacedy2Attribute = "msdyusd_agentscriptactionidtwo"
            });

            fakedContext.AddExecutionMock<RetrieveEnreplacedyRequest>(req =>
            {
                var enreplacedyMetadata = fakedContext.GetEnreplacedyMetadataByName(SupportMethods.AgentScriptActionLogicalName);

                enreplacedyMetadata.DisplayName = new Label(SupportMethods.AgentScriptActionDisplayName, 1033);
                enreplacedyMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "msdyusd_name");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("IntersectEnreplacedyName", "msdyusd_subactioncalls");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy1LogicalName", "msdyusd_agentscriptaction");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy2LogicalName", "msdyusd_agentscriptaction");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy2IntersectAttribute", "msdyusd_agentscriptactionidtwo");

                var response = new RetrieveEnreplacedyResponse()
                {
                    Results = new ParameterCollection
                        {
                            { "EnreplacedyMetadata", enreplacedyMetadata }
                        }
                };
                return response;
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();
            SupportMethods.Getm2mReflexiveRelationshipTypereplacedociateRequests().ToList<replacedociateRequest>().ForEach(r => fakedService.Execute(r));


            DataBuilder DataBuilder = new DataBuilder(fakedService);
            DataBuilder.AppendData(SupportMethods.Getm2mReflexiveRelationshipTypeFetch());

            replacedert.AreEqual(DataBuilder.BuildDataXML().InnerXml, SupportMethods.Getm2mReflexiveRelationshipTypeExpectedData());
        }

19 View Source File : UnitTests_SpecialLogic.cs
License : MIT License
Project Creator : abvogel

[TestMethod]
        public void ReflexiveM2MRelationship_Schema()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.AgentScriptActionLogicalName,
                SupportMethods.AgentScriptActionDisplayName,
                SupportMethods.Getm2mReflexiveRelationshipTypeEnreplacedies());
            fakedContext.AddRelationship("msdyusd_subactioncalls", new XrmFakedRelationship
            {
                IntersectEnreplacedy = "msdyusd_subactioncalls",
                Enreplacedy1LogicalName = "msdyusd_agentscriptaction",
                Enreplacedy1Attribute = "msdyusd_agentscriptactionidone",
                Enreplacedy2LogicalName = "msdyusd_agentscriptaction",
                Enreplacedy2Attribute = "msdyusd_agentscriptactionidtwo"
            });

            fakedContext.AddExecutionMock<RetrieveEnreplacedyRequest>(req =>
            {
                var enreplacedyMetadata = fakedContext.GetEnreplacedyMetadataByName(SupportMethods.AgentScriptActionLogicalName);

                enreplacedyMetadata.DisplayName = new Label(SupportMethods.AgentScriptActionDisplayName, 1033);
                enreplacedyMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "msdyusd_name");
                enreplacedyMetadata.Attributes.First(a => a.LogicalName == "msdyusd_agentscriptactionid").SetSealedPropertyValue("DisplayName", new Label("Agent Script Action", 1033));
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("IntersectEnreplacedyName", "msdyusd_subactioncalls");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy1LogicalName", "msdyusd_agentscriptaction");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy2LogicalName", "msdyusd_agentscriptaction");
                enreplacedyMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Enreplacedy2IntersectAttribute", "msdyusd_agentscriptactionidtwo");

                var response = new RetrieveEnreplacedyResponse()
                {
                    Results = new ParameterCollection
                        {
                            { "EnreplacedyMetadata", enreplacedyMetadata }
                        }
                };
                return response;
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();
            SupportMethods.Getm2mReflexiveRelationshipTypereplacedociateRequests().ToList<replacedociateRequest>().ForEach(r => fakedService.Execute(r));


            DataBuilder DataBuilder = new DataBuilder(fakedService);
            DataBuilder.AppendData(SupportMethods.Getm2mReflexiveRelationshipTypeFetch());

            replacedert.AreEqual(DataBuilder.BuildSchemaXML().InnerXml, SupportMethods.Getm2mReflexiveRelationshipTypeExpectedSchema());
        }

19 View Source File : LazyTreeNode.cs
License : MIT License
Project Creator : Accelerider

public virtual async Task<bool> RefreshAsync()
        {
            if (_isRefreshing) return false;
            _isRefreshing = true;

            if (ChildrenProvider == null) return AbortRefresh();
            var enumerable = await ChildrenProvider(Content);
            if (enumerable == null) return AbortRefresh();

            var collection = enumerable.ToList();
            if (!collection.Any()) return AbortRefresh();

            var children = collection.Select(GenerateLazyTreeNode).ToList();
            children.ForEach(item => item.Parent = this);

            SetChildrenCache(children.AsReadOnly());

            _isRefreshing = false;
            return true;
        }

19 View Source File : DatDirectory.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void AddFilesToList(Dictionary<uint, DatFile> dicFiles)
        {
            Directories.ForEach(d => d.AddFilesToList(dicFiles));

            for (int i = 0; i < DatDirectoryHeader.EntryCount; i++)
                dicFiles[DatDirectoryHeader.Entries[i].ObjectId] = DatDirectoryHeader.Entries[i];
        }

19 View Source File : DataContextTests.cs
License : MIT License
Project Creator : Accelerider

[TestMethod()]
        public void ImportTest()
        {
            var dataContext = new DataContext();
            var viewModelImport = new ViewModelImport(dataContext);
            var viewModelExport = new ViewModelExport(dataContext);
            List<ViewModelImport> viewModelImports = new List<ViewModelImport>
            {
                viewModelImport,
                new ViewModelImport(dataContext),
                new ViewModelImport(dataContext),
                new ViewModelImport(dataContext),
                new ViewModelImport(dataContext),
                new ViewModelImport(dataContext),
            };

            var count = 0;

            viewModelImports.ForEach(item => item.PropertyChanged += (sender, args) =>
            {
                replacedert.AreEqual(nameof(ViewModelImport.Name), args.PropertyName);
                count++;
            });


            for (int i = 0; i < TestStrings.Length; i++)
            {
                viewModelExport.Name = TestStrings[i];

                replacedert.AreEqual((i + 1) * viewModelImports.Count, count);
                foreach (var import in viewModelImports)
                {
                    replacedert.AreEqual(TestStrings[i], import.Name);
                }
            }
        }

19 View Source File : NetworkSession.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

private void DoRequestForRetransmission(uint rcvdSeq)
        {
            var desiredSeq = lastReceivedPacketSequence + 1;
            List<uint> needSeq = new List<uint>();
            needSeq.Add(desiredSeq);
            uint bottom = desiredSeq + 1;
            if (rcvdSeq < bottom || rcvdSeq - bottom > CryptoSystem.MaximumEffortLevel)
            {
                session.Terminate(SessionTerminationReason.AbnormalSequenceReceived);
                return;
            }
            uint seqIdCount = 1;
            for (uint a = bottom; a < rcvdSeq; a++)
            {
                if (!outOfOrderPackets.ContainsKey(a))
                {
                    needSeq.Add(a);
                    seqIdCount++;
                    if (seqIdCount >= MaxNumNakSeqIds)
                    {
                        break;
                    }
                }
            }

            ServerPacket reqPacket = new ServerPacket();
            byte[] reqData = new byte[4 + (needSeq.Count * 4)];
            MemoryStream msReqData = new MemoryStream(reqData, 0, reqData.Length, true, true);
            msReqData.Write(BitConverter.GetBytes((uint)needSeq.Count), 0, 4);
            needSeq.ForEach(k => msReqData.Write(BitConverter.GetBytes(k), 0, 4));
            reqPacket.Data = msReqData;
            reqPacket.Header.Flags = PacketHeaderFlags.RequestRetransmit;

            EnqueueSend(reqPacket);

            LastRequestForRetransmitTime = DateTime.UtcNow;
            packetLog.DebugFormat("[{0}] Requested retransmit of {1}", session.LoggingIdentifier, needSeq.Select(k => k.ToString()).Aggregate((a, b) => a + ", " + b));
            NetworkStatistics.S2C_RequestsForRetransmit_Aggregate_Increment();
        }

See More Examples