System.Collections.Generic.List.FindIndex(System.Predicate)

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 7

19 View Source File : WmiProvider.cs
License : MIT License
Project Creator : AlexGyver

private void RevokeInstance(string identifier) {
      int instanceIndex = activeInstances.FindIndex(
        item => item.Identifier == identifier.ToString()
      );

      if (instanceIndex == -1)
        return;

      try {
        Instrumentation.Revoke(activeInstances[instanceIndex]);
      } catch (Exception) { }

      activeInstances.RemoveAt(instanceIndex);
    }

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

public static List<Candle> CreateCandlesRequiredInterval(int juniorInterval, int seniorInterval, List<Candle> oldCandles)
        {
            var candles = new List<Candle>();

            int index = oldCandles.FindIndex(can => can.TimeStart.Minute % seniorInterval == 0);

            int count = seniorInterval / juniorInterval;

            int counter = 0;

            Candle newCandle = new Candle();

            for (int i = index; i < oldCandles.Count; i++)
            {
                counter++;

                if (counter == 1)
                {
                    newCandle = new Candle();
                    newCandle.Open = oldCandles[i].Open;
                    newCandle.TimeStart = oldCandles[i].TimeStart;
                    newCandle.Low = Decimal.MaxValue;
                }

                newCandle.High = oldCandles[i].High > newCandle.High
                    ? oldCandles[i].High
                    : newCandle.High;

                newCandle.Low = oldCandles[i].Low < newCandle.Low
                    ? oldCandles[i].Low
                    : newCandle.Low;

                newCandle.Volume += oldCandles[i].Volume;

                if (counter == count)
                {
                    newCandle.Close = oldCandles[i].Close;
                    newCandle.State = CandleState.Finished;
                    candles.Add(newCandle);
                    counter = 0;
                }

                if (i == oldCandles.Count - 1 && counter != count)
                {
                    newCandle.Close = oldCandles[i].Close;
                    newCandle.State = CandleState.None;
                    candles.Add(newCandle);
                }
            }

            return candles;
        }

19 View Source File : BaseNode.cs
License : MIT License
Project Creator : alelievr

public bool UpdatePortsForFieldLocal(string fieldName, bool sendPortUpdatedEvent = true)
		{
			bool changed = false;

			if (!nodeFields.ContainsKey(fieldName))
				return false;

			var fieldInfo = nodeFields[fieldName];

			if (!HasCustomBehavior(fieldInfo))
				return false;

			List< string > finalPorts = new List< string >();

			var portCollection = fieldInfo.input ? (NodePortContainer)inputPorts : outputPorts;

			// Gather all fields for this port (before to modify them)
			var nodePorts = portCollection.Where(p => p.fieldName == fieldName);
			// Gather all edges connected to these fields:
			var edges = nodePorts.SelectMany(n => n.GetEdges()).ToList();

			if (fieldInfo.behavior != null)
			{
				foreach (var portData in fieldInfo.behavior(edges))
					AddPortData(portData);
			}
			else
			{
				var customPortTypeBehavior = customPortTypeBehaviorMap[fieldInfo.info.FieldType];

				foreach (var portData in customPortTypeBehavior(fieldName, fieldInfo.name, fieldInfo.info.GetValue(this)))
					AddPortData(portData);
			}

			void AddPortData(PortData portData)
			{
				var port = nodePorts.FirstOrDefault(n => n.portData.identifier == portData.identifier);
				// Guard using the port identifier so we don't duplicate identifiers
				if (port == null)
				{
					AddPort(fieldInfo.input, fieldName, portData);
					changed = true;
				}
				else
				{
					// in case the port type have changed for an incompatible type, we disconnect all the edges attached to this port
					if (!BaseGraph.TypesAreConnectable(port.portData.displayType, portData.displayType))
					{
						foreach (var edge in port.GetEdges().ToList())
							graph.Disconnect(edge.GUID);
					}

					// patch the port data
					if (port.portData != portData)
					{
						port.portData.CopyFrom(portData);
						changed = true;
					}
				}

				finalPorts.Add(portData.identifier);
			}

			// TODO
			// Remove only the ports that are no more in the list
			if (nodePorts != null)
			{
				var currentPortsCopy = nodePorts.ToList();
				foreach (var currentPort in currentPortsCopy)
				{
					// If the current port does not appear in the list of final ports, we remove it
					if (!finalPorts.Any(id => id == currentPort.portData.identifier))
					{
						RemovePort(fieldInfo.input, currentPort);
						changed = true;
					}
				}
			}

			// Make sure the port order is correct:
			portCollection.Sort((p1, p2) => {
				int p1Index = finalPorts.FindIndex(id => p1.portData.identifier == id);
				int p2Index = finalPorts.FindIndex(id => p2.portData.identifier == id);

				if (p1Index == -1 || p2Index == -1)
					return 0;

				return p1Index.CompareTo(p2Index);
			});

			if (sendPortUpdatedEvent)
				onPortsUpdated?.Invoke(fieldName);

			return changed;
		}

19 View Source File : PaginatedMessagesControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon

public void EnsureVisible(Message message)
        {
            var temp = this.Messages.ToList();
            var index = temp.FindIndex(m => m.Id == message.Id);

            int pageNumber = (int)Math.Floor((double)index / this.MessagesPerPage);
            this.ChangePage(pageNumber);
            this.SelectedMessage = this.CurrentPage.First(m => m.Id == message.Id);
        }

19 View Source File : MixtureVariant.cs
License : MIT License
Project Creator : alelievr

public bool SetParameterValue(string name, object value)
        {
            var param = parentGraph.GetExposedParameter(name);

            if (param == null)
                return false;
            
            param = param.Clone();
            param.value = value;

            int index = overrideParameters.FindIndex(p => p == param);
            if (index == -1)
                overrideParameters.Add(param);
            else
                overrideParameters[index].value = value;

            return true;
        }

19 View Source File : ArrayUtilities.cs
License : Apache License 2.0
Project Creator : aivclab

public static int FindIndex<T>(T[] array, Predicate<T> match)
        {
            var list = new List<T>(collection : array);
            return list.FindIndex(match : match);
        }

19 View Source File : ASETextureArrayCreator.cs
License : MIT License
Project Creator : alexismorin

private void BuildArray()
		{
			int sizeX = m_sizes[ m_selectedSizeX ];
			int sizeY = m_sizes[ m_selectedSizeY ];

			Texture2DArray textureArray = new Texture2DArray( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps, m_linearMode );
			textureArray.wrapMode = m_wrapMode;
			textureArray.filterMode = m_filterMode;
			textureArray.anisoLevel = m_anisoLevel;
			textureArray.Apply( false );
			RenderTexture cache = RenderTexture.active;
			RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
			rt.Create();
			for( int i = 0; i < m_allTextures.Count; i++ )
			{
				// build report
				int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
				int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
				if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
					m_message += m_allTextures[ i ].name + " was upscaled\n";
				else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " was downscaled\n";
				else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " changed dimensions\n";

				// blit image to upscale or downscale the image to any size
				RenderTexture.active = rt;

				bool cachedsrgb = GL.sRGBWrite;
				GL.sRGBWrite = !m_linearMode;
				Graphics.Blit( m_allTextures[ i ], rt );
				GL.sRGBWrite = cachedsrgb;

				Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
				t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
				RenderTexture.active = null;

				bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
				if( isCompressed )
				{
					EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
					t2d.Apply( false );
				}

				if( m_mipMaps )
				{
					int maxSize = Mathf.Max( sizeX, sizeY );
					for( int mip = 0; mip < MipCount[ maxSize ]; mip++ )
					{
						CopyToArray( ref t2d, ref textureArray, i, mip, isCompressed );
					}
				}
				else
				{
					CopyToArray( ref t2d, ref textureArray, i, 0, isCompressed );
				}
			}

			rt.Release();
			RenderTexture.active = cache;
			if( m_message.Length > 0 )
				m_message = m_message.Substring( 0, m_message.Length - 1 );

			string path = m_folderPath + m_fileName + ".replacedet";
			Texture2DArray outfile = replacedetDatabase.LoadMainreplacedetAtPath( path ) as Texture2DArray;
			if( outfile != null )
			{
				EditorUtility.CopySerialized( textureArray, outfile );
				replacedetDatabase.Savereplacedets();
				EditorGUIUtility.PingObject( outfile );
				m_lastSaved = outfile;
			}
			else
			{
				replacedetDatabase.Createreplacedet( textureArray, path );
				EditorGUIUtility.PingObject( textureArray );
				m_lastSaved = textureArray;
			}
		}

19 View Source File : SelectionHistory.cs
License : MIT License
Project Creator : acoppes

public void SetSelection(Object obj)
        {
            currentSelectionIndex = _history.FindIndex(e => e.reference.Equals(obj));
        }

19 View Source File : CollisionGroups.cs
License : Apache License 2.0
Project Creator : Algoryx

public bool RemoveGroup( string tag )
    {
      int index = m_groups.FindIndex( entry => entry.Tag == tag );
      if ( index < 0 )
        return false;

      RemoveGroup( m_groups[ index ], Find.LeafObjects( gameObject, m_groups[ index ].PropagateToChildren ) );

      m_groups.RemoveAt( index );

      return true;
    }

19 View Source File : StyleExtensions.cs
License : MIT License
Project Creator : Adoxio

public int Compare(DisplayModeFile x, DisplayModeFile y)
			{
				if (x == null) throw new ArgumentNullException("x");
				if (y == null) throw new ArgumentNullException("y");

				if (x.Name.Item3 > y.Name.Item3)
				{
					return 1;
				}

				if (x.Name.Item3 < y.Name.Item3)
				{
					return -1;
				}

				var xIndex = _displayModes.FindIndex(displayMode => string.Equals(displayMode, x.DisplayModeId, StringComparison.OrdinalIgnoreCase));
				var yIndex = _displayModes.FindIndex(displayMode => string.Equals(displayMode, y.DisplayModeId, StringComparison.OrdinalIgnoreCase));

				return xIndex.CompareTo(yIndex);
			}

19 View Source File : ConnectCamera.xaml.cs
License : MIT License
Project Creator : AlexBrochu

private void delete_cam_btn_Click(object sender, RoutedEventArgs e)
        {
            if (selectedCam == null || cameras == null)
            {
                delete_cam_btn.IsEnabled = false;
                return;
            }
            // Remove Camera login info
            int index = cameras.FindIndex(element => element.CameraName.Equals(selectedCam.CameraName));
            if (index >= 0)
            {
                cameras.RemoveAt(index);
            }

            string json = JsonConvert.SerializeObject(cameras);
            if (!File.Exists(path_to_connexion_file))
            {
                File.CreateText(path_to_connexion_file).Close();
            }
            using (StreamWriter file = new StreamWriter(path_to_connexion_file, false))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, cameras);
            }
            LoadConnexion();
            delete_cam_btn.IsEnabled = false;
        }

19 View Source File : AnchorField.cs
License : MIT License
Project Creator : alelievr

public void		RemoveAnchor(string GUID)
		{
			int index = anchors.FindIndex(a => a.GUID == GUID);

			if (index == -1)
				Debug.LogWarning("Failed to remove the anchor at GUID: " + GUID);
			RemoveAnchor(index);
		}

19 View Source File : Pathfinder.cs
License : GNU General Public License v3.0
Project Creator : aenemenate

private static Node GetSmallestNode( List<Node> list )
        {
            Node smallestNode = new Node( new Point(), 99999, 99999 );
            foreach (Node node in list)
                if (node.F < smallestNode.F)
                    smallestNode = node;

            list.RemoveAt( list.FindIndex( n => n.Pos.Equals( smallestNode.Pos ) ) );

            return smallestNode;
        }

19 View Source File : TemplatesSettings.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj

public int SaveTemplate(GroupTemplates groupTemplates, TemplateSettings template)
        {
            var tmplt = groupTemplates.Templates.SingleOrDefault(x => x.Id.Equals(template.Id));

            if (tmplt == null)
            {
                groupTemplates.Templates.Add(template);
            }
            else
            {
                tmplt.Name = template.Name;
                tmplt.Enabled = template.Enabled;
                tmplt.PerEnreplacedy = template.PerEnreplacedy;
                tmplt.FileExt = template.FileExt;
                tmplt.Code = template.Code;
                tmplt.Language = template.Language;
            }

            Save();

            return groupTemplates.Templates.FindIndex(x => x.Id.Equals(template.Id));
        }

19 View Source File : InspectorFieldsUtility.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public static void UpdateSettingsList(SerializedProperty settings, List<InspectorFieldData> fieldList)
        {
            // Delete existing settings that now have missing field
            // Remove data entries for existing setting matches
            for (int idx = settings.arraySize - 1; idx >= 0; idx--)
            {
                SerializedProperty settingItem = settings.GetArrayElementAtIndex(idx);
                SerializedProperty name = settingItem.FindPropertyRelative("Name");

                int index = fieldList.FindIndex(s => s.Name == name.stringValue);
                if (index != -1)
                {
                    fieldList.RemoveAt(index);
                }
                else
                {
                    settings.DeleteArrayElementAtIndex(idx);
                }
            }

            AddFieldsToSettingsList(settings, fieldList);
        }

19 View Source File : ASETextureArrayCreator.cs
License : MIT License
Project Creator : alexismorin

private void BuildTexture3D()
		{
			int sizeX = m_sizes[ m_selectedSizeX ];
			int sizeY = m_sizes[ m_selectedSizeY ];
			int mipCount = m_mipMaps ? MipCount[ Mathf.Max( sizeX, sizeY ) ] : 1;

			Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
			texture3D.wrapMode = m_wrapMode;
			texture3D.filterMode = m_filterMode;
			texture3D.anisoLevel = m_anisoLevel;
			texture3D.Apply( false );
			RenderTexture cache = RenderTexture.active;
			RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
			rt.Create();
			List<List<Color>> mipColor = new List<List<Color>>();
			if( m_mipMaps )
			{
				for( int i = 0; i < mipCount; i++ )
				{
					mipColor.Add( new List<Color>() );
				}
			}
			else
			{
				mipColor.Add( new List<Color>() );
			}

			for( int i = 0; i < m_allTextures.Count; i++ )
			{
				// build report
				int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
				int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
				if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
					m_message += m_allTextures[ i ].name + " was upscaled\n";
				else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " was downscaled\n";
				else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " changed dimensions\n";

				// blit image to upscale or downscale the image to any size
				RenderTexture.active = rt;

				bool cachedsrgb = GL.sRGBWrite;
				GL.sRGBWrite = !m_linearMode;
				Graphics.Blit( m_allTextures[ i ], rt );
				GL.sRGBWrite = cachedsrgb;

				Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
				t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
				RenderTexture.active = null;

				bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
				if( isCompressed )
				{
					EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
					//	t2d.Apply( false );
				}
				t2d.Apply( false );

				if( m_mipMaps )
				{
					for( int mip = 0; mip < mipCount; mip++ )
					{
						mipColor[ mip ].AddRange( t2d.GetPixels( mip ) );
					}
				}
				else
				{
					mipColor[ 0 ].AddRange( t2d.GetPixels( 0 ) );
				}
			}

			rt.Release();
			RenderTexture.active = cache;

			if( m_message.Length > 0 )
				m_message = m_message.Substring( 0, m_message.Length - 1 );

			for( int i = 0; i < mipCount; i++ )
			{
				texture3D.SetPixels( mipColor[ i ].ToArray(), i );
			}

			texture3D.Apply( false );

			string path = m_folderPath + m_fileName + ".replacedet";
			Texture3D outfile = replacedetDatabase.LoadMainreplacedetAtPath( path ) as Texture3D;
			if( outfile != null )
			{
				EditorUtility.CopySerialized( texture3D, outfile );
				replacedetDatabase.Savereplacedets();
				EditorGUIUtility.PingObject( outfile );
				m_lastSaved = outfile;
			}
			else
			{
				replacedetDatabase.Createreplacedet( texture3D, path );
				EditorGUIUtility.PingObject( texture3D );
				m_lastSaved = texture3D;
			}
		}

19 View Source File : Hand.cs
License : MIT License
Project Creator : ajayyy

private void UpdateHovering()
		{
			if ( ( noSteamVRFallbackCamera == null ) && ( controller == null ) )
			{
				return;
			}

			if ( hoverLocked )
				return;

			if ( applicationLostFocusObject.activeSelf )
				return;

			float closestDistance = float.MaxValue;
			Interactable closestInteractable = null;

			// Pick the closest hovering
			float flHoverRadiusScale = playerInstance.transform.lossyScale.x;
			float flScaledSphereRadius = hoverSphereRadius * flHoverRadiusScale;

			// if we're close to the floor, increase the radius to make things easier to pick up
			float handDiff = Mathf.Abs( transform.position.y - playerInstance.trackingOriginTransform.position.y );
			float boxMult = Util.RemapNumberClamped( handDiff, 0.0f, 0.5f * flHoverRadiusScale, 5.0f, 1.0f ) * flHoverRadiusScale;

			// null out old vals
			for ( int i = 0; i < overlappingColliders.Length; ++i )
			{
				overlappingColliders[i] = null;
			}

			Physics.OverlapBoxNonAlloc(
				hoverSphereTransform.position - new Vector3( 0, flScaledSphereRadius * boxMult - flScaledSphereRadius, 0 ),
				new Vector3( flScaledSphereRadius, flScaledSphereRadius * boxMult * 2.0f, flScaledSphereRadius ),
				overlappingColliders,
				Quaternion.idenreplacedy,
				hoverLayerMask.value
			);

			// DebugVar
			int iActualColliderCount = 0;

			foreach ( Collider collider in overlappingColliders )
			{
				if ( collider == null )
					continue;

				Interactable contacting = collider.GetComponentInParent<Interactable>();

				// Yeah, it's null, skip
				if ( contacting == null )
					continue;

				// Ignore this collider for hovering
				IgnoreHovering ignore = collider.GetComponent<IgnoreHovering>();
				if ( ignore != null )
				{
					if ( ignore.onlyIgnoreHand == null || ignore.onlyIgnoreHand == this )
					{
						continue;
					}
				}

				// Can't hover over the object if it's attached
				if ( attachedObjects.FindIndex( l => l.attachedObject == contacting.gameObject ) != -1 )
					continue;

				// Occupied by another hand, so we can't touch it
				if ( otherHand && otherHand.hoveringInteractable == contacting )
					continue;

				// Best candidate so far...
				float distance = Vector3.Distance( contacting.transform.position, hoverSphereTransform.position );
				if ( distance < closestDistance )
				{
					closestDistance = distance;
					closestInteractable = contacting;
				}
				iActualColliderCount++;
			}

			// Hover on this one
			hoveringInteractable = closestInteractable;

			if ( iActualColliderCount > 0 && iActualColliderCount != prevOverlappingColliders )
			{
				prevOverlappingColliders = iActualColliderCount;
				HandDebugLog( "Found " + iActualColliderCount + " overlapping colliders." );
			}
		}

19 View Source File : ASETextureArrayCreator.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

private void BuildTexture3D()
		{
			int sizeX = m_sizes[ m_selectedSizeX ];
			int sizeY = m_sizes[ m_selectedSizeY ];
			int mipCount = m_mipMaps ? MipCount[ Mathf.Max( sizeX, sizeY ) ] : 1;

			Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
			texture3D.wrapMode = m_wrapMode;
			texture3D.filterMode = m_filterMode;
			texture3D.anisoLevel = m_anisoLevel;
			texture3D.Apply( false );
			RenderTexture cache = RenderTexture.active;
			RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
			rt.Create();
			List<List<Color>> mipColor = new List<List<Color>>();
			if( m_mipMaps )
			{
				for( int i = 0; i < mipCount; i++ )
				{
					mipColor.Add( new List<Color>() );
				}
			}
			else
			{
				mipColor.Add( new List<Color>() );
			}

			for( int i = 0; i < m_allTextures.Count; i++ )
			{
				// build report
				int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
				int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
				if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
					m_message += m_allTextures[ i ].name + " was upscaled\n";
				else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " was downscaled\n";
				else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " changed dimensions\n";

				// blit image to upscale or downscale the image to any size
				RenderTexture.active = rt;

				bool cachedsrgb = GL.sRGBWrite;
				GL.sRGBWrite = !m_linearMode;
				Graphics.Blit( m_allTextures[ i ], rt );
				GL.sRGBWrite = cachedsrgb;

				Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
				t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
				RenderTexture.active = null;

				bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
				if( isCompressed )
				{
					EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
					t2d.Apply( false );
				}

				if( m_mipMaps )
				{
					for( int mip = 0; mip < mipCount; mip++ )
					{
						mipColor[ mip ].AddRange( t2d.GetPixels( mip) );
					}
				}
				else
				{
					mipColor[ 0 ].AddRange( t2d.GetPixels( 0 ) );
				}
			}
			
			rt.Release();
			RenderTexture.active = cache;
			if( m_message.Length > 0 )
				m_message = m_message.Substring( 0, m_message.Length - 1 );

			for( int i = 0; i < mipCount; i++ )
			{
				texture3D.SetPixels( mipColor[ i ].ToArray(), i );
			}

			texture3D.Apply();

			string path = m_folderPath + m_fileName + ".replacedet";
			Texture3D outfile = replacedetDatabase.LoadMainreplacedetAtPath( path ) as Texture3D;
			if( outfile != null )
			{
				EditorUtility.CopySerialized( texture3D, outfile );
				replacedetDatabase.Savereplacedets();
				EditorGUIUtility.PingObject( outfile );
				m_lastSaved = outfile;
			}
			else
			{
				replacedetDatabase.Createreplacedet( texture3D, path );
				EditorGUIUtility.PingObject( texture3D );
				m_lastSaved = texture3D;
			}
		}

19 View Source File : FlvDemuxer.cs
License : MIT License
Project Creator : a1q123456

public void SeekNoLock(double milliseconds, Dictionary<string, object> metaData, CancellationToken ct = default)
        {
            if (metaData == null)
            {
                return;
            }
            var seconds = milliseconds / 1000;
            var keyframes = metaData["keyframes"] as AmfObject;
            var times = keyframes.Fields["times"] as List<object>;
            var idx = times.FindIndex(t => ((double)t) >= seconds);
            if (idx == -1)
            {
                return;
            }
            var filePositions = keyframes.Fields["filepositions"] as List<object>;
            var pos = (double)filePositions[idx];
            _stream.Seek((int)(pos - 4), SeekOrigin.Begin);
        }

19 View Source File : RestoredAGXFile.cs
License : Apache License 2.0
Project Creator : Algoryx

public void AddDisabledPair( string group1, string group2 )
    {
      if ( m_disabledGroups.FindIndex( pair => ( pair.First == group1 && pair.Second == group2 ) || ( pair.Second == group1 && pair.First == group2 ) ) >= 0 )
        return;

      m_disabledGroups.Add( new GroupPair() { First = group1, Second = group2 } );
    }

19 View Source File : PresetScreen.cs
License : MIT License
Project Creator : alelievr

void UpdateSelectedList()
		{
			int i = 0;

			selectedIndices.Clear();
			PresetCellList currentList = presetList;
			while (currentList != null)
			{
				int index = currentList.FindIndex(l => l.enabled);

				if (index == -1)
					return ;
				
				currentList = currentList[index].childs;
				
				selectedIndices.Add(index);
				i++;
			}
		}

19 View Source File : GraphBuilder.cs
License : MIT License
Project Creator : alelievr

public GraphBuilder SortCommands()
		{
			//sort command to put CreateNodes in first
			commands = commands.OrderBy((cmd) => {
				int index = commandOrder.FindIndex(c => cmd.StartsWith(c));
				if (index == -1)
					return commandOrder.Count;
				return index;
			}).ToList();

			return this;
		}

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

int GetHash(string hashName)
        {
            return hashList[hashList.FindIndex(s => s.hashName == hashName)].hash;
        }

19 View Source File : PWArray.cs
License : MIT License
Project Creator : alelievr

public int	FindName(string name)
		{
			return names.FindIndex((n => n == name));
		}

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

public static IEnumerable<CodeInstruction> SocialPage_drawSlot_transpiler(IEnumerable<CodeInstruction> instructions)
        {
            List<CodeInstruction> codes = instructions.ToList();
            if (Helper.ModRegistry.IsLoaded("SG.Partners"))
            {
                Monitor.Log("Keep Your Partners mod is loaded, not patching social page.");
                return codes.AsEnumerable();
            }
            try
            {
                MethodInfo m_IsMarried = AccessTools.Method(typeof(Farmer), "isMarried", null, null);
                int index = codes.FindIndex((CodeInstruction c) => c.operand != null && c.operand is MethodInfo && (MethodInfo)c.operand == m_IsMarried);
                if(index > -1)
                {
                    codes[index - 1].opcode = OpCodes.Nop;
                    codes[index].opcode = OpCodes.Nop;
                    codes[index + 1].opcode = OpCodes.Nop;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(SocialPage_drawSlot_transpiler)}:\n{ex}", LogLevel.Error);
            }
            return codes.AsEnumerable();
        }

19 View Source File : ConnectCamera.xaml.cs
License : MIT License
Project Creator : AlexBrochu

private void OnSave(object sender, RoutedEventArgs e)
        {

            if (camera_name.Text == "")
            {
                camera_name.Background = new SolidColorBrush(Colors.Red);
            }
            else if(address.Text == "")
            {
                address.Background = new SolidColorBrush(Colors.Red);
            }
            else if (user.Text == "")
            {
                user.Background = new SolidColorBrush(Colors.Red);
            }
            else if (preplacedword.Preplacedword == "")
            {
                preplacedword.Background = new SolidColorBrush(Colors.Red);
            }
            else
            {
                CameraConnexion cc = new CameraConnexion();
                cc.Address = address.Text;
                cc.CameraName = camera_name.Text;
                cc.Preplacedword = preplacedword.Preplacedword;
                cc.User = user.Text;

                // write login info in json file
                if (cameras == null)
                {
                    cameras = new List<CameraConnexion>();
                }
                // override camera if is already saved with same name
                int index = cameras.FindIndex(element => element.CameraName.Equals(cc.CameraName));
                if (index == -1)
                {
                    cameras.Add(cc);
                }
                else
                {
                    cameras[index] = cc;
                }
                
                string json = JsonConvert.SerializeObject(cameras);
                if (!File.Exists(path_to_connexion_file))
                {
                    File.CreateText(path_to_connexion_file).Close();
                }
                using (StreamWriter file = new StreamWriter(path_to_connexion_file, false))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, cameras);
                }
                LoadConnexion();

            }
            
        }

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

public void DrawLayerName(SerializedProperty property, List<string> layerDisplayNames)
		{

			var layerNameLabel = new GUIContent
			{
				text = "Data Layer",
				tooltip = "The layer name from the Mapbox tileset that would be used for visualizing a feature"
			};

			//disable the selection if there is no layer
			if (layerDisplayNames.Count == 0)
			{
				EditorGUILayout.LabelField(layerNameLabel, new GUIContent("No layers found: Invalid TilesetId / No Internet."), (GUIStyle)"minipopUp");
				return;
			}

			//check the string value at the current _layerIndex to verify that the stored index matches the property string.
			var layerString = property.FindPropertyRelative("layerName").stringValue;
			if (layerDisplayNames.Contains(layerString))
			{
				//if the layer contains the current layerstring, set it's index to match
				_layerIndex = layerDisplayNames.FindIndex(s => s.Equals(layerString));

			}
			else
			{
				//if the selected layer isn't in the source, add a placeholder entry
				_layerIndex = 0;
				layerDisplayNames.Insert(0, layerString);
				if (!tileJsonData.LayerPropertyDescriptionDictionary.ContainsKey(layerString))
				{
					tileJsonData.LayerPropertyDescriptionDictionary.Add(layerString, new Dictionary<string, string>());
				}

			}

			//create the display name guicontent array with an additional entry for the currently selected item
			_layerTypeContent = new GUIContent[layerDisplayNames.Count];
			for (int extIdx = 0; extIdx < layerDisplayNames.Count; extIdx++)
			{
				_layerTypeContent[extIdx] = new GUIContent
				{
					text = layerDisplayNames[extIdx],
				};
			}

			//draw the layer selection popup
			_layerIndex = EditorGUILayout.Popup(layerNameLabel, _layerIndex, _layerTypeContent);
			var parsedString = layerDisplayNames.ToArray()[_layerIndex].Split(new string[] { tileJsonData.commonLayersKey }, System.StringSplitOptions.None)[0].Trim();
			property.FindPropertyRelative("layerName").stringValue = parsedString;
		}

19 View Source File : Pathfinder.cs
License : GNU General Public License v3.0
Project Creator : aenemenate

private static Node GetSmallestNode( List<Node> list )
        {
            Node smallestNode = new Node( new Point(), 100, 100 );
            foreach (Node node in list)
                if (node.F < smallestNode.F)
                    smallestNode = node;
            try {
                list.RemoveAt( list.FindIndex( n => n.Pos.Equals( smallestNode.Pos ) ) );
            } catch { }

            return smallestNode;
        }

19 View Source File : PaginatedMessagesControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon

private async Task<IEnumerable<Message>> GetFromGroupMeAsync(Message startAt, Message endAt)
        {
            var result = new List<Message>(this.MessagesPerPage);
            long.TryParse(startAt.Id, out var startId);
            long.TryParse(endAt.Id, out var endId);

            // GroupMe only allows before_id searches on Chat's (not after_id), so we have to go backwards...
            // Add 1 to include the endAt message in the returned data.
            long currentId = endId + 1;
            while (currentId > startId)
            {
                var msgs = await this.replacedociateWith.GetMessagesAsync(GroupMeClientApi.MessageRetreiveMode.BeforeId, currentId.ToString());
                result.AddRange(msgs);

                currentId = long.Parse(msgs.Last().Id);
            }

            // Since we went backwards, reverse the list.
            result.Reverse();

            // GroupMe block sizes might not align with the pagination page-sizes.
            // Cut to match the expected page size.
            int startIndex = result.FindIndex(m => m.Id == startAt.Id);
            return result.Skip(startIndex);
        }

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

public void SetColor(string colorName, float fColor)
		{
			int Col = (int)fColor;
			if (sharedColorTables.FindIndex(s => s.name == colorName) > -1)
			{
				Avatar.SetColor(colorName, sharedColorTables[sharedColorTables.FindIndex(s => s.name == colorName)].sharedColorTable.colors[Col]);
			}
			else
			{
				Avatar.SetColor(colorName, GenericColorList.colors[Col]);
			}
		}

19 View Source File : TemplatesSettings.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj

public int SaveGroup(GroupTemplates groupTemplates)
        {
            var group = Groups.SingleOrDefault(x => x.Id.Equals(groupTemplates.Id));

            if (group == null)
            {
                Groups.Add(groupTemplates);
            }
            else
            {
                group.Name = groupTemplates.Name;
                group.Enabled = groupTemplates.Enabled;
            }

            Save();

            return Groups.FindIndex(x => x.Id.Equals(groupTemplates.Id));
        }

19 View Source File : PBXProjectData.cs
License : MIT License
Project Creator : agens-no

public void ReadFromStream(TextReader sr)
        {
            Clear();
            m_RootElements = ParseContent(sr.ReadToEnd());

            if (!m_RootElements.Contains("objects"))
                throw new Exception("Invalid PBX project file: no objects element");

            var objects = m_RootElements["objects"].AsDict();
            m_RootElements.Remove("objects");
            m_RootElements.SetString("objects", "OBJMARKER");

            if (m_RootElements.Contains("objectVersion"))
            {
                m_ObjectVersion = m_RootElements["objectVersion"].replacedtring();
                m_RootElements.Remove("objectVersion");
            }

            var allGuids = new List<string>();
            string prevSectionName = null;
            foreach (var kv in objects.values)
            {
                allGuids.Add(kv.Key);
                var el = kv.Value;

                if (!(el is PBXElementDict) || !el.AsDict().Contains("isa"))
                {
                    m_UnknownObjects.values.Add(kv.Key, el);
                    continue;
                }
                var dict = el.AsDict();
                var sectionName = dict["isa"].replacedtring();

                if (m_Section.ContainsKey(sectionName))
                {
                    var section = m_Section[sectionName];
                    section.AddObject(kv.Key, dict);
                }
                else
                {
                    UnknownSection section;
                    if (m_UnknownSections.ContainsKey(sectionName))
                        section = m_UnknownSections[sectionName];
                    else
                    {
                        section = new UnknownSection(sectionName);
                        m_UnknownSections.Add(sectionName, section);
                    }
                    section.AddObject(kv.Key, dict);

                    // update section order
                    if (!m_SectionOrder.Contains(sectionName))
                    {
                        int pos = 0;
                        if (prevSectionName != null)
                        {
                            // this never fails, because we already added any previous unknown sections
                            // to m_SectionOrder
                            pos = m_SectionOrder.FindIndex(x => x == prevSectionName);
                            pos += 1;
                        }
                        m_SectionOrder.Insert(pos, sectionName);
                    }
                }
                prevSectionName = sectionName;
            }
            RepairStructure(allGuids);
            RefreshAuxMaps();
        }

19 View Source File : ConnectionDialog.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj

public int SaveConnection(ConnectionSettings connection)
        {
            var connItem = Connections.SingleOrDefault(x => x.Id.Equals(connection.Id));

            if (connItem == null)
            {
                Connections.Add(connection);
            }
            else
            {
                connItem.Name = connection.Name;
                connItem.ConnectionString = connection.ConnectionString;
                connItem.ServerType = connection.ServerType;
                connItem.Schema = connection.Schema;
                connItem.PrefixRemoval = connection.PrefixRemoval;
            }

            Save();

            return Connections.FindIndex(x => x.Id.Equals(connection.Id));
        }

19 View Source File : StatisticsHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private ServerStareplacedem GetServerStareplacedem(string itemId)
        {
            long ticks = DateTime.Now.Date.Ticks;
            int cur = Statistic.FindIndex(item => item.itemId == itemId);
            if (cur < 0)
            {
                Statistic.Add(new ServerStareplacedem
                {
                    itemId = itemId,
                    totalUp = 0,
                    totalDown = 0,
                    todayUp = 0,
                    todayDown = 0,
                    dateNow = ticks
                });
                cur = Statistic.Count - 1;
            }
            if (Statistic[cur].dateNow != ticks)
            {
                Statistic[cur].todayUp = 0;
                Statistic[cur].todayDown = 0;
                Statistic[cur].dateNow = ticks;
            }
            return Statistic[cur];
        }

19 View Source File : PropertyNode.cs
License : MIT License
Project Creator : alexismorin

void InitializeAttribsArray()
		{
			m_availableAttribsArr = new string[ m_availableAttribs.Count ];
			m_selectedAttribsArr = new bool[ m_availableAttribs.Count ];
			for( int i = 0; i < m_availableAttribsArr.Length; i++ )
			{
				m_availableAttribsArr[ i ] = m_availableAttribs[ i ].Name;
				m_selectedAttribsArr[ i ] = false;

				if( m_selectedAttribs.FindIndex( x => x == i ) > -1 )
				{
					m_selectedAttribsArr[ i ] = true;
					m_visibleAttribsFoldout = true;
				}
			}
		}

19 View Source File : Hand.cs
License : MIT License
Project Creator : ajayyy

public void DetachObject( GameObject objectToDetach, bool restoreOriginalParent = true )
		{
			int index = attachedObjects.FindIndex( l => l.attachedObject == objectToDetach );
			if ( index != -1 )
			{
				HandDebugLog( "DetachObject " + objectToDetach );

				GameObject prevTopObject = currentAttachedObject;

				Transform parentTransform = null;
				if ( attachedObjects[index].isParentedToHand )
				{
					if ( restoreOriginalParent && ( attachedObjects[index].originalParent != null ) )
					{
						parentTransform = attachedObjects[index].originalParent.transform;
					}
					attachedObjects[index].attachedObject.transform.parent = parentTransform;
				}

				attachedObjects[index].attachedObject.SetActive( true );
				attachedObjects[index].attachedObject.SendMessage( "OnDetachedFromHand", this, SendMessageOptions.DontRequireReceiver );
				attachedObjects.RemoveAt( index );

				GameObject newTopObject = currentAttachedObject;

				//Give focus to the top most object on the stack if it changed
				if ( newTopObject != null && newTopObject != prevTopObject )
				{
					newTopObject.SetActive( true );
					newTopObject.SendMessage( "OnHandFocusAcquired", this, SendMessageOptions.DontRequireReceiver );
				}
			}

			CleanUpAttachedObjectStack();
		}

19 View Source File : ASETextureArrayCreator.cs
License : MIT License
Project Creator : alexismorin

private void BuildTexture3DAutoMips()
		{
			int sizeX = m_sizes[ m_selectedSizeX ];
			int sizeY = m_sizes[ m_selectedSizeY ];

			Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
			texture3D.wrapMode = m_wrapMode;
			texture3D.filterMode = m_filterMode;
			texture3D.anisoLevel = m_anisoLevel;
			texture3D.Apply( false );
			RenderTexture cache = RenderTexture.active;
			RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
			rt.Create();
			List<Color> texColors = new List<Color>();
			
			for( int i = 0; i < m_allTextures.Count; i++ )
			{
				// build report
				int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
				int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
				if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
					m_message += m_allTextures[ i ].name + " was upscaled\n";
				else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " was downscaled\n";
				else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
					m_message += m_allTextures[ i ].name + " changed dimensions\n";

				// blit image to upscale or downscale the image to any size
				RenderTexture.active = rt;

				bool cachedsrgb = GL.sRGBWrite;
				GL.sRGBWrite = !m_linearMode;
				Graphics.Blit( m_allTextures[ i ], rt );
				GL.sRGBWrite = cachedsrgb;

				Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
				t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
				RenderTexture.active = null;

				bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
				if( isCompressed )
				{
					EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
					t2d.Apply( false );
				}
				texColors.AddRange( t2d.GetPixels() );
			}

			rt.Release();
			RenderTexture.active = cache;

			if( m_message.Length > 0 )
				m_message = m_message.Substring( 0, m_message.Length - 1 );

			texture3D.SetPixels( texColors.ToArray() );
			texture3D.Apply();

			string path = m_folderPath + m_fileName + ".replacedet";
			Texture3D outfile = replacedetDatabase.LoadMainreplacedetAtPath( path ) as Texture3D;
			if( outfile != null )
			{
				EditorUtility.CopySerialized( texture3D, outfile );
				replacedetDatabase.Savereplacedets();
				EditorGUIUtility.PingObject( outfile );
				m_lastSaved = outfile;
			}
			else
			{
				replacedetDatabase.Createreplacedet( texture3D, path );
				EditorGUIUtility.PingObject( texture3D );
				m_lastSaved = texture3D;
			}
		}

19 View Source File : InspectorFieldsUtility.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public static bool AreFieldsSame(SerializedProperty settings, List<InspectorFieldData> fieldList)
        {
            // If number of fields don't match, automatically not the same
            if (settings.arraySize != fieldList.Count)
            {
                return false;
            }

            // If same number of fields, ensure union of two lists is a perfect match
            for (int idx = 0; idx < settings.arraySize - 1; idx++)
            {
                SerializedProperty name = settings.GetArrayElementAtIndex(idx).FindPropertyRelative("Name");

                if (fieldList.FindIndex(s => s.Name == name.stringValue) == -1)
                {
                    return false;
                }
            }

            return true;
        }

19 View Source File : TemplateAdditionalDirectivesHelper.cs
License : MIT License
Project Creator : alexismorin

public void AddNativeContainer()
		{
			if( m_nativeDirectives.Count > 0 )
			{
				if( m_additionalDirectives.FindIndex( x => x.Origin.Equals( AdditionalContainerOrigin.Native ) ) == -1 )
				{
					AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
					newItem.Origin = AdditionalContainerOrigin.Native;
					newItem.hideFlags = HideFlags.HideAndDontSave;
					m_additionalDirectives.Add( newItem );
				}
			}
		}

19 View Source File : CharacterReferences.cs
License : MIT License
Project Creator : AkiniKites

public Dictionary<Model, string[]> LoadMap(IEnumerable<Model> models)
        {
            if (!File.Exists(ReferenceMap))
                throw new HzdException("Unable to find npc reference map: " + ReferenceMap);
            var json = File.ReadAllText(ReferenceMap);
            var npcRefs = JsonConvert.DeserializeObject<List<CharacterReference>>(json);

            var map = new Dictionary<Model, string[]>();
            foreach (var model in models)
            {
                var idx = npcRefs.FindIndex(x => x.Source == model.Source && x.Name == model.Name);
                if (idx >= 0)
                {
                    var match = npcRefs[idx];
                    npcRefs.RemoveAt(idx);

                    map.Add(model, match.Files);
                }
                else
                {
                    map.Add(model, new string[0]);
                }
            }

            return map;
        }

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

private List<Candle> BuildCandles(List<Candle> oldCandles, int needTf, int oldTf)
        {
            List<Candle> newCandles = new List<Candle>();

            int index = oldCandles.FindIndex(can => can.TimeStart.Minute % needTf == 0);

            int count = needTf / oldTf;

            int counter = 0;

            Candle newCandle = new Candle();

            for (int i = index; i < oldCandles.Count; i++)
            {
                counter++;

                if (counter == 1)
                {
                    newCandle = new Candle();
                    newCandle.Open = oldCandles[i].Open;
                    newCandle.TimeStart = oldCandles[i].TimeStart;
                    newCandle.Low = Decimal.MaxValue;
                }

                newCandle.High = oldCandles[i].High > newCandle.High
                    ? oldCandles[i].High
                    : newCandle.High;

                newCandle.Low = oldCandles[i].Low < newCandle.Low
                    ? oldCandles[i].Low
                    : newCandle.Low;

                newCandle.Volume += oldCandles[i].Volume;

                if (counter == count)
                {
                    newCandle.Close = oldCandles[i].Close;
                    newCandle.State = CandleState.Finished;
                    newCandles.Add(newCandle);
                    counter = 0;
                }

                if (i == oldCandles.Count - 1 && counter != count)
                {
                    newCandle.Close = oldCandles[i].Close;
                    newCandle.State = CandleState.None;
                    newCandles.Add(newCandle);
                }
            }

            return newCandles;
        }

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

private ColumnModel BuildColumnModel(ColumnRawModel rawColumn, List<IndexColumnModel>? pkCols, List<ColumnRef>? fkList)
        {
            string clrName = ToColCrlName(rawColumn.DbName);

            var pkIndex = pkCols?.FindIndex(c=>c.DbName.Equals(rawColumn.DbName));

            PkInfo? pkInfo = null;
            if (pkIndex >= 0 && pkCols != null)
            {
                pkInfo = new PkInfo(pkIndex.Value, pkCols[pkIndex.Value].IsDescending);
            }

            return new ColumnModel(
                name: clrName,
                dbName: rawColumn.DbName,
                ordinalPosition: rawColumn.OrdinalPosition,
                columnType: this.Database.GetColType(raw: rawColumn),
                pk: pkInfo,
                idenreplacedy: rawColumn.Idenreplacedy,
                defaultValue: this.Database.ParseDefaultValue(rawColumn.DefaultValue),
                fk: fkList);
        }

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

private void SaveSeries(CandleSeries series)
        {
            CandleSeriesSaveInfo mySaveInfo = GetSpecInfo(series.Specification);

            if (mySaveInfo.AllCandlesInFile == null)
            {
                mySaveInfo.AllCandlesInFile = series.CandlesAll;

                int indexSpec = _candleSeriesSaveInfos.FindIndex(s => s.Specification == series.Specification);
                _candleSeriesSaveInfos[indexSpec].AllCandlesInFile = series.CandlesAll;
            }
            if (series.CandlesAll == null ||
                series.CandlesAll.Count == 0)
            {
                return;
            }

            Candle firstCandle = series.CandlesAll[0];
            Candle lastCandle = series.CandlesAll[series.CandlesAll.Count - 1];

            if (firstCandle.TimeStart == mySaveInfo.LastCandleTime &&
                lastCandle.TimeStart == mySaveInfo.StartCandleTime &&
                lastCandle.Close == mySaveInfo.LastCandlePrice)
            {
                return;
            }

            mySaveInfo.InsertCandles(series.CandlesAll);

            if (Directory.Exists(_pathName) == false)
            {
                Directory.CreateDirectory(_pathName);
            }

            StreamWriter writer = new StreamWriter(_pathName + "\\" + series.Specification + ".txt");

            for (int i = 0; i < mySaveInfo.AllCandlesInFile.Count; i++)
            {
                writer.WriteLine(mySaveInfo.AllCandlesInFile[i].StringToSave);
            }

            writer.Close();
        }

19 View Source File : Jsonizer.cs
License : MIT License
Project Creator : alelievr

static string Jsonify(object data)
    {
        Type t = data.GetType();

        if (allowedJsonTypes.FindIndex(a => a.type == t) == -1)
            throw new InvalidOperationException("[Jsonizer] Can't jsonify type '" + t + "'");

        if (t == typeof(string))
            return "\"" + (data as string) + "\"";
        else
            return data.ToString();
    }

19 View Source File : StyleExtensions.cs
License : MIT License
Project Creator : Adoxio

private static IEnumerable<Tuple<string, string, int>> ContentStyles(IPortalViewContext portalViewContext, List<EnreplacedyReference> path)
		{
			ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Getting content styles using query.");

			var serviceContext = portalViewContext.CreateServiceContext();

			var parentPageConditions = path.Select(reference => new Condition("adx_parentpageid", ConditionOperator.Equal, reference.Id)).ToList();

			var fetch = new Fetch
			{
				Enreplacedy = new FetchEnreplacedy("adx_webfile")
				{
					Filters = new List<Filter>
					{
						new Filter
						{
							Type = LogicalOperator.And,
							Conditions = new List<Condition>
							{
								new Condition("adx_websiteid", ConditionOperator.Equal, portalViewContext.Website.EnreplacedyReference.Id),
								new Condition("statecode", ConditionOperator.Equal, 0),
								new Condition("adx_partialurl", ConditionOperator.EndsWith, ".css")
							},
							Filters = new List<Filter> { new Filter { Type = LogicalOperator.Or, Conditions = parentPageConditions } }
						}
					}
				}
			};

			return serviceContext.RetrieveMultiple(fetch).Enreplacedies
				.Select(e => new
				{
					PathOffset = path.FindIndex(pathItem => pathItem.Equals(e.GetAttributeValue<EnreplacedyReference>("adx_parentpageid"))),
					DisplayOrder = e.GetAttributeValue<int?>("adx_displayorder").GetValueOrDefault(0),
					Url = serviceContext.GetUrl(e),
					PartialUrl = e.GetAttributeValue<string>("adx_partialurl")
				})
				.Where(e => !string.IsNullOrEmpty(e.Url))
				.OrderByDescending(e => e.PathOffset)
				.ThenBy(e => e.DisplayOrder)
				.Select(e => new Tuple<string, string, int>(e.Url, e.PartialUrl, e.PathOffset))
				.ToArray();
		}

19 View Source File : CelesteNetModShareComponent.cs
License : MIT License
Project Creator : 0x0ade

public void Handle(CelesteNetConnection con, DataModRec rec) {
            Logger.Log(LogLevel.CRI, "netmod", $"Server recommended mod: {rec.ModName} ({rec.ModID} v{rec.ModVersion})");

            if (Everest.Modules.Any(mod => mod?.Metadata?.Name == rec.ModID))
                return;

            if (Engine.Scene is Level)
                Context.Status.Set($"Main Menu > Mod Options to install {rec.ModName}", 8);
            else if (Engine.Scene is Overworld overworld && overworld.IsCurrent<OuiModOptions>())
                Context.Status.Set($"Reopen Mod Options to install {rec.ModName}", 8);
            else
                Context.Status.Set($"Go to Mod Options to install {rec.ModName}", 8);

            lock (Requested) {
                int index = Requested.FindIndex(other => other.Name == rec.ModID);
                if (index != -1) {
                    Requested[index].Version = rec.ModVersion;
                } else {
                    Requested.Add(new() {
                        Name = rec.ModID,
                        Version = rec.ModVersion,
                        DLL = rec.ModName
                    });
                }
            }
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

private static void UpdateSubIFDOffset(ref IFDEntryInfo ifdInfo, ushort tagId, uint newOffset)
        {
            int index = ifdInfo.IFDEntries.FindIndex(i => i.Tag == tagId);

            if (index != -1)
            {
                ifdInfo.IFDEntries[index] = new IFDEntry(tagId, TagDataType.Long, 1, newOffset);
            }
        }

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

public void SetUpColorDropdownValue(CSColorChangerDD colorDropdown, OverlayColorData colorType)
		{
			if (GenericColorList == null)
			{
				Debug.LogWarning("[TestCustomizerDD] the GenericColorList was null or missing, this must be set.");
				return;
			}
			int colorTableSelected = -1;
			SharedColorTable thisColorTable = null;
			if (sharedColorTables.FindIndex(s => s.name == colorType.name) > -1)
			{
				thisColorTable = sharedColorTables[sharedColorTables.FindIndex(s => s.name == colorType.name)].sharedColorTable;
				if (thisColorTable == null)
				{
					Debug.LogWarning("[TestCustomizerDD] the colorList for " + colorType.name + " was null or missing, please set this or remove it from the list.");
					return;
				}
				for (int i = 0; i < thisColorTable.colors.Length; i++)
				{
					if (ColorToHex(thisColorTable.colors[i].color) == ColorToHex(colorType.color))
					{
						colorTableSelected = i;
						break;
					}
				}
			}
			else
			{
				thisColorTable = GenericColorList;
				for (int i = 0; i < GenericColorList.colors.Length; i++)
				{
					if (ColorToHex(GenericColorList.colors[i].color) == ColorToHex(colorType.color))
					{
						colorTableSelected = i;
						break;
					}
				}
			}
			SetUpColorDropdownOptions(colorDropdown, thisColorTable, colorTableSelected, colorType);
		}

19 View Source File : Projectile.cs
License : GNU General Public License v3.0
Project Creator : aenemenate

public bool Update(Block[] blocks, int width)
        {
            int startIndex = path.FindIndex(i => i.Equals(position));
            if (startIndex == path.Count - 1 
                  || (blocks[path[startIndex + 1].X * width + path[startIndex + 1].Y].Solid 
                        & blocks[path[startIndex + 1].X * width + path[startIndex + 1].Y] is Creature == false)
                     ) {
                DropItem(path[startIndex], blocks, width);
                return true;
            }
            else if (blocks[path[startIndex + 1].X * width + path[startIndex + 1].Y] is Creature c) {
                LaunchAttack(c);
                return true;
            }
            position = path[startIndex + 1];
            return false;
        }

19 View Source File : MainForm.cs
License : MIT License
Project Creator : AlexanderPro

private void WindowDestroyed(object sender, WindowEventArgs e)
        {
            int windowIndex = _windows.FindIndex(w => w.Handle == e.Handle);
            if (windowIndex != -1 && !_windows[windowIndex].ExistSystemTrayIcon)
            {
                _windows[windowIndex].Dispose();
                _windows.RemoveAt(windowIndex);
            }
        }

See More Examples