Here are the examples of the csharp api System.Collections.Generic.List.FindIndex(System.Predicate) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1196 Examples
19
Source : IPSendTimeState.cs
with GNU Affero General Public License v3.0
from blockbasenetwork
with GNU Affero General Public License v3.0
from blockbasenetwork
protected override async Task DoWork()
{
int numberOfIpsToSend = (int)Math.Ceiling(_producers.Count() / 4.0);
var keysToUse = ListHelper.GetListSortedCountingFrontFromIndex(_producers, _producers.FindIndex(m => m.Key == _nodeConfigurations.AccountName)).Take(numberOfIpsToSend).Select(p => p.PublicKey).ToList();
keysToUse.Add(_sidechainPool.ClientPublicKey);
var listEncryptedIps = new List<string>();
var endpoint = _networkConfigurations.GetResolvedIp() + ":" + _networkConfigurations.TcpPort;
foreach (string receiverPublicKey in keysToUse)
{
listEncryptedIps.Add(replacedymetricEncryption.EncryptText(endpoint, _nodeConfigurations.ActivePrivateKey, receiverPublicKey));
}
var addIpsTransaction = await _mainchainService.AddEncryptedIps(_sidechainPool.ClientAccountName, _nodeConfigurations.AccountName, listEncryptedIps);
_hasUpdatedIps = true;
_logger.LogDebug($"Sent encrypted ips. Tx: {addIpsTransaction}");
}
19
Source : ShellList.cs
with MIT License
from BluePointLilac
with MIT License
from BluePointLilac
private static string GetDirectoryTypeName(string directoryType)
{
if(directoryType == null) return null;
int index = DirectoryTypes.FindIndex(type => directoryType.Equals(type, StringComparison.OrdinalIgnoreCase));
if(index >= 0) return DirectoryTypeNames[index];
else return null;
}
19
Source : ShellList.cs
with MIT License
from BluePointLilac
with MIT License
from BluePointLilac
private static string GetPerceivedTypeName(string perceivedType)
{
int index = 0;
if(perceivedType != null) index = PerceivedTypes.FindIndex(type => perceivedType.Equals(type, StringComparison.OrdinalIgnoreCase));
if(index == -1) index = 0;
return PerceivedTypeNames[index];
}
19
Source : SystemManager.cs
with Apache License 2.0
from bnoazx005
with Apache License 2.0
from bnoazx005
public SystemId _registerSystem<T>(T system, List<T> specializedSystemsArray, byte systemTypeMask = 0x0)
where T: clreplaced, ISystem
{
if (system == null)
{
throw new ArgumentNullException("system", "An input argument 'system' cannot equal to null");
}
int registeredSystemId = 0;
int specializedSystemId = 0;
// if the system's already registered just return its identifier
if ((registeredSystemId = mActiveSystems.FindIndex(t => t == system)) >= 0 && (specializedSystemId = specializedSystemsArray.FindIndex(t => t == system)) != -1)
{
return (SystemId)((specializedSystemId << 16) | registeredSystemId | (systemTypeMask << 29));
}
//else if ((registeredSystemId = mDeactivatedSystems.FindIndex(t => t == system)) >= 0)
//{
// return (uint)registeredSystemId;
//}
registeredSystemId = (int)_pushSystemToActiveSystems(system);
specializedSystemId = specializedSystemsArray.Count;
specializedSystemsArray.Add(system);
// NOTE: enreplacedy's identifier constists of two parts. The high 2 bytes equals to index within specialized array
// and low 2 bytes are an index within common array
return (SystemId)((specializedSystemId << 16) | registeredSystemId | (systemTypeMask << 29));
}
19
Source : SystemManager.cs
with Apache License 2.0
from bnoazx005
with Apache License 2.0
from bnoazx005
protected SystemId _pushSystemToActiveSystems(ISystem system)
{
int registeredSystemId = mActiveSystems.FindIndex(t => t == system);
if (registeredSystemId != -1)
{
return (SystemId)registeredSystemId;
}
/// if there are free entries in the current array use it
if (mFreeEntries.Count >= 1)
{
registeredSystemId = mFreeEntries.First.Value;
mFreeEntries.RemoveFirst();
mActiveSystems[registeredSystemId] = system;
}
else
{
registeredSystemId = mActiveSystems.Count;
mActiveSystems.Add(system);
}
return (SystemId)registeredSystemId;
}
19
Source : DefaultSubscription.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public override bool AddEvent(string eventKey, Topic topic)
{
base.AddEvent(eventKey, topic);
lock (_cursors)
{
// O(n), but small n and it's not common
var index = _cursors.FindIndex(c => c.Key == eventKey);
if (index == -1)
{
_cursors.Add(new Cursor(eventKey, GetMessageId(topic), _stringMinifier.Minify(eventKey)));
_cursorTopics.Add(topic);
return true;
}
return false;
}
}
19
Source : DefaultSubscription.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public override void RemoveEvent(string eventKey)
{
base.RemoveEvent(eventKey);
lock (_cursors)
{
var index = _cursors.FindIndex(c => c.Key == eventKey);
if (index != -1)
{
_cursors.RemoveAt(index);
_cursorTopics.RemoveAt(index);
}
}
}
19
Source : DefaultSubscription.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public override void SetEventTopic(string eventKey, Topic topic)
{
base.SetEventTopic(eventKey, topic);
lock (_cursors)
{
// O(n), but small n and it's not common
var index = _cursors.FindIndex(c => c.Key == eventKey);
if (index != -1)
{
_cursorTopics[index] = topic;
}
}
}
19
Source : DefaultSubscription.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
private bool UpdateCursor(string key, ulong id)
{
lock (_cursors)
{
// O(n), but small n and it's not common
var index = _cursors.FindIndex(c => c.Key == key);
if (index != -1)
{
_cursors[index].Id = id;
return true;
}
return false;
}
}
19
Source : 071_unknown_quality_in_profile.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public void SplitQualityPrepend(int find, int quality)
{
foreach (var profile in _profiles)
{
if (profile.Items.Any(v => v.Quality == quality)) continue;
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
profile.Items.Insert(findIndex, new ProfileItem70
{
Quality = quality,
Allowed = profile.Items[findIndex].Allowed
});
if (profile.Cutoff == find)
{
profile.Cutoff = quality;
}
_changedProfiles.Add(profile);
}
}
19
Source : 071_unknown_quality_in_profile.cs
with GNU General Public License v3.0
from bonarr
with GNU General Public License v3.0
from bonarr
public void SplitQualityAppend(int find, int quality)
{
foreach (var profile in _profiles)
{
if (profile.Items.Any(v => v.Quality == quality)) continue;
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
profile.Items.Insert(findIndex + 1, new ProfileItem70
{
Quality = quality,
Allowed = false
});
_changedProfiles.Add(profile);
}
}
19
Source : FixedWidthBaseProvider.cs
with MIT License
from borisdj
with MIT License
from borisdj
private object ParserBoolean(string valueString, string typeName, string format)
{
var valueFormatIndex = format.Split(';').ToList().FindIndex(a => a == valueString);
object value = valueFormatIndex == 0 ? true : valueFormatIndex == 2 ? false : (bool?)null;
return value;
}
19
Source : FormBuilder.cs
with MIT License
from BotBuilderCommunity
with MIT License
from BotBuilderCommunity
private IFormBuilder<T> AddField(IField<T> field)
{
field.Form = _form;
_form._fields.Add(field);
var step = new FieldStep<T>(field.Name, _form);
var stepIndex = this._form._steps.FindIndex(s => s.Name == field.Name);
if (stepIndex >= 0)
{
_form._steps[stepIndex] = step;
}
else
{
_form._steps.Add(step);
}
return this;
}
19
Source : BlueprintBrowser.cs
with MIT License
from cabarius
with MIT License
from cabarius
public static IEnumerable OnGUI() {
if (blueprints == null) {
blueprints = BlueprintLoader.Shared.GetBlueprints();
if (blueprints != null) UpdateSearchResults();
}
// Stackable browser
using (UI.HorizontalScope(UI.Width(350))) {
var remainingWidth = UI.ummWidth;
// First column - Type Selection Grid
using (UI.VerticalScope(GUI.skin.box)) {
UI.ActionSelectionGrid(ref settings.selectedBPTypeFilter,
blueprintTypeFilters.Select(tf => tf.name).ToArray(),
1,
(selected) => { UpdateSearchResults(); },
UI.buttonStyle,
UI.Width(200));
}
remainingWidth -= 350;
var collationChanged = false;
if (collatedBPs != null) {
using (UI.VerticalScope(GUI.skin.box)) {
var selectedKey = collationKeys.ElementAt(selectedCollationIndex);
if (UI.VPicker<string>("Categories", ref selectedKey, collationKeys, null, s => s, ref collationSearchText, UI.Width(300))) {
collationChanged = true; BlueprintListUI.needsLayout = true;
}
if (selectedKey != null)
selectedCollationIndex = collationKeys.IndexOf(selectedKey);
#if false
UI.ActionSelectionGrid(ref selectedCollationIndex, collationKeys.ToArray(),
1,
(selected) => { collationChanged = true; BlueprintListUI.needsLayout = true; },
UI.buttonStyle,
UI.Width(200));
#endif
}
remainingWidth -= 450;
}
// Section Column - Main Area
using (UI.VerticalScope(UI.MinWidth(remainingWidth))) {
// Search Field and modifiers
using (UI.HorizontalScope()) {
UI.ActionTextField(
ref settings.searchText,
"searhText",
(text) => { },
() => UpdateSearchResults(),
UI.Width(400));
UI.Space(50);
UI.Label("Limit", UI.AutoWidth());
UI.Space(15);
UI.ActionIntTextField(
ref settings.searchLimit,
"searchLimit",
(limit) => { },
() => UpdateSearchResults(),
UI.Width(75));
if (settings.searchLimit > 1000) { settings.searchLimit = 1000; }
UI.Space(25);
if (UI.Toggle("Search Descriptions", ref settings.searchesDescriptions, UI.AutoWidth())) UpdateSearchResults();
UI.Space(25);
if (UI.Toggle("Attributes", ref settings.showAttributes, UI.AutoWidth())) UpdateSearchResults();
UI.Space(25);
UI.Toggle("Show GUIDs", ref settings.showreplacedetIDs, UI.AutoWidth());
UI.Space(25);
UI.Toggle("Components", ref settings.showComponents, UI.AutoWidth());
UI.Space(25);
UI.Toggle("Elements", ref settings.showElements, UI.AutoWidth());
}
// Search Button and Results Summary
using (UI.HorizontalScope()) {
UI.ActionButton("Search", () => {
UpdateSearchResults();
}, UI.AutoWidth());
UI.Space(25);
if (firstSearch) {
UI.Label("please note the first search may take a few seconds.".green(), UI.AutoWidth());
}
else if (matchCount > 0) {
var replacedle = "Matches: ".green().bold() + $"{matchCount}".orange().bold();
if (matchCount > settings.searchLimit) { replacedle += " => ".cyan() + $"{settings.searchLimit}".cyan().bold(); }
UI.Label(replacedle, UI.ExpandWidth(false));
}
UI.Space(130);
UI.Label($"Page: ".green() + $"{Math.Min(currentPage + 1, pageCount + 1)}".orange() + " / " + $"{pageCount + 1}".cyan(), UI.AutoWidth());
UI.ActionButton("-", () => {
currentPage = Math.Max(currentPage -= 1, 0);
UpdatePaginatedResults();
}, UI.AutoWidth());
UI.ActionButton("+", () => {
currentPage = Math.Min(currentPage += 1, pageCount);
UpdatePaginatedResults();
}, UI.AutoWidth());
UI.Space(25);
var pageNum = currentPage + 1;
if (UI.Slider(ref pageNum, 1, pageCount + 1, 1)) UpdatePaginatedResults();
currentPage = pageNum - 1;
}
UI.Space(10);
if (filteredBPs != null) {
CharacterPicker.OnGUI();
UnitReference selected = CharacterPicker.GetSelectedCharacter();
var bps = filteredBPs;
if (selectedCollationIndex == 0) {
selectedCollatedBPs = null;
matchCount = uncolatedMatchCount;
UpdatePageCount();
}
if (selectedCollationIndex > 0) {
if (collationChanged) {
UpdateCollation();
}
bps = selectedCollatedBPs;
}
BlueprintListUI.OnGUI(selected, bps, 0, remainingWidth, null, selectedTypeFilter, (keys) => {
if (keys.Length > 0) {
var changed = false;
//var bpTypeName = keys[0];
//var newTypeFilterIndex = blueprintTypeFilters.FindIndex(f => f.type.Name == bpTypeName);
//if (newTypeFilterIndex >= 0) {
// settings.selectedBPTypeFilter = newTypeFilterIndex;
// changed = true;
//}
if (keys.Length > 1) {
var collationKey = keys[1];
var newCollationIndex = collationKeys.FindIndex(ck => ck == collationKey);
if (newCollationIndex >= 0) {
selectedCollationIndex = newCollationIndex;
UpdateCollation();
}
}
if (changed) {
UpdateSearchResults();
}
}
}).ForEach(action => action());
}
UI.Space(25);
}
}
return null;
}
19
Source : SavesBAB.cs
with MIT License
from cabarius
with MIT License
from cabarius
public static void ApplySingleStat(UnitDescriptor unit, LevelUpState state, BlueprintCharacterClreplaced[] appliedClreplacedes, StatType stat, BlueprintStatProgression[] statProgs, ProgressionPolicy policy = ProgressionPolicy.Largest) {
if (appliedClreplacedes.Count() <= 0) return;
//Mod.Debug($"stat: {stat} baseValue: {unit.Stats.GetStat(stat).BaseValue}");
var newClreplacedLvls = appliedClreplacedes.Select(cd => unit.Progression.GetClreplacedLevel(cd)).ToArray();
var appliedClreplacedCount = newClreplacedLvls.Length;
var oldBonuses = new int[appliedClreplacedCount];
var newBonuses = new int[appliedClreplacedCount];
for (var i = 0; i < appliedClreplacedCount; i++) {
newBonuses[i] = statProgs[i].GetBonus(newClreplacedLvls[i]);
oldBonuses[i] = statProgs[i].GetBonus(newClreplacedLvls[i] - 1);
}
var mainClreplacedIndex = appliedClreplacedes.ToList().FindIndex(cd => cd == state.SelectedClreplaced);
//v($"mainClreplacedIndex = {mainClreplacedIndex}");
var mainClreplacedInc = newBonuses[mainClreplacedIndex] - oldBonuses[mainClreplacedIndex];
var increase = 0;
switch (policy) {
case ProgressionPolicy.Average:
if (appliedClreplacedCount == 0)
break;
for (var i = 0; i < appliedClreplacedCount; i++) increase += Math.Max(0, newBonuses[i] - oldBonuses[i]);
unit.Stats.GetStat(stat).BaseValue += increase / appliedClreplacedCount - mainClreplacedInc;
break;
case ProgressionPolicy.Largest:
int maxOldValue = 0, maxNewValue = 0;
for (var i = 0; i < appliedClreplacedCount; i++) maxOldValue = Math.Max(maxOldValue, oldBonuses[i]);
for (var i = 0; i < appliedClreplacedCount; i++) maxNewValue = Math.Max(maxNewValue, newBonuses[i]);
increase = maxNewValue - maxOldValue;
unit.Stats.GetStat(stat).BaseValue += increase - mainClreplacedInc;
break;
case ProgressionPolicy.Sum:
for (var i = 0; i < appliedClreplacedCount; i++) increase += Math.Max(0, newBonuses[i] - oldBonuses[i]);
unit.Stats.GetStat(stat).BaseValue += increase - mainClreplacedInc;
break;
default:
break; ;
}
}
19
Source : HP.cs
with MIT License
from cabarius
with MIT License
from cabarius
public static void ApplyHPDice(UnitDescriptor unit, LevelUpState state, BlueprintCharacterClreplaced[] appliedClreplacedes) {
if (appliedClreplacedes.Count() <= 0) return;
var newClreplacedLvls = appliedClreplacedes.Select(cl => unit.Progression.GetClreplacedLevel(cl)).ToArray();
var clreplacedCount = newClreplacedLvls.Length;
var hitDies = appliedClreplacedes.Select(cl => (int)cl.HitDie).ToArray();
var mainClreplacedIndex = appliedClreplacedes.ToList().FindIndex(ch => ch == state.SelectedClreplaced);
//Logger.ModLoggerDebug($"mainClreplacedIndex = {mainClreplacedIndex}");
var mainClreplacedHPDie = hitDies[mainClreplacedIndex];
var currentHPIncrease = hitDies[mainClreplacedIndex];
var newIncrease = currentHPIncrease;
switch (Main.settings.multiclreplacedHitPointPolicy) {
case ProgressionPolicy.Average:
newIncrease = hitDies.Sum() / clreplacedCount;
break;
case ProgressionPolicy.Largest:
newIncrease = hitDies.Max();
break;
case ProgressionPolicy.Sum:
newIncrease = hitDies.Sum();
break;
default:
break; ;
}
unit.Stats.GetStat(StatType.HitPoints).BaseValue += newIncrease - currentHPIncrease;
}
19
Source : CreateEventTypeLabels.cs
with GNU General Public License v2.0
from Caeden117
with GNU General Public License v2.0
from Caeden117
public int EventTypeToLaneId(int eventType) => laneObjs.FindIndex(it => it.Type == eventType);
19
Source : TextureAtlasCreator.cs
with MIT License
from caioteixeira
with MIT License
from caioteixeira
private void UpdateMeshes(Rect[] newUvs, Material material)
{
for (int i = 0; i < meshFilters.Count; i++)
{
var renderer = meshRenderers[i];
var texture = renderer.sharedMaterial.mainTexture;
var textIndex = textures.FindIndex(tex => tex == texture);
var mesh = meshFilters[i].mesh;
var uvRectOnAtlas = newUvs[textIndex];
var transformedUv = ComputeUvsOnAtlas(mesh, uvRectOnAtlas);
mesh.uv = transformedUv;
renderer.material = material;
}
}
19
Source : LeanData.cs
with Apache License 2.0
from Capnode
with Apache License 2.0
from Capnode
public static bool TryParsePath(string fileName, out Symbol symbol, out DateTime date, out Resolution resolution)
{
symbol = null;
resolution = Resolution.Daily;
date = default(DateTime);
try
{
var info = SplitDataPath(fileName);
// find where the useful part of the path starts - i.e. the securityType
var startIndex = info.FindIndex(x => SecurityTypeAsDataPath.Contains(x.ToLowerInvariant()));
var securityType = ParseDataSecurityType(info[startIndex]);
var market = Market.USA;
string ticker;
if (securityType == SecurityType.Base)
{
if (!Enum.TryParse(info[startIndex + 2], true, out resolution))
{
resolution = Resolution.Daily;
}
// the last part of the path is the file name
var fileNameNoPath = info[info.Count - 1].Split('_').First();
if (!DateTime.TryParseExact(fileNameNoPath,
DateFormat.EightCharacter,
DateTimeFormatInfo.InvariantInfo,
DateTimeStyles.None,
out date))
{
// if parsing the date failed we replacedume filename is ticker
ticker = fileNameNoPath;
}
else
{
// ticker must be the previous part of the path
ticker = info[info.Count - 2];
}
}
else
{
resolution = (Resolution)Enum.Parse(typeof(Resolution), info[startIndex + 2], true);
// Gather components used to create the security
market = info[startIndex + 1];
ticker = info[startIndex + 3];
// If resolution is Daily or Hour, we do not need to set the date and tick type
if (resolution < Resolution.Hour)
{
date = Parse.DateTimeExact(info[startIndex + 4].Substring(0, 8), DateFormat.EightCharacter);
}
if (securityType == SecurityType.Crypto)
{
ticker = ticker.Split('_').First();
}
}
symbol = Symbol.Create(ticker, securityType, market);
}
catch (Exception ex)
{
Log.Debug($"LeanData.TryParsePath(): Error encountered while parsing the path {fileName}. Error: {ex.GetBaseException()}");
return false;
}
return true;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public replacedetsFileInstance LoadreplacedetsFile(Stream stream, string path, bool loadDeps, string root = "", BundleFileInstance bunInst = null)
{
replacedetsFileInstance instance;
int index = files.FindIndex(f => f.path.ToLower() == Path.GetFullPath(path).ToLower());
if (index == -1)
{
instance = new replacedetsFileInstance(stream, path, root);
instance.parentBundle = bunInst;
files.Add(instance);
}
else
{
instance = files[index];
}
if (loadDeps)
{
if (bunInst == null)
LoadDependencies(instance, Path.GetDirectoryName(path));
else
LoadBundleDependencies(instance, bunInst, Path.GetDirectoryName(path));
}
if (updateAfterLoad)
UpdateDependencies(instance);
return instance;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public bool UnloadreplacedetsFile(string path)
{
int index = files.FindIndex(f => f.path.ToLower() == Path.GetFullPath(path).ToLower());
if (index != -1)
{
replacedetsFileInstance replacedetsInst = files[index];
replacedetsInst.file.Close();
files.Remove(replacedetsInst);
return true;
}
return false;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public BundleFileInstance LoadBundleFile(FileStream stream, bool unpackIfPacked = true)
{
BundleFileInstance bunInst;
int index = bundles.FindIndex(f => f.path.ToLower() == Path.GetFullPath(stream.Name).ToLower());
if (index == -1)
{
bunInst = new BundleFileInstance(stream, "", unpackIfPacked);
bundles.Add(bunInst);
}
else
{
bunInst = bundles[index];
}
return bunInst;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public bool UnloadBundleFile(string path)
{
int index = bundles.FindIndex(f => f.path.ToLower() == Path.GetFullPath(path).ToLower());
if (index != -1)
{
BundleFileInstance bunInst = bundles[index];
bunInst.file.Close();
foreach (replacedetsFileInstance replacedetsInst in bunInst.replacedetsFiles)
{
replacedetsInst.file.Close();
}
bundles.Remove(bunInst);
return true;
}
return false;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public replacedetsFileInstance LoadreplacedetsFileFromBundle(BundleFileInstance bunInst, int index, bool loadDeps = false)
{
var dirInf = bunInst.file.bundleInf6.dirInf[index];
string replacedetMemPath = Path.Combine(bunInst.path, dirInf.name);
int listIndex = files.FindIndex(f => f.path.ToLower() == Path.GetFullPath(replacedetMemPath).ToLower());
if (listIndex == -1)
{
if (bunInst.file.IsreplacedetsFile(bunInst.file.reader, dirInf))
{
byte[] replacedetData = BundleHelper.LoadreplacedetDataFromBundle(bunInst.file, index);
MemoryStream ms = new MemoryStream(replacedetData);
replacedetsFileInstance replacedetsInst = LoadreplacedetsFile(ms, replacedetMemPath, loadDeps, bunInst: bunInst);
bunInst.replacedetsFiles.Add(replacedetsInst);
return replacedetsInst;
}
}
else
{
return files[listIndex];
}
return null;
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public void UpdateDependencies(replacedetsFileInstance ofFile)
{
var depList = ofFile.file.dependencies;
for (int i = 0; i < depList.dependencyCount; i++)
{
replacedetsFileDependency dep = depList.dependencies[i];
int index = files.FindIndex(f => Path.GetFileName(dep.replacedetPath.ToLower()) == Path.GetFileName(f.path.ToLower()));
if (index != -1)
{
ofFile.dependencies[i] = files[index];
}
}
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public void LoadDependencies(replacedetsFileInstance ofFile, string path)
{
for (int i = 0; i < ofFile.dependencies.Count; i++)
{
string depPath = ofFile.file.dependencies.dependencies[i].replacedetPath;
if (files.FindIndex(f => Path.GetFileName(f.path).ToLower() == Path.GetFileName(depPath).ToLower()) == -1)
{
string absPath = Path.Combine(path, depPath);
string localAbsPath = Path.Combine(path, Path.GetFileName(depPath));
if (File.Exists(absPath))
{
LoadreplacedetsFile(File.OpenRead(absPath), true);
}
else if (File.Exists(localAbsPath))
{
LoadreplacedetsFile(File.OpenRead(localAbsPath), true);
}
}
}
}
19
Source : AssetsManager.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public void LoadBundleDependencies(replacedetsFileInstance ofFile, BundleFileInstance ofBundle, string path)
{
for (int i = 0; i < ofFile.dependencies.Count; i++)
{
string depPath = ofFile.file.dependencies.dependencies[i].replacedetPath;
if (files.FindIndex(f => Path.GetFileName(f.path).ToLower() == Path.GetFileName(depPath).ToLower()) == -1)
{
string bunPath = Path.GetFileName(depPath);
int bunIndex = Array.FindIndex(ofBundle.file.bundleInf6.dirInf, d => Path.GetFileName(d.name) == bunPath);
//by default, the directory of an replacedets file is the bundle's file path (somepath\bundle.unity3d\file.replacedets)
//we back out again to get the directory the bundle is in
string noBunPath = Path.Combine(path, "..");
string nbAbsPath = Path.Combine(noBunPath, depPath);
string nbLocalAbsPath = Path.Combine(noBunPath, Path.GetFileName(depPath));
//if the user chose to set the path to the directory the bundle is in,
//we need to check for that as well
string absPath = Path.Combine(path, depPath);
string localAbsPath = Path.Combine(path, Path.GetFileName(depPath));
if (bunIndex != -1)
{
LoadreplacedetsFileFromBundle(ofBundle, bunIndex, true);
}
else if (File.Exists(absPath))
{
LoadreplacedetsFile(File.OpenRead(absPath), true);
}
else if (File.Exists(localAbsPath))
{
LoadreplacedetsFile(File.OpenRead(localAbsPath), true);
}
else if (File.Exists(nbAbsPath))
{
LoadreplacedetsFile(File.OpenRead(nbAbsPath), true);
}
else if (File.Exists(nbLocalAbsPath))
{
LoadreplacedetsFile(File.OpenRead(nbLocalAbsPath), true);
}
}
}
}
19
Source : MarketDepth.cs
with MIT License
from centaurus-project
with MIT License
from centaurus-project
private bool AddOrder(OrderInfo order)
{
if (order == null)
throw new ArgumentNullException(nameof(order));
var price = NormalizePrice(order.Price);
var source = prices[order.Side];
var currentPrice = source.FirstOrDefault(p => p.Price == price);
if (currentPrice == null)
{
currentPrice = new MarketDepthPrice(price);
var indexToInsert = source.FindIndex(p => p.Price < price);
if (indexToInsert == -1 && source.Count == maxPricesCount)
return false;
if (indexToInsert == -1)
source.Add(currentPrice);
else
source.Insert(indexToInsert, currentPrice);
}
currentPrice.Amount += order.AmountDiff;
currentPrice.Orders.Add(order.OrderId);
return true;
}
19
Source : MockStorage.cs
with MIT License
from centaurus-project
with MIT License
from centaurus-project
public Task Savereplacedytics(List<PriceHistoryFrameModel> update)
{
foreach (var frame in update)
{
var frameIndex = frames.FindIndex(f => f.Id == frame.Id);
if (frameIndex >= 0)
frames[frameIndex] = frame;
else
frames.Add(frame);
}
return Task.CompletedTask;
}
19
Source : VRTK_SDKSetupEditor.cs
with MIT License
from charles-river-analytics
with MIT License
from charles-river-analytics
public override void OnInspectorGUI()
{
VRTK_SDKSetup setup = (VRTK_SDKSetup)target;
serializedObject.Update();
using (new EditorGUILayout.VerticalScope("Box"))
{
VRTK_EditorUtilities.AddHeader("SDK Selection", false);
Func<VRTK_SDKInfo, ReadOnlyCollection<VRTK_SDKInfo>, string> sdkNameSelector = (info, installedInfos)
=> info.description.prettyName + (installedInfos.Contains(info) ? "" : SDKNotInstalledDescription);
string[] availableSystemSDKNames = VRTK_SDKManager.AvailableSystemSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledSystemSDKInfos)).ToArray();
string[] availableBoundariesSDKNames = VRTK_SDKManager.AvailableBoundariesSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledBoundariesSDKInfos)).ToArray();
string[] availableHeadsetSDKNames = VRTK_SDKManager.AvailableHeadsetSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledHeadsetSDKInfos)).ToArray();
string[] availableControllerSDKNames = VRTK_SDKManager.AvailableControllerSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledControllerSDKInfos)).ToArray();
string[] availableTrackerSDKNames = VRTK_SDKManager.AvailableTrackerSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledTrackerSDKInfos)).ToArray();
string[] availableHandSDKNames = VRTK_SDKManager.AvailableHandSDKInfos.Select(info => sdkNameSelector(info, VRTK_SDKManager.InstalledHandSDKInfos)).ToArray();
string[] allAvailableSDKNames = availableSystemSDKNames
.Concat(availableBoundariesSDKNames)
.Concat(availableHeadsetSDKNames)
.Concat(availableControllerSDKNames)
.Concat(availableTrackerSDKNames)
.Concat(availableHandSDKNames)
.Distinct()
.ToArray();
using (new EditorGUILayout.HorizontalScope())
{
EditorGUI.BeginChangeCheck();
List<GUIContent> quickSelectOptions = allAvailableSDKNames
.Select(sdkName => new GUIContent(sdkName))
.ToList();
int quicklySelectedSDKIndex = 0;
if (AreAllSDKsTheSame())
{
quicklySelectedSDKIndex = allAvailableSDKNames
.ToList()
.FindIndex(availableSDKName => availableSDKName.Replace(SDKNotInstalledDescription, "")
== setup.systemSDKInfo.description.prettyName);
}
else
{
quickSelectOptions.Insert(0, new GUIContent("Mixed..."));
}
quicklySelectedSDKIndex = EditorGUILayout.Popup(
new GUIContent("Quick Select", "Quickly select one of the SDKs into all slots."),
quicklySelectedSDKIndex,
quickSelectOptions.ToArray());
if (!AreAllSDKsTheSame())
{
quicklySelectedSDKIndex--;
}
if (EditorGUI.EndChangeCheck() && (AreAllSDKsTheSame() || quicklySelectedSDKIndex != -1))
{
string quicklySelectedSDKName = allAvailableSDKNames[quicklySelectedSDKIndex].Replace(SDKNotInstalledDescription, "");
Func<VRTK_SDKInfo, bool> predicate = info => info.description.prettyName == quicklySelectedSDKName;
VRTK_SDKInfo newSystemSDKInfo = VRTK_SDKManager.AvailableSystemSDKInfos.FirstOrDefault(predicate);
VRTK_SDKInfo newBoundariesSDKInfo = VRTK_SDKManager.AvailableBoundariesSDKInfos.FirstOrDefault(predicate);
VRTK_SDKInfo newHeadsetSDKInfo = VRTK_SDKManager.AvailableHeadsetSDKInfos.FirstOrDefault(predicate);
VRTK_SDKInfo newControllerSDKInfo = VRTK_SDKManager.AvailableControllerSDKInfos.FirstOrDefault(predicate);
VRTK_SDKInfo newTrackerSDKInfo = VRTK_SDKManager.AvailableTrackerSDKInfos.FirstOrDefault(predicate);
VRTK_SDKInfo newHandSDKInfo = VRTK_SDKManager.AvailableHandSDKInfos.FirstOrDefault(predicate);
Undo.RecordObject(setup, "SDK Change (Quick Select)");
if (newSystemSDKInfo != null)
{
setup.systemSDKInfo = newSystemSDKInfo;
}
if (newBoundariesSDKInfo != null)
{
setup.boundariesSDKInfo = newBoundariesSDKInfo;
}
if (newHeadsetSDKInfo != null)
{
setup.headsetSDKInfo = newHeadsetSDKInfo;
}
if (newControllerSDKInfo != null)
{
setup.controllerSDKInfo = newControllerSDKInfo;
}
if (newTrackerSDKInfo != null)
{
setup.trackerSDKInfo = newTrackerSDKInfo;
}
if (newHandSDKInfo != null)
{
setup.handSDKInfo = newHandSDKInfo;
}
UpdateDetailedSDKSelectionFoldOut();
}
if (AreAllSDKsTheSame())
{
VRTK_SDKInfo selectedInfo = new[]
{
setup.systemSDKInfo,
setup.boundariesSDKInfo,
setup.headsetSDKInfo,
setup.controllerSDKInfo,
setup.trackerSDKInfo,
setup.handSDKInfo
}.First(info => info != null);
DrawVRDeviceNameLabel(selectedInfo, "System, Boundaries, Headset, Controller, Trackers, and Hands", 0);
}
}
EditorGUI.indentLevel++;
if (!isDetailedSDKSelectionFoldOut.HasValue)
{
UpdateDetailedSDKSelectionFoldOut();
}
isDetailedSDKSelectionFoldOut = EditorGUI.Foldout(
EditorGUILayout.GetControlRect(),
isDetailedSDKSelectionFoldOut.Value,
"Detailed Selection",
true
);
if (isDetailedSDKSelectionFoldOut.Value)
{
EditorGUI.BeginChangeCheck();
DrawAndHandleSDKSelection<SDK_BaseSystem>("The SDK to use to deal with all system actions.", 1);
DrawAndHandleSDKSelection<SDK_BaseBoundaries>("The SDK to use to utilize room scale boundaries.", 1);
DrawAndHandleSDKSelection<SDK_BaseHeadset>("The SDK to use to utilize the VR headset.", 1);
DrawAndHandleSDKSelection<SDK_BaseController>("The SDK to use to utilize the input devices.", 1);
DrawAndHandleSDKSelection<SDK_BaseTracker>("The SDK to use for tracked objects.", 1);
DrawAndHandleSDKSelection<SDK_BaseHand>("The SDK to use to utilize the hand-style input devices.", 1);
if (EditorGUI.EndChangeCheck())
{
UpdateDetailedSDKSelectionFoldOut();
}
}
EditorGUI.indentLevel--;
string errorDescriptions = string.Join("\n", setup.GetSimplifiedErrorDescriptions());
if (!string.IsNullOrEmpty(errorDescriptions))
{
EditorGUILayout.HelpBox(errorDescriptions, MessageType.Error);
}
if (allAvailableSDKNames.Length != availableSystemSDKNames.Length
|| allAvailableSDKNames.Length != availableBoundariesSDKNames.Length
|| allAvailableSDKNames.Length != availableHeadsetSDKNames.Length
|| allAvailableSDKNames.Length != availableControllerSDKNames.Length
|| allAvailableSDKNames.Length != availableTrackerSDKNames.Length
|| allAvailableSDKNames.Length != availableHandSDKNames.Length)
{
EditorGUILayout.HelpBox("Only endpoints that are supported by the selected SDK are changed by Quick Select, the others are left untouched."
+ "\n\nSome of the available SDK implementations are only available for a subset of SDK endpoints. Quick Select"
+ " shows SDKs that provide an implementation for *any* of the different SDK endpoints in VRTK"
+ " (System, Boundaries, Headset, Controller, Trackers, Hands).", MessageType.Info);
}
}
using (new EditorGUILayout.VerticalScope("Box"))
{
VRTK_EditorUtilities.AddHeader("Object References", false);
using (new EditorGUILayout.HorizontalScope())
{
EditorGUI.BeginChangeCheck();
bool autoPopulate = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("autoPopulateObjectReferences", "Auto Populate"),
setup.autoPopulateObjectReferences,
GUILayout.ExpandWidth(false));
if (EditorGUI.EndChangeCheck())
{
serializedObject.FindProperty("autoPopulateObjectReferences").boolValue = autoPopulate;
serializedObject.ApplyModifiedProperties();
setup.PopulateObjectReferences(false);
}
const string populateNowDescription = "Populate Now";
GUIContent populateNowGUIContent = new GUIContent(populateNowDescription, "Set the SDK object references to the objects of the selected SDKs.");
if (GUILayout.Button(populateNowGUIContent, GUILayout.MaxHeight(GUI.skin.label.CalcSize(populateNowGUIContent).y)))
{
Undo.RecordObject(setup, populateNowDescription);
setup.PopulateObjectReferences(true);
}
}
if (setup.autoPopulateObjectReferences)
{
EditorGUILayout.HelpBox("The SDK Setup is configured to automatically populate object references so the following fields are disabled."
+ " Uncheck `Auto Populate` above to enable customization of the fields below.", MessageType.Info);
}
using (new EditorGUI.DisabledGroupScope(setup.autoPopulateObjectReferences))
{
using (new EditorGUILayout.VerticalScope("Box"))
{
VRTK_EditorUtilities.AddHeader("Actual Objects", false);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualBoundaries"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualBoundaries", "Boundaries")
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualHeadset"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualHeadset", "Headset")
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualLeftController"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualLeftController", "Left Controller")
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualRightController"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualRightController", "Right Controller")
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualTrackers"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualTrackers", "Trackers"),
true
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("actualHand"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("actualHand", "Hands")
);
}
using (new EditorGUILayout.VerticalScope("Box"))
{
VRTK_EditorUtilities.AddHeader("Model Aliases", false);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("modelAliasLeftController"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("modelAliasLeftController", "Left Controller")
);
EditorGUILayout.PropertyField(
serializedObject.FindProperty("modelAliasRightController"),
VRTK_EditorUtilities.BuildGUIContent<VRTK_SDKSetup>("modelAliasRightController", "Right Controller")
);
}
}
EditorGUILayout.HelpBox(
"The game object this SDK Setup is attached to will be set inactive automatically to allow for SDK loading and switching.",
MessageType.Info
);
IEnumerable<GameObject> referencedObjects = new[]
{
setup.actualBoundaries,
setup.actualHeadset,
setup.actualLeftController,
setup.actualRightController,
setup.modelAliasLeftController,
setup.modelAliasRightController
}.Where(referencedObject => referencedObject != null);
if (referencedObjects.Any(referencedObject => !referencedObject.transform.IsChildOf(setup.transform)))
{
EditorGUILayout.HelpBox(
"There is at least one referenced object that is neither a child of, deep child (child of a child) of nor attached to the game object this SDK Setup is attached to.",
MessageType.Error
);
}
}
serializedObject.ApplyModifiedProperties();
}
19
Source : GenericUserInterface.cs
with GNU General Public License v3.0
from chatrat12
with GNU General Public License v3.0
from chatrat12
public void InsertIntoLayers(string layerName, List<GameInterfaceLayer> layers, InterfaceScaleType scaleType = InterfaceScaleType.UI)
{
int inventoryIndex = layers.FindIndex(layer => layer.Name.Equals(layerName));
if (inventoryIndex != -1)
{
layers.Insert(inventoryIndex + 1, new LegacyGameInterfaceLayer(LayerName, () =>
{
if (Visible) Draw(Main.spriteBatch, new GameTime());
return true;
}, scaleType));
}
}
19
Source : TextDocumentManager.cs
with GNU General Public License v3.0
from CheezLang
with GNU General Public License v3.0
from CheezLang
public void Change(Uri uri, long version, TextDoreplacedentContentChangeEvent[] changeEvents)
{
var index = _all.FindIndex(x => x.uri == uri);
if (index < 0)
{
return;
}
var doreplacedent = _all[index];
if (doreplacedent.version >= version)
{
return;
}
foreach (var ev in changeEvents)
{
Apply(doreplacedent, ev);
}
doreplacedent.version = version;
OnChanged(doreplacedent);
}
19
Source : TextDocumentManager.cs
with GNU General Public License v3.0
from CheezLang
with GNU General Public License v3.0
from CheezLang
public void Remove(Uri uri)
{
var index = _all.FindIndex(x => x.uri == uri);
if (index < 0)
{
return;
}
_all.RemoveAt(index);
}
19
Source : HttpContextPipeline.cs
with MIT License
from chkr1011
with MIT License
from chkr1011
public void InsertAfter<TBefore>(IHttpContextPipelineHandler processor) where TBefore : IHttpContextPipelineHandler
{
if (processor == null) throw new ArgumentNullException(nameof(processor));
Insert(_handlers.FindIndex(h => h is TBefore) + 1, processor);
}
19
Source : HttpContextPipeline.cs
with MIT License
from chkr1011
with MIT License
from chkr1011
public void InsertBefore<TAfter>(IHttpContextPipelineHandler processor) where TAfter : IHttpContextPipelineHandler
{
Insert(_handlers.FindIndex(h => h is TAfter), processor);
}
19
Source : MessageBus.cs
with MIT License
from Chris3606
with MIT License
from Chris3606
public void UnregisterSubscriber<TMessage>(ISubscriber<TMessage> subscriber)
{
var messageType = typeof(TMessage);
if (_subscriberRefs.TryGetValue(messageType, out List<ISubscriberRef> handlerRefs))
{
int item = handlerRefs.FindIndex(i => ReferenceEquals(i.Subscriber, subscriber));
if (item == -1)
throw new ArgumentException($"Tried to remove a subscriber from a {nameof(MessageBus)} that was never added.");
handlerRefs.RemoveAt(item);
if (handlerRefs.Count == 0)
_subscriberRefs.Remove(messageType);
SubscriberCount--;
}
else
throw new ArgumentException($"Tried to remove a subscriber from a {nameof(MessageBus)} that was never added.");
}
19
Source : Interface.cs
with MIT License
from circles-arrows
with MIT License
from circles-arrows
void IRefactorInterface.RemoveEnreplacedy(string enreplacedy)
{
if (Parent is null)
throw new InvalidOperationException("You cannot change an 'ad-hoc' interface.");
int index = enreplacedies.FindIndex((e) => e.Name == enreplacedy);
if (index == -1)
return;
enreplacedies.RemoveAt(index);
}
19
Source : Variables.cs
with GNU Affero General Public License v3.0
from citizenfx
with GNU Affero General Public License v3.0
from citizenfx
private int GetIndexByName(string name)
{
return List.FindIndex(v => v.Key == name);
}
19
Source : Procedure.cs
with GNU General Public License v3.0
from ClayLipscomb
with GNU General Public License v3.0
from ClayLipscomb
public bool HasArgumentOfOracleType(string oracleType) {
if (Arguments == null) return false;
return Arguments.FindIndex(a => (a.DataType == oracleType || a.TypeName == oracleType || a.PlsType == oracleType) ) != -1;
}
19
Source : StringExtensionsTest.cs
with MIT License
from cmxl
with MIT License
from cmxl
private static string GetTestFolder()
{
var startupPath = AppContext.BaseDirectory;
var pathItems = startupPath.Split(Path.DirectorySeparatorChar);
var pos = pathItems.Reverse().ToList().FindIndex(x => string.Equals("bin", x));
var projectPath = string.Join(Path.DirectorySeparatorChar.ToString(), pathItems.Take(pathItems.Length - pos - 1));
return projectPath;
}
19
Source : CompilationDatabaseSettingsList.cs
with Apache License 2.0
from CoatiSoftware
with Apache License 2.0
from CoatiSoftware
public void AppendOrUpdate(CompilationDatabaseSettings cdb)
{
if(_settings.Exists(item => item.Name == cdb.Name && item.Directory == cdb.Directory) == false)
{
_settings.Add(cdb);
}
else
{
int idx = _settings.FindIndex(item => item.Name == cdb.Name && item.Directory == cdb.Directory);
_settings[idx] = cdb;
}
}
19
Source : Overload.cs
with BSD 3-Clause "New" or "Revised" License
from cobbr
with BSD 3-Clause "New" or "Revised" License
from cobbr
public static string FindDecoyModule(long MinSize, bool LegitSigned = true)
{
string SystemDirectoryPath = Environment.GetEnvironmentVariable("WINDIR") + Path.DirectorySeparatorChar + "System32";
List<string> files = new List<string>(Directory.GetFiles(SystemDirectoryPath, "*.dll"));
foreach (ProcessModule Module in Process.GetCurrentProcess().Modules)
{
if (files.Any(s => s.Equals(Module.FileName, StringComparison.OrdinalIgnoreCase)))
{
files.RemoveAt(files.FindIndex(x => x.Equals(Module.FileName, StringComparison.OrdinalIgnoreCase)));
}
}
// Pick a random candidate that meets the requirements
Random r = new Random();
// List of candidates that have been considered and rejected
List<int> candidates = new List<int>();
while (candidates.Count != files.Count)
{
// Iterate through the list of files randomly
int rInt = r.Next(0, files.Count);
string currentCandidate = files[rInt];
// Check that the size of the module meets requirements
if (candidates.Contains(rInt) == false &&
new FileInfo(currentCandidate).Length >= MinSize)
{
// Check that the module meets signing requirements
if (LegitSigned == true)
{
if (Misc.Utilities.FileHasValidSignature(currentCandidate) == true)
{
return currentCandidate;
}
else
{
candidates.Add(rInt);
}
}
else
{
return currentCandidate;
}
}
candidates.Add(rInt);
}
return string.Empty;
}
19
Source : SpineAtlasAssetInspector.cs
with MIT License
from coding2233
with MIT License
from coding2233
static public void UpdateSpriteSlices (Texture texture, Atlas atlas) {
string texturePath = replacedetDatabase.GetreplacedetPath(texture.GetInstanceID());
var t = (TextureImporter)TextureImporter.GetAtPath(texturePath);
t.spriteImportMode = SpriteImportMode.Multiple;
var spriteSheet = t.spritesheet;
var sprites = new List<SpriteMetaData>(spriteSheet);
var regions = SpineAtlasreplacedetInspector.GetRegions(atlas);
char[] FilenameDelimiter = {'.'};
int updatedCount = 0;
int addedCount = 0;
foreach (var r in regions) {
string pageName = r.page.name.Split(FilenameDelimiter, StringSplitOptions.RemoveEmptyEntries)[0];
string textureName = texture.name;
bool pageMatch = string.Equals(pageName, textureName, StringComparison.Ordinal);
// if (pageMatch) {
// int pw = r.page.width;
// int ph = r.page.height;
// bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize;
// if (mismatchSize)
// Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height);
// }
int spriteIndex = pageMatch ? sprites.FindIndex(
(s) => string.Equals(s.name, r.name, StringComparison.Ordinal)
) : -1;
bool spriteNameMatchExists = spriteIndex >= 0;
if (pageMatch) {
Rect spriteRect = new Rect();
if (r.rotate) {
spriteRect.width = r.height;
spriteRect.height = r.width;
} else {
spriteRect.width = r.width;
spriteRect.height = r.height;
}
spriteRect.x = r.x;
spriteRect.y = r.page.height - spriteRect.height - r.y;
if (spriteNameMatchExists) {
var s = sprites[spriteIndex];
s.rect = spriteRect;
sprites[spriteIndex] = s;
updatedCount++;
} else {
sprites.Add(new SpriteMetaData {
name = r.name,
pivot = new Vector2(0.5f, 0.5f),
rect = spriteRect
});
addedCount++;
}
}
}
t.spritesheet = sprites.ToArray();
EditorUtility.SetDirty(t);
replacedetDatabase.Importreplacedet(texturePath, ImportreplacedetOptions.ForceUpdate);
EditorGUIUtility.PingObject(texture);
Debug.Log(string.Format("Applied sprite slices to {2}. {0} added. {1} updated.", addedCount, updatedCount, texture.name));
}
19
Source : Asset.cs
with MIT License
from colinator27
with MIT License
from colinator27
public int FindIndex(string name)
{
return FindIndex(a => a.Name == name);
}
19
Source : EventBus.cs
with Apache License 2.0
from cs-util-com
with Apache License 2.0
from cs-util-com
private Delegate AddOrReplace(List<KeyValuePair<object, Delegate>> self, object subscriber, Delegate callback) {
var i = self.FindIndex(x => x.Key == subscriber);
var newEntry = new KeyValuePair<object, Delegate>(subscriber, callback);
if (i >= 0) {
var oldEntry = self[i];
self[i] = newEntry;
return oldEntry.Value;
} else {
self.Insert(0, newEntry); // Always add new subscribers at the front of the list
return null;
}
}
19
Source : TableHeader.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
public void RemoveCell(GameObject cell, RectTransform parent = null)
{
var index = CellsInfo.FindIndex(x => x.Rect.gameObject == cell);
var cell_info = CellsInfo[index];
if (index == -1)
{
Debug.LogWarning("Cell not in header", cell);
return;
}
cell.SetActive(false);
cell.transform.SetParent(parent, false);
if (parent == null)
{
Destroy(cell);
}
// remove from cells
CellsInfo.RemoveAt(index);
// remove events
var events = Utilites.GetOrAddComponent<TableHeaderCell>(cell);
events.OnInitializePotentialDragEvent.RemoveListener(OnInitializePotentialDrag);
events.OnBeginDragEvent.RemoveListener(OnBeginDrag);
events.OnDragEvent.RemoveListener(OnDrag);
events.OnEndDragEvent.RemoveListener(OnEndDrag);
// decrease position for cells where >cell_position
CellsInfo.ForEach(x =>
{
if (x.Position > cell_info.Position)
{
x.Position -= 1;
}
});
// update list widths
LayoutUtilites.UpdateLayout(layout);
Resize();
}
19
Source : ObservableList.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
public int FindIndex(Predicate<T> match)
{
return Items.FindIndex(match);
}
19
Source : Party.cs
with MIT License
from csinkers
with MIT License
from csinkers
void SetLeader(PartyMemberId value)
{
int index = _walkOrder.FindIndex(x => x.Id == value);
if (index == -1)
return;
var player = _walkOrder[index];
_walkOrder.RemoveAt(index);
_walkOrder.Insert(0, player);
}
19
Source : FileList.cs
with MIT License
from cwensley
with MIT License
from cwensley
static void LoadFile(object obj)
{
var fileList = (FileList)obj;
string directoryPath = null;
if (!string.IsNullOrEmpty(fileList._fileName))
{
directoryPath = File.Exists(fileList._fileName) ? Path.GetDirectoryName(fileList._fileName) : fileList._fileName;
if (!string.IsNullOrEmpty(directoryPath))
{
fileList._directory = EtoDirectoryInfo.GetDirectory(directoryPath);
}
}
if (fileList._directory != null)
{
fileList.UpdateDirectory();
if (directoryPath != fileList._fileName)
{
int index = fileList.items.FindIndex(r => r.FullName.Equals(fileList._fileName, StringComparison.InvariantCultureIgnoreCase));
if (index >= 0)
{
Application.Instance.AsyncInvoke(() => fileList.SelectedIndex = index);
}
}
}
}
19
Source : FileList.cs
with MIT License
from cwensley
with MIT License
from cwensley
void SetFileName()
{
if (!string.IsNullOrEmpty(newFileName))
{
int index = items.FindIndex(r => r.FullName.Equals(newFileName, StringComparison.InvariantCultureIgnoreCase));
if (index >= 0)
SelectedIndex = index;
}
newFileName = null;
}
See More Examples