System.Convert.ToBoolean(System.DateTime)

Here are the examples of the csharp api System.Convert.ToBoolean(System.DateTime) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

892 Examples 7

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

private string ConvertTokenToXmlValue(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.String)
            {
                return (reader.Value != null) ? reader.Value.ToString() : null;
            }
            else if (reader.TokenType == JsonToken.Integer)
            {
#if !(NET20 || NET35 || PORTABLE || PORTABLE40)
                if (reader.Value is BigInteger)
                {
                    return ((BigInteger)reader.Value).ToString(CultureInfo.InvariantCulture);
                }
#endif

                return XmlConvert.ToString(Convert.ToInt64(reader.Value, CultureInfo.InvariantCulture));
            }
            else if (reader.TokenType == JsonToken.Float)
            {
                if (reader.Value is decimal)
                {
                    return XmlConvert.ToString((decimal)reader.Value);
                }
                if (reader.Value is float)
                {
                    return XmlConvert.ToString((float)reader.Value);
                }

                return XmlConvert.ToString(Convert.ToDouble(reader.Value, CultureInfo.InvariantCulture));
            }
            else if (reader.TokenType == JsonToken.Boolean)
            {
                return XmlConvert.ToString(Convert.ToBoolean(reader.Value, CultureInfo.InvariantCulture));
            }
            else if (reader.TokenType == JsonToken.Date)
            {
#if !NET20
                if (reader.Value is DateTimeOffset)
                {
                    return XmlConvert.ToString((DateTimeOffset)reader.Value);
                }
#endif

                DateTime d = Convert.ToDateTime(reader.Value, CultureInfo.InvariantCulture);
#if !PORTABLE
                return XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind));
#else
                return XmlConvert.ToString(d);
#endif
            }
            else if (reader.TokenType == JsonToken.Null)
            {
                return null;
            }
            else
            {
                throw JsonSerializationException.Create(reader, "Cannot get an XML string value from token type '{0}'.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }
        }

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

public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams );
			m_from = (TransformSpace)Enum.Parse( typeof( TransformSpace ), GetCurrentParam( ref nodeParams ) );
			m_to = (TransformSpace)Enum.Parse( typeof( TransformSpace ), GetCurrentParam( ref nodeParams ) );
			m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			if( UIUtils.CurrentShaderVersion() > 15800 )
			{
				m_inverseTangentType = (InverseTangentType)Enum.Parse( typeof( InverseTangentType ), GetCurrentParam( ref nodeParams ) );
			}
			UpdateSubreplacedle();
		}

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

public void HandleKeyboardCommand(CmdStruct cmdStruct, MotionCommand command)
        {
            // vfptr[12] - IsActive
            if (!IsActive()) return;

            bool start;

            if (cmdStruct.Command == MotionCommand.AutoRun)
            {
                start = Convert.ToBoolean(cmdStruct.Args[cmdStruct.Curr]);
                cmdStruct.Curr++;
                if (cmdStruct.Curr >= cmdStruct.Size)
                {
                    AutoRunSpeed = 1.0f;
                }
                else
                {
                    AutoRunSpeed = BitConverter.ToSingle(BitConverter.GetBytes(cmdStruct.Args[cmdStruct.Curr]));
                    cmdStruct.Curr++;
                }
                // vfptr[16].OnLoseFocus - ToggleAutoRun
                ToggleAutoRun();
                // vfptr[6].OnAction - SendMovementEvent
                SendMovementEvent();
                return;
            }

            if (((uint)cmdStruct.Command & (uint)CommandMask.UI) != 0)
                return;

            start = Convert.ToBoolean(cmdStruct.Args[cmdStruct.Curr]);
            cmdStruct.Curr++;

            var speed = 1.0f;
            if (cmdStruct.Curr < cmdStruct.Size)
            {
                speed = BitConverter.ToSingle(BitConverter.GetBytes(cmdStruct.Args[cmdStruct.Curr]));
                cmdStruct.Curr++;
            }

            if (ControlledByServer && !start)
            {
                // vfptr[1].OnLoseFocus - MovePlayer?
                MovePlayer((MotionCommand)cmdStruct.Command, start, speed, false, false);
                return;
            }

            // vfptr[8].OnLoseFocus(a2) - ACCmdInterp::TakeControlFromServer?
            TakeControlFromServer();

            if (cmdStruct.Command == MotionCommand.HoldRun‬)
            {
                // vfptr[2].OnLoseFocus

                if (!IsStandingStill())
                    SendMovementEvent();

                return;
            }

            if (cmdStruct.Command == MotionCommand.HoldSidestep)
            {
                // vfptr[3]

                if (!IsStandingStill())
                    SendMovementEvent();

                return;
            }

            // vfptr[2] - Bookkeep
            if (!BookkeepCommandAndModifyIfNecessary(cmdStruct.Command, start, speed, false, false))
            {
                SendMovementEvent();
                return;
            }

            // vfptr[4].OnAction - ApplyHoldKeysToCommand
            ApplyHoldKeysToCommand(ref cmdStruct.Command, speed);

            // vfptr[13].OnAction - MovePlayer
            MovePlayer(cmdStruct.Command, start, speed, false, false);

            // vfptr[6].OnAction - SendMovementEvent
            if (cmdStruct.Command != MotionCommand.Jump)
                SendMovementEvent();
        }

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

private void PopulateListControlIfFirstLoad(ListControl listControl)
		{
			if (listControl.Items.Count > 0)
			{
				return;
			}

			if (Metadata.IgnoreDefaultValue && listControl is DropDownList)
			{
				var empty = new Lisreplacedem(string.Empty, string.Empty);
				empty.Attributes["label"] = " ";
				listControl.Items.Add(empty);
			}

			if (Metadata.BooleanOptionSetMetadata.FalseOption.Value != null)
			{
				var label = Metadata.BooleanOptionSetMetadata.FalseOption.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == Metadata.LanguageCode);

				listControl.Items.Add(new Lisreplacedem
				{
					Value = Metadata.BooleanOptionSetMetadata.FalseOption.Value.Value.ToString(CultureInfo.InvariantCulture),
					Text = (listControl is RadioButtonList ? "<span clreplaced='sr-only'>" + Metadata.Label + " </span>" : string.Empty) +
						(label == null ? Metadata.BooleanOptionSetMetadata.FalseOption.Label.GetLocalizedLabelString() : label.Label)
				});
			}
			else
			{
				listControl.Items.Add(new Lisreplacedem { Value = "0", Text = "False", });
			}

			if (Metadata.BooleanOptionSetMetadata.TrueOption.Value != null)
			{
				var label = Metadata.BooleanOptionSetMetadata.TrueOption.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == Metadata.LanguageCode);

				listControl.Items.Add(new Lisreplacedem
				{
					Value = Metadata.BooleanOptionSetMetadata.TrueOption.Value.Value.ToString(CultureInfo.InvariantCulture),
					Text = (listControl is RadioButtonList ? "<span clreplaced='sr-only'>" + Metadata.Label + " </span>" : string.Empty) +
						(label == null ? Metadata.BooleanOptionSetMetadata.TrueOption.Label.GetLocalizedLabelString() : label.Label)
				});
			}
			else
			{
				listControl.Items.Add(new Lisreplacedem { Value = "1", Text = "True", });
			}

			if (Metadata.IgnoreDefaultValue || Metadata.DefaultValue == null)
			{
				return;
			}

			if (Convert.ToBoolean(Metadata.DefaultValue))
			{
				if (Metadata.BooleanOptionSetMetadata.TrueOption.Value.HasValue)
				{
					listControl.SelectedValue = Metadata.BooleanOptionSetMetadata.TrueOption.Value.Value.ToString(CultureInfo.InvariantCulture);
				}
			}
			else
			{
				if (Metadata.BooleanOptionSetMetadata.FalseOption.Value.HasValue)
				{
					listControl.SelectedValue = Metadata.BooleanOptionSetMetadata.FalseOption.Value.Value.ToString(CultureInfo.InvariantCulture);
				}
			}
		}

[GameAction(GameActionType.ModifyAllegianceGuestPermission)]
        public static void Handle(ClientMessage message, Session session)
        {
            //Console.WriteLine("Received 0x267 - House - ModifyAllegianceGuestPermission");

            // whether we are adding or removing permissions
            var add = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionModifyAllegianceGuestPermission(add);
        }

[GameAction(GameActionType.ConfirmationResponse)]
        public static void Handle(ClientMessage message, Session session)
        {
            var confirmType = (ConfirmationType)message.Payload.ReadInt32();
            var context = message.Payload.ReadUInt32();
            var response = Convert.ToBoolean(message.Payload.ReadInt32());

            session.Player.ConfirmationManager.HandleResponse(confirmType, context, response);
        }

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

private int HookProc(int code, IntPtr wParam, ref KeyboardLLHookStruct lParam)
        {
            if (code == HC_ACTION)
            {
                if (wParam.ToInt32() == WM_KEYDOWN || wParam.ToInt32() == WM_SYSKEYDOWN)
                {
                    foreach (var item in _menuItems.Items.Flatten(x => x.Items).Where(x => x.Type == MenuItemType.Item))
                    {
                        var key1 = true;
                        var key2 = true;

                        if (item.Key1 != VirtualKeyModifier.None)
                        {
                            var key1State = GetAsyncKeyState((int)item.Key1) & 0x8000;
                            key1 = Convert.ToBoolean(key1State);
                        }

                        if (item.Key2 != VirtualKeyModifier.None)
                        {
                            var key2State = GetAsyncKeyState((int)item.Key2) & 0x8000;
                            key2 = Convert.ToBoolean(key2State);
                        }

                        if (key1 && key2 && lParam.vkCode == (int)item.Key3)
                        {
                            var handler = Hooked;
                            if (handler != null)
                            {
                                var menuItemId = MenuItemId.GetId(item.Name);
                                var eventArgs = new HotKeyEventArgs(menuItemId);
                                handler.Invoke(this, eventArgs);
                                if (eventArgs.Succeeded)
                                {
                                    return 1;
                                }
                            }
                        }
                    }

                    foreach (var item in _menuItems.WindowSizeItems)
                    {
                        var key1 = true;
                        var key2 = true;

                        if (item.Key1 != VirtualKeyModifier.None)
                        {
                            var key1State = GetAsyncKeyState((int)item.Key1) & 0x8000;
                            key1 = Convert.ToBoolean(key1State);
                        }

                        if (item.Key2 != VirtualKeyModifier.None)
                        {
                            var key2State = GetAsyncKeyState((int)item.Key2) & 0x8000;
                            key2 = Convert.ToBoolean(key2State);
                        }

                        if (key1 && key2 && lParam.vkCode == (int)item.Key3)
                        {
                            var handler = Hooked;
                            if (handler != null)
                            {
                                var eventArgs = new HotKeyEventArgs(item.Id);
                                handler.Invoke(this, eventArgs);
                                if (eventArgs.Succeeded)
                                {
                                    return 1;
                                }
                            }
                        }
                    }
                }
            }

            return CallNextHookEx(_hookHandle, code, wParam, ref lParam);
        }

19 View Source File : EShopOnAbpPublicWebModule.cs
License : MIT License
Project Creator : abpframework

public override void ConfigureServices(ServiceConfigurationContext context)
        {
            Microsoft.IdenreplacedyModel.Logging.IdenreplacedyModelEventSource.ShowPII = true;
            var hostingEnvironment = context.Services.GetHostingEnvironment();
            var configuration = context.Services.GetConfiguration();

            Configure<AbpMulreplacedenancyOptions>(options =>
            {
                options.IsEnabled = true;
            });

            Configure<AbpDistributedCacheOptions>(options =>
            {
                options.KeyPrefix = "EShopOnAbp:";
            });

            Configure<AppUrlOptions>(options =>
            {
                options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
            });

            context.Services.AddAuthentication(options =>
                {
                    options.DefaultScheme = "Cookies";
                    options.DefaultChallengeScheme = "oidc";
                })
                .AddCookie("Cookies", options =>
                {
                    options.ExpireTimeSpan = TimeSpan.FromDays(365);
                })
                .AddAbpOpenIdConnect("oidc", options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
                    options.ResponseType = OpenIdConnectResponseType.CodeIdToken;

                    options.ClientId = configuration["AuthServer:ClientId"];
                    options.ClientSecret = configuration["AuthServer:ClientSecret"];

                    options.SaveTokens = true;
                    options.GetClaimsFromUserInfoEndpoint = true;

                    options.Scope.Add("role");
                    options.Scope.Add("email");
                    options.Scope.Add("phone");
                    options.Scope.Add("AdministrationService");
                    // options.Scope.Add("ProductService");
                });

            var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
            context.Services
                .AddDataProtection()
                .PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys")
                .SetApplicationName("eShopOnAbp-PublicWeb");

            Configure<AbpNavigationOptions>(options =>
            {
                options.MenuContributors.Add(new EShopOnAbpPublicWebMenuContributor(configuration));
            });

            Configure<AbpToolbarOptions>(options =>
            {
                options.Contributors.Add(new EShopOnAbpPublicWebToolbarContributor());
            });
        }

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

public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams );
			if( UIUtils.CurrentShaderVersion() >= 13901 )
			{
				m_convertToLinear = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			}
			if( UIUtils.CurrentShaderVersion() > 15607 )
			{
				m_saturate = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			}

			if( UIUtils.CurrentShaderVersion() > 15700 )
			{
				m_mirror = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			}
		}

[GameAction(GameActionType.ModifyAllegianceStoragePermission)]
        public static void Handle(ClientMessage message, Session session)
        {
            //Console.WriteLine("Received 0x268 - House - ModifyAllegianceStoragePermission");

            // whether we are adding or removing permissions
            var add = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionModifyAllegianceStoragePermission(add);
        }

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

private void AddSpecialBindingAndHiddenFieldsToPersistDisabledCheckBox(Control container, CheckBox checkBox)
		{
			checkBox.InputAttributes["clreplaced"] = "{0} readonly".FormatWith(CssClreplaced);
			checkBox.InputAttributes["disabled"] = "disabled";
			checkBox.InputAttributes["aria-disabled"] = "true";

			var hiddenValue = new HiddenField
			{
				ID = "{0}_Value".FormatWith(ControlID),
				Value = checkBox.Checked.ToString(CultureInfo.InvariantCulture)
			};
			container.Controls.Add(hiddenValue);

			RegisterClientSideDependencies(container);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () =>
				{
					bool value;
					return bool.TryParse(hiddenValue.Value, out value) ? new bool?(value) : null;
				},
				Set = obj =>
				{
					var value = Convert.ToBoolean(obj);
					checkBox.Checked = value;
					hiddenValue.Value = value.ToString(CultureInfo.InvariantCulture);
				}
			};
		}

19 View Source File : BlogsService.cs
License : MIT License
Project Creator : ADefWebserver

public BlogDTO GetBlog(int BlogId)
        {
            BlogDTO objBlog = (from blog in _context.Blogs
                                     .Where(x => x.BlogId == BlogId)
                               select new BlogDTO
                               {
                                   BlogId = blog.BlogId,
                                   Blogreplacedle = blog.Blogreplacedle,
                                   BlogDate = blog.BlogDate,
                                   BlogUserName = blog.BlogUserName,
                                   BlogSummary = blog.BlogSummary,
                                   BlogContent = blog.BlogContent,
                                   BlogDisplayName = "",
                               }).AsNoTracking().FirstOrDefault();

            // Add Blog Categories
            objBlog.BlogCategory = new List<BlogCategory>();

            var BlogCategories = _context.BlogCategory
                .Where(x => x.BlogId == objBlog.BlogId)
                .AsNoTracking().ToList();

            foreach (var item in BlogCategories)
            {
                objBlog.BlogCategory.Add(item);
            }

            // Try to get name
            var objUser = _context.AspNetUsers
                .Where(x => x.Email.ToLower() == objBlog.BlogUserName).AsNoTracking()
                .FirstOrDefault();

            if (objUser != null)
            {
                if (objUser.DisplayName != null)
                {
                    objBlog.BlogDisplayName = objUser.DisplayName;
                }
            }

            // Get GoogleTrackingID and DisqusEnabled
            var Settings = _context.Settings.AsNoTracking().ToList();

            objBlog.DisqusEnabled = Convert.ToBoolean(Settings.FirstOrDefault(x => x.SettingName == "DisqusEnabled").SettingValue);

            if (Settings.FirstOrDefault(x => x.SettingName == "GoogleTrackingID") != null)
            {
                objBlog.GoogleTrackingID = Convert.ToString(Settings.FirstOrDefault(x => x.SettingName == "GoogleTrackingID").SettingValue);
            }
            else
            {
                objBlog.GoogleTrackingID = "";
            }

            return objBlog;
        }

[GameAction(GameActionType.BreakAllegianceBoot)]
        public static void Handle(ClientMessage message, Session session)
        {
            var playerName = message.Payload.ReadString16L();
            var accountBoot = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionBreakAllegianceBoot(playerName, accountBoot);
        }

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

protected override void InstantiateControlIn(Control container)
		{
			var checkbox = new CheckBox { ID = ControlID, CssClreplaced = CssClreplaced, ToolTip = Metadata.ToolTip };

			container.Controls.Add(checkbox);

			Bindings[Metadata.DataFieldName] = new CellBinding
			{
				Get = () => checkbox.Checked,
				Set = obj => { checkbox.Checked = Convert.ToBoolean(obj); }
			};
		}

19 View Source File : AuthorizationAttribute.cs
License : Apache License 2.0
Project Creator : 91270

public void OnAuthorization(AuthorizationFilterContext context)
        {
            #region 判断是否登录
            var _tokenManager = context.HttpContext.RequestServices.GetService<TokenManager>();

            if (!_tokenManager.IsAuthenticated())
            {
                ApiResult response = new ApiResult
                {
                    StatusCode = (int)StatusCodeType.Unauthorized,
                    Message = StatusCodeType.Unauthorized.GetEnumText()
                };

                context.Result = new JsonResult(response) { StatusCode = (int)StatusCodeType.Success };
                return;
            }

            #endregion

            #region 判断是否拥有权限
            if (!string.IsNullOrEmpty(Power))
            {
                if (Convert.ToBoolean(AppSettings.Configuration["AppSettings:Demo"]))
                {
                    if (Power.Contains("UPDATE") || Power.Contains("CREATE") || Power.Contains("DELETE") || Power.Contains("RESETPreplacedWD"))
                    {
                        ApiResult response = new ApiResult
                        {
                            StatusCode = (int)StatusCodeType.Error,
                            Message = "当前为演示模式 , 您无权修改任何数据"
                        };

                        context.Result = new JsonResult(response) { StatusCode = (int)StatusCodeType.Success };
                        return;
                    }
                }

                if (!_tokenManager.GetSessionInfo().UserPower.Contains(Power))
                {
                    ApiResult response = new ApiResult
                    {
                        StatusCode = (int)StatusCodeType.Forbidden,
                        Message = StatusCodeType.Forbidden.GetEnumText()
                    };

                    context.Result = new JsonResult(response) { StatusCode = (int)StatusCodeType.Success };
                    return;
                }
            }
            #endregion
        }

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

protected void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent)
		{
			if (feature.Properties.ContainsKey("extrude") && !Convert.ToBoolean(feature.Properties["extrude"]))
				return;

			if (feature.Points.Count < 1)
				return;

			//this will be improved in next version and will probably be replaced by filters
			var styleSelectorKey = _layerProperties.coreOptions.sublayerName;

			var meshData = new MeshData();
			meshData.TileRect = tile.Rect;

			//and finally, running the modifier stack on the feature
			var processed = false;

			if (!processed)
			{
				if (_defaultStack != null)
				{
					_defaultStack.Execute(tile, feature, meshData, parent, styleSelectorKey);
				}
			}
		}

[GameAction(GameActionType.ChangeStoragePermission)]
        public static void Handle(ClientMessage message, Session session)
        {
            //Console.WriteLine("Received 0x249 - House - ChangeStoragePermissions");

            var guestName = message.Payload.ReadString16L();
            var hasPermission = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionModifyStorage(guestName, hasPermission);
        }

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

private int HookProc(int code, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
        {
            if (code == NativeConstants.HC_ACTION)
            {
                if (wParam.ToInt32() == NativeConstants.WM_KEYDOWN || wParam.ToInt32() == NativeConstants.WM_SYSKEYDOWN)
                {
                    var key1 = true;
                    var key2 = true;

                    if (_key1 != (int)VirtualKeyModifier.None)
                    {
                        var key1State = NativeMethods.GetAsyncKeyState(_key1) & 0x8000;
                        key1 = Convert.ToBoolean(key1State);
                    }

                    if (_key2 != (int)VirtualKeyModifier.None)
                    {
                        var key2State = NativeMethods.GetAsyncKeyState(_key2) & 0x8000;
                        key2 = Convert.ToBoolean(key2State);
                    }

                    if (key1 && key2 && lParam.vkCode == _key3)
                    {
                        var handler = Hooked;
                        if (handler != null)
                        {
                            handler.BeginInvoke(this, EventArgs.Empty, null, null);
                        }
                    }
                }
            }
            return NativeMethods.CallNextHookEx(_hookHandle, code, wParam, ref lParam);
        }

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

private void lvServers_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            if (e.Column < 0)
            {
                return;
            }

            try
            {
                var tag = lvServers.Columns[e.Column].Tag?.ToString();
                bool asc = Utils.IsNullOrEmpty(tag) ? true : !Convert.ToBoolean(tag);
                if (ConfigHandler.SortServers(ref config, (EServerColName)e.Column, asc) != 0)
                {
                    return;
                }
                lvServers.Columns[e.Column].Tag = Convert.ToString(asc);
                RefreshServers();
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }

            if (e.Column < 0)
            {
                return;
            }

        }

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

public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams );
			m_multiCompile = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
			if( UIUtils.CurrentShaderVersion() > 14403 )
			{
				m_defaultValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				if( UIUtils.CurrentShaderVersion() > 14101 )
				{
					m_materialValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				}
			}
			else
			{
				m_defaultValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? 1 : 0;
				if( UIUtils.CurrentShaderVersion() > 14101 )
				{
					m_materialValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? 1 : 0;
				}
			}

			if( UIUtils.CurrentShaderVersion() > 13104 )
			{
				m_createToggle = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
				m_currentKeyword = GetCurrentParam( ref nodeParams );
				m_currentKeywordId = UIUtils.GetKeywordId( m_currentKeyword );
			}
			if( UIUtils.CurrentShaderVersion() > 14001 )
			{
				m_keywordModeType = (KeywordModeType)Enum.Parse( typeof( KeywordModeType ), GetCurrentParam( ref nodeParams ) );
			}

			if( UIUtils.CurrentShaderVersion() > 14403 )
			{
				m_keywordEnumAmount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				for( int i = 0; i < m_keywordEnumAmount; i++ )
				{
					m_defaultKeywordNames[ i ] = GetCurrentParam( ref nodeParams );
				}

				UpdateLabels();
			}

			if( m_createToggle )
				UIUtils.RegisterPropertyNode( this );
			else
				UIUtils.UnregisterPropertyNode( this );

			if( UIUtils.CurrentShaderVersion() > 16304 )
			{
				string currentVarMode = GetCurrentParam( ref nodeParams );
				CurrentVarMode = (StaticSwitchVariableMode)Enum.Parse( typeof( StaticSwitchVariableMode ), currentVarMode );
				if( CurrentVarMode == StaticSwitchVariableMode.Reference )
				{
					m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				}
			}
			else
			{
				CurrentVarMode = (StaticSwitchVariableMode)m_variableMode;
			}

			if( UIUtils.CurrentShaderVersion() > 16700 )
			{
				m_isLocal = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			}
		}

[GameAction(GameActionType.SetHooksVisibility)]
        public static void Handle(ClientMessage message, Session session)
        {
            //Console.WriteLine("Received 0x266 - House - SetHooksVisibility");

            var visible = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionSetHooksVisible(visible);
        }

[GameAction(GameActionType.ModifyGlobalSquelch)]
        public static void Handle(ClientMessage message, Session session)
        {
            var squelch = Convert.ToBoolean(message.Payload.ReadUInt32());
            var messageType = (ChatMessageType)message.Payload.ReadUInt32();

            session.Player.SquelchManager.HandleActionModifyGlobalSquelch(squelch, messageType);
        }

19 View Source File : UserCenterController.cs
License : Apache License 2.0
Project Creator : 91270

[HttpPost]
        [Authorization]
        public IActionResult UpdatePreplacedword([FromBody] UserCenterUpdatePreplacedwordDto parm)
        {
            if (Convert.ToBoolean(AppSettings.Configuration["AppSettings:Demo"]))
            {
                toResponse(StatusCodeType.Error, "当前为演示模式 , 您无权修改任何数据");
            }

            var userSession = _tokenManager.GetSessionInfo();

            var userInfo = _usersService.GetId(userSession.UserID);

            // 验证旧密码是否正确
            if (!PreplacedwordUtil.ComparePreplacedwords(userInfo.UserID, userInfo.Preplacedword, parm.CurrentPreplacedword.Trim()))
            {
                return toResponse(StatusCodeType.Error, "旧密码输入不正确");
            }

            // 更新用户密码
            var response = _usersService.Update(m => m.UserID == userInfo.UserID, m => new Sys_Users()
            {
                Preplacedword = PreplacedwordUtil.CreateDbPreplacedword(userInfo.UserID, parm.ConfirmPreplacedword.Trim())
            });

            // 删除登录会话记录
            _tokenManager.RemoveAllSession(userInfo.UserID);

            return toResponse(response);
        }

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

[GameAction(GameActionType.SetOpenHouseStatus)]
        public static void Handle(ClientMessage message, Session session)
        {
            //Console.WriteLine("Received 0x247 - SetOpenHouseStatus");

            var openHouse = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionSetOpenStatus(openHouse);
        }

[GameAction(GameActionType.ModifyCharacterSquelch)]
        public static void Handle(ClientMessage message, Session session)
        {
            var squelch = Convert.ToBoolean(message.Payload.ReadUInt32());
            var playerGuid = message.Payload.ReadUInt32();
            var playerName = message.Payload.ReadString16L();
            var messageType = (ChatMessageType)message.Payload.ReadUInt32();

            session.Player.SquelchManager.HandleActionModifyCharacterSquelch(squelch, playerGuid, playerName, messageType);
        }

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

protected object GetValue(JToken token, Type propertyType)
		{
			var value = token.ToObject<object>();

			if (value == null)
			{
				return null;
			}

			if (propertyType == typeof(bool?))
			{
				return Convert.ToBoolean(value);
			}

			if (propertyType == typeof(CrmEnreplacedyReference))
			{
				EnreplacedyReference enreplacedyReference;

				if (TryGetEnreplacedyReference(value, out enreplacedyReference))
				{
					return new CrmEnreplacedyReference(enreplacedyReference.LogicalName, enreplacedyReference.Id);
				}

				throw new FormatException("Unable to convert value {0} for attribute {1} to {2}.".FormatWith(value, Attribute.CrmPropertyAttribute.LogicalName, typeof(EnreplacedyReference)));
			}

			if (propertyType == typeof(DateTime?))
			{
				var dateTimeValue = value is DateTime ? (DateTime)value : Convert.ToDateTime(value);

				return dateTimeValue.Kind == DateTimeKind.Utc ? dateTimeValue : dateTimeValue.ToUniversalTime();
			}

			if (propertyType == typeof(double?))
			{
				return Convert.ToDouble(value);
			}

			if (propertyType == typeof(decimal))
			{
				return Convert.ToDecimal(value);
			}

			if (propertyType == typeof(EnreplacedyReference))
			{
				EnreplacedyReference enreplacedyReference;

				if (TryGetEnreplacedyReference(value, out enreplacedyReference))
				{
					return enreplacedyReference;
				}

				throw new FormatException("Unable to convert value {0} for attribute {1} to {2}.".FormatWith(value, Attribute.CrmPropertyAttribute.LogicalName, typeof(EnreplacedyReference)));
			}

			if (propertyType == typeof(Guid?))
			{
				return value is Guid ? value : new Guid(value.ToString());
			}

			if (propertyType == typeof(int?))
			{
				return Convert.ToInt32(value);
			}

			if (propertyType == typeof(long?))
			{
				return Convert.ToInt64(value);
			}

			if (propertyType == typeof(string))
			{
				return value is string ? value : value.ToString();
			}

			if (propertyType.IsreplacedignableFrom(value.GetType()))
			{
				return value;
			}

			throw new InvalidOperationException("Unable to convert value of type".FormatWith(value.GetType(), propertyType, Attribute.CrmPropertyAttribute.LogicalName));
		}

19 View Source File : GeneralSettingsService.cs
License : MIT License
Project Creator : ADefWebserver

public async Task<GeneralSettings> GetGeneralSettingsAsync()
        {
            GeneralSettings objGeneralSettings = new GeneralSettings();

            var resuts = await _context.Settings.AsNoTracking().ToListAsync();

            objGeneralSettings.SMTPServer = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "SMTPServer").SettingValue);
            objGeneralSettings.SMTPAuthendication = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "SMTPAuthendication").SettingValue);
            objGeneralSettings.SMTPSecure = Convert.ToBoolean(resuts.FirstOrDefault(x => x.SettingName == "SMTPSecure").SettingValue);
            objGeneralSettings.SMTPUserName = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "SMTPUserName").SettingValue);
            objGeneralSettings.SMTPPreplacedword = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "SMTPPreplacedword").SettingValue);
            objGeneralSettings.SMTPFromEmail = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "SMTPFromEmail").SettingValue);

            objGeneralSettings.AllowRegistration = Convert.ToBoolean(resuts.FirstOrDefault(x => x.SettingName == "AllowRegistration").SettingValue);
            objGeneralSettings.VerifiedRegistration = Convert.ToBoolean(resuts.FirstOrDefault(x => x.SettingName == "VerifiedRegistration").SettingValue);

            objGeneralSettings.ApplicationName = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "ApplicationName").SettingValue);
            objGeneralSettings.ApplicationLogo = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "ApplicationLogo").SettingValue);
            objGeneralSettings.ApplicationHeader = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "ApplicationHeader").SettingValue);

            objGeneralSettings.DisqusEnabled = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "DisqusEnabled").SettingValue);
            objGeneralSettings.DisqusShortName = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "DisqusShortName").SettingValue);

            if (resuts.FirstOrDefault(x => x.SettingName == "GoogleTrackingID") != null)
            {
                objGeneralSettings.GoogleTrackingID = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "GoogleTrackingID").SettingValue);
            }
            else
            {
                objGeneralSettings.GoogleTrackingID = "";
            }

            objGeneralSettings.VersionNumber = Convert.ToString(resuts.FirstOrDefault(x => x.SettingName == "VersionNumber").SettingValue);

            return objGeneralSettings;
        }

[GameAction(GameActionType.AllegianceUpdateRequest)]
        public static void Handle(ClientMessage message, Session session)
        {
            var uiPanel = Convert.ToBoolean(message.Payload.ReadUInt32());

            var player = session.Player;

            var allegiance = player != null ? player.Allegiance : null;
            var allegianceNode = player != null ? player.AllegianceNode : null;

            var allegianceUpdate = new GameEventAllegianceUpdate(session, allegiance, allegianceNode);

            session.Network.EnqueueSend(allegianceUpdate, new GameEventAllegianceAllegianceUpdateDone(session));
        }

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

private void InstantiateCheckboxControlIn(Control container)
		{
			var checkbox = new CheckBox
			{
				ID = ControlID,
				CssClreplaced = string.Join(" ", CssClreplaced, Metadata.CssClreplaced),
				ToolTip = Metadata.ToolTip
			};

			checkbox.Attributes.Add("onclick", "setIsDirty(this.id);");

			container.Controls.Add(checkbox);

			if (!container.Page.IsPostBack)
			{
				checkbox.Checked = Convert.ToBoolean(Metadata.DefaultValue);
			}

			if (Metadata.ReadOnly)
			{
				AddSpecialBindingAndHiddenFieldsToPersistDisabledCheckBox(container, checkbox);
			}
			else
			{
				Bindings[Metadata.DataFieldName] = new CellBinding
				{
					Get = () => checkbox.Checked,
					Set = obj => { checkbox.Checked = Convert.ToBoolean(obj); }
				};	
			}
		}

19 View Source File : UserCenterController.cs
License : Apache License 2.0
Project Creator : 91270

[HttpPost]
        [Authorization]
        public IActionResult AvatarUpload([FromForm(Name = "file")] IFormFile file)
        {
            try
            {

                if (Convert.ToBoolean(AppSettings.Configuration["AppSettings:Demo"]))
                {
                    return toResponse(StatusCodeType.Error, "当前为演示模式 , 您无权修改任何数据");
                }

                var fileExtName = Path.GetExtension(file.FileName).ToLower();

                var fileName = DateTime.Now.Ticks.ToString() + fileExtName;

                string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".jpeg" };

                int MaxContentLength = 1024 * 1024 * 4;

                if (!AllowedFileExtensions.Contains(fileExtName))
                {
                    return toResponse(StatusCodeType.Error, "上传失败,未经允许上传类型");
                }


                if (file.Length > MaxContentLength)
                {
                    return toResponse(StatusCodeType.Error, "上传图片过大,不能超过 " + (MaxContentLength / 1024).ToString() + " MB");
                }

                var filePath = $"/{DateTime.Now:yyyyMMdd}/";

                var avatarDirectory = $"{AppSettings.Configuration["AvatarUpload:AvatarDirectory"]}{filePath}";

                if (!Directory.Exists(avatarDirectory))
                {
                    Directory.CreateDirectory(avatarDirectory);
                }

                using (var stream = new FileStream($"{avatarDirectory}{fileName}", FileMode.Create))
                {
                    file.CopyTo(stream);
                }

                var avatarUrl = $"{AppSettings.Configuration["AvatarUpload:AvatarUrl"]}{filePath}{fileName}";

                var userSession = _tokenManager.GetSessionInfo();

                #region 更新用户信息
                var response = _usersService.Update(m => m.UserID == userSession.UserID, m => new Sys_Users
                {
                    AvatarUrl = avatarUrl,
                    UpdateID = userSession.UserID,
                    UpdateName = userSession.UserName,
                    UpdateTime = DateTime.Now
                });
                #endregion

                #region 更新登录会话记录

                _tokenManager.RefreshSession(userSession.UserID);

                #endregion

                return toResponse(avatarUrl);
            }
            catch (Exception)
            {
                throw;
            }
        }

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

protected override void InstantiateControlIn(Control container)
		{
			var checkbox = new CheckBox { ID = ControlID, CssClreplaced = string.Join(" ", "checkbox", CssClreplaced, Metadata.CssClreplaced, Metadata.GroupName), ToolTip = Metadata.ToolTip };

			checkbox.Attributes.Add("onclick", "setIsDirty(this.id);");

			container.Controls.Add(checkbox);

			if (!container.Page.IsPostBack)
			{
				checkbox.Checked = Convert.ToBoolean(Metadata.DefaultValue);
			}

			if (Metadata.ReadOnly)
			{
				AddSpecialBindingAndHiddenFieldsToPersistDisabledCheckBox(container, checkbox);
			}
			else
			{
				Bindings[Metadata.DataFieldName] = new CellBinding
				{
					Get = () => checkbox.Checked,
					Set = obj => { checkbox.Checked = Convert.ToBoolean(obj); }
				};
			}

			var validator = container.FindControl(string.Format("multipleChoiceValidator{0}", Metadata.GroupName));

			if (validator == null)
			{
				var multipleChoiceValidatorErrorMessage = string.Empty;
				if (Metadata.MinMultipleChoiceSelectedCount > 0 && Metadata.MaxMultipleChoiceSelectedCount > 0)
				{
					multipleChoiceValidatorErrorMessage = string.Format(ResourceManager.GetString("Minimum_Most_Options_Selection_Exception"), Metadata.MinMultipleChoiceSelectedCount, Metadata.MaxMultipleChoiceSelectedCount);
				}
				else if (Metadata.MinMultipleChoiceSelectedCount == 0 && Metadata.MaxMultipleChoiceSelectedCount > 0)
				{
					multipleChoiceValidatorErrorMessage = string.Format(ResourceManager.GetString("Maximum_Options_Selection_Exception"), Metadata.MaxMultipleChoiceSelectedCount);
				}
				else if (Metadata.MinMultipleChoiceSelectedCount > 0 && Metadata.MaxMultipleChoiceSelectedCount == 0)
				{
					multipleChoiceValidatorErrorMessage = string.Format(ResourceManager.GetString("Minimum_Options_Selection_Exception"), Metadata.MinMultipleChoiceSelectedCount);
				}
				
				var multipleChoiceValidator = new MultipleChoiceCheckboxValidator
				{
					ID = string.Format("multipleChoiceValidator{0}", Metadata.GroupName),
					ControlToValidate = ControlID,
					ValidationGroup = ValidationGroup,
					ErrorMessage = ValidationSummaryMarkup((string.IsNullOrWhiteSpace(Metadata.MultipleChoiceValidationErrorMessage) ? multipleChoiceValidatorErrorMessage : Metadata.MultipleChoiceValidationErrorMessage)),
					Text = "*",
					CssClreplaced = "validator-text",
					Display = ValidatorDisplay.None,
					Container = container.Parent.Parent.Parent,
					GroupName = Metadata.GroupName,
					MinSelectedCount = Metadata.MinMultipleChoiceSelectedCount,
					MaxSelectedCount = Metadata.MaxMultipleChoiceSelectedCount
				};

				container.Controls.Add(multipleChoiceValidator);
			}
		}

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

[GameAction(GameActionType.ChessStalemate)]
        public static void Handle(ClientMessage message, Session session)
        {
            var stalemate = Convert.ToBoolean(message.Payload.ReadInt32());
            session.Player.HandleActionChessStalemate(stalemate);
        }

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

public override bool? ReadAsBoolean()
        {
            EnsureBuffer();

            switch (_currentState)
            {
                case State.Start:
                case State.Property:
                case State.Array:
                case State.ArrayStart:
                case State.Constructor:
                case State.ConstructorStart:
                case State.PostValue:
                    while (true)
                    {
                        char currentChar = _chars[_charPos];

                        switch (currentChar)
                        {
                            case '\0':
                                if (ReadNullChar())
                                {
                                    SetToken(JsonToken.None, null, false);
                                    return null;
                                }
                                break;
                            case '"':
                            case '\'':
                                ParseString(currentChar, ReadType.Read);
                                return ReadBooleanString(_stringReference.ToString());
                            case 'n':
                                HandleNull();
                                return null;
                            case '-':
                            case '.':
                            case '0':
                            case '1':
                            case '2':
                            case '3':
                            case '4':
                            case '5':
                            case '6':
                            case '7':
                            case '8':
                            case '9':
                                ParseNumber(ReadType.Read);
                                bool b;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
                                if (Value is BigInteger)
                                {
                                    b = (BigInteger)Value != 0;
                                }
                                else
#endif
                                {
                                    b = Convert.ToBoolean(Value, CultureInfo.InvariantCulture);
                                }
                                SetToken(JsonToken.Boolean, b, false);
                                return b;
                            case 't':
                            case 'f':
                                bool isTrue = currentChar == 't';
                                string expected = isTrue ? JsonConvert.True : JsonConvert.False;

                                if (!MatchValueWithTrailingSeparator(expected))
                                {
                                    throw CreateUnexpectedCharacterException(_chars[_charPos]);
                                }
                                SetToken(JsonToken.Boolean, isTrue);
                                return isTrue;
                            case '/':
                                ParseComment(false);
                                break;
                            case ',':
                                ProcessValueComma();
                                break;
                            case ']':
                                _charPos++;
                                if (_currentState == State.Array || _currentState == State.ArrayStart || _currentState == State.PostValue)
                                {
                                    SetToken(JsonToken.EndArray);
                                    return null;
                                }
                                throw CreateUnexpectedCharacterException(currentChar);
                            case StringUtils.CarriageReturn:
                                ProcessCarriageReturn(false);
                                break;
                            case StringUtils.LineFeed:
                                ProcessLineFeed();
                                break;
                            case ' ':
                            case StringUtils.Tab:
                                // eat
                                _charPos++;
                                break;
                            default:
                                _charPos++;

                                if (!char.IsWhiteSpace(currentChar))
                                {
                                    throw CreateUnexpectedCharacterException(currentChar);
                                }

                                // eat
                                break;
                        }
                    }
                case State.Finished:
                    ReadFinished();
                    return null;
                default:
                    throw JsonReaderException.Create(this, "Unexpected state: {0}.".FormatWith(CultureInfo.InvariantCulture, CurrentState));
            }
        }

19 View Source File : About.cs
License : MIT License
Project Creator : 1CM69

private void GetSettingsValues()
        {
            try
            {
                this.RegularMode.Checked = Convert.ToBoolean(Properties.Settings.Default.Regular);
                this.NightMode.Checked = Convert.ToBoolean(Properties.Settings.Default.Night);

            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.ToString());
                Properties.Settings.Default.Regular = RegularMode.Checked;
                Properties.Settings.Default.Night =  NightMode.Checked;
                Properties.Settings.Default.Save();
            }
        }

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

private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.AddAuthentication()
                .AddJwtBearer(options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
                    options.Audience = "Sample";
                });
        }

[GameAction(GameActionType.FellowshipUpdateRequest)]
        public static void Handle(ClientMessage message, Session session)
        {
            // indicates if fellowship panel on client is visible
            var panelOpen = Convert.ToBoolean(message.Payload.ReadInt32());

            session.Player.HandleFellowshipUpdateRequest(panelOpen);
        }

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

private void WindowKeyboardEvent(object sender, BasicHookEventArgs e)
        {
            var wParam = e.WParam.ToInt64();
            if (wParam == NativeConstants.VK_DOWN)
            {
                var controlState = NativeMethods.GetAsyncKeyState(NativeConstants.VK_CONTROL) & 0x8000;
                var shiftState = NativeMethods.GetAsyncKeyState(NativeConstants.VK_SHIFT) & 0x8000;
                var controlKey = Convert.ToBoolean(controlState);
                var shiftKey = Convert.ToBoolean(shiftState);
                if (controlKey && shiftKey)
                {
                    IntPtr handle = NativeMethods.GetForegroundWindow();
                    Window window = _windows.FirstOrDefault(w => w.Handle == handle);
                    window?.MinimizeToSystemTray();
                }
            }
        }

19 View Source File : JwtBearerConfigurationHelper.cs
License : MIT License
Project Creator : abpframework

public static void Configure(
            ServiceConfigurationContext context,
            string audience)
        {
            var configuration = context.Services.GetConfiguration();

            context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
                .AddJwtBearer(options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
                    options.Audience = audience;
                });
        }

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

private int HookProc(int code, int wParam, IntPtr lParam)
        {
            if (code == HC_ACTION)
            {
                if (_mouseButton != MouseButton.None && 
                    (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN || wParam == WM_MBUTTONDOWN || wParam == WM_LBUTTONUP || wParam == WM_RBUTTONUP || wParam == WM_MBUTTONUP))
                {
                    var key1 = true;
                    var key2 = true;

                    if (_key1 != VirtualKeyModifier.None)
                    {
                        var key1State = GetAsyncKeyState((int)_key1) & 0x8000;
                        key1 = Convert.ToBoolean(key1State);
                    }

                    if (_key2 != VirtualKeyModifier.None)
                    {
                        var key2State = GetAsyncKeyState((int)_key2) & 0x8000;
                        key2 = Convert.ToBoolean(key2State);
                    }

                    if (key1 && key2 && ((_mouseButton == MouseButton.Left && wParam == WM_LBUTTONDOWN) || (_mouseButton == MouseButton.Right && wParam == WM_RBUTTONDOWN) || (_mouseButton == MouseButton.Middle && wParam == WM_MBUTTONDOWN)))
                    {
                        var handler = Hooked;
                        if (handler != null)
                        {
                            var mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));
                            var eventArgs = new MouseEventArgs(mouseHookStruct.pt);
                            handler.BeginInvoke(this, eventArgs, null, null);
                            return 1;
                        }
                    }

                    if (key1 && key2 && ((_mouseButton == MouseButton.Left && wParam == WM_LBUTTONUP) || (_mouseButton == MouseButton.Right && wParam == WM_RBUTTONUP) || (_mouseButton == MouseButton.Middle && wParam == WM_MBUTTONUP)))
                    {
                        return 1;
                    }
                }
            }

            return CallNextHookEx(_hookHandle, code, wParam, lParam);
        }

[GameAction(GameActionType.ModifyAccountSquelch)]
        public static void Handle(ClientMessage message, Session session)
        {
            var squelch = Convert.ToBoolean(message.Payload.ReadUInt32());
            var playerName = message.Payload.ReadString16L();

            session.Player.SquelchManager.HandleActionModifyAccountSquelch(squelch, playerName);
        }

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

public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams );
			if( UIUtils.CurrentShaderVersion() < 13204 )
			{
				m_workflow = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? ASEStandardSurfaceWorkflow.Specular : ASEStandardSurfaceWorkflow.Metallic;
			}
			else
			{
				m_workflow = (ASEStandardSurfaceWorkflow)Enum.Parse( typeof( ASEStandardSurfaceWorkflow ), GetCurrentParam( ref nodeParams ) );
			}
			UpdateSpecularMetallicPorts();

			if( UIUtils.CurrentShaderVersion() >= 14402 )
			{
				m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) );
			}
			UpdatePort();
		}

19 View Source File : FunctionExpressionResovle.cs
License : Apache License 2.0
Project Creator : 1448376744

protected override Expression VisitConstant(ConstantExpression node)
        {
            var value = VisitConstantValue(node);
            if (value == null)
            {
                value = "NULL";
            }
            else if (value is string)
            {
                value = $"'{value}'";
            }
            else if (value is bool)
            {
                value = Convert.ToBoolean(value) ? 1 : 0;
            }
            _textBuilder.Append($"{value},");
            return node;
        }

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

public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams );
			m_name = GetCurrentParam( ref nodeParams );
			m_indexX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
			m_arrayLengthX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
			m_type = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
			m_autoRangeCheck = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
			if( UIUtils.CurrentShaderVersion() > 15801 )
			{
				m_isJagged = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
				m_indexY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				m_arrayLengthY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
				m_autoRegister = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
				m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) );
				m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
			}
			SetAdditonalreplacedleText( string.Format( Constants.SubreplacedleValueFormatStr, m_name ) );
			UpdatePorts();
		}

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

[GameAction(GameActionType.SetAfkMode)]
        public static void Handle(ClientMessage message, Session session)
        {
            var afk = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionSetAFKMode(afk);
        }

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

[GameAction(GameActionType.AcceptTrade)]
        public static void Handle(ClientMessage message, Session session)
        {
            uint partnerGuid = message.Payload.ReadUInt32();
            double tradeStamp = message.Payload.ReadDouble();
            uint tradeStatus = message.Payload.ReadUInt32();
            uint initiatorGuid = message.Payload.ReadUInt32();
            bool initatorAccepts = Convert.ToBoolean(message.Payload.ReadUInt32());
            bool partnerAccepts = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionAcceptTrade();
        }

19 View Source File : DbQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

private string ResovleBatchInsert(IEnumerable<T> enreplacedys)
        {
            var table = GetTableMetaInfo().TableName;
            var filters = new GroupExpressionResovle(_filterExpression).Resovle().Split(',');
            var columns = GetColumnMetaInfos()
                .Where(a => !a.IsComplexType).ToList();
            var intcolumns = columns
                .Where(a => !filters.Contains(a.ColumnName) && !a.IsNotMapped && !a.IsIdenreplacedy)
                .ToList();
            var columnNames = string.Join(",", intcolumns.Select(s => s.ColumnName));
            if (_context.DbContextType == DbContextType.Mysql)
            {
                var buffer = new StringBuilder();
                buffer.Append($"INSERT INTO {table}({columnNames}) VALUES ");
                var serializer = GlobalSettings.EnreplacedyMapperProvider.GetDeserializer(typeof(T));
                var list = enreplacedys.ToList();
                for (var i = 0; i < list.Count; i++)
                {
                    var item = list[i];
                    var values = serializer(item);
                    buffer.Append("(");
                    for (var j = 0; j < intcolumns.Count; j++)
                    {
                        var column = intcolumns[j];
                        var value = values[column.CsharpName];
                        if (value == null)
                        {
                            buffer.Append(column.IsDefault ? "DEFAULT" : "NULL");
                        }
                        else if (column.CsharpType == typeof(bool) || column.CsharpType == typeof(bool?))
                        {
                            buffer.Append(Convert.ToBoolean(value) == true ? 1 : 0);
                        }
                        else if (column.CsharpType == typeof(DateTime) || column.CsharpType == typeof(DateTime?))
                        {
                            buffer.Append($"'{value}'");
                        }
                        else if (column.CsharpType.IsValueType || (Nullable.GetUnderlyingType(column.CsharpType)?.IsValueType == true))
                        {
                            buffer.Append(value);
                        }
                        else
                        {
                            var str = SqlEncoding(value.ToString());
                            buffer.Append($"'{str}'");
                        }
                        if (j + 1 < intcolumns.Count)
                        {
                            buffer.Append(",");
                        }
                    }
                    buffer.Append(")");
                    if (i + 1 < list.Count)
                    {
                        buffer.Append(",");
                    }
                }
                return buffer.Remove(buffer.Length - 1, 0).ToString();
            }
            throw new NotImplementedException();
        }

19 View Source File : Help.cs
License : MIT License
Project Creator : 1CM69

private void GetSettingsValues()
        {
            try
            {
                this.RegularMode.Checked = Convert.ToBoolean(Properties.Settings.Default.Regular);
                this.NightMode.Checked = Convert.ToBoolean(Properties.Settings.Default.Night);

            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.ToString());
                Properties.Settings.Default.Regular = RegularMode.Checked;
                Properties.Settings.Default.Night = NightMode.Checked;
                Properties.Settings.Default.Save();
            }
        }

19 View Source File : UserCenterController.cs
License : Apache License 2.0
Project Creator : 91270

[HttpPost]
        [Authorization]
        public IActionResult Update([FromBody] UserCenterUpdateDto parm)
        {
            var userSession = _tokenManager.GetSessionInfo();

            if (Convert.ToBoolean(AppSettings.Configuration["AppSettings:Demo"]))
            {
                toResponse(StatusCodeType.Error, "当前为演示模式 , 您无权修改任何数据");
            }

            #region 更新用户信息
            var response = _usersService.Update(m => m.UserID == userSession.UserID, m => new Sys_Users
            {
                NickName = parm.NickName,
                Email = parm.Email,
                Sex = parm.Sex,
                QQ = parm.QQ,
                Phone = parm.Phone,
                Birthday = parm.Birthday,
                UpdateID = userSession.UserID,
                UpdateName = userSession.UserName,
                UpdateTime = DateTime.Now
            });
            #endregion

            #region 更新登录会话记录

            _tokenManager.RefreshSession(userSession.UserID);

            #endregion

            return toResponse(response);
        }

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

[GameAction(GameActionType.AllegianceChatGag)]
        public static void Handle(ClientMessage message, Session session)
        {
            var playerName = message.Payload.ReadString16L();
            var enabled = Convert.ToBoolean(message.Payload.ReadUInt32());

            session.Player.HandleActionAllegianceChatGag(playerName, enabled);
        }

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

protected object GetValue(JToken token, AttributeTypeCode attributeType)
		{
			var value = token.ToObject<object>();

			if (value == null)
			{
				return null;
			}

			if (attributeType == AttributeTypeCode.Customer || attributeType == AttributeTypeCode.Lookup || attributeType == AttributeTypeCode.Owner)
			{
				EnreplacedyReference enreplacedyReference;

				if (TryGetEnreplacedyReference(value, out enreplacedyReference))
				{
					return enreplacedyReference;
				}

				throw new FormatException("Unable to convert value {0} for attribute {1} to {2}.".FormatWith(value, Attribute.LogicalName, typeof(EnreplacedyReference)));
			}

			// Option set values will be in Int64 form from the JSON deserialization -- convert those to OptionSetValues
			// for option set attributes.
			if (attributeType == AttributeTypeCode.EnreplacedyName || attributeType == AttributeTypeCode.Picklist || attributeType == AttributeTypeCode.State || attributeType == AttributeTypeCode.Status)
			{
				return new OptionSetValue(Convert.ToInt32(value));
			}

			if (attributeType == AttributeTypeCode.Memo || attributeType == AttributeTypeCode.String)
			{
				return value is string ? value : value.ToString();
			}

			if (attributeType == AttributeTypeCode.BigInt)
			{
				return Convert.ToInt64(value);
			}

			if (attributeType == AttributeTypeCode.Boolean)
			{
				return Convert.ToBoolean(value);
			}

			if (attributeType == AttributeTypeCode.DateTime)
			{
				var dateTimeValue = Convert.ToDateTime(value);

				return dateTimeValue.Kind == DateTimeKind.Utc ? dateTimeValue : dateTimeValue.ToUniversalTime();
			}

			if (attributeType == AttributeTypeCode.Decimal)
			{
				return Convert.ToDecimal(value);
			}

			if (attributeType == AttributeTypeCode.Double)
			{
				return Convert.ToDouble(value);
			}

			if (attributeType == AttributeTypeCode.Integer)
			{
				return Convert.ToInt32(value);
			}

			if (attributeType == AttributeTypeCode.Money)
			{
				return new Money(Convert.ToDecimal(value));
			}

			if (attributeType == AttributeTypeCode.Uniqueidentifier)
			{
				return value is Guid ? value : new Guid(value.ToString());
			}

			return value;
		}

See More Examples