Here are the examples of the csharp api System.Collections.Generic.Dictionary.TryGetValue(string, out System.Collections.Generic.List) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
981 Examples
19
View Source File : TestFileSystem.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public IEnumerable<string> EnumerateFiles(string path, string pattern, SearchOption searchOption)
{
if (this._directories.TryGetValue(path, out var list))
{
return list;
}
throw new Exception("Directory does not exists: " + path);
}
19
View Source File : TestFileSystem.cs
License : MIT License
Project Creator : 0x1000000
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 : CustomEditorBase.cs
License : MIT License
Project Creator : 39M
License : MIT License
Project Creator : 39M
protected void specifyCustomDecorator(string propertyName, Action<SerializedProperty> decoratorDrawer) {
if (!validateProperty(propertyName)) {
return;
}
List<Action<SerializedProperty>> list;
if (!_specifiedDecorators.TryGetValue(propertyName, out list)) {
list = new List<Action<SerializedProperty>>();
_specifiedDecorators[propertyName] = list;
}
list.Add(decoratorDrawer);
}
19
View Source File : CustomEditorBase.cs
License : MIT License
Project Creator : 39M
License : MIT License
Project Creator : 39M
protected void specifyConditionalDrawing(Func<bool> conditional, params string[] dependantProperties) {
for (int i = 0; i < dependantProperties.Length; i++) {
string dependant = dependantProperties[i];
if (!validateProperty(dependant)) {
continue;
}
List<Func<bool>> list;
if (!_conditionalProperties.TryGetValue(dependant, out list)) {
list = new List<Func<bool>>();
_conditionalProperties[dependant] = list;
}
list.Add(conditional);
}
}
19
View Source File : CustomEditorBase.cs
License : MIT License
Project Creator : 39M
License : MIT License
Project Creator : 39M
public override void OnInspectorGUI() {
_modifiedProperties.Clear();
SerializedProperty iterator = serializedObject.Gereplacederator();
bool isFirst = true;
while (iterator.NextVisible(isFirst)) {
List<Func<bool>> conditionalList;
if (_conditionalProperties.TryGetValue(iterator.name, out conditionalList)) {
bool allTrue = true;
for (int i = 0; i < conditionalList.Count; i++) {
allTrue &= conditionalList[i]();
}
if (!allTrue) {
continue;
}
}
Action<SerializedProperty> customDrawer;
List<Action<SerializedProperty>> decoratorList;
if (_specifiedDecorators.TryGetValue(iterator.name, out decoratorList)) {
for (int i = 0; i < decoratorList.Count; i++) {
decoratorList[i](iterator);
}
}
EditorGUI.BeginChangeCheck();
if (_specifiedDrawers.TryGetValue(iterator.name, out customDrawer)) {
customDrawer(iterator);
} else {
using (new EditorGUI.DisabledGroupScope(isFirst)) {
EditorGUILayout.PropertyField(iterator, true);
}
}
if (EditorGUI.EndChangeCheck()) {
_modifiedProperties.Add(iterator.Copy());
}
isFirst = false;
}
serializedObject.ApplyModifiedProperties();
}
19
View Source File : DataContext.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
public void Export<T>(Expression<Func<T>> propertyExpression, string key = null)
{
key = key ?? PropertySupport.ExtractPropertyName(propertyExpression);
if (_exportPropertyGetterDictionary.ContainsKey(key))
throw new ArgumentException(string.Format(Resources.DataContext_ExportHasBeenExported_Exception, propertyExpression), nameof(propertyExpression));
var getter = propertyExpression.Compile();
_exportPropertyGetterDictionary[key] = getter;
PropertyObserver.Observes(propertyExpression, () =>
{
if (!_importPropertySetterDictionary.TryGetValue(key, out var setterDelegates)) return;
foreach (var setterDelegate in setterDelegates)
{
var setter = (Action<T>)setterDelegate;
setter(getter());
}
});
}
19
View Source File : HouseManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
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 : VssApiResourceLocationCollection.cs
License : MIT License
Project Creator : actions
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 : VssApiResourceLocationCollection.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public IEnumerable<ApiResourceLocation> GetResourceLocations(String area, String resourceName)
{
List<ApiResourceLocation> locationsByKey;
String locationCacheKey = GetLocationCacheKey(area, resourceName);
if (m_locationsByKey.TryGetValue(locationCacheKey, out locationsByKey))
{
return locationsByKey;
}
else
{
return Enumerable.Empty<ApiResourceLocation>();
}
}
19
View Source File : DacKeyDeclarationAnalyzerBase.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
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 : DacKeyDeclarationAnalyzerBase.cs
License : GNU General Public License v3.0
Project Creator : Acumatica
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 : ItemFinder.cs
License : MIT License
Project Creator : adainrivers
License : MIT License
Project Creator : adainrivers
public static ItemData Gereplacedem(string localizedName, int? gearScore, int? tier)
{
var acceptableDistance = localizedName.Length > 10 ? 2 : 1;
localizedName = FixWords(localizedName);
if (Items == null || Items.Count == 0)
{
return null;
}
if (Items.TryGetValue(localizedName, out var itemPossibilities))
{
return GereplacedemIdFromPossibilities(itemPossibilities, gearScore, tier);
}
if (localizedName.Contains("m"))
{
var rrName = localizedName.Replace("m", "rr");
if (Items.TryGetValue(rrName, out var rrPossibilities))
{
return GereplacedemIdFromPossibilities(rrPossibilities, gearScore, tier);
}
}
var smallestDistance = int.MaxValue;
var currentName = localizedName;
foreach (var itemName in Items.Keys)
{
var distance = DamerauLevenshteinDistance(localizedName, itemName, 5);
if (smallestDistance <= distance) continue;
smallestDistance = distance;
currentName = itemName;
}
if (smallestDistance <= acceptableDistance)
{
return GereplacedemIdFromPossibilities(Items[currentName], gearScore, tier);
}
return null;
}
19
View Source File : ItemFinder.cs
License : MIT License
Project Creator : adainrivers
License : MIT License
Project Creator : adainrivers
public static void Initialize()
{
var bytes = Resources.trading_post_items;
if (bytes == null || bytes.Length <= 0)
{
return;
}
var json = System.Text.Encoding.UTF8.GetString(bytes);
var items = JsonConvert.DeserializeObject<List<TradingPosreplacedem>>(json);
foreach (var item in items)
{
foreach (var localizedName in item.Names)
{
if (!Items.TryGetValue(localizedName, out var itemDatas))
{
itemDatas = new List<ItemData>();
Items[localizedName] = itemDatas;
}
itemDatas.Add(
new ItemData{
Id = item.Id,
Name = localizedName,
GearScore = item.GS,
MinGearScore = item.MinGS,
MaxGearScore = item.MaxGS,
Tier = item.Tier
});
}
}
}
19
View Source File : ClothFactory.cs
License : GNU General Public License v3.0
Project Creator : aelariane
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 : ClothFactory.cs
License : GNU General Public License v3.0
Project Creator : aelariane
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 : PoolObject.cs
License : GNU General Public License v3.0
Project Creator : aelariane
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 : WebSocketNotify.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static void Publish(string clreplacedify, string replacedle, string value)
{
if (string.IsNullOrEmpty(value))
return;
if (!Handlers.TryGetValue(clreplacedify, out var list))
return;
var array = list.ToArray();
Task.Factory.StartNew(() => PublishAsync(array, replacedle, value));
}
19
View Source File : WebSocketNotify.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
private static async Task Acceptor(HttpContext hc, Func<Task> n)
{
if (!hc.WebSockets.IsWebSocketRequest ||!hc.Request.PathBase.HasValue)
return;
var clreplacedify = hc.Request.PathBase.Value.Trim('\\', '/', ' ');
if (!Handlers.TryGetValue(clreplacedify, out var list))
{
return;
}
var socket = await hc.WebSockets.AcceptWebSocketAsync();
var notify = new WebSocketNotify(socket, clreplacedify);
list.Add(notify);
await notify.EchoLoop();
list.Remove(notify);
}
19
View Source File : EventScope.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
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);
}
19
View Source File : XmlKeyDecryptionOptions.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public void AddKeyDecryptionCertificate(X509Certificate2 certificate)
{
var key = GetKey(certificate);
if (!_certs.TryGetValue(key, out var certificates))
{
certificates = _certs[key] = new List<X509Certificate2>();
}
certificates.Add(certificate);
}
19
View Source File : XmlKeyDecryptionOptions.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public bool TryGetKeyDecryptionCertificates(X509Certificate2 certInfo, out IReadOnlyList<X509Certificate2> keyDecryptionCerts)
{
var key = GetKey(certInfo);
var retVal = _certs.TryGetValue(key, out var keyDecryptionCertsRetVal);
keyDecryptionCerts = keyDecryptionCertsRetVal;
return retVal;
}
19
View Source File : BaseViewModelWithAnnotationValidation.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
public IEnumerable GetErrors(string propertyName)
{
return propertyName != null
? _ValidationErrorsByProperty.TryGetValue(propertyName, out List<object> errors) ? errors : (IEnumerable)Array.Empty<object>()
: Array.Empty<object>();
}
19
View Source File : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek
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 : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
public IEnumerable GetErrors(string propertyName)
{
if (!string.IsNullOrEmpty(propertyName))
{
return _errors.TryGetValue(propertyName, out List<string> propertyErrors) ? propertyErrors : null;
}
else
{
return _errors.SelectMany(err => err.Value.ToList());
}
}
19
View Source File : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek
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 : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
protected override void NotifyOfPropertyChange(string propertyName = null)
{
base.NotifyOfPropertyChange(propertyName);
if (string.IsNullOrEmpty(propertyName))
{
ValidateAllRules();
}
else
{
if (_validationRules.TryGetValue(propertyName, out List<ValidationRule> ruleSet))
{
foreach (var rule in ruleSet)
{
if (rule.IsValid())
{
RemoveError(propertyName, rule.ErrorMessage);
}
else
{
AddError(propertyName, rule.ErrorMessage);
}
}
}
}
}
19
View Source File : ValidationPropertyChangedBase.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
protected void RemoveError(string propertyName, string error)
{
if (_errors.TryGetValue(propertyName, out List<string> propertyErrors))
{
if (propertyErrors.Contains(error))
{
propertyErrors.Remove(error);
if (!propertyErrors.Any())
{
_errors.Remove(propertyName);
}
OnErrorsChanged(propertyName);
}
}
}
19
View Source File : CatalogEntry.cs
License : MIT License
Project Creator : ai-traders
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 : XmlNodeConverter.cs
License : MIT License
Project Creator : akaskela
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 : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public List< PortView > GetPortViewsFromFieldName(string fieldName)
{
List< PortView > ret;
portsPerFieldName.TryGetValue(fieldName, out ret);
return ret;
}
19
View Source File : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public PortView AddPort(FieldInfo fieldInfo, Direction direction, BaseEdgeConnectorListener listener, PortData portData)
{
PortView p = CreatePortView(direction, fieldInfo, portData, listener);
if (p.direction == Direction.Input)
{
inputPortViews.Add(p);
if (portData.vertical)
topPortContainer.Add(p);
else
inputContainer.Add(p);
}
else
{
outputPortViews.Add(p);
if (portData.vertical)
bottomPortContainer.Add(p);
else
outputContainer.Add(p);
}
p.Initialize(this, portData?.displayName);
List< PortView > ports;
portsPerFieldName.TryGetValue(p.fieldName, out ports);
if (ports == null)
{
ports = new List< PortView >();
portsPerFieldName[p.fieldName] = ports;
}
ports.Add(p);
return p;
}
19
View Source File : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public void RemovePort(PortView p)
{
// Remove all connected edges:
var edgesCopy = p.GetEdges().ToList();
foreach (var e in edgesCopy)
owner.Disconnect(e, refreshPorts: false);
if (p.direction == Direction.Input)
{
if (inputPortViews.Remove(p))
p.RemoveFromHierarchy();
}
else
{
if (outputPortViews.Remove(p))
p.RemoveFromHierarchy();
}
List< PortView > ports;
portsPerFieldName.TryGetValue(p.fieldName, out ports);
ports.Remove(p);
}
19
View Source File : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
protected virtual void DrawDefaultInspector(bool fromInspector = false)
{
var fields = nodeTarget.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
// Filter fields from the BaseNode type since we are only interested in user-defined fields
// (better than BindingFlags.DeclaredOnly because we keep any inherited user-defined fields)
.Where(f => f.DeclaringType != typeof(BaseNode));
fields = nodeTarget.OverrideFieldOrder(fields).Reverse();
foreach (var field in fields)
{
//skip if the field is a node setting
if(field.GetCustomAttribute(typeof(SettingAttribute)) != null)
{
hreplacedettings = true;
continue;
}
//skip if the field is not serializable
bool serializeField = field.GetCustomAttribute(typeof(SerializeField)) != null;
if((!field.IsPublic && !serializeField) || field.IsNotSerialized)
{
AddEmptyField(field, fromInspector);
continue;
}
//skip if the field is an input/output and not marked as SerializedField
bool hasInputAttribute = field.GetCustomAttribute(typeof(InputAttribute)) != null;
bool hasInputOrOutputAttribute = hasInputAttribute || field.GetCustomAttribute(typeof(OutputAttribute)) != null;
bool showAsDrawer = !fromInspector && field.GetCustomAttribute(typeof(ShowAsDrawer)) != null;
if (!serializeField && hasInputOrOutputAttribute && !showAsDrawer)
{
AddEmptyField(field, fromInspector);
continue;
}
//skip if marked with NonSerialized or HideInInspector
if (field.GetCustomAttribute(typeof(System.NonSerializedAttribute)) != null || field.GetCustomAttribute(typeof(HideInInspector)) != null)
{
AddEmptyField(field, fromInspector);
continue;
}
// Hide the field if we want to display in in the inspector
var showInInspector = field.GetCustomAttribute<ShowInInspector>();
if (!serializeField && showInInspector != null && !showInInspector.showInNode && !fromInspector)
{
AddEmptyField(field, fromInspector);
continue;
}
var showInputDrawer = field.GetCustomAttribute(typeof(InputAttribute)) != null && field.GetCustomAttribute(typeof(SerializeField)) != null;
showInputDrawer |= field.GetCustomAttribute(typeof(InputAttribute)) != null && field.GetCustomAttribute(typeof(ShowAsDrawer)) != null;
showInputDrawer &= !fromInspector; // We can't show a drawer in the inspector
showInputDrawer &= !typeof(IList).IsreplacedignableFrom(field.FieldType);
string displayName = ObjectNames.NicifyVariableName(field.Name);
var inspectorNameAttribute = field.GetCustomAttribute<InspectorNameAttribute>();
if (inspectorNameAttribute != null)
displayName = inspectorNameAttribute.displayName;
var elem = AddControlField(field, displayName, showInputDrawer);
if (hasInputAttribute)
{
hideElementIfConnected[field.Name] = elem;
// Hide the field right away if there is already a connection:
if (portsPerFieldName.TryGetValue(field.Name, out var pvs))
if (pvs.Any(pv => pv.GetEdges().Count > 0))
elem.style.display = DisplayStyle.None;
}
}
}
19
View Source File : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
void UpdateFieldVisibility(string fieldName, object newValue)
{
if (newValue == null)
return;
if (visibleConditions.TryGetValue(fieldName, out var list))
{
foreach (var elem in list)
{
if (newValue.Equals(elem.value))
elem.target.style.display = DisplayStyle.Flex;
else
elem.target.style.display = DisplayStyle.None;
}
}
}
19
View Source File : BaseNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
protected VisualElement AddControlField(FieldInfo field, string label = null, bool showInputDrawer = false, Action valueChangedCallback = null)
{
if (field == null)
return null;
var element = new PropertyField(FindSerializedProperty(field.Name), showInputDrawer ? "" : label);
element.Bind(owner.serializedGraph);
#if UNITY_2020_3 // In Unity 2020.3 the empty label on property field doesn't hide it, so we do it manually
if ((showInputDrawer || String.IsNullOrEmpty(label)) && element != null)
element.AddToClreplacedList("DrawerField_2020_3");
#endif
if (typeof(IList).IsreplacedignableFrom(field.FieldType))
EnableSyncSelectionBorderHeight();
element.RegisterValueChangeCallback(e => {
UpdateFieldVisibility(field.Name, field.GetValue(nodeTarget));
valueChangedCallback?.Invoke();
NotifyNodeChanged();
});
// Disallow picking scene objects when the graph is not linked to a scene
if (element != null && !owner.graph.IsLinkedToScene())
{
var objectField = element.Q<ObjectField>();
if (objectField != null)
objectField.allowSceneObjects = false;
}
if (!fieldControlsMap.TryGetValue(field, out var inputFieldList))
inputFieldList = fieldControlsMap[field] = new List<VisualElement>();
inputFieldList.Add(element);
if(element != null)
{
if (showInputDrawer)
{
var box = new VisualElement {name = field.Name};
box.AddToClreplacedList("port-input-element");
box.Add(element);
inputContainerElement.Add(box);
}
else
{
controlsContainer.Add(element);
}
element.name = field.Name;
}
else
{
// Make sure we create an empty placeholder if FieldFactory can not provide a drawer
if (showInputDrawer) AddEmptyField(field, false);
}
var visibleCondition = field.GetCustomAttribute(typeof(VisibleIf)) as VisibleIf;
if (visibleCondition != null)
{
// Check if target field exists:
var conditionField = nodeTarget.GetType().GetField(visibleCondition.fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (conditionField == null)
Debug.LogError($"[VisibleIf] Field {visibleCondition.fieldName} does not exists in node {nodeTarget.GetType()}");
else
{
visibleConditions.TryGetValue(visibleCondition.fieldName, out var list);
if (list == null)
list = visibleConditions[visibleCondition.fieldName] = new List<(object value, VisualElement target)>();
list.Add((visibleCondition.value, element));
UpdateFieldVisibility(visibleCondition.fieldName, conditionField.GetValue(nodeTarget));
}
}
return element;
}
19
View Source File : TileJsonData.cs
License : MIT License
Project Creator : alen-smajic
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 : CommandLineAnalyzer.cs
License : MIT License
Project Creator : AlexGhiondea
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 : SoundManager.cs
License : MIT License
Project Creator : alexjhetherington
License : MIT License
Project Creator : alexjhetherington
public AudioSource PlaySoundInternal(string name, Vector3 position, Transform followTarget, float pitchOverride) {
List<SoundEntry> soundEntries;
if(!groupedSoundEntries.TryGetValue(name, out soundEntries))
{
Debug.LogError("Sound was not found in library: " + name);
foreach(var entry in groupedSoundEntries.Keys)
{
Debug.Log(entry);
}
return null;
}
SoundEntry soundEntry = soundEntries[Random.Range(0, soundEntries.Count)];
var go = PoolManager.SpawnObject(prototype);
DontDestroyOnLoad(go);
go.name = "(Sound) " + soundEntry.audioClip.name;
var audioSource = go.GetComponent<AudioSource>();
var audioSourceLifecycle = go.GetComponent<AudioSourceLifeCycle>();
go.transform.position = position;
audioSource.clip = soundEntry.audioClip;
audioSource.volume = soundEntry.volume;
audioSource.loop = soundEntry.looping;
audioSource.spatialBlend = soundEntry.spatialBlend;
audioSource.outputAudioMixerGroup = soundEntry.audioMixerGroup;
if (soundEntry.pitchVariation != 0)
audioSource.pitch = 1 + Random.Range(-soundEntry.pitchVariation, soundEntry.pitchVariation);
else
audioSource.pitch = 1;
if (pitchOverride != 0)
audioSource.pitch = pitchOverride;
audioSourceLifecycle.toFollow = followTarget;
audioSource.Play();
return audioSource;
}
19
View Source File : CanonicalRequestBuilder.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
private static void AppendSortedQueryString(ref NoAllocStringBuilder builder, string query)
{
if (!string.IsNullOrEmpty(query))
{
var queryParameters = HttpUtility.ParseQueryString(query);
var parsedParameters = new Dictionary<string, List<string>>(queryParameters.Count);
foreach (string parameterName in queryParameters)
{
var parameterValues = queryParameters.GetValues(parameterName)!;
if (!parsedParameters.TryGetValue(parameterName, out var cachedParameterValues))
parsedParameters[parameterName] = parameterValues.ToList();
else
cachedParameterValues.AddRange(parameterValues);
}
var isFirst = true;
foreach (var parameter in parsedParameters.OrderBy(x => x.Key, StringComparer.Ordinal))
{
foreach (var parameterValue in parameter.Value.OrderBy(x => x, StringComparer.Ordinal))
{
if (!isFirst)
builder.Append('&');
builder.Append(UrlEncoder.Encode(parameter.Key, false));
builder.Append('=');
builder.Append(UrlEncoder.Encode(parameterValue, false));
isFirst = false;
}
}
}
builder.Append('\n');
}
19
View Source File : ShaderMethodGenerator.cs
License : MIT License
Project Creator : Aminator
License : MIT License
Project Creator : Aminator
private static IList<MetadataReference> GetMetadataReferences(replacedembly replacedembly, params replacedemblyName[] additionalreplacedemblyNames)
{
if (!loadedMetadataReferencesPerreplacedembly.TryGetValue(replacedembly.FullName, out List<MetadataReference> metadataReferences))
{
metadataReferences = new List<MetadataReference>();
loadedMetadataReferencesPerreplacedembly.Add(replacedembly.FullName, metadataReferences);
IEnumerable<replacedemblyName> referencedreplacedemblies = replacedembly.GetReferencedreplacedemblies().Concat(additionalreplacedemblyNames);
foreach (replacedemblyName referencedreplacedemblyName in referencedreplacedemblies)
{
if (referencedreplacedemblyName.Name == "netstandard")
{
metadataReferences.AddRange(GetMetadataReferences(replacedembly.Load(referencedreplacedemblyName)));
}
metadataReferences.Add(GetMetadataReference(referencedreplacedemblyName));
}
}
return metadataReferences;
}
19
View Source File : ItemIgnore.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private static void AddIgnore(Dictionary<string, List<string>> add, SvnItem item, string name)
{
if (item == null)
return;
if (!item.IsVersioned)
return;
List<string> toAdd;
if (!add.TryGetValue(item.FullPath, out toAdd))
{
toAdd = new List<string>();
add.Add(item.FullPath, toAdd);
}
if (!toAdd.Contains(name))
toAdd.Add(name);
}
19
View Source File : SynchronizedObjectListener.cs
License : Apache License 2.0
Project Creator : Anapher
License : Apache License 2.0
Project Creator : Anapher
public T GetSynchronizedObject<T>(string syncObjId) where T : clreplaced
{
lock (_lock)
{
if (!_cachedData.TryGetValue(syncObjId, out var events))
throw new InvalidOperationException("The synchronized object was never received.");
var serializer = JsonSerializer.Create(JsonSettings);
var initialEvent = events.Last(x => !x.IsPatch);
var patches = events.Skip(events.IndexOf(initialEvent) + 1);
var initialObj = initialEvent.Payload.DeepClone();
foreach (var patch in patches.Select(x => x.Payload))
{
var jsonPatch = patch.DeepClone().ToObject<JsonPatchDoreplacedent<JToken>>(serializer);
if (jsonPatch == null) throw new NullReferenceException("A patch must never be null.");
jsonPatch.ApplyTo(initialObj);
}
var result = initialObj.ToObject<T>(serializer);
if (result == null) throw new NullReferenceException("The sync object must not be null.");
return result;
}
}
19
View Source File : SynchronizedObjectListener.cs
License : Apache License 2.0
Project Creator : Anapher
License : Apache License 2.0
Project Creator : Anapher
private void AddEvent(SyncObjPayload<JToken> value, bool isPatch)
{
List<AsyncAutoResetEvent> autoResetEvents;
lock (_lock)
{
if (!_cachedData.TryGetValue(value.Id, out var events))
_cachedData[value.Id] = events = new List<SyncObjEvent>();
events.Add(new SyncObjEvent(isPatch, value.Value));
autoResetEvents = _waiters.ToList();
}
foreach (var autoResetEvent in autoResetEvents)
{
autoResetEvent.Set();
}
}
19
View Source File : UpdateSynchronizedObjectUseCaseTests.cs
License : Apache License 2.0
Project Creator : Anapher
License : Apache License 2.0
Project Creator : Anapher
private void ParticipantHreplacedubscribed(Participant participant, SynchronizedObjectId subscribed)
{
if (!_participantSubscriptions.TryGetValue(subscribed.ToString(), out var participants))
_participantSubscriptions[subscribed.ToString()] = participants = new List<Participant>();
participants.Add(participant);
_mediator.Setup(x => x.Send(It.IsAny<FetchSubscribedParticipantsRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(participants);
}
19
View Source File : ResourceRedirectManager.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm
License : GNU General Public License v3.0
Project Creator : AndrasMumm
public string GetRedirect(string path)
{
if (path.StartsWith("replacedets/") || path.StartsWith("replacedets/"))
{
path = path.Substring(7);
}
path = path.Replace("\\", "/");
List<string> result = null;
PathRedirections.TryGetValue(path, out result);
if (result != null)
{
//UnityEngine.Debug.Log(path + " redirects to RootPath " + result);
if (result.Count > 0)
{
return result[result.Count - 1];
}
else
{
return string.Empty;
}
}
else
{
return string.Empty;
}
}
19
View Source File : ResourceRedirectManager.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm
License : GNU General Public License v3.0
Project Creator : AndrasMumm
public List<string> GetAllRedirects(string path)
{
if (path.StartsWith("replacedets/") || path.StartsWith("replacedets/"))
{
path = path.Substring(7);
}
path = path.Replace("\\", "/");
List<string> result = null;
PathRedirections.TryGetValue(path, out result);
return result;
}
19
View Source File : ValidationResult.cs
License : MIT License
Project Creator : ansel86castro
License : MIT License
Project Creator : ansel86castro
public ValidationResult AddError(string member, string error)
{
if(!Errors.TryGetValue(member, out var list))
{
list = new List<string>();
Errors.Add(member, list);
}
list.Add(error);
return this;
}
19
View Source File : GeneratorContext.cs
License : GNU General Public License v3.0
Project Creator : anydream
License : GNU General Public License v3.0
Project Creator : anydream
public void AddStaticField(string typeName, string sfldName, bool hasRef)
{
if (!InitFldsMap.TryGetValue(typeName, out var nameSet))
{
nameSet = new List<Tuple<string, bool>>();
InitFldsMap.Add(typeName, nameSet);
}
nameSet.Add(new Tuple<string, bool>(sfldName, hasRef));
}
19
View Source File : MultiParameterLambdaState.cs
License : MIT License
Project Creator : aquilahkj
License : MIT License
Project Creator : aquilahkj
public override ISelector CreateSelector(string[] fullPaths)
{
var dict = new Dictionary<string, List<string>>();
foreach (var fullPath in fullPaths) {
var index = fullPath.IndexOf(".", StringComparison.Ordinal);
if (index < 0) {
if (_mapDict.ContainsKey(fullPath)) {
if (!dict.TryGetValue(fullPath, out var list)) {
list = new List<string>();
dict.Add(fullPath, list);
}
if (!list.Contains(string.Empty)) {
list.Add(string.Empty);
}
}
else {
throw new LambdaParseException(LambdaParseMessage.ExpressionFieldPathError, fullPath);
}
}
else {
var name = fullPath.Substring(0, index);
var path = fullPath.Substring(index);
if (_mapDict.ContainsKey(name)) {
if (!dict.TryGetValue(name, out var list)) {
list = new List<string>();
dict.Add(name, list);
}
if (!list.Contains(path)) {
list.Add(path);
}
}
else {
throw new LambdaParseException(LambdaParseMessage.ExpressionFieldPathNotExists, fullPath);
}
}
}
var selectDict = new Dictionary<string, Selector>();
foreach (var kvs in dict) {
var map = _mapDict[kvs.Key];
var alias = _aliasDict[kvs.Key];
var selector = map.CreateSelector(kvs.Value.ToArray()) as Selector;
if (selector == null) {
throw new LambdaParseException(LambdaParseMessage.NotSupportRelateEnreplacedyJoinSelect);
}
selectDict.Add(alias, selector);
}
var joinSelector = Selector.ComposeSelector(selectDict);
return joinSelector;
}
19
View Source File : SavedSearchProvider.cs
License : MIT License
Project Creator : arasplm
License : MIT License
Project Creator : arasplm
public List<SavedSearch> GetSavedSearch(string itemTypeName)
{
List<SavedSearch> resultList;
if (!cachedSavedSearches.TryGetValue(itemTypeName, out resultList))
{
resultList = new List<SavedSearch>();
dynamic savedSearches = innovatorInstance.newItem();
savedSearches.loadAML(string.Format(@"
<AML>
<Item type=""SavedSearch"" action=""get"">
<itname>{0}</itname>
<auto_saved>0</auto_saved>
</Item>
</AML>", itemTypeName));
savedSearches = savedSearches.apply();
var searchesCount = savedSearches.gereplacedemCount();
for (int i = 0; i < searchesCount; i++)
{
var search = new SavedSearch();
var savedSearch = savedSearches.gereplacedemByIndex(i);
search.SearchId = savedSearch.getID();
search.SearchName = savedSearch.getProperty("label");
search.ItemName = itemTypeName;
string criteria = savedSearch.getProperty("criteria");
if (!string.IsNullOrEmpty(criteria))
{
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.LoadXml(criteria);
var properties = doc.FirstChild.ChildNodes;
foreach (XmlNode prop in properties)
{
var propertyInfo = new ItemSearchPropertyInfo();
propertyInfo.PropertyName = prop.Name;
propertyInfo.PropertyValue = prop.InnerText;
search.SavedSearchProperties.Add(propertyInfo);
}
}
resultList.Add(search);
}
cachedSavedSearches.Add(itemTypeName, resultList);
}
return resultList;
}
See More Examples