System.Collections.Generic.Dictionary.Add(string, System.Collections.Generic.List)

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

1187 Examples 7

19 View Source File : VectorTileFactory.cs
License : MIT License
Project Creator : alen-smajic

public virtual LayerVisualizerBase AddPOIVectorLayerVisualizer(PrefabItemOptions poiSubLayer)
		{
			LayerVisualizerBase visualizer = CreateInstance<LocationPrefabsLayerVisualizer>();
			poiSubLayer.performanceOptions = _properties.performanceOptions;
			((LocationPrefabsLayerVisualizer)visualizer).SetProperties((PrefabItemOptions)poiSubLayer);

			visualizer.LayerVisualizerHasChanged += UpdateTileFactory;

			visualizer.Initialize();
			if (visualizer == null)
			{
				return null;
			}

			if (_layerBuilder.ContainsKey(visualizer.Key))
			{
				_layerBuilder[visualizer.Key].Add(visualizer);
			}
			else
			{
				_layerBuilder.Add(visualizer.Key, new List<LayerVisualizerBase>() { visualizer });
			}

			return visualizer;
		}

19 View Source File : HeatSeriesFunctions.cs
License : MIT License
Project Creator : alfarok

[IsVisibleInDynamoLibrary(false)]
        public static Dictionary<string, List<double>> GetNodeInput(List<string> xLabels, List<string> yLabels, List<List<double>> values, List<DSCore.Color> colors)
        {
            // TODO - just preplaced input data unmodified instead?
            if (xLabels.Count != values.Count && xLabels.Count > 0)
            {
                return null;
            }

            var output = new Dictionary<string, List<double>>();

            for(var i = 0; i < xLabels.Count; i++)
            {
                output.Add(xLabels[i], values[i]);
            }

            return output;
        }

19 View Source File : GrpcPeer.cs
License : MIT License
Project Creator : AElfProject

public Dictionary<string, List<RequestMetric>> GetRequestMetrics()
        {
            Dictionary<string, List<RequestMetric>> metrics = new Dictionary<string, List<RequestMetric>>();
            foreach (var roundtripTime in _recentRequestsRoundtripTimes.ToArray())
            {
                var metricsToAdd = new List<RequestMetric>();

                metrics.Add(roundtripTime.Key, metricsToAdd);
                foreach (var requestMetric in roundtripTime.Value)
                {
                    metricsToAdd.Add(requestMetric);
                }
            }

            return metrics;
        }

19 View Source File : SubscriptionListener.cs
License : Apache License 2.0
Project Creator : ajuna-network

private void GenericCallBack<T>(string subscription, T result)
        {
            Logger.Debug($"{subscription}: {result}");

            if (_headerCallbacks.ContainsKey(subscription))
            {
                ((Action<string, T>) _headerCallbacks[subscription])(subscription, result);
            }
            else
            {
                if (!_pendingHeaders.ContainsKey(subscription)) _pendingHeaders.Add(subscription, new List<object>());
                _pendingHeaders[subscription].Add(result);
            }
        }

19 View Source File : RouteData.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public void Prepare(HttpContext context)
        {
            var request = context.Request;
            Uri = request.GetUri();
            string userAgent = null;
            foreach (var head in request.Headers)
            {
                var key = head.Key.ToUpper();
                var vl = head.Value.ToList();
                Headers.Add(key, vl);
                switch (key)
                {
                    case "AUTHORIZATION":
                        Token = vl.LinkToString();
                        break;
                    case "USER-AGENT":
                        userAgent = head.Value.LinkToString("|");
                        break;
                }
            }
            HttpMethod = request.Method.ToUpper();

            
            GlobalContext.SetRequestContext(new RequestInfo
            {
                RequestId = RandomOperate.Generate(8),
                UserAgent = userAgent,
                Token = Token,
                RequestType = RequestType.Http,
                ArgumentType = ArgumentType.Json,
                Ip = context.Connection.RemoteIpAddress?.ToString(),
                Port = context.Connection.RemotePort.ToString(),
            });
        }

19 View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

private static SoundEffect GetSoundEffect(string cueName)
        {

            foreach (KeyValuePair<string, WaveBankFileData> kvp in waveBankFileDatas)
            {
                if (kvp.Value.wavebank.ContainsKey(cueName))
                {
                    if (!EffectsList.ContainsKey(cueName))
                    {
                        EffectsList.Add(cueName, new List<SoundEffect>());
                        foreach (string code in kvp.Value.wavebank[cueName])
                        {
                            string filePath = $"{kvp.Key}\\replacedets\\{code}.wav";
                            SoundEffect effect = SoundEffect.FromStream(new FileStream(filePath, FileMode.Open));
                            EffectsList[cueName].Add(effect);
                        }
                    }
                    int idx = Game1.random.Next(0, EffectsList[cueName].Count);
                    return EffectsList[cueName][idx];

                }
            }
            return null;
        }

19 View Source File : CommandLineAnalyzer.cs
License : MIT License
Project Creator : AlexGhiondea

private static Dictionary<string, List<Argument>> CreateArgumentMapForType(INamedTypeSymbol namedTypeSymbol, SymbolreplacedysisContext context, out ActionArgument actionArg)
        {
            Dictionary<string, List<Argument>> mapGroupAndProps
                            = new Dictionary<string, List<Argument>>(StringComparer.OrdinalIgnoreCase);

            // find the action arg.
            var typeMembers = namedTypeSymbol.GetMembers();
            actionArg = GetActionArgument(typeMembers, context);

            // setup the groups available based on the actionArg
            if (actionArg == null)
            {
                // If we don't have an Action attribute, we are going to use the empty string
                // to represent a single common group for all the properties.
                mapGroupAndProps.Add("", new List<Argument>());
            }
            else
            {
                // If the action attribute has been set (and we could find all the possible values)
                // then add those as the group values.
                foreach (var grp in actionArg.Values)
                {
                    mapGroupAndProps.Add(grp, new List<Argument>());
                }
            }

            // traverse the properties again and add them to the groups as needed.
            foreach (var member in typeMembers)
            {
                // Make sure that we are only looking at properties.
                if (!(member is IPropertySymbol))
                {
                    continue;
                }

                var attributes = member.GetAttributes();
                if (!attributes.Any())
                {
                    // nothing to do if we don't have any attributes.
                    continue;
                }

                // we should skip over the action argument.
                if (actionArg != null && actionArg.Symbol == member)
                {
                    continue;
                }

                Argument arg = null;
                List<string> argGroup = new List<string>();
                Dictionary<string, Dictionary<ISymbol, int>> mapOfOverridesPerGroup = new Dictionary<string, Dictionary<ISymbol, int>>();

                bool isCommon = false;
                bool isAttributeGroup = false;

                foreach (var attribute in attributes)
                {
                    // Do a quick check to make sure the attribute we are looking at is coming from the CommandLine replacedembly
                    if (!StringComparer.OrdinalIgnoreCase.Equals("CommandLine", attribute.AttributeClreplaced.Containingreplacedembly.Name))
                    {
                        continue;
                    }

                    if (attribute.ConstructorArguments.Length >= 3)
                    {
                        if (attribute.AttributeClreplaced.Name == "RequiredArgumentAttribute")
                        {
                            RequiredArgument ra = new RequiredArgument();
                            ra.Position = (int)attribute.ConstructorArguments[0].Value; // position

                            ra.Name = attribute.ConstructorArguments[1].Value as string;
                            ra.Description = attribute.ConstructorArguments[2].Value as string;
                            if (attribute.ConstructorArguments.Length == 4)
                            {
                                ra.IsCollection = (bool)attribute.ConstructorArguments[3].Value;
                            }

                            if (arg != null)
                            {
                                // can't have a property be both optional and required
                                context.ReportDiagnostic(Diagnostic.Create(ConflictingPropertyDeclarationRule, member.Locations.First()));
                            }

                            arg = ra;
                        }
                        else if (attribute.AttributeClreplaced.Name == "OptionalArgumentAttribute")
                        {
                            OptionalArgument oa = new OptionalArgument();
                            oa.DefaultValue = attribute.ConstructorArguments[0].Value; // default value
                            oa.Name = attribute.ConstructorArguments[1].Value as string;
                            oa.Description = attribute.ConstructorArguments[2].Value as string;
                            if (attribute.ConstructorArguments.Length == 4)
                            {
                                oa.IsCollection = (bool)attribute.ConstructorArguments[3].Value;
                            }

                            if (arg != null)
                            {
                                // can't have a property be both optional and required
                                context.ReportDiagnostic(Diagnostic.Create(ConflictingPropertyDeclarationRule, member.Locations.First()));
                            }
                            arg = oa;
                        }
                    }

                    if (attribute.AttributeClreplaced.Name == "CommonArgumentAttribute")
                    {
                        isCommon = true;
                    }

                    if (attribute.AttributeClreplaced.Name == "ArgumentGroupAttribute")
                    {
                        isAttributeGroup = true;
                        string groupName = attribute.ConstructorArguments[0].Value as string;
                        argGroup.Add(groupName);

                        // does it have an additional constructor?
                        if (attribute.ConstructorArguments.Length > 1)
                        {
                            var overridePosition = (int)attribute.ConstructorArguments[1].Value;

                            if (overridePosition >= 0)
                            {
                                // need to map the member to the new position 
                                Dictionary<ISymbol, int> map;
                                if (!mapOfOverridesPerGroup.TryGetValue(groupName, out map))
                                {
                                    map = new Dictionary<ISymbol, int>();
                                    mapOfOverridesPerGroup[groupName] = map;
                                }

                                map[member] = overridePosition;
                            }
                        }
                    }
                }

                // we did not find the Required/Optional attribute on that type.
                if (arg == null)
                {
                    // we could not identify an argument because we don't have the required/optional attribute, but we do have the commonattribute/attributeGroup which does not make sense.
                    if (isCommon == true || isAttributeGroup == true)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(CannotSpecifyAGroupForANonPropertyRule, member.Locations.First()));
                    }

                    // we don't understand this argument, nothing to do.
                    continue;
                }

                // store the member symbol on the argument object
                arg.Symbol = member;

                // add the argument to all the groups
                if (isCommon == true)
                {
                    foreach (var key in mapGroupAndProps.Keys)
                    {
                        mapGroupAndProps[key].Add(arg);
                    }

                    // give an error about the action argument being a string and using a common attribute with that.
                    if (actionArg != null && (actionArg.Symbol as IPropertySymbol).Type.BaseType?.SpecialType != SpecialType.System_Enum)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(CommonArgumentAttributeUsedWhenActionArgumentNotEnumRule, arg.Symbol.Locations.First()));
                    }
                }
                else
                {
                    // if we have found an attribute that specifies a group, add it to that.
                    if (argGroup.Count > 0)
                    {
                        // add the current argument to all the argument groups defined.
                        foreach (var item in argGroup)
                        {
                            if (!mapGroupAndProps.TryGetValue(item, out List<Argument> args))
                            {
                                args = new List<Argument>();
                                mapGroupAndProps[item] = args;
                            }

                            // we might need to change the position for this arg based on the override list
                            if (mapOfOverridesPerGroup.ContainsKey(item))
                            {
                                // if the current symbol is the one redirected, then redirect.
                                if (mapOfOverridesPerGroup[item].ContainsKey(arg.Symbol))
                                {
                                    var overridePosition = mapOfOverridesPerGroup[item][arg.Symbol];

                                    // we need to clone the arg.

                                    var reqArg = arg as RequiredArgument;
                                    var clonedArg = reqArg.Clone();
                                    clonedArg.Position = overridePosition;
                                    args.Add(clonedArg);
                                }
                                else
                                {
                                    args.Add(arg);
                                }
                            }
                            else
                            {
                                args.Add(arg);
                            }
                        }
                    }
                    else
                    {
                        //add it to the default one.
                        mapGroupAndProps[string.Empty].Add(arg);
                    }
                }
            }

            return mapGroupAndProps;
        }

19 View Source File : FeatureDatabase.cs
License : Microsoft Public License
Project Creator : achimismaili

private void AddToLocationFeatures(FeatureParent location, Feature feature)
        {
            string lkey = location.Key;
            if (!_LocationFeatures.ContainsKey(lkey))
            {
                _LocationFeatures.Add(lkey, new List<Feature>());
            }
            List<Feature> features = _LocationFeatures[lkey];
            if (!features.Contains(feature))
            {
                features.Add(feature);
            }
        }

19 View Source File : DelegationHelper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static Dictionary<string, List<Rule>> SortRulesByDelegationPolicyPath(List<Rule> rules, out List<Rule> unsortableRules)
        {
            Dictionary<string, List<Rule>> result = new Dictionary<string, List<Rule>>();
            unsortableRules = new List<Rule>();

            foreach (Rule rule in rules)
            {
                if (!TryGetDelegationPolicyPathFromRule(rule, out string path))
                {
                    unsortableRules.Add(rule);
                    continue;
                }

                if (result.ContainsKey(path))
                {
                    result[path].Add(rule);
                }
                else
                {
                    result.Add(path, new List<Rule> { rule });
                }
            }

            return result;
        }

19 View Source File : DacKeyDeclarationAnalyzerBase.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

private Dictionary<string, List<INamedTypeSymbol>> GetKeysGroupedBySetOfFields(List<INamedTypeSymbol> keyDeclarations,
																					   Dictionary<INamedTypeSymbol, List<ITypeSymbol>> dacFieldsByKey, 
																					   CancellationToken cancellationToken)
		{
			var processedKeysByHash = new Dictionary<string, List<INamedTypeSymbol>>(capacity: keyDeclarations.Count);

			foreach (var key in keyDeclarations)
			{
				cancellationToken.ThrowIfCancellationRequested();

				var stringHash = GetHashForSetOfDacFieldsUsedByKey(key, dacFieldsByKey);

				if (stringHash == null)
					continue;

				if (processedKeysByHash.TryGetValue(stringHash, out var processedKeysList))
				{
					processedKeysList.Add(key);
				}
				else
				{
					processedKeysList = new List<INamedTypeSymbol>(capacity: 1) { key };
					processedKeysByHash.Add(stringHash, processedKeysList);
				}
			}

			return processedKeysByHash;
		}

19 View Source File : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek

protected void AddError(string propertyName, string error)
        {
            if (!_errors.TryGetValue(propertyName, out List<string> propertyErrors))
            {
                propertyErrors = new List<string>();
                _errors.Add(propertyName, propertyErrors);
            }
            if (!propertyErrors.Contains(error))
            {
                propertyErrors.Add(error);
                OnErrorsChanged(propertyName);
            }
        }

19 View Source File : StationCounter.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

private void Collect(StationConfig station, string json)
        {
            using (OnceScope.CreateScope(minuteLine))
            {
                var now = JsonConvert.DeserializeObject<StationCounreplacedem>(json);
                if (!StationCounreplacedems.TryGetValue(station.StationName, out var item))
                {
                    now.Count = 1;
                    StationCounreplacedems.Add(station.StationName, now);
                    return;
                }

                item.CheckValue(station, now);

                WebSocketNotify.Publish("status", station.StationName, JsonConvert.SerializeObject(item));
                long value = station.StationType == ZeroStationType.Api ||
                             station.StationType == ZeroStationType.Vote
                    ? item.LastTps
                    : item.LastQps;
                if (minuteLine.TryGetValue(station.StationName, out var kLine))
                {
                    if (kLine.Count == 0)
                    {
                        kLine.Total = value;
                        kLine.Open = value;
                        kLine.Close = value;
                        kLine.Max = value;
                        kLine.Min = value;
                    }
                    else
                    {
                        kLine.Total += value;
                        kLine.Close = value;
                        if (kLine.Max < value)
                            kLine.Max = value;
                        if (kLine.Min > value)
                            kLine.Min = value;
                    }

                    kLine.Count++;
                }
                else
                {
                    minuteLine.Add(station.StationName, kLine = new KLine
                    {
                        Time = GetTime(BaseLine),
                        Count = 1,
                        Total = value,
                        Open = value,
                        Close = value,
                        Max = value,
                        Min = value,
                        Avg = value
                    });
                    KLines.Add(station.StationName, new List<KLine> { kLine });
                }
            }

            if ((DateTime.Now - BaseLine).TotalMinutes < 1)
                return;
            NewBaseTime();
            foreach (var key in KLines.Keys.ToArray())
            {
                if (!minuteLine.TryGetValue(key, out var line))
                {
                    minuteLine.Add(key, line = new KLine
                    {
                        Time = GetTime(BaseLine),
                        Count = 1
                    });
                }
                if (line.Count == 0)
                    line.Avg = 0;
                else
                    line.Avg = decimal.Round(line.Total / line.Count, 4);
                while (KLines[key].Count > 240)
                    KLines[key].RemoveAt(0);
                KLines[key].Add(line);
                WebSocketNotify.Publish("kline", key, JsonConvert.SerializeObject(line));
                var nLine = new KLine
                {
                    Time = GetTime(BaseLine)
                };
                minuteLine[key] = nLine;
            }

        }

19 View Source File : SubscriberWorker.cs
License : MIT License
Project Creator : ad313

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            Console.WriteLine($"{DateTime.Now} ----------------------------------------");

            foreach (var channel in AopSubscriberAttribute.ChannelList)
            {
                Console.WriteLine($"{DateTime.Now} AopCache:生产者频道:{channel}");

                var methodList = AopSubscriberAttribute.MethodList.Where(d =>
                    d.GetCustomAttributes<AopSubscriberAttribute>().ToList().Exists(t => t.Channel == channel)).ToList();

                var subscribers = new List<(AopCacheAttribute, AopSubscriberAttribute)>();

                foreach (var method in methodList)
                {
                    var cacheAttribute = method.GetCustomAttribute<AopCacheAttribute>();
                    if (cacheAttribute == null)
                        continue;

                    Console.WriteLine($"{DateTime.Now} AopCache:消费者订阅方法:{method.DeclaringType?.FullName}.{method.Name}");

                    var subscriberTag = method.GetCustomAttributes<AopSubscriberAttribute>().First(d => d.Channel == channel);

                    subscribers.Add((cacheAttribute, subscriberTag));
                }

                ChannelSubscribersDictionary.Add(channel, subscribers);

                Console.WriteLine($"{DateTime.Now} ----------------------------------------");
            }

            //开始订阅
            foreach (var keyValuePair in ChannelSubscribersDictionary)
            {
                _eventBusProvider.Subscribe<Dictionary<string, object>>(keyValuePair.Key, msg =>
                {
                    foreach ((AopCacheAttribute cache, AopSubscriberAttribute sub) item in keyValuePair.Value)
                    {
                        var cacheAttribute = item.cache;
                        var subscriberTag = item.sub;

                        switch (subscriberTag.ActionType)
                        {
                            case ActionType.DeleteByKey:

                                var key = subscriberTag.GetKey(cacheAttribute.Key, msg.Data);
                                key = cacheAttribute.FormatPrefix(key);
                                _cacheProvider.Remove(key);
                                Console.WriteLine($"{DateTime.Now} Key:{msg.Key}:清除缓存:{key}");
                                break;
                            //case ActionType.DeleteByGroup:
                            //    break;
                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                    }
                }, true);
            }

            await Task.CompletedTask;
        }

19 View Source File : TileJsonData.cs
License : MIT License
Project Creator : alen-smajic

public void ProcessTileJSONData(TileJSONResponse tjr)
		{
			tileJSONLoaded = true;
			List<string> layerPropertiesList = new List<string>();

			if (tjr == null || tjr.VectorLayers == null || tjr.VectorLayers.Length == 0)
			{
				return;
			}

			ClearData();

			var propertyName = "";
			var propertyDescription = "";
			var layerSource = "";

			foreach (var layer in tjr.VectorLayers)
			{
				//load layer names
				var layerName = layer.Id;
				layerPropertiesList = new List<string>();
				layerSource = layer.Source;

				//loading layer sources
				if (LayerSourcesDictionary.ContainsKey(layerName))
				{
					LayerSourcesDictionary[layerName].Add(layerSource);
				}
				else
				{
					LayerSourcesDictionary.Add(layerName, new List<string>() { layerSource });
				}

				//loading layers to a data source
				if (SourceLayersDictionary.ContainsKey(layerSource))
				{
					List<string> sourceList = new List<string>();
					LayerSourcesDictionary.TryGetValue(layerName, out sourceList);

					if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source
					{
						if (SourceLayersDictionary.ContainsKey(commonLayersKey))
						{
							SourceLayersDictionary[commonLayersKey].Add(layerName);
						}
						else
						{
							SourceLayersDictionary.Add(commonLayersKey, new List<string>() { layerName });
						}

						if (LayerDisplayNames.Contains(layerName))
						{
							LayerDisplayNames.Remove(layerName);
						}
						LayerDisplayNames.Add(layerName);
					}
					else
					{
						SourceLayersDictionary[layerSource].Add(layerName);
						LayerDisplayNames.Add(layerName);
					}
				}
				else
				{
					SourceLayersDictionary.Add(layerSource, new List<string>() { layerName });
					LayerDisplayNames.Add(layerName);
				}


				//Load properties
				foreach (var property in layer.Fields)
				{
					propertyName = property.Key;
					propertyDescription = property.Value;
					layerPropertiesList.Add(propertyName);

					//adding property descriptions
					if (LayerPropertyDescriptionDictionary.ContainsKey(layerName))
					{
						if (!LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName))
						{
							LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription);
						}
					}
					else
					{
						LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary<string, string>() { { propertyName, propertyDescription } });
					}

					//Loading display names for properties
					if (PropertyDisplayNames.ContainsKey(layerName))
					{
						if (!PropertyDisplayNames[layerName].Contains(propertyName))
						{
							PropertyDisplayNames[layerName].Add(propertyName);

							//logic to add the list of masked properties from all sources that are not #1
							if (LayerSourcesDictionary[layerName].Count > 1 && !string.IsNullOrEmpty(tjr.Source))
							{
								var firstSource = tjr.Source.Split(new string[] { "," }, System.StringSplitOptions.None)[0].Trim();
								if (layerSource != firstSource)
								{
									if (PropertyDisplayNames[layerName].Contains(propertyName))
									{
										PropertyDisplayNames[layerName].Remove(propertyName);
									}

									PropertyDisplayNames[layerName].Add(propertyName);
								}
							}
						}
					}
					else
					{
						PropertyDisplayNames.Add(layerName, new List<string> { propertyName });
					}
				}

				if (PropertyDisplayNames.ContainsKey(layerName) && PropertyDisplayNames[layerName].Count > 1)
				{
					PropertyDisplayNames[layerName].Sort();
				}
			}


			if (LayerDisplayNames.Count > 1)
			{
				LayerDisplayNames.Sort();
			}
		}

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

private static void QueryMultiHouse()
        {
            var slumlordBiotas = DatabaseManager.Shard.BaseDatabase.GetBiotasByType(WeenieType.SlumLord);

            var playerHouses = new Dictionary<IPlayer, List<Biota>>();
            var accountHouses = new Dictionary<string, List<Biota>>();

            foreach (var slumlord in slumlordBiotas)
            {
                var biotaOwner = slumlord.BiotaPropertiesIID.FirstOrDefault(i => i.Type == (ushort)PropertyInstanceId.HouseOwner);
                if (biotaOwner == null)
                {
                    // this is fine. this is just a house that was purchased, and then later abandoned
                    //Console.WriteLine($"HouseManager.QueryMultiHouse(): couldn't find owner for house {slumlord.Id:X8}");
                    continue;
                }
                var owner = PlayerManager.FindByGuid(biotaOwner.Value);
                if (owner == null)
                {
                    Console.WriteLine($"HouseManager.QueryMultiHouse(): couldn't find owner {biotaOwner.Value:X8}");
                    continue;
                }

                if (!playerHouses.TryGetValue(owner, out var houses))
                {
                    houses = new List<Biota>();
                    playerHouses.Add(owner, houses);
                }
                houses.Add(slumlord);

                var accountName = owner.Account != null ? owner.Account.AccountName : "NULL";

                if (!accountHouses.TryGetValue(accountName, out var aHouses))
                {
                    aHouses = new List<Biota>();
                    accountHouses.Add(accountName, aHouses);
                }
                aHouses.Add(slumlord);
            }


            if (PropertyManager.GetBool("house_per_char").Item)
            {
                var results = playerHouses.Where(i => i.Value.Count() > 1).OrderByDescending(i => i.Value.Count());

                if (results.Count() > 0)
                    Console.WriteLine("Multi-house owners:");

                foreach (var playerHouse in results)
                {
                    Console.WriteLine($"{playerHouse.Key.Name}: {playerHouse.Value.Count}");

                    for (var i = 0; i < playerHouse.Value.Count; i++)
                        Console.WriteLine($"{i + 1}. {GetCoords(playerHouse.Value[i])}");
                }
            }
            else
            {
                var results = accountHouses.Where(i => i.Value.Count() > 1).OrderByDescending(i => i.Value.Count());

                if (results.Count() > 0)
                    Console.WriteLine("Multi-house owners:");

                foreach (var accountHouse in results)
                {
                    Console.WriteLine($"{accountHouse.Key}: {accountHouse.Value.Count}");

                    for (var i = 0; i < accountHouse.Value.Count; i++)
                        Console.WriteLine($"{i + 1}. {GetCoords(accountHouse.Value[i])}");
                }
            }
        }

19 View Source File : DbSchema.cs
License : MIT License
Project Creator : AlenToma

public T LoadChildren<T>(T item, bool onlyFirstLevel = false, List<string> clreplacedes = null, List<string> ignoreList = null, Dictionary<string, List<string>> pathLoaded = null, string parentProb = null, string id = null)
        {

            if (pathLoaded == null)
                pathLoaded = new Dictionary<string, List<string>>();
            if (item == null)
                return default(T);
            GlobalConfiguration.Log?.Info("Loading Children for " + item.GetType() + "", item);
            switch (item)
            {
                case IList _:
                    foreach (var replacedem in (IList)item)
                    {
                        var enreplacedy = replacedem;
                        if (enreplacedy == null)
                            continue;
                        LoadChildren(enreplacedy, onlyFirstLevel, clreplacedes, ignoreList, pathLoaded, parentProb, enreplacedy.GetPrimaryKeyValue().ConvertValue<string>());
                    }
                    break;
                default:
                    if ((item) == null)
                        return item;
                    var props = DeepCloner.GetFastDeepClonerProperties(item.GetType());

                    id = item.GetPrimaryKeyValue().ToString();
                    foreach (var prop in props.Where(x => x.CanRead && !x.IsInternalType && !x.ContainAttribute<ExcludeFromAbstract>() && !x.ContainAttribute<JsonDoreplacedent>() && !x.ContainAttribute<XmlDoreplacedent>()))
                    {
                        var path = string.Format("{0}.{1}", parentProb ?? "", prop.Name).TrimEnd('.').TrimStart('.');
                        var propCorrectPathName = path?.Split('.').Length >= 2 ? string.Join(".", path.Split('.').Reverse().Take(2).Reverse()) : path;

                        if (clreplacedes != null && clreplacedes.All(x => x != propCorrectPathName))
                            continue;
                        if (ignoreList != null && ignoreList.Any(x => x == propCorrectPathName))
                            continue;

                        var propValue = prop.GetValue(item);
                        if (propValue != null)
                            if (!(propValue is IList) || (propValue as IList).Any())
                                continue;

                        if (pathLoaded.ContainsKey(id) && pathLoaded[id].Any(x => x == path))
                            continue;

                        if (!pathLoaded.ContainsKey(id))
                            pathLoaded.Add(id, new List<string>() { path });
                        else if (pathLoaded[id].All(x => x != path)) pathLoaded[id].Add(path);

                        var propertyName = prop.Name;
                        if (path?.Split('.').Length >= 2)
                            propertyName = string.Join(".", path.Split('.').Reverse().Take(3).Reverse()) + "." + parentProb.Split('.').Last() + "." + propertyName;

                        var type = prop.PropertyType.GetActualType();

                        var key = props.FirstOrDefault(x => x.ContainAttribute<ForeignKey>() && x.GetCustomAttribute<ForeignKey>().Type == type && (string.IsNullOrEmpty(x.GetCustomAttribute<ForeignKey>().PropertyName) || x.GetCustomAttribute<ForeignKey>().PropertyName == prop.Name));
                        if (key == null)
                        {
                            var column = DeepCloner.GetFastDeepClonerProperties(type).FirstOrDefault(x => x.GetCustomAttribute<ForeignKey>()?.Type == item.GetType() && string.IsNullOrEmpty(x.GetCustomAttribute<ForeignKey>().PropertyName));
                            var primaryKey = item.GetType().GetPrimaryKey();
                            if (column == null || primaryKey == null)
                                continue;
                            var keyValue = primaryKey.GetValue(item);
                            if (keyValue.ObjectIsNew()) continue;
                            var result = GetByColumn(keyValue, column.Name, prop.PropertyType);
                            prop.SetValue(item, result);
                            if (result != null && !onlyFirstLevel)
                                LoadChildren(result, onlyFirstLevel, clreplacedes, ignoreList, pathLoaded, propertyName, id);
                        }
                        else
                        {
                            var isGeneric = prop.PropertyType.GetActualType() != prop.PropertyType;
                            var keyValue = key.GetValue(item);
                            if (keyValue.ObjectIsNew() && !isGeneric) continue;
                            object result = null;
                            if (isGeneric && key.GetCustomAttribute<ForeignKey>().Type == item.GetType()) // trying to load children 
                                result = GetByColumn(item.GetPrimaryKeyValue(), key.GetPropertyName(), prop.PropertyType);
                            else
                                result = GetById(keyValue, prop.PropertyType);

                            prop.SetValue(item, result);
                            if (result != null && !onlyFirstLevel)
                                LoadChildren(result, onlyFirstLevel, clreplacedes, ignoreList, pathLoaded, propertyName, id);
                        }
                    }

                    break;
            }

            return item;
        }

19 View Source File : ClothFactory.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static GameObject GetHair(GameObject reference, string name, Material material, Color color)
    {
        List<GameObject> list;
        bool flag = ClothFactory.clothCache.TryGetValue(name, out list);
        GameObject result;
        if (flag)
        {
            for (int i = 0; i < list.Count; i++)
            {
                GameObject gameObject = list[i];
                bool flag2 = gameObject == null;
                if (flag2)
                {
                    Debug.Log("Hair is null");
                    list.RemoveAt(i);
                    i = Mathf.Max(i - 1, 0);
                }
                else
                {
                    ParentFollow component = gameObject.GetComponent<ParentFollow>();
                    bool flag3 = !component.isActiveInScene;
                    if (flag3)
                    {
                        component.isActiveInScene = true;
                        gameObject.renderer.material = material;
                        gameObject.renderer.material.color = color;
                        gameObject.GetComponent<Cloth>().enabled = true;
                        gameObject.GetComponent<SkinnedMeshRenderer>().enabled = true;
                        gameObject.GetComponent<ParentFollow>().SetParent(reference.transform);
                        ClothFactory.ReapplyClothBones(reference, gameObject);
                        return gameObject;
                    }
                }
            }
            GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
            gameObject2.renderer.material = material;
            gameObject2.renderer.material.color = color;
            gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
            list.Add(gameObject2);
            ClothFactory.clothCache[name] = list;
            result = gameObject2;
        }
        else
        {
            GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
            gameObject2.renderer.material = material;
            gameObject2.renderer.material.color = color;
            gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
            list = new List<GameObject>
            {
                gameObject2
            };
            ClothFactory.clothCache.Add(name, list);
            result = gameObject2;
        }
        return result;
    }

19 View Source File : BarChartFunctions.cs
License : MIT License
Project Creator : alfarok

[IsVisibleInDynamoLibrary(false)]
        public static Dictionary<string, List<double>> GetNodeInput(List<string> labels, List<List<double>> values, List<DSCore.Color> colors)
        {
            // TODO - just preplaced input data unmodified instead?
            var output = new Dictionary<string, List<double>>();

            if (labels.Count != values.Count)
            {
                return output;
            }

            for(var i = 0; i < labels.Count; i++)
            {
                output.Add(labels[i], values[i]);
            }

            return output;
        }

19 View Source File : DynamicCharacterSystem.cs
License : Apache License 2.0
Project Creator : A7ocin

public void AddRecipes(UMATextRecipe[] uparts, string filename = "")
		{
			foreach (UMATextRecipe u in uparts)
			{
				if (filename == "" || (filename != "" && filename.Trim() == u.name))
				{
					var thisWardrobeSlot = u.wardrobeSlot;
					if (u.GetType() == typeof(UMAWardrobeCollection))
					{
						//we have a problem here because when the placeholder replacedet is returned its wardrobeCollection.sets.Count == 0
						//so we need to do it the other way round i.e. add it when its downloading but if the libraries contain it when its downloaded and the sets count is 0 remove it
						if ((u as UMAWardrobeCollection).wardrobeCollection.sets.Count == 0)
						{
							if (RecipeIndex.ContainsKey(u.name))
							{
								Debug.LogWarning("DCS removed " + u.name + " from RecipeIndex");
								RecipeIndex.Remove(u.name);
							}
							else if (!DynamicreplacedetLoader.Instance.downloadingreplacedetsContains(u.name))
							{
								continue;
							}
						}
						thisWardrobeSlot = "WardrobeCollection";
					}
					//we might be refreshing so check its not already there
					if (!RecipeIndex.ContainsKey(u.name))
						RecipeIndex.Add(u.name, u);
					else
					{
						RecipeIndex[u.name] = u;
					}
					for (int i = 0; i < u.compatibleRaces.Count; i++)
					{
						if (u.GetType() == typeof(UMAWardrobeCollection) && (u as UMAWardrobeCollection).wardrobeCollection.sets.Count > 0)
						{
							//if the collection doesn't have a wardrobeSet for this race continue
							//again when its downloading this data isn't there
							if ((u as UMAWardrobeCollection).wardrobeCollection[u.compatibleRaces[i]].Count == 0)
							{
								if (Recipes.ContainsKey(u.compatibleRaces[i]))
								{
									if (Recipes[u.compatibleRaces[i]].ContainsKey("WardrobeCollection"))
									{
										if (Recipes[u.compatibleRaces[i]]["WardrobeCollection"].Contains(u))
										{
											Debug.LogWarning("DCS removed " + u.name + " from Recipes");
											Recipes[u.compatibleRaces[i]]["WardrobeCollection"].Remove(u);
											if (RecipeIndex.ContainsKey(u.name))
											{
												Debug.LogWarning("DCS removed " + u.name + " from RecipeIndex");
												RecipeIndex.Remove(u.name);
											}
											continue;
										}
									}
								}
								if (DynamicreplacedetLoader.Instance != null)
									if (!DynamicreplacedetLoader.Instance.downloadingreplacedetsContains(u.name))
									{
										continue;
									}
							}
						}
						//When recipes that are compatible with multiple races are downloaded we may not have all the races actually downloaded
						//but that should not stop DCS making an index of recipes that are compatible with that race for when it becomes available
						if (!Recipes.ContainsKey(u.compatibleRaces[i]))
						{
							Recipes.Add(u.compatibleRaces[i], new Dictionary<string, List<UMATextRecipe>>());
						}
						if (Recipes.ContainsKey(u.compatibleRaces[i]))
						{
							Dictionary<string, List<UMATextRecipe>> RaceRecipes = Recipes[u.compatibleRaces[i]];

							if (!RaceRecipes.ContainsKey(thisWardrobeSlot))
							{
								RaceRecipes.Add(thisWardrobeSlot, new List<UMATextRecipe>());
							}
							//we might be refreshing so replace anything that is already there with the downloaded versions- else add
							bool added = false;
							for (int ir = 0; ir < RaceRecipes[thisWardrobeSlot].Count; ir++)
							{
								if (RaceRecipes[thisWardrobeSlot][ir].name == u.name)
								{
									RaceRecipes[thisWardrobeSlot][ir] = u;
									added = true;
								}
							}
							if (!added)
							{
								RaceRecipes[thisWardrobeSlot].Add(u);
							}
						}
						//backwards compatible race slots
						foreach (string racekey in Recipes.Keys)
						{
							//here we also need to check that the race itself has a wardrobe slot that matches the one in the compatible race
							//11012017 Dont trigger backwards compatible races to download
							RaceData raceKeyRace = (context.raceLibrary as DynamicRaceLibrary).GetRace(racekey, false);
							if (raceKeyRace == null)
								continue;
							if (raceKeyRace.IsCrossCompatibleWith(u.compatibleRaces[i]) && (raceKeyRace.wardrobeSlots.Contains(thisWardrobeSlot) || thisWardrobeSlot == "WardrobeCollection"))
                            {
								Dictionary<string, List<UMATextRecipe>> RaceRecipes = Recipes[racekey];
								if (!RaceRecipes.ContainsKey(thisWardrobeSlot))
								{
									RaceRecipes.Add(thisWardrobeSlot, new List<UMATextRecipe>());
								}
								//we might be refreshing so replace anything that is already there with the downloaded versions- else add
								bool added = false;
								for (int ir = 0; ir < RaceRecipes[thisWardrobeSlot].Count; ir++)
								{
									if (RaceRecipes[thisWardrobeSlot][ir].name == u.name)
									{
										RaceRecipes[thisWardrobeSlot][ir] = u;
										added = true;
									}
								}
								if (!added)
								{
									RaceRecipes[thisWardrobeSlot].Add(u);
								}
							}
						}
					}
				}
			}
			//This doesn't actually seem to do anything apart from slow things down
			//StartCoroutine(CleanFilesFromResourcesAndBundles());
		}

19 View Source File : bindED.cs
License : GNU General Public License v3.0
Project Creator : alterNERDtive

private static Dictionary<string, List<string>> ReadBinds(string file)
        {
            XElement rootElement;

            rootElement = XElement.Load(file);

            Dictionary<string, List<string>> binds = new Dictionary<string, List<string>>(512);
            if (rootElement != null)
            {
                foreach (XElement c in rootElement.Elements().Where(i => i.Elements().Count() > 0))
                {
                    List<string> keys = new List<string>();
                    foreach (var element in c.Elements().Where(i => i.HasAttributes))
                    {
                        if (element.Name == "Primary")
                        {
                            if (element.Attribute("Device").Value == "Keyboard" && !String.IsNullOrWhiteSpace(element.Attribute("Key").Value) && element.Attribute("Key").Value.StartsWith("Key_"))
                            {
                                foreach (var modifier in element.Elements().Where(i => i.Name.LocalName == "Modifier"))
                                {
                                    keys.Add(modifier.Attribute("Key").Value);
                                }
                                keys.Add(element.Attribute("Key").Value);
                            }
                        }
                        if (keys.Count == 0 && element.Name == "Secondary") //nothing found in primary... look in secondary
                        {
                            if (element.Attribute("Device").Value == "Keyboard" && !String.IsNullOrWhiteSpace(element.Attribute("Key").Value) && element.Attribute("Key").Value.StartsWith("Key_"))
                            {
                                foreach (var modifier in element.Elements().Where(i => i.Name.LocalName == "Modifier"))
                                {
                                    keys.Add(modifier.Attribute("Key").Value);
                                }
                                keys.Add(element.Attribute("Key").Value);
                            }
                        }
                    }
                    binds.Add($"ed{c.Name.LocalName}", keys);
                }
            }
            return binds;
        }

19 View Source File : CSRedisClientAsync.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

async private Task<long> ExecuteNonQueryAsync(string[] key, Func<RedisConnection2, string[], Task<long>> hander) {
			if (key == null || key.Any() == false) return 0;
			if (ClusterRule == null || ClusterNodes.Count == 1) {
				var pool = ClusterNodes.First().Value;
				var keys = key.Select(a => string.Concat(pool.Prefix, a)).ToArray();
				return await GetConnectionAndExecuteAsync(pool, conn => hander(conn, keys));
			}
			var rules = new Dictionary<string, List<string>>();
			for (var a = 0; a < key.Length; a++) {
				var rule = ClusterRule(key[a]);
				if (rules.ContainsKey(rule)) rules[rule].Add(key[a]);
				else rules.Add(rule, new List<string> { key[a] });
			}
			long affrows = 0;
			foreach (var r in rules) {
				var pool = ClusterNodes.TryGetValue(r.Key, out var b) ? b : ClusterNodes.First().Value;
				var keys = r.Value.Select(a => string.Concat(pool.Prefix, a)).ToArray();
				affrows += await GetConnectionAndExecuteAsync(pool, conn => hander(conn, keys));
			}
			return affrows;
		}

19 View Source File : MulitStringDictionary.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public void Add(string name , string value)
        {
            if(string.IsNullOrWhiteSpace(value))
            {
                return ;
            }
            if(string.IsNullOrWhiteSpace(name))
            {
                _global.Add(value) ;
            }
            else
            {
                name = name.Trim() ;
                value = value.Trim() ;
                if(!ContainsKey(name))
                {
                    base.Add(name , new List<string>()) ;
                }
                base[name].Add(value) ;
            }
        }

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

private void DoAddSubscription(Type handlerType, string eventName)
        {
            if (!HreplacedubscriptionsForEvent(eventName))
            {
                _handlers.Add(eventName, new List<SubscriptionInfo>());
            }

            if (_handlers[eventName].Any(s => s.HandlerType == handlerType))
            {
                throw new ArgumentException(
                    $"Handler Type {handlerType.Name} already registered for '{eventName}'", nameof(handlerType));
            }

            _handlers[eventName].Add(SubscriptionInfo.Typed(handlerType));
        }

19 View Source File : StationCounter.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

private void StationEvent(ZeroNetEventArgument e)
        {
            switch (e.Event)
            {
                case ZeroNetEventType.CenterStationJoin:
                case ZeroNetEventType.CenterStationLeft:
                case ZeroNetEventType.CenterStationPause:
                case ZeroNetEventType.CenterStationResume:
                case ZeroNetEventType.CenterStationClosing:
                case ZeroNetEventType.CenterStationInstall:
                case ZeroNetEventType.CenterStationUpdate:
                case ZeroNetEventType.CenterStationRemove:
                    PublishConfig(e.EventConfig);
                    return;
                case ZeroNetEventType.AppStop:
                case ZeroNetEventType.AppRun:
                    NewBaseTime();
                    ZeroApplication.Config.Foreach(cfg =>
                    {
                        PublishConfig(cfg);
                        if (!KLines.ContainsKey(cfg.StationName))
                            KLines.Add(cfg.StationName, new List<KLine>());
                        var nLine = new KLine
                        {
                            Time = GetTime(BaseLine)
                        };
                        if (minuteLine.ContainsKey(cfg.StationName))
                            minuteLine[cfg.StationName] = nLine;
                        else
                            minuteLine.Add(cfg.StationName, nLine);
                    });
                    return;
                case ZeroNetEventType.AppEnd:
                    File.WriteAllText(Path.Combine(ZeroApplication.Config.DataFolder, "kline_station.json"),
                        JsonConvert.SerializeObject(KLines));
                    return;
                case ZeroNetEventType.CenterStationState:
                    if (e.EventConfig == null || e.Context == null)
                        return;
                    Collect(e.EventConfig, e.Context);
                    return;
            }
        }

19 View Source File : DacKeyDeclarationAnalyzerBase.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

private IEnumerable<List<INamedTypeSymbol>> GetDuplicateKeysGroupsForSameTargetDAC(PXContext context, List<INamedTypeSymbol> keysWithSameDacFields)
		{
			var duplicateKeysByTargetDac = new Dictionary<string, List<INamedTypeSymbol>>();

			foreach (INamedTypeSymbol key in keysWithSameDacFields)
			{
				string parentDacName = GetParentDacFromKey(context, key)?.MetadataName;

				if (parentDacName.IsNullOrWhiteSpace())
					continue;

				if (duplicateKeysByTargetDac.TryGetValue(parentDacName, out List<INamedTypeSymbol> processedKeysList))
				{
					processedKeysList.Add(key);
				}
				else
				{
					processedKeysList = new List<INamedTypeSymbol>(capacity: 1) { key };
					duplicateKeysByTargetDac.Add(parentDacName, processedKeysList);
				}
			}

			return duplicateKeysByTargetDac.Values.Where(keys => keys.Count > 1);
		}

19 View Source File : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek

protected void AddValidationRule<TProperty>(Expression<Func<TProperty>> property, Func<TProperty, bool> validate, string errorMsg)
        {
            var propertyName = ExpressionHelper.GetMemberName(property);

            var rule = new ValidationRule
            {
                ErrorMessage = errorMsg,
                IsValid = () =>
                {
                    var val = property.Compile()();
                    return validate(val);
                }
            };

            if (!_validationRules.TryGetValue(propertyName, out List<ValidationRule> ruleSet))
            {
                ruleSet = new List<ValidationRule>();
                _validationRules.Add(propertyName, ruleSet);
            }
            ruleSet.Add(rule);
        }

19 View Source File : WebSocketNotify.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static void Binding(IApplicationBuilder app, string clreplacedify)
        {
            Handlers.Add(clreplacedify, new List<WebSocketNotify>());
            app.Map($"/{clreplacedify}", Map);
        }

19 View Source File : ProcessingDelegatesWalker.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

private void replacedyzeSetProcessDelegate(string viewName, ArgumentListSyntax argumentList)
		{
			ThrowIfCancellationRequested();

			var handlerNode = argumentList?.Arguments.First()?.Expression;
			if (handlerNode == null)
			{
				return;
			}

			if (!ProcessDelegateListByView.ContainsKey(viewName))
			{
				ProcessDelegateListByView.Add(viewName, new List<ProcessingDelegateInfo>());
			}

			ProcessDelegateListByView[viewName].Add(GetDelegateInfo(handlerNode));

			if (argumentList.Arguments.Count == 1)
			{
				return;
			}

			var finallyHandlerNode = argumentList.Arguments[1]?.Expression;
			if (finallyHandlerNode == null)
			{
				return;
			}

			if (!FinallyProcessDelegateListByView.ContainsKey(viewName))
			{
				FinallyProcessDelegateListByView.Add(viewName, new List<ProcessingDelegateInfo>());
			}

			FinallyProcessDelegateListByView[viewName].Add(GetDelegateInfo(finallyHandlerNode));
		}

19 View Source File : CatalogEntry.cs
License : MIT License
Project Creator : ai-traders

public static DependencyGroup[] ToDependencyGroups(List<LiGet.Enreplacedies.PackageDependency> dependencies, 
            string catalogUri, Func<string, Uri> getRegistrationUrl)
        {
            if(dependencies == null || !dependencies.Any())
                return new DependencyGroup[0];

            var groups = new List<DependencyGroup>();
            var frameworkDeps = dependencies.Where(d => d.IsFrameworkDependency()).Select(d => d.TargetFramework).Distinct();
            foreach(var frameworkDep in frameworkDeps) {
                var g = new DependencyGroup() {
                    CatalogUrl = catalogUri + $"#dependencygroup/.{frameworkDep}",
                    TargetFramework = frameworkDep
                };
                groups.Add(g);
            }
            // empty string key implies no target framework
            Dictionary<string, List<PackageDependency>> dependenciesByFramework = new Dictionary<string, List<PackageDependency>>();
            foreach (var packageDependency in dependencies.Where(d => !d.IsFrameworkDependency()))
            {
                var dep = new PackageDependency() {
                    Id = packageDependency.Id,
                    Range = packageDependency.VersionRange
                };
                string framework = packageDependency.TargetFramework == null ? "" : packageDependency.TargetFramework;
                List<PackageDependency> deps = new List<PackageDependency>();
                if (!dependenciesByFramework.TryGetValue(framework, out deps)) {
                    deps = new List<PackageDependency>();
                    dependenciesByFramework.Add(framework, deps);
                }
                deps.Add(dep);
            }
            var perFrameworkDeps = 
                dependenciesByFramework.GroupBy(d => d.Key)
                .Select(grouppedDeps => 
                {
                    var framework = string.IsNullOrEmpty(grouppedDeps.Key) ? null : grouppedDeps.Key;
                    string catalogForGroup = catalogUri + "#dependencygroup";
                    if(framework != null)
                        catalogForGroup = catalogUri + $"#dependencygroup/.{framework}";
                    var g = new DependencyGroup() {         
                        CatalogUrl = catalogForGroup,           
                        TargetFramework = framework,
                        Dependencies = grouppedDeps.SelectMany(d => d.Value)
                            .Select(d => new PackageDependency() {
                                CatalogUrl = catalogUri + $"#dependencygroup/.{grouppedDeps.Key}/{d.Id}",
                                Id = d.Id,
                                Range = d.Range,
                                Registration = getRegistrationUrl(d.Id).AbsoluteUri
                            }).ToArray()
                    };
                    return g;
                });

            return groups.Concat(perFrameworkDeps).ToArray();
        }

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

public void Import<T>(Expression<Func<T>> propertyExpression, string key = null)
        {
            var parameter = Expression.Parameter(typeof(T));
            var setter = Expression.Lambda<Action<T>>(
                Expression.replacedign(
                    propertyExpression.Body,
                    parameter),
                parameter).Compile();

            key = key ?? PropertySupport.ExtractPropertyName(propertyExpression);
            if (!_importPropertySetterDictionary.ContainsKey(key))
            {
                _importPropertySetterDictionary.Add(key, new List<Delegate>());
            }
            _importPropertySetterDictionary[key].Add(setter);
        }

19 View Source File : XmlNodeConverter.cs
License : MIT License
Project Creator : akaskela

private void SerializeGroupedNodes(JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
        {
            // group nodes together by name
            Dictionary<string, List<IXmlNode>> nodesGroupedByName = new Dictionary<string, List<IXmlNode>>();

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                IXmlNode childNode = node.ChildNodes[i];
                string nodeName = GetPropertyName(childNode, manager);

                List<IXmlNode> nodes;
                if (!nodesGroupedByName.TryGetValue(nodeName, out nodes))
                {
                    nodes = new List<IXmlNode>();
                    nodesGroupedByName.Add(nodeName, nodes);
                }

                nodes.Add(childNode);
            }

            // loop through grouped nodes. write single name instances as normal,
            // write multiple names together in an array
            foreach (KeyValuePair<string, List<IXmlNode>> nodeNameGroup in nodesGroupedByName)
            {
                List<IXmlNode> groupedNodes = nodeNameGroup.Value;
                bool writeArray;

                if (groupedNodes.Count == 1)
                {
                    writeArray = IsArray(groupedNodes[0]);
                }
                else
                {
                    writeArray = true;
                }

                if (!writeArray)
                {
                    SerializeNode(writer, groupedNodes[0], manager, writePropertyName);
                }
                else
                {
                    string elementNames = nodeNameGroup.Key;

                    if (writePropertyName)
                    {
                        writer.WritePropertyName(elementNames);
                    }

                    writer.WriteStartArray();

                    for (int i = 0; i < groupedNodes.Count; i++)
                    {
                        SerializeNode(writer, groupedNodes[i], manager, false);
                    }

                    writer.WriteEndArray();
                }
            }
        }

19 View Source File : SortGroupViewModel.cs
License : GNU General Public License v3.0
Project Creator : aduskin

public List<ChatUserModel> Sort(List<ChatUserModel> Temps)
      {
         List<ChatUserModel> ResultList = new List<ChatUserModel>();
         Dictionary<string, List<ChatUserModel>> dic = new Dictionary<string, List<ChatUserModel>>();
         List<string> sorts = new List<string>() { "群组", "A", "B", "C", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#" };
         foreach (var item in sorts)
            dic.Add(item, new List<ChatUserModel>());
         //将对象按字母顺序存起来
         for (int i = 0; i < Temps.Count; i++)
         {
            //群组
            if (Temps[i].ContactType == ContactType.Group)
            {
               dic["群组"].Add(Temps[i]);
               continue;
            }
            //个人
            var subhead = AduSkin.Utility.Extend.StringExtend.GetFirstPinyin(Temps[i].UserName);
            Temps[i].SortID = subhead;
            if (dic.ContainsKey(subhead))
               dic[subhead].Add(Temps[i]);
         }
         //先把群组存入列表
         var groupsort = new ChatUserModel() { SortID = "群组", ContactType = ContactType.SerialNumber };
         ResultList.Add(groupsort);
         foreach (var item in dic["群组"])
         {
            ResultList.Add(item);
         }

         foreach (var item in dic)
         {
            if (item.Value.Count <= 0 || item.Key == "群组")
            {
               continue;
            }
            var sortid = new ChatUserModel() { SortID = item.Key, ContactType = ContactType.SerialNumber };
            if (!ResultList.Contains(sortid))
            {
               ResultList.Add(sortid);
            }
            foreach (var chatuser in item.Value)
            {
               chatuser.ContactType = ContactType.Single;
               ResultList.Add(chatuser);
            }
         }
         return ResultList;
      }

19 View Source File : TileJsonData.cs
License : MIT License
Project Creator : alen-smajic

public void ProcessTileJSONData(TileJSONResponse tjr)
		{
			tileJSONLoaded = true;
			List<string> layerPropertiesList = new List<string>();

			if (tjr == null || tjr.VectorLayers == null || tjr.VectorLayers.Length == 0)
			{
				return;
			}

			ClearData();

			var propertyName = "";
			var propertyDescription = "";
			var layerSource = "";

			foreach (var layer in tjr.VectorLayers)
			{
				//load layer names
				var layerName = layer.Id;
				layerPropertiesList = new List<string>();
				layerSource = layer.Source;

				//loading layer sources
				if (LayerSourcesDictionary.ContainsKey(layerName))
				{
					LayerSourcesDictionary[layerName].Add(layerSource);
				}
				else
				{
					LayerSourcesDictionary.Add(layerName, new List<string>() { layerSource });
				}

				//loading layers to a data source
				if (SourceLayersDictionary.ContainsKey(layerSource))
				{
					List<string> sourceList = new List<string>();
					LayerSourcesDictionary.TryGetValue(layerName, out sourceList);

					if (sourceList.Count > 1 && sourceList.Contains(layerSource)) // the current layerName has more than one source
					{
						if (SourceLayersDictionary.ContainsKey(commonLayersKey))
						{
							SourceLayersDictionary[commonLayersKey].Add(layerName);
						}
						else
						{
							SourceLayersDictionary.Add(commonLayersKey, new List<string>() { layerName });
						}

						if (LayerDisplayNames.Contains(layerName))
						{
							LayerDisplayNames.Remove(layerName);
						}
						LayerDisplayNames.Add(layerName);
					}
					else
					{
						SourceLayersDictionary[layerSource].Add(layerName);
						LayerDisplayNames.Add(layerName);
					}
				}
				else
				{
					SourceLayersDictionary.Add(layerSource, new List<string>() { layerName });
					LayerDisplayNames.Add(layerName);
				}


				//Load properties
				foreach (var property in layer.Fields)
				{
					propertyName = property.Key;
					propertyDescription = property.Value;
					layerPropertiesList.Add(propertyName);

					//adding property descriptions
					if (LayerPropertyDescriptionDictionary.ContainsKey(layerName))
					{
						if (!LayerPropertyDescriptionDictionary[layerName].ContainsKey(propertyName))
						{
							LayerPropertyDescriptionDictionary[layerName].Add(propertyName, propertyDescription);
						}
					}
					else
					{
						LayerPropertyDescriptionDictionary.Add(layerName, new Dictionary<string, string>() { { propertyName, propertyDescription } });
					}

					//Loading display names for properties
					if (PropertyDisplayNames.ContainsKey(layerName))
					{
						if (!PropertyDisplayNames[layerName].Contains(propertyName))
						{
							PropertyDisplayNames[layerName].Add(propertyName);

							//logic to add the list of masked properties from all sources that are not #1
							if (LayerSourcesDictionary[layerName].Count > 1 && !string.IsNullOrEmpty(tjr.Source))
							{
								var firstSource = tjr.Source.Split(new string[] { "," }, System.StringSplitOptions.None)[0].Trim();
								if (layerSource != firstSource)
								{
									if (PropertyDisplayNames[layerName].Contains(propertyName))
									{
										PropertyDisplayNames[layerName].Remove(propertyName);
									}

									PropertyDisplayNames[layerName].Add(propertyName);
								}
							}
						}
					}
					else
					{
						PropertyDisplayNames.Add(layerName, new List<string> { propertyName });
					}
				}

				if (PropertyDisplayNames.ContainsKey(layerName) && PropertyDisplayNames[layerName].Count > 1)
				{
					PropertyDisplayNames[layerName].Sort();
				}
			}


			if (LayerDisplayNames.Count > 1)
			{
				LayerDisplayNames.Sort();
			}
		}

19 View Source File : DynamicDNAConverterBehaviour.cs
License : Apache License 2.0
Project Creator : A7ocin

public bool AddDnaCallbackDelegate(UnityAction<string, float> callback, string targetDnaName)
		{
			bool added = false;

			if (!_dnaCallbackDelegates.ContainsKey(targetDnaName))
			{
				_dnaCallbackDelegates.Add(targetDnaName, new List<UnityAction<string, float>>());
				_dnaCallbackDelegates[targetDnaName].Add(callback);
				added = true;
			}
			else
			{
				bool found = false;
				for(int i = 0; i < _dnaCallbackDelegates[targetDnaName].Count; i++)
				{
					if(_dnaCallbackDelegates[targetDnaName][i] == callback)
					{
						found = true;
						break;
					}
				}
				if (!found)
				{
					_dnaCallbackDelegates[targetDnaName].Add(callback);
					added = true;
				}
			}
			return added;
		}

19 View Source File : VectorTileFactory.cs
License : MIT License
Project Creator : alen-smajic

public virtual LayerVisualizerBase AddVectorLayerVisualizer(VectorSubLayerProperties subLayer)
		{
			//if its of type prefabitemoptions then separate the visualizer type
			LayerVisualizerBase visualizer = CreateInstance<VectorLayerVisualizer>();

			//TODO : FIX THIS !!
			visualizer.LayerVisualizerHasChanged += UpdateTileFactory;

			// Set honorBuildingSettings - need to set here in addition to the UI.
			// Not setting it here can lead to wrong filtering.

			bool isPrimitiveTypeValidForBuidingIds = (subLayer.coreOptions.geometryType == VectorPrimitiveType.Polygon) || (subLayer.coreOptions.geometryType == VectorPrimitiveType.Custom);
			bool isSourceValidForBuildingIds = _properties.sourceType != VectorSourceType.MapboxStreets;

			subLayer.honorBuildingIdSetting = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds;
			// Setup visualizer.
			((VectorLayerVisualizer)visualizer).SetProperties(subLayer);

			visualizer.Initialize();
			if (visualizer == null)
			{
				return visualizer;
			}

			if (_layerBuilder.ContainsKey(visualizer.Key))
			{
				_layerBuilder[visualizer.Key].Add(visualizer);
			}
			else
			{
				_layerBuilder.Add(visualizer.Key, new List<LayerVisualizerBase> { visualizer });
			}
			return visualizer;
		}

19 View Source File : ClothFactory.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static GameObject GetCape(GameObject reference, string name, Material material)
    {
        List<GameObject> list;
        bool flag = ClothFactory.clothCache.TryGetValue(name, out list);
        GameObject result;
        if (flag)
        {
            for (int i = 0; i < list.Count; i++)
            {
                GameObject gameObject = list[i];
                bool flag2 = gameObject == null;
                if (flag2)
                {
                    list.RemoveAt(i);
                    i = Mathf.Max(i - 1, 0);
                }
                else
                {
                    ParentFollow component = gameObject.GetComponent<ParentFollow>();
                    bool flag3 = !component.isActiveInScene;
                    if (flag3)
                    {
                        component.isActiveInScene = true;
                        gameObject.renderer.material = material;
                        gameObject.GetComponent<Cloth>().enabled = true;
                        gameObject.GetComponent<SkinnedMeshRenderer>().enabled = true;
                        gameObject.GetComponent<ParentFollow>().SetParent(reference.transform);
                        ClothFactory.ReapplyClothBones(reference, gameObject);
                        return gameObject;
                    }
                }
            }
            GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
            gameObject2.renderer.material = material;
            gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
            list.Add(gameObject2);
            ClothFactory.clothCache[name] = list;
            result = gameObject2;
        }
        else
        {
            GameObject gameObject2 = ClothFactory.GenerateCloth(reference, name);
            gameObject2.renderer.material = material;
            gameObject2.AddComponent<ParentFollow>().SetParent(reference.transform);
            list = new List<GameObject>
            {
                gameObject2
            };
            ClothFactory.clothCache.Add(name, list);
            result = gameObject2;
        }
        return result;
    }

19 View Source File : CommandLineAnalyzer.cs
License : MIT License
Project Creator : AlexGhiondea

private static Dictionary<string, List<Argument>> CreateArgumentMapForType(INamedTypeSymbol namedTypeSymbol, SymbolreplacedysisContext context, out ActionArgument actionArg)
        {
            Dictionary<string, List<Argument>> mapGroupAndProps
                            = new Dictionary<string, List<Argument>>(StringComparer.OrdinalIgnoreCase);

            // find the action arg.
            var typeMembers = namedTypeSymbol.GetMembers();
            actionArg = GetActionArgument(typeMembers, context);

            // setup the groups available based on the actionArg
            if (actionArg == null)
            {
                // If we don't have an Action attribute, we are going to use the empty string
                // to represent a single common group for all the properties.
                mapGroupAndProps.Add("", new List<Argument>());
            }
            else
            {
                // If the action attribute has been set (and we could find all the possible values)
                // then add those as the group values.
                foreach (var grp in actionArg.Values)
                {
                    mapGroupAndProps.Add(grp, new List<Argument>());
                }
            }

            // traverse the properties again and add them to the groups as needed.
            foreach (var member in typeMembers)
            {
                // Make sure that we are only looking at properties.
                if (!(member is IPropertySymbol))
                {
                    continue;
                }

                var attributes = member.GetAttributes();
                if (!attributes.Any())
                {
                    // nothing to do if we don't have any attributes.
                    continue;
                }

                // we should skip over the action argument.
                if (actionArg != null && actionArg.Symbol == member)
                {
                    continue;
                }

                Argument arg = null;
                List<string> argGroup = new List<string>();
                Dictionary<string, Dictionary<ISymbol, int>> mapOfOverridesPerGroup = new Dictionary<string, Dictionary<ISymbol, int>>();

                bool isCommon = false;
                bool isAttributeGroup = false;

                foreach (var attribute in attributes)
                {
                    // Do a quick check to make sure the attribute we are looking at is coming from the CommandLine replacedembly
                    if (!StringComparer.OrdinalIgnoreCase.Equals("CommandLine", attribute.AttributeClreplaced.Containingreplacedembly.Name))
                    {
                        continue;
                    }

                    if (attribute.ConstructorArguments.Length >= 3)
                    {
                        if (attribute.AttributeClreplaced.Name == "RequiredArgumentAttribute")
                        {
                            RequiredArgument ra = new RequiredArgument();
                            ra.Position = (int)attribute.ConstructorArguments[0].Value; // position

                            ra.Name = attribute.ConstructorArguments[1].Value as string;
                            ra.Description = attribute.ConstructorArguments[2].Value as string;
                            if (attribute.ConstructorArguments.Length == 4)
                            {
                                ra.IsCollection = (bool)attribute.ConstructorArguments[3].Value;
                            }

                            if (arg != null)
                            {
                                // can't have a property be both optional and required
                                context.ReportDiagnostic(Diagnostic.Create(ConflictingPropertyDeclarationRule, member.Locations.First()));
                            }

                            arg = ra;
                        }
                        else if (attribute.AttributeClreplaced.Name == "OptionalArgumentAttribute")
                        {
                            OptionalArgument oa = new OptionalArgument();
                            oa.DefaultValue = attribute.ConstructorArguments[0].Value; // default value
                            oa.Name = attribute.ConstructorArguments[1].Value as string;
                            oa.Description = attribute.ConstructorArguments[2].Value as string;
                            if (attribute.ConstructorArguments.Length == 4)
                            {
                                oa.IsCollection = (bool)attribute.ConstructorArguments[3].Value;
                            }

                            if (arg != null)
                            {
                                // can't have a property be both optional and required
                                context.ReportDiagnostic(Diagnostic.Create(ConflictingPropertyDeclarationRule, member.Locations.First()));
                            }
                            arg = oa;
                        }
                    }

                    if (attribute.AttributeClreplaced.Name == "CommonArgumentAttribute")
                    {
                        isCommon = true;
                    }

                    if (attribute.AttributeClreplaced.Name == "ArgumentGroupAttribute")
                    {
                        isAttributeGroup = true;
                        string groupName = attribute.ConstructorArguments[0].Value as string;
                        argGroup.Add(groupName);

                        // does it have an additional constructor?
                        if (attribute.ConstructorArguments.Length > 1)
                        {
                            var overridePosition = (int)attribute.ConstructorArguments[1].Value;

                            if (overridePosition >= 0)
                            {
                                // need to map the member to the new position 
                                Dictionary<ISymbol, int> map;
                                if (!mapOfOverridesPerGroup.TryGetValue(groupName, out map))
                                {
                                    map = new Dictionary<ISymbol, int>();
                                    mapOfOverridesPerGroup[groupName] = map;
                                }

                                map[member] = overridePosition;
                            }
                        }
                    }
                }

                // we did not find the Required/Optional attribute on that type.
                if (arg == null)
                {
                    // we could not identify an argument because we don't have the required/optional attribute, but we do have the commonattribute/attributeGroup which does not make sense.
                    if (isCommon == true || isAttributeGroup == true)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(CannotSpecifyAGroupForANonPropertyRule, member.Locations.First()));
                    }

                    // we don't understand this argument, nothing to do.
                    continue;
                }

                // store the member symbol on the argument object
                arg.Symbol = member;

                // add the argument to all the groups
                if (isCommon == true)
                {
                    foreach (var key in mapGroupAndProps.Keys)
                    {
                        mapGroupAndProps[key].Add(arg);
                    }

                    // give an error about the action argument being a string and using a common attribute with that.
                    if (actionArg != null && (actionArg.Symbol as IPropertySymbol).Type.BaseType?.SpecialType != SpecialType.System_Enum)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(CommonArgumentAttributeUsedWhenActionArgumentNotEnumRule, arg.Symbol.Locations.First()));
                    }
                }
                else
                {
                    // if we have found an attribute that specifies a group, add it to that.
                    if (argGroup.Count > 0)
                    {
                        // add the current argument to all the argument groups defined.
                        foreach (var item in argGroup)
                        {
                            if (!mapGroupAndProps.TryGetValue(item, out List<Argument> args))
                            {
                                args = new List<Argument>();
                                mapGroupAndProps[item] = args;
                            }

                            // we might need to change the position for this arg based on the override list
                            if (mapOfOverridesPerGroup.ContainsKey(item))
                            {
                                // if the current symbol is the one redirected, then redirect.
                                if (mapOfOverridesPerGroup[item].ContainsKey(arg.Symbol))
                                {
                                    var overridePosition = mapOfOverridesPerGroup[item][arg.Symbol];

                                    // we need to clone the arg.

                                    var reqArg = arg as RequiredArgument;
                                    var clonedArg = reqArg.Clone();
                                    clonedArg.Position = overridePosition;
                                    args.Add(clonedArg);
                                }
                                else
                                {
                                    args.Add(arg);
                                }
                            }
                            else
                            {
                                args.Add(arg);
                            }
                        }
                    }
                    else
                    {
                        //add it to the default one.
                        mapGroupAndProps[string.Empty].Add(arg);
                    }
                }
            }

            return mapGroupAndProps;
        }

19 View Source File : FeatureDatabase.cs
License : Microsoft Public License
Project Creator : achimismaili

private void AddToLocationFeatures(Location location, Feature feature)
        {
            string lkey = location.Key;
            if (!_LocationFeatures.ContainsKey(lkey))
            {
                _LocationFeatures.Add(lkey, new List<Feature>());
            }
            List<Feature> features = _LocationFeatures[lkey];
            if (!features.Contains(feature))
            {
                features.Add(feature);
            }
        }

19 View Source File : KrakenClient.cs
License : Apache License 2.0
Project Creator : AlexWan

public List<Candle> GetCandles(string name, TimeSpan tf, int? since = null)
        {
            try
            {
                var candlesArray = _kraken.GetOHLC(name, (int)tf.TotalMinutes, since);
                //var ret = JsonConvert.DeserializeObject<GetOHLCResponse>(candlesArray.ToString());
                JObject obj = (JObject)JsonConvert.DeserializeObject(candlesArray.ToString());
                JArray err = (JArray)obj["error"];

                if (err.Count != 0)
                {
                    return null;
                }

                JObject result = obj["result"].Value<JObject>();

                var ret = new GetOHLCResult();
                ret.Pairs = new Dictionary<string, List<OHLC>>();

                foreach (var o in result)
                {
                    if (o.Key == "last")
                    {
                        ret.Last = o.Value.Value<long>();
                    }
                    else
                    {
                        var ohlc = new List<OHLC>();
                        foreach (var v in o.Value.ToObject<decimal[][]>())
                            ohlc.Add(new OHLC()
                            {
                                Time = (int)v[0],
                                Open = v[1],
                                High = v[2],
                                Low = v[3],
                                Close = v[4],
                                Vwap = v[5],
                                Volume = v[6],
                                Count = (int)v[7]
                            });
                        ret.Pairs.Add(o.Key, ohlc);
                    }
                }


                var candles = ret.Pairs[name];

                List<Candle> candlesReady = new List<Candle>();

                for (int i = 0; i < candles.Count; i++)
                {
                    Candle newCandle = new Candle();

                    newCandle.TimeStart = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(candles[i].Time);

                    newCandle.Open = candles[i].Open;
                    newCandle.High = candles[i].High;
                    newCandle.Low = candles[i].Low;
                    newCandle.Close = candles[i].Close;
                    newCandle.Volume = candles[i].Volume;

                    candlesReady.Add(newCandle);
                }

                return candlesReady;

            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }
            return null;
        }

19 View Source File : PoolObject.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private GameObject PickObject(string name)
        {
            if (!cache.TryGetValue(name, out List<GameObject> list))
            {
                List<GameObject> goList = new List<GameObject>();
                Expand(name, goList, 5);
                cache.Add(name, goList);
                list = cache[name];
            }
            GameObject result = null;
            lock (list)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].activeInHierarchy)
                    {
                        continue;
                    }

                    result = list[i];
                }
                if (result == null)
                {
                    Expand(name, list, 5);
                    result = PickObject(name);
                }
            }
            return result;
        }

19 View Source File : BasicLineChartFunctions.cs
License : MIT License
Project Creator : alfarok

[IsVisibleInDynamoLibrary(false)]
        public static Dictionary<string, List<double>> GetNodeInput(List<string> replacedles, List<List<double>> values, List<DSCore.Color> colors)
        {
            // TODO - just preplaced input data unmodified instead?
            var output = new Dictionary<string, List<double>>();

            if (replacedles.Count != values.Count)
            {
                return output;
            }

            for (var i = 0; i < replacedles.Count; i++)
            {
                output.Add(replacedles[i], values[i]);
            }

            return output;
        }

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

public static void LoadMismatchSearchMatrix(Options o)
        {
            if (o.Warning)
            {
                foreach (var x in (JsonConvert.DeserializeObject<JObject>(new WebClient().DownloadString(o.MitreMatrix))["objects"] as JArray)!
                    .Where(x => x["external_references"] != null && x["external_references"].Any(y => y["source_name"] != null && x["kill_chain_phases"] != null)))
                {
                    var techId = x["external_references"]
                        .First(x => x["source_name"].ToString() == "mitre-attack")["external_id"]
                        .ToString();
                    if (!mismatchSearchMatrix.ContainsKey(techId))
                        mismatchSearchMatrix.Add(techId,
                            x["kill_chain_phases"]!.Select(x => x["phase_name"].ToString()).ToList()
                        );
                    else
                    {
                        mismatchSearchMatrix[techId] = mismatchSearchMatrix[techId].Concat(x["kill_chain_phases"]!.Select(x => x["phase_name"].ToString())).ToList();
                    }
                }
            }
        }

19 View Source File : ScatterPlotFunctions.cs
License : MIT License
Project Creator : alfarok

[IsVisibleInDynamoLibrary(false)]
        public static Dictionary<string, Dictionary<string, List<double>>> GetNodeInput(List<string> replacedles, List<List<double>> xValues, List<List<double>> yValues, List<DSCore.Color> colors)
        {
            // TODO - just preplaced input data unmodified instead?
            var output = new Dictionary<string, Dictionary<string, List<double>>>();

            if (replacedles.Count != xValues.Count || xValues.Count != yValues.Count)
            {
                return output;
            }

            for (var i = 0; i < replacedles.Count; i++)
            {
                var coordinates = new Dictionary<string, List<double>>();
                coordinates.Add("X", xValues[i]);
                coordinates.Add("Y", yValues[i]);
                output.Add(replacedles[i], coordinates);
            }

            return output;
        }

19 View Source File : CSRedisClientAsync.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

async private Task<T[]> ExeucteArrayAsync<T>(string[] key, Func<RedisConnection2, string[], Task<T[]>> hander) {
			if (key == null || key.Any() == false) return new T[0];
			if (ClusterRule == null || ClusterNodes.Count == 1) {
				var pool = ClusterNodes.First().Value;
				var keys = key.Select(a => string.Concat(pool.Prefix, a)).ToArray();
				return await GetConnectionAndExecuteAsync(pool, conn => hander(conn, keys));
			}
			var rules = new Dictionary<string, List<(string, int)>>();
			for (var a = 0; a < key.Length; a++) {
				var rule = ClusterRule(key[a]);
				if (rules.ContainsKey(rule)) rules[rule].Add((key[a], a));
				else rules.Add(rule, new List<(string, int)> { (key[a], a) });
			}
			T[] ret = new T[key.Length];
			foreach (var r in rules) {
				var pool = ClusterNodes.TryGetValue(r.Key, out var b) ? b : ClusterNodes.First().Value;
				var keys = r.Value.Select(a => string.Concat(pool.Prefix, a.Item1)).ToArray();
				await GetConnectionAndExecuteAsync(pool, async conn => {
					var vals = await hander(conn, keys);
					for (var z = 0; z < r.Value.Count; z++) {
						ret[r.Value[z].Item2] = vals == null || z >= vals.Length ? default(T) : vals[z];
					}
					return 0;
				});
			}
			return ret;
		}

19 View Source File : VssApiResourceLocationCollection.cs
License : MIT License
Project Creator : actions

public void AddResourceLocation(ApiResourceLocation location)
        {
            ApiResourceLocation existingLocation;
            if (m_locationsById.TryGetValue(location.Id, out existingLocation))
            {
                if (!location.Equals(existingLocation))  // unit tests will register same resources multiple times, so only throw if the ApiResourceLocation doesn't match what is already cached.
                {
                    throw new VssApiResourceDuplicateIdException(location.Id);
                }
            }

            m_locationsById[location.Id] = location;

            List<ApiResourceLocation> locationsByKey;
            String locationCacheKey = GetLocationCacheKey(location.Area, location.ResourceName);
            if (!m_locationsByKey.TryGetValue(locationCacheKey, out locationsByKey))
            {
                locationsByKey = new List<ApiResourceLocation>();
                m_locationsByKey.Add(locationCacheKey, locationsByKey);
            }

            if (!locationsByKey.Any(x => x.Id.Equals(location.Id)))
            {
                locationsByKey.Add(location);
            }
        }

19 View Source File : TestFileSystem.cs
License : MIT License
Project Creator : 0x1000000

public void AddFile(string path, string content)
        {
            var dir = Path.GetDirectoryName(path) ?? string.Empty;

            if (!this._directories.TryGetValue(dir, out var list))
            {
                list = new List<string>();
                this._directories.Add(dir, list);
            }
            list.Add(path);

            if(!this._files.TryAdd(path, content))
            {
                throw new Exception("File already exists: " + path);
            }
        }

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

public static Dictionary<string, List<string>> ParseRuleFile(string ruleFilePath)
        {
            Dictionary<string, List<string>> res = new Dictionary<string, List<string>>();
            var contents = new StringReader(File.ReadAllText(ruleFilePath));
            string line = contents.ReadLine();
                while (line != null)
                {
                    try
                    {
                        //if the line contains a mitre_technique
                        if (line.Contains("mitre_technique_id "))
                        {
                            List<string> techniques = new List<string>();
                            //get all indexes from all technique ids and add them all to a list
                            IEnumerable<int> indexes = Regex.Matches(line, "mitre_technique_id ").Cast<Match>().Select(m => m.Index + "mitre_technique_id ".Length);
                            foreach (int index in indexes) 
                                techniques.Add(line.Substring(index, line.IndexOfAny(new [] { ',', ';' }, index) - index));
                            int head = line.IndexOf("msg:\"") + "msg:\"".Length;
                            int tail = line.IndexOf("\"", head);
                            string msg = line.Substring(head, tail - head);
                            head = line.IndexOf("sid:") + "sid:".Length;
                            tail = line.IndexOfAny(new char[] { ',', ';' }, head);
                            string sid = line.Substring(head, tail - head);
                            //for each found technique add the sid along with the message to the content
                            foreach( string technique in techniques)
                            {
                                if (res.ContainsKey(technique))
                                    res[technique].Add($"{sid} - {msg}");
                                else
                                    res.Add(technique, new List<string> { $"{sid} - {msg}" });
                            }
                        }
                        line = contents.ReadLine();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(line);
                        Console.WriteLine(e.Message);
                        line = contents.ReadLine();
                }
                }
                return res;
            }

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

private static void AttachAxisToGroup(AxisBase axis, string newGroupName)
        {
            lock (AxisByGroup)
            {
                if (!AxisByGroup.ContainsKey(newGroupName))
                {
                    AxisByGroup.Add(newGroupName, new List<AxisInfo>());
                }

                // Use Rx.FromEvent to get observable stream of VisibleRangeChanged events 
                IObservable<EventPattern<VisibleRangeChangedEventArgs>> observable =
                    Observable.FromEventPattern<VisibleRangeChangedEventArgs>(
                        h => axis.VisibleRangeChanged += h,
                        h => axis.VisibleRangeChanged -= h);

                // Subscribe to the observable and preplaced in parameters plus group name 
                var subscription = observable
                    .Subscribe(eventArgs => OnVisibleRangeChanged((AxisBase) eventArgs.Sender,
                        eventArgs.EventArgs.NewVisibleRange, newGroupName));

                // Add 
                AxisByGroup[newGroupName].Add(new AxisInfo() {Axis = axis, Subscription = subscription});
            }
        }

19 View Source File : ProcessingDelegatesWalker.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

private void replacedyzeSetParametersDelegate(string viewName, ArgumentListSyntax argumentList)
		{
			ThrowIfCancellationRequested();

			var handlerNode = argumentList?.Arguments.First()?.Expression;
			if (handlerNode == null)
			{
				return;
			}

			if (!ParametersDelegateListByView.ContainsKey(viewName))
			{
				ParametersDelegateListByView.Add(viewName, new List<ProcessingDelegateInfo>());
			}

			ParametersDelegateListByView[viewName].Add(GetDelegateInfo(handlerNode));
		}

19 View Source File : EventScope.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static EventScope CreateScope(object config,string category, string property)
        {
            string name = $"{category}.{property}";
            if (Events.TryGetValue(name, out var configs))
            {
                if (configs.Contains(config))
                    return null;
            }
            else
            {
                Events.Add(name, new List<object>());
            }
            return new EventScope(config, name);
        }

See More Examples