string.Compare(string, int, string, int, int, System.StringComparison)

Here are the examples of the csharp api string.Compare(string, int, string, int, int, System.StringComparison) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2233 Examples 7

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

private static void PerformKiss(NPC npc, Vector2 midpoint, string partner)
        {
            int spouseFrame = 28;
            bool facingRight = true;
            string name = npc.Name;
            if (name == "Sam")
            {
                spouseFrame = 36;
                facingRight = true;
            }
            else if (name == "Penny")
            {
                spouseFrame = 35;
                facingRight = true;
            }
            else if (name == "Sebastian")
            {
                spouseFrame = 40;
                facingRight = false;
            }
            else if (name == "Alex")
            {
                spouseFrame = 42;
                facingRight = true;
            }
            else if (name == "Krobus")
            {
                spouseFrame = 16;
                facingRight = true;
            }
            else if (name == "Maru")
            {
                spouseFrame = 28;
                facingRight = false;
            }
            else if (name == "Emily")
            {
                spouseFrame = 33;
                facingRight = false;
            }
            else if (name == "Harvey")
            {
                spouseFrame = 31;
                facingRight = false;
            }
            else if (name == "Shane")
            {
                spouseFrame = 34;
                facingRight = false;
            }
            else if (name == "Elliott")
            {
                spouseFrame = 35;
                facingRight = false;
            }
            else if (name == "Leah")
            {
                spouseFrame = 25;
                facingRight = true;
            }
            else if (name == "Abigail")
            {
                spouseFrame = 33;
                facingRight = false;
            }

            bool right = npc.position.X < midpoint.X;
            if(npc.position == midpoint)
            {
                right = String.Compare(npc.Name, partner) < 0;
            }
            else if(npc.position.X == midpoint.X)
            {
                right = npc.position.Y > midpoint.Y;
            }

            bool flip = (facingRight && !right) || (!facingRight && right);

            int offset = 24;
            if (right)
                offset *= -1;

            npc.position.Value = new Vector2(midpoint.X+offset,midpoint.Y);

            int delay = 1000;
            npc.movementPause = delay;
            npc.Sprite.setCurrentAnimation(new List<FarmerSprite.AnimationFrame>
                {
                    new FarmerSprite.AnimationFrame(spouseFrame, delay, false, flip, new AnimatedSprite.endOfAnimationBehavior(npc.haltMe), true)
                });
            npc.doEmote(20, true);
            if (ModEntry.config.RealKissSound && kissEffect != null)
            {
                float distance = 1f / ((Vector2.Distance(midpoint, Game1.player.position) / 256) + 1);
                float pan = (float)(Math.Atan((midpoint.X - Game1.player.position.X) / Math.Abs(midpoint.Y - Game1.player.position.Y)) /(Math.PI/2));
                //ModEntry.PMonitor.Log($"kiss distance: {distance} pan: {pan}");
                kissEffect.Play(distance * Game1.options.soundVolumeLevel, 0, pan);
            }
            else
            {
                Game1.currentLocation.playSound("dwop", NetAudio.SoundContext.NPC);
            }

            npc.Sprite.UpdateSourceRect();
        }

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

public bool Equals(SmartSystemMenuSettings other)
        {
            if (other == null)
            {
                return false;
            }

            if (object.ReferenceEquals(this, other))
            {
                return true;
            }

            if (GetType() != other.GetType())
            {
                return false;
            }

            if (ProcessExclusions.Count != other.ProcessExclusions.Count)
            {
                return false;
            }

            if (MenuItems.WindowSizeItems.Count != other.MenuItems.WindowSizeItems.Count)
            {
                return false;
            }

            if (MenuItems.StartProgramItems.Count != other.MenuItems.StartProgramItems.Count)
            {
                return false;
            }

            if (MenuItems.Items.Count != other.MenuItems.Items.Count)
            {
                return false;
            }

            for (var i = 0; i < ProcessExclusions.Count; i++)
            {
                if (string.Compare(ProcessExclusions[i], other.ProcessExclusions[i], StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    return false;
                }
            }

            for (var i = 0; i < MenuItems.WindowSizeItems.Count; i++)
            {
                if (string.Compare(MenuItems.WindowSizeItems[i].replacedle, other.MenuItems.WindowSizeItems[i].replacedle, StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    MenuItems.WindowSizeItems[i].Left != other.MenuItems.WindowSizeItems[i].Left ||
                    MenuItems.WindowSizeItems[i].Top != other.MenuItems.WindowSizeItems[i].Top ||
                    MenuItems.WindowSizeItems[i].Width != other.MenuItems.WindowSizeItems[i].Width ||
                    MenuItems.WindowSizeItems[i].Height != other.MenuItems.WindowSizeItems[i].Height ||
                    MenuItems.WindowSizeItems[i].Key1 != other.MenuItems.WindowSizeItems[i].Key1 ||
                    MenuItems.WindowSizeItems[i].Key2 != other.MenuItems.WindowSizeItems[i].Key2 ||
                    MenuItems.WindowSizeItems[i].Key3 != other.MenuItems.WindowSizeItems[i].Key3)
                {
                    return false;
                }
            }

            for (var i = 0; i < MenuItems.StartProgramItems.Count; i++)
            {
                if (string.Compare(MenuItems.StartProgramItems[i].replacedle, other.MenuItems.StartProgramItems[i].replacedle, StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    string.Compare(MenuItems.StartProgramItems[i].FileName, other.MenuItems.StartProgramItems[i].FileName, StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    string.Compare(MenuItems.StartProgramItems[i].Arguments, other.MenuItems.StartProgramItems[i].Arguments, StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    return false;
                }
            }

            for (var i = 0; i < MenuItems.Items.Count; i++)
            {
                if (string.Compare(MenuItems.Items[i].Name, other.MenuItems.Items[i].Name, StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    MenuItems.Items[i].Show != other.MenuItems.Items[i].Show ||
                    MenuItems.Items[i].Type != other.MenuItems.Items[i].Type ||
                    MenuItems.Items[i].Key1 != other.MenuItems.Items[i].Key1 ||
                    MenuItems.Items[i].Key2 != other.MenuItems.Items[i].Key2 ||
                    MenuItems.Items[i].Key3 != other.MenuItems.Items[i].Key3)
                {
                    return false;
                }

                if (MenuItems.Items[i].Items.Count != other.MenuItems.Items[i].Items.Count)
                {
                    return false;
                }

                for (var j = 0; j < MenuItems.Items[i].Items.Count; j++)
                {
                    if (string.Compare(MenuItems.Items[i].Items[j].Name, other.MenuItems.Items[i].Items[j].Name, StringComparison.CurrentCultureIgnoreCase) != 0 ||
                        MenuItems.Items[i].Items[j].Show != other.MenuItems.Items[i].Items[j].Show ||
                        MenuItems.Items[i].Items[j].Type != other.MenuItems.Items[i].Items[j].Type ||
                        MenuItems.Items[i].Items[j].Key1 != other.MenuItems.Items[i].Items[j].Key1 ||
                        MenuItems.Items[i].Items[j].Key2 != other.MenuItems.Items[i].Items[j].Key2 ||
                        MenuItems.Items[i].Items[j].Key3 != other.MenuItems.Items[i].Items[j].Key3)
                    {
                        return false;
                    }
                }
            }

            if (Closer.Type != other.Closer.Type || Closer.Key1 != other.Closer.Key1 || Closer.Key2 != other.Closer.Key2 || Closer.MouseButton != other.Closer.MouseButton)
            {
                return false;
            }

            if (Sizer != other.Sizer)
            {
                return false;
            }

            if (string.Compare(LanguageName, other.LanguageName, StringComparison.CurrentCultureIgnoreCase) != 0)
            {
                return false;
            }

            return true;
        }

19 View Source File : ConvertItemHelper.cs
License : MIT License
Project Creator : Actipro

public static IList GetTrail(object rooreplacedem, string path) {
			// Make sure the specified path is valid
			if (string.IsNullOrEmpty(path))
				return null;

			// If the root item was not preplaceded, then we cannot build a trail
			MyComputerData myComputerData = rooreplacedem as MyComputerData;
			if (null == myComputerData)
				return null;

			// Break the path up based on the available path separators
			string[] pathEntries = path.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
				StringSplitOptions.RemoveEmptyEntries);
			if (null == pathEntries || 0 == pathEntries.Length)
				return null;

			// Start to build the trail
			List<object> trail = new List<object>();
			trail.Add(myComputerData);

			if (0 != string.Compare("My Computer", pathEntries[0], StringComparison.CurrentCultureIgnoreCase)) {
				// For the remaining entries in the path, we will search the child items for a match at each level. If at any
				//   point we don't find a match, then we will need to cancel the conversion.
				//
				if (!Directory.Exists(path))
					return null;

				// The split above will remove the backslash, which we need for the comparison for drives below.
				string driveEntry = pathEntries[0] + "\\";

				// The first entry should be a drive, so we will start there
				DriveData driveData = null;
				for (int driveIndex = 0; driveIndex < myComputerData.Drives.Count; driveIndex++) {
					// Get the next DriveData and see if it's a match, if so the exit the loop
					driveData = myComputerData.Drives[driveIndex];
					if (0 == string.Compare(driveData.Info.Name, driveEntry, StringComparison.CurrentCultureIgnoreCase))
						break;

					// Set to null, because we didn't find a match and we want driveData to be null in that case
					driveData = null;
				}

				// If we found the drive, then add it to the trail and continue. Otherwise, there's a problem and we have
				//   failed to convert.
				if (null != driveData) {
					trail.Add(driveData);

					// See if there are more items, which should be all directories
					if (pathEntries.Length > 1) {

						// We need to get the first directory directly from the drive object
						DirectoryData directoryData = null;
						for (int directoryIndex = 0; directoryIndex < driveData.Directories.Count; directoryIndex++) {
							// Get the next DirectoryData and see if it's a match, if so the exit the loop
							directoryData = driveData.Directories[directoryIndex];
							if (0 == string.Compare(directoryData.Info.Name, pathEntries[1], StringComparison.CurrentCultureIgnoreCase))
								break;

							// Set to null, because we didn't find a match and we want directoryData to be null in that case
							directoryData = null;
						}

						// If we found the directory, then add it to the trail and continue. Otherwise, there's a problem and
						//   we have failed to convert.
						if (null != directoryData) {
							trail.Add(directoryData);

							// We are now looking for the remaining directories, which we can do in this loop
							for (int index = 2; index < pathEntries.Length; index++) {
								bool found = false;
								for (int directoryIndex = 0; directoryIndex < directoryData.Directories.Count; directoryIndex++) {
									// Get the next DirectoryData and see if it's a match, if so the exit the loop
									DirectoryData childDirectoryData = directoryData.Directories[directoryIndex];
									if (0 == string.Compare(childDirectoryData.Info.Name, pathEntries[index], StringComparison.CurrentCultureIgnoreCase)) {
										found = true;
										trail.Add(childDirectoryData);
										directoryData = childDirectoryData;
										break;
									}
								}

								if (!found)
									return null;
							}

							return trail;
						}
					}
					else {
						return trail;
					}
				}
			}
			else {
				return trail;
			}

			return null;
		}

19 View Source File : SubKeyIndirectListCell.cs
License : MIT License
Project Creator : ADeltaX

public int Compare(int x, int y)
            {
                Cell cell = _hive.GetCell<Cell>(x);
                ListCell listCell = cell as ListCell;

                int result;
                if (listCell != null)
                {
                    int cellIndex;
                    result = listCell.FindKey(_searchName, out cellIndex);
                    if (result == 0)
                    {
                        CellIndex = cellIndex;
                    }

                    return -result;
                }
                result = string.Compare(((KeyNodeCell)cell).Name, _searchName, StringComparison.OrdinalIgnoreCase);
                if (result == 0)
                {
                    CellIndex = x;
                }

                return result;
            }

19 View Source File : RegistryKey.cs
License : MIT License
Project Creator : ADeltaX

public void DeleteValue(string name, bool throwOnMissingValue)
        {
            bool foundValue = false;

            if (_cell.NumValues != 0)
            {
                byte[] valueList = _hive.RawCellData(_cell.ValueListIndex, _cell.NumValues * 4);

                int i = 0;
                while (i < _cell.NumValues)
                {
                    int valueIndex = EndianUtilities.ToInt32LittleEndian(valueList, i * 4);
                    ValueCell valueCell = _hive.GetCell<ValueCell>(valueIndex);
                    if (string.Compare(valueCell.Name, name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        foundValue = true;
                        _hive.FreeCell(valueIndex);
                        _cell.NumValues--;
                        _hive.UpdateCell(_cell, false);
                        break;
                    }

                    ++i;
                }

                // Move following value's to fill gap
                if (i < _cell.NumValues)
                {
                    while (i < _cell.NumValues)
                    {
                        int valueIndex = EndianUtilities.ToInt32LittleEndian(valueList, (i + 1) * 4);
                        EndianUtilities.WriteBytesLittleEndian(valueIndex, valueList, i * 4);

                        ++i;
                    }

                    _hive.WriteRawCellData(_cell.ValueListIndex, valueList, 0, _cell.NumValues * 4);
                }

                // TODO: Update maxbytes for value name and value content if this was the largest value for either.
                // Windows seems to repair this info, if not accurate, though.
            }

            if (throwOnMissingValue && !foundValue)
            {
                throw new ArgumentException("No such value: " + name, nameof(name));
            }
        }

19 View Source File : ChildObject3.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Child3"));
		}

19 View Source File : WorkFlowInstanceService.cs
License : MIT License
Project Creator : aishang2015

public async Task<bool> ApproveOrDisApproveNode(WorkFlowInstanceHandleViewModel viewModel)
        {
            var account = _httpContextAccessor.HttpContext?.User?.GetUserName();

            // 取得当前用户待处理的节点
            var route = _instanceRouteRepository.Get(route =>
                route.WorkFlowInstanceId == viewModel.WorkFlowInstanceId &&
                route.HandlePepleAccount == account &&
                route.HandleState == HandleStateEnum.未处理).FirstOrDefault();

            if (route != null)
            {
                // 取得节点对应的流转中的工作流实例
                var instance = _instanceRepository.Get(i => i.Id == route.WorkFlowInstanceId &&
                    i.WorkFlowInstanceState == WorkFlowInstanceStateEnum.CirCulation).FirstOrDefault();
                if (instance != null)
                {
                    try
                    {
                        if (viewModel.IsPreplaced)
                        {
                            route.HandleState = HandleStateEnum.通过;
                            route.HandleComment = viewModel.HandleComment;

                            var currentNode = await _nodeRepository.GetAsync(instance.CurrentNodeId);

                            // 取得下一个节点
                            var targetIds = from link in _linkRepository.Get()
                                            where link.SourceId == currentNode.DomId &&
                                                link.WorkFlowId == instance.WorkFlowId
                                            select link.TargetId;

                            // 判断是否能够进入下一个节点
                            var haveNext = false;

                            // 循环所有目标节点
                            foreach (var targetId in targetIds.ToList())
                            {
                                // 找出流转到该节点的条件组
                                var conditions = from c in _conditionRepository.Get()
                                                 where c.WorkFlowId == instance.WorkFlowId &&
                                                        c.SourceId == currentNode.DomId &&
                                                        c.TargetId == targetId
                                                 select c;

                                // 比较
                                var isCompare = true;

                                // 无条件,直接进入
                                if (conditions.Count() == 0)
                                {
                                    isCompare = true;
                                    haveNext = true;
                                }
                                else
                                {
                                    // 有条件,判断条件
                                    foreach (var condition in conditions.ToList())
                                    {
                                        // 取得实例中表单的值
                                        var formValue = (from value in _instanceValueRepository.Get()
                                                         join control in _controlRepository.Get() on value.FormControlDomId equals control.DomId
                                                         where control.Id == condition.FormControlId &&
                                                             value.WorkFlowInstanceId == instance.Id
                                                         select value.Value).FirstOrDefault();

                                        // 对所有条件进行and判断
                                        switch (condition.CompareMode)
                                        {
                                            case CompareModeEnum.Equal:
                                                isCompare = isCompare && (formValue == condition.CompareValue);
                                                break;
                                            case CompareModeEnum.EqualOrGreater:
                                                isCompare = isCompare && (string.Compare(formValue, condition.CompareValue) >= 0);
                                                break;
                                            case CompareModeEnum.EqualOrSmaller:
                                                isCompare = isCompare && (string.Compare(formValue, condition.CompareValue) <= 0);
                                                break;
                                            case CompareModeEnum.Greater:
                                                isCompare = isCompare && (string.Compare(formValue, condition.CompareValue) > 0);
                                                break;
                                            case CompareModeEnum.Smaller:
                                                isCompare = isCompare && (string.Compare(formValue, condition.CompareValue) < 0);
                                                break;
                                        }

                                        // 出现条件不满足的情况直接退出判断
                                        if (!isCompare)
                                        {
                                            break;
                                        }
                                    }
                                }

                                // 条件全部满足则转入到该节点
                                if (isCompare)
                                {
                                    haveNext = true;
                                    var nextNode = _nodeRepository.Get(n => n.DomId == targetId).FirstOrDefault();

                                    instance.CurrentNodeId = nextNode.Id;

                                    if (nextNode.NodeType == NodeTypeEnum.EndNode)
                                    {
                                        instance.WorkFlowInstanceState = WorkFlowInstanceStateEnum.End;

                                        // 添加节点处理记录
                                        var routeInfo = new WorkFlowInstanceRoute
                                        {
                                            NodeId = nextNode.Id,
                                            NodeName = nextNode.Name,
                                            HandlePeopleName = "系统",
                                            HandleState = HandleStateEnum.通过,
                                            HandleTime = DateTime.Now,
                                            WorkFlowInstanceId = instance.Id
                                        };
                                        await _instanceRouteRepository.AddAsync(routeInfo);
                                    }
                                    else
                                    {

                                        // 获取处理人员
                                        var users = GetHandleUsers(nextNode, account);

                                        foreach (var u in users.ToList())
                                        {
                                            // 添加节点处理记录
                                            var routeInfo = new WorkFlowInstanceRoute
                                            {
                                                NodeId = nextNode.Id,
                                                NodeName = nextNode.Name,
                                                HandlePeopleName = u.Name,
                                                HandlePepleAccount = u.UserName,
                                                HandleState = HandleStateEnum.未处理,
                                                HandleTime = DateTime.Now,
                                                WorkFlowInstanceId = instance.Id
                                            };
                                            await _instanceRouteRepository.AddAsync(routeInfo);
                                        }
                                    }
                                    _instanceRepository.Update(instance);
                                    break;
                                }
                            }

                            if (!haveNext)
                            {
                                // 无法进行,异常结束
                                instance.WorkFlowInstanceState = WorkFlowInstanceStateEnum.BadEnd;
                            }
                        }
                        else
                        {
                            route.HandleState = HandleStateEnum.拒绝;
                            route.HandleComment = viewModel.HandleComment;

                            // 获取开始节点id
                            var startNode = await _nodeRepository.Get(n => n.WorkFlowId == instance.WorkFlowId &&
                                n.NodeType == NodeTypeEnum.StartNode).FirstOrDefaultAsync();

                            instance.CurrentNodeId = startNode.Id;
                            instance.WorkFlowInstanceState = WorkFlowInstanceStateEnum.ReturnBack;
                        }
                        _instanceRouteRepository.Update(route);
                        _instanceRepository.Update(instance);
                        await _unitOfWork.SaveAsync();
                        return true;
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                        return false;
                    }
                }
            }

            return false;
        }

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

internal static IDictionary<string, object> TranslateToJwtClaims(IEnumerable<Claim> claims)
        {
            ArgumentUtility.CheckForNull(claims, nameof(claims));

            Dictionary<string, object> ret = new Dictionary<string, object>();

            //there are two claim names that get special treatment
            foreach (Claim claim in claims)
            {
                string claimName = claim.Type;
                if (string.Compare(claimName, JsonWebTokenClaims.NameIdLongName, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.NameId;
                }
                else if (string.Compare(claimName, JsonWebTokenClaims.IdenreplacedyProviderLongName, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.IdenreplacedyProvider;
                }

                ret.Add(claimName, claim.Value);
            }

            return ret;
        }

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

protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            _oneInstanceMutex = new Mutex(false, "AwesomeWallpaperOneInstanceMutex", out var createNew);
            if (!createNew)
            {
                Shutdown();
                return;
            }

            _manager = new ViewManager();
            var isSettingsLoaded = _manager.LoadSettings();
            if (isSettingsLoaded)
            {
                if (_manager.Settings.WallpaperType == Settings.WallpaperType.Window && 
                    _manager.Settings.WindowUseAfterRestart && 
                    !string.IsNullOrEmpty(_manager.Settings.WindowProcessName))
                {
                    EnumWindows(new EnumWindowsProc((hWnd, lParam) =>
                    {
                        var processName = WindowUtils.GetProcessName(hWnd);
                        var windowText = WindowUtils.GetWmGetText(hWnd);
                        var windowClreplacedName = WindowUtils.GetClreplacedName(hWnd);
                        if (string.Compare(windowText, _manager.Settings.WindowText, StringComparison.CurrentCultureIgnoreCase) == 0 &&
                            string.Compare(windowClreplacedName, _manager.Settings.WindowClreplacedName, StringComparison.CurrentCultureIgnoreCase) == 0 &&
                            string.Compare(processName, _manager.Settings.WindowProcessName, StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            _manager.Settings.WindowHandle = hWnd == IntPtr.Zero ? null : (long?)hWnd.ToInt64();
                            _manager.Settings.WindowExTool = WindowUtils.IsExToolWindow(hWnd);
                            _manager.Settings.WindowStatus = "Selected";
                            return false;
                        }
                        return true;
                    }), IntPtr.Zero);
                }
                _manager.CreateViews();
                _manager.InitTray();

                _timerSystemTray = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(1),
                };
                _timerSystemTray.Tick += TimerTick;
                _timerSystemTray.Start();
            }
        }

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

private static void ValidateAudience(JsonWebToken token, JsonWebTokenValidationParameters parameters)
        {
            ArgumentUtility.CheckForNull(token, nameof(token));
            ArgumentUtility.CheckForNull(parameters, nameof(parameters));

            if (!parameters.ValidateAudience)
            {
                return;
            }

            ArgumentUtility.CheckStringForNullOrEmpty(token.Audience, nameof(token.Audience));
            ArgumentUtility.CheckEnumerableForNullOrEmpty(parameters.AllowedAudiences, nameof(parameters.AllowedAudiences));

            foreach (string audience in parameters.AllowedAudiences)
            {
                if (string.Compare(audience, token.Audience, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return;
                }
            }

            throw new InvalidAudienceException(); //validation exception;            
        }

19 View Source File : SubKeyIndirectListCell.cs
License : MIT License
Project Creator : ADeltaX

internal override int UnlinkSubKey(string name)
        {
            if (ListType == "ri")
            {
                if (CellIndexes.Count == 0)
                {
                    throw new NotImplementedException("Empty indirect list");
                }

                for (int i = 0; i < CellIndexes.Count; ++i)
                {
                    int tempIndex;
                    ListCell cell = _hive.GetCell<ListCell>(CellIndexes[i]);
                    if (cell.FindKey(name, out tempIndex) <= 0)
                    {
                        CellIndexes[i] = cell.UnlinkSubKey(name);
                        if (cell.Count == 0)
                        {
                            _hive.FreeCell(CellIndexes[i]);
                            CellIndexes.RemoveAt(i);
                        }

                        return _hive.UpdateCell(this, false);
                    }
                }
            }
            else
            {
                for (int i = 0; i < CellIndexes.Count; ++i)
                {
                    KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(CellIndexes[i]);
                    if (string.Compare(name, cell.Name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        CellIndexes.RemoveAt(i);
                        return _hive.UpdateCell(this, true);
                    }
                }
            }

            return Index;
        }

19 View Source File : SubKeyHashedListCell.cs
License : MIT License
Project Creator : ADeltaX

internal int Add(string name, int cellIndex)
        {
            for (int i = 0; i < _numElements; ++i)
            {
                KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(_subKeyIndexes[i]);
                if (string.Compare(cell.Name, name, StringComparison.OrdinalIgnoreCase) > 0)
                {
                    _subKeyIndexes.Insert(i, cellIndex);
                    _nameHashes.Insert(i, CalcHash(name));
                    _numElements++;
                    return i;
                }
            }

            _subKeyIndexes.Add(cellIndex);
            _nameHashes.Add(CalcHash(name));
            return _numElements++;
        }

19 View Source File : ParentObject.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Parent"));
		}

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

private static Enreplacedy LookupPageByUrlPath(OrganizationServiceContext context, Enreplacedy website, string urlPath, Func<Enreplacedy, bool> predicate)
		{
			website.replacedertEnreplacedyName("adx_website");

			if (website.Id == Guid.Empty) throw new NullReferenceException("Unable to retrieve the Id of the website.  Lookup failed.");

			var urlWithoutWebsitePath = WebsitePathUtility.ToRelative(website, urlPath);

			var webPages = website.GetRelatedEnreplacedies(context, "adx_website_webpage").Where(predicate);

			// Check if we can find a page with the exact URL.
			var page = webPages.Where(wp => string.Compare(wp.GetAttributeValue<string>("adx_partialurl"), urlWithoutWebsitePath, StringComparison.InvariantCultureIgnoreCase) == 0).FirstOrDefault();

			if (page != null)
			{
				// We found the page (probably root).
				return page;
			}

			string parentPath;
			string thisPath;

			if (ParseParentPath(urlWithoutWebsitePath, out parentPath, out thisPath))
			{
				var parentPage = LookupPageByUrlPath(context, website, parentPath, predicate);

				if (parentPage != null)
				{
					page = context.GetChildPages(parentPage).Where(p => predicate(p) && string.Equals(p.GetAttributeValue<string>("adx_partialurl"), thisPath, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

					if (page != null)
					{
						return page;
					}
				}
			}

			return null;
		}

19 View Source File : RoomFilterItem.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas

private static int ParameterComparedToString(Parameter param, string value)
        {
            // ReSharper disable once InconsistentNaming
            const int Result = 441976;
            if (!param.HasValue || string.IsNullOrWhiteSpace(value))
            {
                return Result;
            }
            switch (param.StorageType)
            {
                case StorageType.Double:
                    if (double.TryParse(value, out var parse))
                    {
                        return param.AsDouble().CompareTo(parse);
                    }
                    break;

                case StorageType.String:
                #pragma warning disable CA1307 // Specify StringComparison
                return string.Compare(param.replacedtring(), value, StringComparison.Ordinal);
                #pragma warning restore CA1307 // Specify StringComparison

                case StorageType.Integer:
                    if (int.TryParse(value, out var iparse))
                    {
                        return param.AsInteger().CompareTo(iparse);
                    }
                    break;

                case StorageType.ElementId:
                    return Result;

                default:
                    return Result;
            }
            return Result;
        }

19 View Source File : RecoveryResults.cs
License : MIT License
Project Creator : aerosoul94

public int Compare(object x, object y)
            {
                // Default, don't swap order.
                int result = 0;

                ListViewItem itemX = (ListViewItem)x;
                ListViewItem itemY = (ListViewItem)y;

                if (itemX.Tag == null ||
                    itemY.Tag == null)
                {
                    return result;
                }

                if (itemX.Index == 0)
                {
                    // Skip "up" item
                    return result;
                }

                DatabaseFile direntX = (DatabaseFile)((NodeTag)itemX.Tag).Tag;
                DatabaseFile direntY = (DatabaseFile)((NodeTag)itemY.Tag).Tag;

                switch (column)
                {
                    case ColumnIndex.Index:
                        result = UInt32.Parse(itemX.Text).CompareTo(UInt32.Parse(itemY.Text));
                        break;
                    case ColumnIndex.Name:
                        result = String.Compare(direntX.FileName, direntY.FileName);
                        break;
                    case ColumnIndex.Size:
                        result = direntX.FileSize.CompareTo(direntY.FileSize);
                        break;
                    case ColumnIndex.Created:
                        result = direntX.CreationTime.AsDateTime().CompareTo(direntY.CreationTime.AsDateTime());
                        break;
                    case ColumnIndex.Modified:
                        result = direntX.LastWriteTime.AsDateTime().CompareTo(direntY.LastWriteTime.AsDateTime());
                        break;
                    case ColumnIndex.Accessed:
                        result = direntX.LastAccessTime.AsDateTime().CompareTo(direntY.LastAccessTime.AsDateTime());
                        break;
                    case ColumnIndex.Offset:
                        result = direntX.Offset.CompareTo(direntY.Offset);
                        break;
                    case ColumnIndex.Cluster:
                        result = direntX.Cluster.CompareTo(direntY.Cluster);
                        break;
                }

                if (order == SortOrder.Ascending)
                {
                    return result;
                }
                else
                {
                    return -result;
                }
            }

19 View Source File : ChildObject2.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Child2"));
		}

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

void OnGUI()
    {
        if( position.width != _oldPosition.width && Event.current.type == EventType.Layout )
        {
            Drawings = null;
            _oldPosition = position;
        }
 
        GUILayout.BeginHorizontal();
 
        if( GUILayout.Toggle( _showingStyles, "Styles", EditorStyles.toolbarButton ) != _showingStyles )
        {
            _showingStyles = !_showingStyles;
            _showingIcons = !_showingStyles;
            Drawings = null;
        }
 
        if( GUILayout.Toggle( _showingIcons, "Icons", EditorStyles.toolbarButton ) != _showingIcons )
        {
            _showingIcons = !_showingIcons;
            _showingStyles = !_showingIcons;
            Drawings = null;
        }
 
        GUILayout.EndHorizontal();
 
	    string newSearch = GUILayout.TextField(_search);
	    if (newSearch != _search)
	    {
		    _search = newSearch;
		    Drawings = null;
	    }
 
	    float top = 36;
 
        if( Drawings == null )
        {
	        string lowerSearch = _search.ToLower();
 
            Drawings = new List<Drawing>();
 
            GUIContent inactiveText = new GUIContent("inactive");
            GUIContent activeText = new GUIContent( "active" );
 
            float x = 5.0f;
            float y = 5.0f;
 
            if( _showingStyles )
            {
                foreach( GUIStyle ss in GUI.skin.customStyles )
                {
					if (lowerSearch != "" && !ss.name.ToLower().Contains(lowerSearch))
		                continue;
 
                    GUIStyle thisStyle = ss;
 
                    Drawing draw = new Drawing();
 
                    float width = Mathf.Max(
                        100.0f,
                        GUI.skin.button.CalcSize( new GUIContent( ss.name ) ).x,
                        ss.CalcSize( inactiveText ).x + ss.CalcSize( activeText ).x
                                      ) + 16.0f;
 
                    float height = 60.0f;
 
                    if( x + width > position.width - 32 && x > 5.0f )
                    {
                        x = 5.0f;
                        y += height + 10.0f;
                    }
 
                    draw.Rect = new Rect( x, y, width, height );
 
                    width -= 8.0f;
 
                    draw.Draw = () =>
                    {
                        if( GUILayout.Button( thisStyle.name, GUILayout.Width( width ) ) )
                            CopyText( "(GUIStyle)\"" + thisStyle.name + "\"" );
 
                        GUILayout.BeginHorizontal();
                        GUILayout.Toggle( false, inactiveText, thisStyle, GUILayout.Width( width / 2 ) );
                        GUILayout.Toggle( false, activeText, thisStyle, GUILayout.Width( width / 2 ) );
                        GUILayout.EndHorizontal();
                    };
 
                    x += width + 18.0f;
 
                    Drawings.Add( draw );
                }
            }
            else if( _showingIcons )
            {
                if( _objects == null )
                {
                    _objects = new List<UnityEngine.Object>( Resources.FindObjectsOfTypeAll( typeof( Texture ) ) );
                    _objects.Sort( ( pA, pB ) => System.String.Compare( pA.name, pB.name, System.StringComparison.OrdinalIgnoreCase ) );
                }
 
                float rowHeight = 0.0f;
 
                foreach( UnityEngine.Object oo in _objects )
                {
                    Texture texture = (Texture)oo;
 
                    if( texture.name == "" )
                        continue;
 
					if (lowerSearch != "" && !texture.name.ToLower().Contains(lowerSearch))
						continue;
 
                    Drawing draw = new Drawing();
 
                    float width = Mathf.Max(
                        GUI.skin.button.CalcSize( new GUIContent( texture.name ) ).x,
                        texture.width
                    ) + 8.0f;
 
                    float height = texture.height + GUI.skin.button.CalcSize( new GUIContent( texture.name ) ).y + 8.0f;
 
                    if( x + width > position.width - 32.0f )
                    {
                        x = 5.0f;
                        y += rowHeight + 8.0f;
                        rowHeight = 0.0f;
                    }
 
                    draw.Rect = new Rect( x, y, width, height );
 
                    rowHeight = Mathf.Max( rowHeight, height );
 
                    width -= 8.0f;
 
                    draw.Draw = () =>
                    {
                        if( GUILayout.Button( texture.name, GUILayout.Width( width ) ) )
                            CopyText( "EditorGUIUtility.FindTexture( \"" + texture.name + "\" )" );
 
                        Rect textureRect = GUILayoutUtility.GetRect( texture.width, texture.width, texture.height, texture.height, GUILayout.ExpandHeight( false ), GUILayout.ExpandWidth( false ) );
                        EditorGUI.DrawTextureTransparent( textureRect, texture );
                    };
 
                    x += width + 8.0f;
 
                    Drawings.Add( draw );
                }
            }
 
            _maxY = y;
        }
 
        Rect r = position;
        r.y = top;
	    r.height -= r.y;
        r.x = r.width - 16;
        r.width = 16;
 
		float areaHeight = position.height - top;
        _scrollPos = GUI.VerticalScrollbar( r, _scrollPos, areaHeight, 0.0f, _maxY );
 
		Rect area = new Rect(0, top, position.width - 16.0f, areaHeight);
        GUILayout.BeginArea( area );
 
        int count = 0;
        foreach( Drawing draw in Drawings )
        {
            Rect newRect = draw.Rect;
            newRect.y -= _scrollPos;
 
            if( newRect.y + newRect.height > 0 && newRect.y < areaHeight )
            {
                GUILayout.BeginArea( newRect, GUI.skin.textField );
                draw.Draw();
                GUILayout.EndArea();
 
                count++;
            }
        }
 
        GUILayout.EndArea();
    }

19 View Source File : PanelChat.cs
License : Apache License 2.0
Project Creator : AantCoder

private void PlayerItemMenu(ListBoxPlayerItem item)
        {
            if (item.Groupreplacedle) return;

            var listMenu = new List<FloatMenuOption>();
            var myLogin = SessionClientController.My.Login;
            ///Личное сообщение
            if (item.Login != myLogin)
            {
                listMenu.Add(new FloatMenuOption("OCity_Dialog_PrivateMessage".Translate(), () =>
                {
                    var privateChat = String.Compare(myLogin, item.Login) < 0
                        ? myLogin + " · " + item.Login
                        : item.Login + " · " + myLogin;
                    var index = lbCannals.DataSource.IndexOf(privateChat);
                    if (index >= 0)
                    {
                        lbCannals.SelectedIndex = index;
                        return;
                    }
                    //создаем канал
                    var mainCannal = SessionClientController.Data.Chats[0];
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(mainCannal.Id, "/createChat '" + privateChat.Replace("'", "''") + "' '" + item.Login.Replace("'", "''") + "'");
                    });

                    lbCannalsGoToChat = privateChat;
                }));
            }

            ///Добавить участника
            if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
            {
                var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];

                if (!item.InChat)
                {
                    listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelAddUser".Translate(), () =>
                    {
                        SessionClientController.Command((connect) =>
                        {
                            connect.PostingChat(selectCannal.Id, "/addPlayer '" + item.Login.Replace("'", "''") + "'");
                        });
                    }));
                }
            }

            if (SessionClientController.Data.Players.ContainsKey(item.Login))
                listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelPlayerInfo".Translate(), () =>
                {
                    var pl = SessionClientController.Data.Players[item.Login];
                    Dialog_MainOnlineCity.ShowInfo("OCity_Dialog_ChennelPlayerInforeplacedle".Translate() + item.Login, pl.GetTextInfo());
                }));

            if (listMenu.Count == 0) return;
            var menu = new FloatMenu(listMenu);
            Find.WindowStack.Add(menu);
        }

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

[HandleProcessCorruptedStateExceptions]
        private bool TryToLoadPlugin(ProgramSettings settings, IList<Plugin> plugins, string fileName, out IntPtr pluginHandle, out Plugin plugin)
        {
            pluginHandle = IntPtr.Zero;
            plugin = null;
            foreach (var sourcePlugin in plugins)
            {
                try
                {
                    PluginInfo pluginInfo = settings.Plugins.FirstOrDefault(x => string.Compare(x.Path, sourcePlugin.ModuleName) == 0);
                    string extension = Path.GetExtension(fileName).TrimStart('.');
                    if (pluginInfo.Extensions.Count == 0 || pluginInfo.Extensions.Contains(extension.ToLower()) || pluginInfo.Extensions.Contains(extension.ToUpper()))
                    {
                        pluginHandle = sourcePlugin.ListLoad(pnlLister.Handle, fileName);
                    }
                }
                catch
                {
                }

                if (pluginHandle != IntPtr.Zero)
                {
                    plugin = sourcePlugin;
                    break;
                }
            }
            return pluginHandle != IntPtr.Zero;
        }

19 View Source File : Hyphenator.cs
License : MIT License
Project Creator : adamped

private void hyphenateWithNoPatterns(HyphenationType[] result, UInt16[] word, int len, icu.Locale locale)
  {
	result[0] = HyphenationType.DONT_BREAK;
	for (int i = 1; i < len; i++)
	{
	  UInt16 prevChar = word[i - 1];
	  if (i > 1 && isLineBreakingHyphen(new UInt16(prevChar)))
	  {
		// Break after hyphens, but only if they don't start the word.

		if ((prevChar == GlobalMembers.CHAR_HYPHEN_MINUS || prevChar == GlobalMembers.CHAR_HYPHEN) && string.Compare(locale.getLanguage(), "pl") == 0 && minikin.GlobalMembers.getScript(word[i]) == USCRIPT_LATIN)
		{
		  // In Polish, hyphens get repeated at the next line. To be safe,
		  // we will do this only if the next character is Latin.
		  result[i] = HyphenationType.BREAK_AND_INSERT_HYPHEN_AT_NEXT_LINE;
		}
		else
		{
		  result[i] = HyphenationType.BREAK_AND_DONT_INSERT_HYPHEN;
		}
	  }
	  else if (i > 1 && prevChar == GlobalMembers.CHAR_SOFT_HYPHEN)
	  {
		// Break after soft hyphens, but only if they don't start the word (a soft
		// hyphen starting the word doesn't give any useful break opportunities).
		// The type of the break is based on the script of the character we break
		// on.
		if (minikin.GlobalMembers.getScript(word[i]) == USCRIPT_ARABIC)
		{
		  // For Arabic, we need to look and see if the characters around the soft
		  // hyphen actually join. If they don't, we'll just insert a normal
		  // hyphen.
		  result[i] = minikin.GlobalMembers.getHyphTypeForArabic(new UInt16(word), len, i);
		}
		else
		{
		  result[i] = minikin.GlobalMembers.hyphenationTypeBasedOnScript(word[i]);
		}
	  }
	  else if (prevChar == GlobalMembers.CHAR_MIDDLE_DOT && minPrefix < i && i <= len - minSuffix && ((word[i - 2] == 'l' && word[i] == 'l') || (word[i - 2] == 'L' && word[i] == 'L')) && string.Compare(locale.getLanguage(), "ca") == 0)
	  {
		// In Catalan, "l·l" should break as "l-" on the first line
		// and "l" on the next line.
		result[i] = HyphenationType.BREAK_AND_REPLACE_WITH_HYPHEN;
	  }
	  else
	  {
		result[i] = HyphenationType.DONT_BREAK;
	  }
	}
  }

19 View Source File : RegistryKey.cs
License : MIT License
Project Creator : ADeltaX

private RegistryValue AddRegistryValue(string name)
        {
            byte[] valueList = _hive.RawCellData(_cell.ValueListIndex, _cell.NumValues * 4);
            if (valueList == null)
            {
                valueList = new byte[0];
            }

            int insertIdx = 0;
            while (insertIdx < _cell.NumValues)
            {
                int valueCellIndex = EndianUtilities.ToInt32LittleEndian(valueList, insertIdx * 4);
                ValueCell cell = _hive.GetCell<ValueCell>(valueCellIndex);
                if (string.Compare(name, cell.Name, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    break;
                }

                ++insertIdx;
            }

            // Allocate a new value cell (note _hive.UpdateCell does actual allocation).
            ValueCell valueCell = new ValueCell(name);
            _hive.UpdateCell(valueCell, true);

            // Update the value list, re-allocating if necessary
            byte[] newValueList = new byte[_cell.NumValues * 4 + 4];
            Array.Copy(valueList, 0, newValueList, 0, insertIdx * 4);
            EndianUtilities.WriteBytesLittleEndian(valueCell.Index, newValueList, insertIdx * 4);
            Array.Copy(valueList, insertIdx * 4, newValueList, insertIdx * 4 + 4, (_cell.NumValues - insertIdx) * 4);
            if (_cell.ValueListIndex == -1 ||
                !_hive.WriteRawCellData(_cell.ValueListIndex, newValueList, 0, newValueList.Length))
            {
                int newListCellIndex = _hive.AllocateRawCell(MathUtilities.RoundUp(newValueList.Length, 8));
                _hive.WriteRawCellData(newListCellIndex, newValueList, 0, newValueList.Length);

                if (_cell.ValueListIndex != -1)
                {
                    _hive.FreeCell(_cell.ValueListIndex);
                }

                _cell.ValueListIndex = newListCellIndex;
            }

            // Record the new value and save this cell
            _cell.NumValues++;
            _hive.UpdateCell(_cell, false);

            // Finally, set the data in the value cell
            return new RegistryValue(_hive, valueCell);
        }

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

public static WeaponProperties GenerateRandomWeaponProperties(string categoryName, WeaponPropertiesTemplate template)
		{
			float chance = Random.value;

			float multiplier = 1f;

			WeaponRank rank = WeaponRank.Common;

			if (chance <= template.CommonRankChance)
			{
				multiplier = template.CommonRankMultiplier;

				rank = WeaponRank.Common;
			}
			else if (chance > template.CommonRankChance && chance <= template.UncommonRankChance)
			{
				multiplier = template.UncommonRankChance;

				rank = WeaponRank.Uncommon;
			}
			else if (chance > template.UncommonRankChance && chance <= template.RareRankChance)
			{
				multiplier = template.RareRankMultiplier;

				rank = WeaponRank.Rare;
			}
			else if (chance > template.RareRankChance && chance <= template.EpicRankChance)
			{
				multiplier = template.EpicRankMultiplier;

				rank = WeaponRank.Epic;
			}
			else if (chance > template.EpicRankChance && chance <= template.LegendaryRankChance)
			{
				multiplier = template.LegendaryRankMultiplier;

				rank = WeaponRank.Legendary;
			}

			for (int i = 0; i < template.Categories.Count; i++)
			{
				WeaponProperties category = template.Categories[i];

				if (category != null)
				{
					if (!string.IsNullOrEmpty(category.CategoryName) || !string.IsNullOrWhiteSpace(category.CategoryName))
					{
						if (string.Compare(category.CategoryName, categoryName) == 0)
						{
							return new WeaponProperties()
							{
								CategoryName = categoryName,

								Rank = rank,

								Damage = Random.Range(category.Damage, category.Damage * multiplier),
								Accuracy = Random.Range(category.Accuracy, Mathf.Max(0f, category.Accuracy - ((category.Accuracy * multiplier) - category.Accuracy))),
								Recoil = Random.Range(category.Recoil, Mathf.Max(0f, category.Recoil - ((category.Recoil * multiplier) - category.Recoil))),
								FireRate = Random.Range(category.FireRate, Mathf.Max(0f, category.FireRate - ((category.FireRate * multiplier) - category.FireRate))),

								ProjectilesPerShot = Mathf.RoundToInt(Random.Range(category.ProjectilesPerShot, category.ProjectilesPerShot * multiplier)),
								MagazineSize = Mathf.RoundToInt(Random.Range(category.MagazineSize, category.MagazineSize * multiplier)),
							};
						}
					}
				}
			}

			return new WeaponProperties();
		}

19 View Source File : RegistryKey.cs
License : MIT License
Project Creator : ADeltaX

private RegistryValue GetRegistryValue(string name)
        {
            if (name != null && name.Length == 0)
            {
                name = null;
            }

            if (_cell.NumValues != 0)
            {
                byte[] valueList = _hive.RawCellData(_cell.ValueListIndex, _cell.NumValues * 4);

                for (int i = 0; i < _cell.NumValues; ++i)
                {
                    int valueIndex = EndianUtilities.ToInt32LittleEndian(valueList, i * 4);
                    ValueCell cell = _hive.GetCell<ValueCell>(valueIndex);
                    if (string.Compare(cell.Name, name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return new RegistryValue(_hive, cell);
                    }
                }
            }

            return null;
        }

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

private static void ValidateIssuer(JsonWebToken token, JsonWebTokenValidationParameters parameters)
        {
            ArgumentUtility.CheckForNull(token, nameof(token));
            ArgumentUtility.CheckForNull(parameters, nameof(parameters));

            if (!parameters.ValidateIssuer)
            {
                return;
            }

            ArgumentUtility.CheckStringForNullOrEmpty(token.Issuer, nameof(token.Issuer));
            ArgumentUtility.CheckEnumerableForNullOrEmpty(parameters.ValidIssuers, nameof(parameters.ValidIssuers));

            foreach (string issuer in parameters.ValidIssuers)
            {
                if (string.Compare(issuer, token.Issuer, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return;
                }
            }

            throw new InvalidIssuerException(); //validation exception;
        }

19 View Source File : SubKeyIndirectListCell.cs
License : MIT License
Project Creator : ADeltaX

internal override int LinkSubKey(string name, int cellIndex)
        {
            // Look for the first sublist that has a subkey name greater than name
            if (ListType == "ri")
            {
                if (CellIndexes.Count == 0)
                {
                    throw new NotImplementedException("Empty indirect list");
                }

                for (int i = 0; i < CellIndexes.Count - 1; ++i)
                {
                    int tempIndex;
                    ListCell cell = _hive.GetCell<ListCell>(CellIndexes[i]);
                    if (cell.FindKey(name, out tempIndex) <= 0)
                    {
                        CellIndexes[i] = cell.LinkSubKey(name, cellIndex);
                        return _hive.UpdateCell(this, false);
                    }
                }

                ListCell lastCell = _hive.GetCell<ListCell>(CellIndexes[CellIndexes.Count - 1]);
                CellIndexes[CellIndexes.Count - 1] = lastCell.LinkSubKey(name, cellIndex);
                return _hive.UpdateCell(this, false);
            }
            for (int i = 0; i < CellIndexes.Count; ++i)
            {
                KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(CellIndexes[i]);
                if (string.Compare(name, cell.Name, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    CellIndexes.Insert(i, cellIndex);
                    return _hive.UpdateCell(this, true);
                }
            }

            CellIndexes.Add(cellIndex);
            return _hive.UpdateCell(this, true);
        }

19 View Source File : SubKeyHashedListCell.cs
License : MIT License
Project Creator : ADeltaX

private int FindKeyAt(string name, int listIndex, out int cellIndex)
        {
            Cell cell = _hive.GetCell<Cell>(_subKeyIndexes[listIndex]);
            if (cell == null)
            {
                cellIndex = 0;
                return -1;
            }

            ListCell listCell = cell as ListCell;
            if (listCell != null)
            {
                return listCell.FindKey(name, out cellIndex);
            }

            cellIndex = _subKeyIndexes[listIndex];
            return string.Compare(name, ((KeyNodeCell)cell).Name, StringComparison.OrdinalIgnoreCase);
        }

19 View Source File : ChildObject.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Child"));
		}

19 View Source File : SubKeyIndirectListCell.cs
License : MIT License
Project Creator : ADeltaX

private int DoFindKey(string name, int listIndex, out int cellIndex)
        {
            Cell cell = _hive.GetCell<Cell>(CellIndexes[listIndex]);
            ListCell listCell = cell as ListCell;
            if (listCell != null)
            {
                return listCell.FindKey(name, out cellIndex);
            }

            cellIndex = CellIndexes[listIndex];
            return string.Compare(name, ((KeyNodeCell)cell).Name, StringComparison.OrdinalIgnoreCase);
        }

19 View Source File : AudioManager.cs
License : MIT License
Project Creator : absurd-joy

static public string[] GetSoundFXNames( string currentValue, out int currentIdx ) {
		currentIdx = 0;
		names.Clear();
		if ( theAudioManager == null ) {
			if ( !FindAudioManager() ) {
				return defaultSound;
			}
		}
		names.Add( nullSound.name );
		for ( int group = 0; group < theAudioManager.soundGroupings.Length; group++ ) {
			for ( int i = 0; i < theAudioManager.soundGroupings[group].soundList.Length; i++ ) {
				if ( string.Compare( currentValue, theAudioManager.soundGroupings[group].soundList[i].name, true ) == 0 ) {
					currentIdx = names.Count;
				}
				names.Add( theAudioManager.soundGroupings[group].name + "/" + theAudioManager.soundGroupings[group].soundList[i].name );
			}
		}
		//names.Sort( delegate( string s1, string s2 ) { return s1.CompareTo( s2 ); } );
		return names.ToArray();

	}

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

object IExpressionBuilderProvider.Evaluate(NameValueCollection arguments, Type controlType, string propertyName, string expressionPrefix)
			{
				var name = arguments.GetValueByIndexOrName(0, "Name");
				var eval = arguments.GetValueByIndexOrName(1, "Eval");

				if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(eval))
				{
					ThrowException(propertyName, expressionPrefix);
				}

				var format = arguments.GetValueByIndexOrName(2, "Format");
				var portalName = arguments.GetValueByIndexOrName(3, "Portal");
				var portal = PortalCrmConfigurationManager.CreatePortalContext(portalName);
				var timeZone = portal.GetTimeZone();

				if (!string.IsNullOrWhiteSpace(name))
				{
					if (string.Compare(name, "id", StringComparison.InvariantCultureIgnoreCase) == 0)
					{
						return timeZone.Id;
					}

					if (string.Compare(name, "displayname", StringComparison.InvariantCultureIgnoreCase) == 0)
					{
						return timeZone.DisplayName;
					}

					ThrowException(propertyName, expressionPrefix);
				}

				return timeZone != null
					? GetEvalData(timeZone, null, eval, format)
					: null;
			}

19 View Source File : ChildObject1.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Child1"));
		}

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

private static void PerformEmbrace(NPC npc, Vector2 midpoint, string partner)
        {
            string name = npc.Name;
            int spouseFrame = Misc.GetKissingFrame(name);
            bool facingRight = Misc.GetFacingRight(name);

            List<string> customFrames = Config.CustomKissFrames.Split(',').ToList();
            foreach(string nameframe in customFrames)
            {
                if (nameframe.StartsWith(name + ":"))
                {
                    int.TryParse(nameframe.Substring(name.Length + 1), out spouseFrame);
                    break;
                }
            }
            

            bool right = npc.position.X < midpoint.X;
            if(npc.position == midpoint)
            {
                right = String.Compare(npc.Name, partner) < 0;
            }
            else if(npc.position.X == midpoint.X)
            {
                right = npc.position.Y > midpoint.Y;
            }

            bool flip = (facingRight && !right) || (!facingRight && right);

            int offset = 24;
            if (right)
                offset *= -1;

            npc.position.Value = new Vector2(midpoint.X+offset,midpoint.Y);

            int delay = 1000;
            npc.movementPause = delay;
            npc.Sprite.setCurrentAnimation(new List<FarmerSprite.AnimationFrame>
                {
                    new FarmerSprite.AnimationFrame(spouseFrame, delay, false, flip, new AnimatedSprite.endOfAnimationBehavior(npc.haltMe), true)
                });
            npc.Sprite.UpdateSourceRect();
        }

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

private static Transform RecursiveFindBoneInHierarchy(Transform bone, Transform hierarchyRoot, Dictionary<Transform, Transform> boneMap)
	    {
			if (bone == null)
			{
				return null;
			}

	        Transform res;
	        if (boneMap.TryGetValue(bone, out res))
	        {
	            return res;
	        }
	        if (string.Compare(hierarchyRoot.name, bone.name) == 0)
	        {
	            boneMap.Add(bone, hierarchyRoot);
	            return hierarchyRoot;
	        }
	        else
	        {
				res = null;
				var parent = RecursiveFindBoneInHierarchy(bone.parent, hierarchyRoot, boneMap);
	            if (parent != null)
				{
					res = parent.Find(bone.name);
					if (res != null)
					{
						boneMap.Add(bone, res);
					}
				}

	            return res;
	        }
	    }

19 View Source File : FileExplorer.cs
License : MIT License
Project Creator : aerosoul94

public int Compare(object x, object y)
            {
                // Default, don't swap order.
                int result = 0;

                ListViewItem itemX = (ListViewItem)x;
                ListViewItem itemY = (ListViewItem)y;

                if (itemX.Tag == null ||
                    itemY.Tag == null)
                {
                    return result;
                }

                if (itemX.Index == 0)
                {
                    // Skip "up" item
                    return result;
                }

                DirectoryEntry direntX = (DirectoryEntry)((NodeTag)itemX.Tag).Tag;
                DirectoryEntry direntY = (DirectoryEntry)((NodeTag)itemY.Tag).Tag;

                switch (column)
                {
                    case ColumnIndex.Index:
                        result = UInt32.Parse(itemX.Text).CompareTo(UInt32.Parse(itemY.Text));
                        break;
                    case ColumnIndex.Name:
                        result = String.Compare(direntX.FileName, direntY.FileName);
                        break;
                    case ColumnIndex.Size:
                        result = direntX.FileSize.CompareTo(direntY.FileSize);
                        break;
                    case ColumnIndex.Created:
                        result = direntX.CreationTime.AsDateTime().CompareTo(direntY.CreationTime.AsDateTime());
                        break;
                    case ColumnIndex.Modified:
                        result = direntX.LastWriteTime.AsDateTime().CompareTo(direntY.LastWriteTime.AsDateTime());
                        break;
                    case ColumnIndex.Accessed:
                        result = direntX.LastAccessTime.AsDateTime().CompareTo(direntY.LastAccessTime.AsDateTime());
                        break;
                    case ColumnIndex.Offset:
                        result = direntX.Offset.CompareTo(direntY.Offset);
                        break;
                    case ColumnIndex.Cluster:
                        result = direntX.Cluster.CompareTo(direntY.Cluster);
                        break;
                }

                if (order == SortOrder.Ascending)
                {
                    return result;
                }
                else
                {
                    return -result;
                }
            }

19 View Source File : ChildObject4.cs
License : MIT License
Project Creator : Actipro

protected override bool ShouldSerializeName() {
			return (0 != string.Compare(this.Name, "Child4"));
		}

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

public virtual int Compare(TreeNode x, TreeNode y) {
            if (x is DirectoryRecord)
                if (y is DirectoryRecord)
                    return string.Compare(x.Name, y.Name);
                else
                    return -1;
            else
                if (y is DirectoryRecord)
                    return 1;
                else
                    return string.Compare(x.Name, y.Name);
        }

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

[System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "y")]
        [System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "x")]
        public int Compare(string x, int indexX, string y, int indexY, int length) { return String.Compare(x, indexX, y, indexY, length, m_stringComparison); }

19 View Source File : AdminLoginController.cs
License : MIT License
Project Creator : albyho

[HttpPost]
        [Route("Login")]
        [AllowAnonymous]
        public async Task<ApiResultDataUrl<ApiResultTokenData>> Login(AccountPreplacedwordValidationCodeLoginInput input)
        {
            var result = new ApiResultDataUrl<ApiResultTokenData>();
            var validationCode = HttpContext.Session.GetString(ValidationCodeKey);
            if (validationCode == null)
            {
                result.Code = 400;
                result.Message = "验证码已到期,请重新输入";
                return result;
            }

            if (String.Compare(validationCode, input.ValidationCode, StringComparison.OrdinalIgnoreCase) != 0)
            {
                result.Code = 400;
                result.Message = "请输入正确的验证码";
                return result;
            }

            HttpContext.Session.Remove(ValidationCodeKey);

            var userInfo = await _userService.GetNormalUserAsync(input.Account, input.Preplacedword);
            if (userInfo == null)
            {
                result.Code = 400;
                result.Message = "账号或密码错误,或用户状态不允许登录";
                return result;
            }

            await _userActionLogService.SaveAsync(new UserActionLogInput
            {
                UserId = userInfo.UserId,
                ActionTypeId = 1,
                ClientTypeId = input.ClientTypeId,
                ClientAgent = input.ClientAgent,
                Remark = "后台登录"
            }, ModelState);

            result.Data = await _tokenService.GenerateApiResultTokenData(userInfo);
            result.Url = _frontendSettings.CoreEnvironment.IsDevelopment ? _frontendSettings.CoreEnvironment.DevelopmentHost + "/modules/index.html" : Url.Action("Index", "View");
            result.Code = 200;
            result.Message = "登录成功";

            return result;
        }

19 View Source File : ApplicationViewModel.cs
License : MIT License
Project Creator : Actipro

private ProducreplacedemInfo FindProductInfo(Uri uri) {
			if ((uri != null) && (productData != null)) {
				var targetPath = uri.LocalPath;

				foreach (var familyInfo in productData.ProductFamilies) {
					if ((familyInfo.OverviewItem != null) && (string.Compare(familyInfo.OverviewItem.Path, targetPath, StringComparison.OrdinalIgnoreCase) == 0))
						return familyInfo.OverviewItem;

					foreach (var itemInfo in familyInfo.Items) {
						if (string.Compare(itemInfo.Path, targetPath, StringComparison.OrdinalIgnoreCase) == 0)
							return itemInfo;
					}
				}

				foreach (var itemInfo in productData.Utilities.Items) {
					if (string.Compare(itemInfo.Path, targetPath, StringComparison.OrdinalIgnoreCase) == 0)
						return itemInfo;
				}
			}

			return null;
		}

19 View Source File : RandomOrgClient.cs
License : MIT License
Project Creator : alexanderkozlenko

private async Task<JsonRpcResponse> SendJsonRpcRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken)
        {
            var requestId = request.Id;

            using (var requestStream = new MemoryStream())
            {
                _jsonRpcSerializer.SerializeRequest(request, requestStream);

                requestStream.Position = 0;

                using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, s_serviceUri))
                {
                    var requestContent = new StreamContent(requestStream);

                    requestContent.Headers.Add("Content-Type", s_contentTypeHeaderValue);

                    httpRequest.Content = requestContent;
                    httpRequest.Headers.Date = DateTime.UtcNow;
                    httpRequest.Headers.ExpectContinue = false;
                    httpRequest.Headers.Add("Accept", JsonRpcTransport.MediaType);
                    httpRequest.Headers.Add("Accept-Charset", JsonRpcTransport.Charset);
                    httpRequest.Headers.Add("User-Agent", s_userAgentHeaderValue);

                    using (var httpResponse = await _httpInvoker.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false))
                    {
                        if (httpResponse.StatusCode != HttpStatusCode.OK)
                        {
                            throw new RandomOrgProtocolException(httpResponse.StatusCode, Strings.GetString("protocol.http.status_code.invalid_value"));
                        }

                        var contentTypeHeaderValue = httpResponse.Content.Headers.ContentType;

                        if (contentTypeHeaderValue is null)
                        {
                            throw new RandomOrgProtocolException(httpResponse.StatusCode, Strings.GetString("protocol.http.headers.content_type.invalid_value"));
                        }
                        if (!contentTypeHeaderValue.MediaType.Equals(JsonRpcTransport.MediaType, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new RandomOrgProtocolException(httpResponse.StatusCode, Strings.GetString("protocol.http.headers.content_type.invalid_value"));
                        }
                        if ((contentTypeHeaderValue.CharSet is not null) && (string.Compare(contentTypeHeaderValue.CharSet, JsonRpcTransport.Charset, StringComparison.OrdinalIgnoreCase) != 0))
                        {
                            throw new RandomOrgProtocolException(httpResponse.StatusCode, Strings.GetString("protocol.http.headers.content_type.invalid_value"));
                        }

                        var responseData = default(JsonRpcData<JsonRpcResponse>);

                        using (var responseStream = await httpResponse.Content.ReadreplacedtreamAsync(cancellationToken).ConfigureAwait(false))
                        {
                            _jsonRpcContractResolver.AddResponseBinding(requestId, request.Method);

                            try
                            {
                                responseData = await _jsonRpcSerializer.DeserializeResponseDataAsync(responseStream, cancellationToken).ConfigureAwait(false);
                            }
                            catch (JsonException e)
                            {
                                throw new RandomOrgClientException(Strings.GetString("protocol.rpc.message.invalid_value"), e);
                            }
                            catch (JsonRpcException e)
                            {
                                throw new RandomOrgClientException(Strings.GetString("protocol.rpc.message.invalid_value"), e);
                            }
                            finally
                            {
                                _jsonRpcContractResolver.RemoveResponseBinding(requestId);
                            }
                        }

                        if (responseData.IsBatch)
                        {
                            throw new RandomOrgProtocolException(httpResponse.StatusCode, Strings.GetString("protocol.random.message.invalid_value"));
                        }

                        var responseItem = responseData.Item;

                        if (!responseItem.IsValid)
                        {
                            throw new RandomOrgClientException(Strings.GetString("protocol.random.message.invalid_value"), responseItem.Exception);
                        }

                        var response = responseItem.Message;

                        if (!response.Success)
                        {
                            throw new RandomOrgException(request.Method, response.Error.Code, response.Error.Message);
                        }
                        if (response.Result is null)
                        {
                            throw new RandomOrgClientException(Strings.GetString("protocol.random.message.invalid_value"));
                        }

                        return response;
                    }
                }
            }
        }

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

public int CompareTo(TableRef? other)
        {
            if (ReferenceEquals(this, other)) return 0;
            if (ReferenceEquals(null, other)) return 1;
            var schemaComparison = string.Compare(this.Schema, other.Schema, StringComparison.Ordinal);
            if (schemaComparison != 0) return schemaComparison;
            return string.Compare(this.Name, other.Name, StringComparison.Ordinal);
        }

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

static void ProcessCommandLine(ToggleParser toggleParser)
        {
            // Clear Clipboard
            if (toggleParser.HasToggle("clearclipboard"))
            {
                Clipboard.Clear();
            }

            var windowHandles = new List<IntPtr>();
            var processId = (int?)null;
            if (toggleParser.HasToggle("processId"))
            {
                var processIdString = toggleParser.GetToggleValueOrDefault("processId", null);
                processId = !string.IsNullOrWhiteSpace(processIdString) && int.TryParse(processIdString, out var pid) ? pid : (int?)null;
            }

            if (toggleParser.HasToggle("handle"))
            {
                var windowHandleString = toggleParser.GetToggleValueOrDefault("handle", null);
                if (!string.IsNullOrWhiteSpace(windowHandleString))
                {
                    var windowHandle = windowHandleString.StartsWith("0x") ? int.TryParse(windowHandleString.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier, null, out var number) ? new IntPtr(number) :
                        IntPtr.Zero : int.TryParse(windowHandleString, out var number2) ? new IntPtr(number2) : IntPtr.Zero;
                    windowHandles.Add(windowHandle);
                }
            }

            if (toggleParser.HasToggle("replacedle"))
            {
                var windowreplacedle = toggleParser.GetToggleValueOrDefault("replacedle", null);
                var handles = WindowUtils.FindWindowByreplacedle(windowreplacedle, processId, (value, replacedle) => string.Compare(value, replacedle, true) == 0);
                windowHandles.AddRange(handles);
            }

            if (toggleParser.HasToggle("replacedleBegins"))
            {
                var windowreplacedle = toggleParser.GetToggleValueOrDefault("replacedleBegins", null);
                var handles = WindowUtils.FindWindowByreplacedle(windowreplacedle, processId, (value, replacedle) => replacedle.StartsWith(value, StringComparison.OrdinalIgnoreCase));
                windowHandles.AddRange(handles);
            }

            if (toggleParser.HasToggle("replacedleEnds"))
            {
                var windowreplacedle = toggleParser.GetToggleValueOrDefault("replacedleEnds", null);
                var handles = WindowUtils.FindWindowByreplacedle(windowreplacedle, processId, (value, replacedle) => replacedle.EndsWith(value, StringComparison.OrdinalIgnoreCase));
                windowHandles.AddRange(handles);
            }

            if (toggleParser.HasToggle("replacedleContains"))
            {
                var windowreplacedle = toggleParser.GetToggleValueOrDefault("replacedleContains", null);
                var handles = WindowUtils.FindWindowByreplacedle(windowreplacedle, processId, (value, replacedle) => replacedle.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0);
                windowHandles.AddRange(handles);
            }


            foreach (var windowHandle in windowHandles.Where(x => x != IntPtr.Zero))
            {
                var window = new Window(windowHandle);

                // Set a Window monitor
                if (toggleParser.HasToggle("m") || toggleParser.HasToggle("monitor"))
                {
                    var monitorString = toggleParser.GetToggleValueOrDefault("m", null) ?? toggleParser.GetToggleValueOrDefault("monitor", null);
                    if (int.TryParse(monitorString, out var monitor))
                    {
                        var monitorItem = SystemUtils.GetMonitors().Select((x, i) => new { Index = i, MonitorHandle = x }).FirstOrDefault(x => x.Index == monitor);
                        if (monitorItem != null)
                        {
                            window.MoveToMonitor(monitorItem.MonitorHandle);
                        }
                    }
                }

                // Set a Window width
                if (toggleParser.HasToggle("width"))
                {
                    if (int.TryParse(toggleParser.GetToggleValueOrDefault("width", null), out var width))
                    {
                        window.SetWidth(width);
                    }
                }

                // Set a Window height
                if (toggleParser.HasToggle("height"))
                {
                    if (int.TryParse(toggleParser.GetToggleValueOrDefault("height", null), out var height))
                    {
                        window.SetHeight(height);
                    }
                }

                // Set a Window left position
                if (toggleParser.HasToggle("left"))
                {
                    if (int.TryParse(toggleParser.GetToggleValueOrDefault("left", null), out var left))
                    {
                        window.SetLeft(left);
                    }
                }

                // Set a Window top position
                if (toggleParser.HasToggle("top"))
                {
                    if (int.TryParse(toggleParser.GetToggleValueOrDefault("top", null), out var top))
                    {
                        window.SetTop(top);
                    }
                }

                // Set a Window position
                if (toggleParser.HasToggle("a") || toggleParser.HasToggle("alignment"))
                {
                    var windowAlignmentString = toggleParser.GetToggleValueOrDefault("a", null) ?? toggleParser.GetToggleValueOrDefault("alignment", null);
                    var windowAlignment = Enum.TryParse<WindowAlignment>(windowAlignmentString, true, out var alignment) ? alignment : 0;
                    window.SetAlignment(windowAlignment);
                }

                // Set a Window transparency
                if (toggleParser.HasToggle("t") || toggleParser.HasToggle("transparency"))
                {
                    var transparencyString = toggleParser.GetToggleValueOrDefault("t", null) ?? toggleParser.GetToggleValueOrDefault("transparency", null);
                    if (byte.TryParse(transparencyString, out var transparency))
                    {
                        transparency = transparency > 100 ? (byte)100 : transparency;
                        window.SetTransparency(transparency);
                    }
                }

                // Set a Process priority
                if (toggleParser.HasToggle("p") || toggleParser.HasToggle("priority"))
                {
                    var processPriorityString = toggleParser.GetToggleValueOrDefault("p", null) ?? toggleParser.GetToggleValueOrDefault("priority", null);
                    var processPriority = Enum.TryParse<Priority>(processPriorityString, true, out var priority) ? priority : 0;
                    window.SetPriority(processPriority);
                }

                // Set a Window AlwaysOnTop
                if (toggleParser.HasToggle("alwaysontop"))
                {
                    var alwaysontopString = toggleParser.GetToggleValueOrDefault("alwaysontop", string.Empty).ToLower();

                    if (alwaysontopString == "on")
                    {
                        window.MakeTopMost(true);
                    }

                    if (alwaysontopString == "off")
                    {
                        window.MakeTopMost(false);
                    }
                }

                // Set a Window Aero Glreplaced
                if (toggleParser.HasToggle("g") || toggleParser.HasToggle("aeroglreplaced"))
                {
                    var aeroglreplacedString = (toggleParser.GetToggleValueOrDefault("g", null) ?? toggleParser.GetToggleValueOrDefault("aeroglreplaced", string.Empty)).ToLower();
                    var enabled = aeroglreplacedString == "on" ? true : aeroglreplacedString == "off" ? false : (bool?)null;

                    if (enabled.HasValue)
                    {
                        var version = Environment.OSVersion.Version;
                        if (version.Major == 6 && (version.Minor == 0 || version.Minor == 1))
                        {
                            window.AeroGlreplacedForVistaAndSeven(enabled.Value);
                        }
                        else if (version.Major >= 6)
                        {
                            window.AeroGlreplacedForEightAndHigher(enabled.Value);
                        }
                    }
                }

                // Send To Bottom Window
                if (toggleParser.HasToggle("sendtobottom"))
                {
                    window.SendToBottom();
                }

                // Open File In Explorer
                if (toggleParser.HasToggle("o") || toggleParser.HasToggle("openinexplorer"))
                {
                    try
                    {
                        SystemUtils.RunAsDesktopUser("explorer.exe", "/select, " + window.Process.GetMainModuleFileName());
                    }
                    catch
                    {
                    }
                }

                // Copy to clipboard
                if (toggleParser.HasToggle("c") || toggleParser.HasToggle("copytoclipboard"))
                {
                    var text = window.ExtractText();
                    if (text != null)
                    {
                        Clipboard.SetText(text);
                    }
                }

                //Information dialog
                if (toggleParser.HasToggle("i") || toggleParser.HasToggle("information"))
                {
                    var settingsFileName = Path.Combine(replacedemblyUtils.replacedemblyDirectory, "SmartSystemMenu.xml");
                    var languageFileName = Path.Combine(replacedemblyUtils.replacedemblyDirectory, "Language.xml");
                    var settings = SmartSystemMenuSettings.Read(settingsFileName, languageFileName);
                    var dialog = new InfoForm(window.GetWindowInfo(), settings.LanguageSettings);
                    dialog.ShowDialog();
                }

                //Save Screenshot
                if (toggleParser.HasToggle("s") || toggleParser.HasToggle("savescreenshot"))
                {
                    var settingsFileName = Path.Combine(replacedemblyUtils.replacedemblyDirectory, "SmartSystemMenu.xml");
                    var languageFileName = Path.Combine(replacedemblyUtils.replacedemblyDirectory, "Language.xml");
                    var settings = SmartSystemMenuSettings.Read(settingsFileName, languageFileName);
                    var bitmap = WindowUtils.PrintWindow(window.Handle);
                    var dialog = new SaveFileDialog
                    {
                        OverwritePrompt = true,
                        ValidateNames = true,
                        replacedle = settings.LanguageSettings.GetValue("save_screenshot_replacedle"),
                        FileName = settings.LanguageSettings.GetValue("save_screenshot_filename"),
                        DefaultExt = settings.LanguageSettings.GetValue("save_screenshot_default_ext"),
                        RestoreDirectory = false,
                        Filter = settings.LanguageSettings.GetValue("save_screenshot_filter")
                    };
                    if (dialog.ShowDialog(window.Win32Window) == DialogResult.OK)
                    {
                        var fileExtension = Path.GetExtension(dialog.FileName).ToLower();
                        var imageFormat = fileExtension == ".bmp" ? ImageFormat.Bmp :
                            fileExtension == ".gif" ? ImageFormat.Gif :
                            fileExtension == ".jpeg" ? ImageFormat.Jpeg :
                            fileExtension == ".png" ? ImageFormat.Png :
                            fileExtension == ".tiff" ? ImageFormat.Tiff : ImageFormat.Wmf;
                        bitmap.Save(dialog.FileName, imageFormat);
                    }
                }
            }
        }

19 View Source File : NamespaceComparer.cs
License : MIT License
Project Creator : adamant

public int Compare(string? x, string? y)
        {
            var xParts = x!.Split('.');
            var yParts = y!.Split('.');

            if (xParts[0] == "System" && yParts[0] != "System") return -1;
            if (xParts[0] != "System" && yParts[0] == "System") return 1;

            var length = Math.Min(xParts.Length, yParts.Length);
            for (int i = 0; i < length; i++)
            {
                var cmp = string.Compare(xParts[i], yParts[i], StringComparison.InvariantCulture);
                if (cmp != 0) return cmp;
            }

            return xParts.Length.CompareTo(yParts.Length);
        }

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

internal static IEnumerable<Claim> TranslateFromJwtClaims(IDictionary<string, object> claims)
        {
            ArgumentUtility.CheckForNull(claims, nameof(claims));

            List<Claim> ret = new List<Claim>();

            //there are two claim names that get special treatment
            foreach (var claim in claims)
            {
                string claimName = claim.Key;
                if (string.Compare(claimName, JsonWebTokenClaims.NameId, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.NameIdLongName;
                }
                else if (string.Compare(claimName, JsonWebTokenClaims.IdenreplacedyProvider, StringComparison.Ordinal) == 0)
                {
                    claimName = JsonWebTokenClaims.IdenreplacedyProviderLongName;
                }

                ret.Add(new Claim(claimName, claim.Value.ToString()));
            }

            return ret;
        }

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

public int CompareTo(ColumnRef? other)
        {
            if (ReferenceEquals(this, other)) return 0;
            if (ReferenceEquals(null, other)) return 1;
            var tableComparison = this.Table.CompareTo(other.Table);
            if (tableComparison != 0) return tableComparison;
            return string.Compare(this.Name, other.Name, StringComparison.Ordinal);
        }

19 View Source File : UserCommandHandler.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826

public async Task<Unit> Handle(ResetPreplacedwordCommand command, CancellationToken cancellationToken)
        {
            var email = command.Email;
            var code = command.Code;
            var preplacedword = command.Preplacedword;

            var user = await _userDomainService.Get(p => p.Email == email);
            if (user == null)
            {
                await _bus.RaiseEvent(new DomainNotification("输入信息有误,请确认邮箱是否无误"));
                return Unit.Value;
            }

            string key = string.Format(RedisKey.ResetPreplacedword, user.Id);// $"resetpreplacedword_{user.Id}";
            long ttl = await _redisDb.KeyTimeToLive(key);
            if (ttl < 0)
            {
                await _bus.RaiseEvent(new DomainNotification($"找回密码验证码已超时,请重试"));
                return Unit.Value;
            }

            string emailCode = await _redisDb.StringGet<string>(key);

            if (string.Compare(emailCode ,code,true) != 0)
            {
                await _bus.RaiseEvent(new DomainNotification($"找回密码验证码已失效,请重试"));
                return Unit.Value;
            }

            await _redisDb.KeyDelete(key);

            user.Preplacedword = preplacedword.ToMd5();
            await _userDomainService.Update(user);

            if (await Commit())
            {
                await _bus.RaiseEvent(new ResetPreplacedwordEvent(user)).ConfigureAwait(false);
            }

            return Unit.Value;
        }

19 View Source File : AudioManagerInspector.cs
License : MIT License
Project Creator : absurd-joy

void DrawCategories( Event e ) {

		// do any housework before we start drawing
		if ( moveQueued ) {
			// make a temp copy
			List<SoundFX> origSoundList = new List<SoundFX>( audioManager.soundGroupings[origGroup].soundList );
			SoundFX temp = origSoundList[origIndex];
			List<SoundFX> moveToSoundList = new List<SoundFX>( audioManager.soundGroupings[moveToGroup].soundList );
			// add it to the move to group
			moveToSoundList.Add( temp );
			audioManager.soundGroupings[moveToGroup].soundList = moveToSoundList.ToArray();
			// and finally, remove it from the original group
			origSoundList.RemoveAt( origIndex );
			audioManager.soundGroupings[origGroup].soundList = origSoundList.ToArray();
			Debug.Log( "> Moved '" + temp.name + "' from " + "'" + audioManager.soundGroupings[origGroup].name + "' to '" + audioManager.soundGroupings[moveToGroup].name );
			MarkDirty();
			moveQueued = false;
		}
		// switch to the next group
		if ( nextGroup > -1 ) {
			selectedGroup = nextGroup;
			nextGroup = -1;
		}
		// add a sound
		if ( addSound ) {
			List<SoundFX> soundList = new List<SoundFX>( audioManager.soundGroupings[selectedGroup].soundList );
			SoundFX soundFX = new SoundFX();
			soundFX.name = audioManager.soundGroupings[selectedGroup].name.ToLower() + "_new_unnamed_sound_fx";
			soundList.Add( soundFX );
			audioManager.soundGroupings[selectedGroup].soundList = soundList.ToArray();
			MarkDirty();
			addSound = false;
		}
		// sort the sounds
		if ( sortSounds ) {
			List<SoundFX> soundList = new List<SoundFX>( audioManager.soundGroupings[selectedGroup].soundList );
			soundList.Sort( delegate ( SoundFX sfx1, SoundFX sfx2 ) { return string.Compare( sfx1.name, sfx2.name ); } );
			audioManager.soundGroupings[selectedGroup].soundList = soundList.ToArray();
			MarkDirty();
			sortSounds = false;
		}
		// delete a sound
		if ( deleteSoundIdx > -1 ) {
			List<SoundFX> soundList = new List<SoundFX>( audioManager.soundGroupings[selectedGroup].soundList );
			soundList.RemoveAt( deleteSoundIdx );
			audioManager.soundGroupings[selectedGroup].soundList = soundList.ToArray();
			MarkDirty();
			deleteSoundIdx = -1;
		}
		// duplicate a sound
		if ( dupeSoundIdx > -1 ) {
			List<SoundFX> soundList = new List<SoundFX>( audioManager.soundGroupings[selectedGroup].soundList );
			SoundFX origSoundFX = soundList[dupeSoundIdx];
			// clone this soundFX
			string json = JsonUtility.ToJson( origSoundFX );
			SoundFX soundFX = JsonUtility.FromJson<SoundFX>( json );
			soundFX.name += "_duplicated";
			soundList.Insert( dupeSoundIdx + 1, soundFX );
			audioManager.soundGroupings[selectedGroup].soundList = soundList.ToArray();
			MarkDirty();
			dupeSoundIdx = -1;
		}

		if ( e.type == EventType.Repaint ) {
			groups.Clear();
		}

		GUILayout.Space( 6f );
		
		Color defaultColor = GUI.contentColor;
		BeginContents();

		if ( DrawHeader( "Sound FX Groups", true ) ) {
			EditorGUILayout.BeginVertical( GUI.skin.box );
			soundGroups.Clear();
			for ( int i = 0; i < audioManager.soundGroupings.Length; i++ ) {
				soundGroups.Add( audioManager.soundGroupings[i] );
			}
			for ( int i = 0; i < soundGroups.size; i++ ) {
				EditorGUILayout.BeginHorizontal();
				{
					if ( i == selectedGroup ) {
						GUI.contentColor = ( i == editGroup ) ? Color.white : Color.yellow;
					} else {
						GUI.contentColor = defaultColor;
					}
					if ( ( e.type == EventType.KeyDown ) && ( ( e.keyCode == KeyCode.Return ) || ( e.keyCode == KeyCode.KeypadEnter ) ) ) {
						// toggle editing
						if ( editGroup >= 0 ) {
							editGroup = -1;
						}
						Event.current.Use();
					}
					if ( i == editGroup ) {
						soundGroups[i].name = GUILayout.TextField( soundGroups[i].name, GUILayout.MinWidth( Screen.width - 80f ) );
					} else {
						GUILayout.Label( soundGroups[i].name, ( i == selectedGroup ) ? EditorStyles.whiteLabel : EditorStyles.label, GUILayout.ExpandWidth( true ) );
					}
					GUILayout.FlexibleSpace();
					if ( GUILayout.Button( GUIContent.none, "OL Minus", GUILayout.Width(17f) ) ) {	// minus button
						if ( EditorUtility.DisplayDialog( "Delete '" + soundGroups[i].name + "'", "Are you sure you want to delete the selected sound group?", "Continue", "Cancel" ) ) {
							soundGroups.RemoveAt( i );
							MarkDirty();
						}
					}
				}
				EditorGUILayout.EndHorizontal();
				// build a list of items
				Rect lastRect = GUILayoutUtility.GetLastRect();
				if ( e.type == EventType.Repaint ) {
					groups.Add ( new ItemRect( i, lastRect, null ) );
				}
				if ( ( e.type == EventType.MouseDown ) && lastRect.Contains( e.mousePosition ) ) {
					if ( ( i != selectedGroup ) || ( e.clickCount == 2 ) ) {
						nextGroup = i;
						if ( e.clickCount == 2 ) {
							editGroup = i;
						} else if ( editGroup != nextGroup ) {
							editGroup = -1;
						}
						Repaint();
					}
				}
			}
			// add the final plus button
			EditorGUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();
			if ( GUILayout.Button( GUIContent.none, "OL Plus", GUILayout.Width(17f) ) ) {	// plus button
				soundGroups.Add( new SoundGroup( "unnamed sound group" ) );
				selectedGroup = editGroup = soundGroups.size - 1;
				MarkDirty();
			}
			EditorGUILayout.EndHorizontal();
			EditorGUILayout.EndVertical();

			// reset the color
			GUI.contentColor = defaultColor;

			// the sort and import buttons
			EditorGUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();
			if ( GUILayout.Button( "Sort", GUILayout.Width( 70f ) ) ) {
				soundGroups.Sort( delegate( SoundGroup sg1, SoundGroup sg2 ) { return string.Compare( sg1.name, sg2.name ); } );
				MarkDirty();
			}
			EditorGUILayout.EndHorizontal();

			// draw a rect around the selected item
			if ( ( selectedGroup >= 0 ) && ( selectedGroup < groups.size ) ) {
				EditorGUI.DrawRect( groups[selectedGroup].rect, new Color( 1f, 1f, 1f, 0.06f ) );      
			}

			// finally move the sound groups back into the audio manager
			if ( soundGroups.size > 0 ) {
				audioManager.soundGroupings = soundGroups.ToArray();
			}

			// calculate the drop area rect
			if ( ( e.type == EventType.Repaint ) && ( groups.size > 0 ) ) {
				dropArea.x = groups[0].rect.x;
				dropArea.y = groups[0].rect.y;
				dropArea.width = groups[0].rect.width;
				dropArea.height = ( groups[groups.size-1].rect.y - groups[0].rect.y ) + groups[groups.size-1].rect.height;
			}
		}
		// draw the sound group properties now
		DrawSoundGroupProperties();

		EndContents();

		EditorGUILayout.HelpBox("Create and delete sound groups by clicking + and - respectively.  Double click to rename sound groups.  Drag and drop sounds from below to the groups above to move them.", MessageType.Info);

	}

19 View Source File : ControlDataRepository.cs
License : MIT License
Project Creator : Actipro

public IEnumerable<ControlData> FindByCategory(string category) {
			return Controls.Where(x => string.Compare(x.Category, category, StringComparison.InvariantCultureIgnoreCase) == 0);
		}

19 View Source File : SubKeyHashedListCell.cs
License : MIT License
Project Creator : ADeltaX

public int Compare(int x, int y)
            {
                // TODO: Be more efficient at ruling out no-hopes by using the hash values
                KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(x);
                int result = string.Compare(cell.Name, _searchName, StringComparison.OrdinalIgnoreCase);
                if (result == 0)
                {
                    CellIndex = x;
                }

                return result;
            }

See More Examples