System.Convert.ToBoolean(object)

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

1006 Examples 7

19 Source : QuickCommandManageForm.cs
with Apache License 2.0
from 214175590

private void skinDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            int cell = e.ColumnIndex;
            if (row >= 0)
            {
                button1.Enabled = true;
                if (cell == 3)
                { // 删除

                    DataGridViewCell indexCell = currRow.Cells[0];
                    if (null != indexCell)
                    {
                        int index = (int)indexCell.Value;
                        DialogResult dr = MessageBox.Show("确认删除此项吗?", "提示", MessageBoxButtons.OKCancel);
                        if (dr == DialogResult.OK)
                        {
                            //用户选择确认的操作
                            DefaultConfig.RemoveShellLisreplacedem(config.ShellList, index);
                            skinDataGridView1.Rows.RemoveAt(row);
                        }
                    }
                }
                else if (cell == 2)
                {
                    DataGridViewCell indexCell = currRow.Cells[0];
                    if (null != indexCell)
                    {
                        DataGridViewTextBoxCell textCell = (DataGridViewTextBoxCell) currRow.Cells[1];
                        string cmd = (string)textCell.Value;
                        int index = (int)indexCell.Value;                        
                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)skinDataGridView1.Rows[row].Cells[cell];
                        if (null != checkCell)
                        {
                            bool isChecked = Convert.ToBoolean(checkCell.EditedFormattedValue);
                            if(isChecked){
                                cmd += "\n";
                            }
                            DefaultConfig.UpdateShellLisreplacedem(config.ShellList, index, cmd);
                        }
                    }
                }
            }
            else
            {
                button1.Enabled = false;
            }
        }

19 Source : QuickCommandManageForm.cs
with Apache License 2.0
from 214175590

private void skinDataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (null != currRow)
            {
                int row = e.RowIndex;
                if(row > 0){
                    DataGridViewCell indexCell = currRow.Cells[0];
                    if (null != indexCell)
                    {
                        int index = (int)indexCell.Value;
                        string cmd = (string) skinDataGridView1.Rows[row].Cells[1].Value;
                        bool isChecked = Convert.ToBoolean(currRow.Cells[2].Value);
                        if(isChecked){
                            cmd += "\n";
                        }
                        DefaultConfig.UpdateShellLisreplacedem(config.ShellList, index, cmd);
                    }                    
                }                
            }            
        }

19 Source : dlgSettings.cs
with MIT License
from 86Box

private void LoadSettings()
        {
            try
            {
                RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", false); //Open the key as read only

                //If the key doesn't exist yet, fallback to defaults
                if (regkey == null)
                {
                    MessageBox.Show("86Box Manager settings could not be loaded. This is normal if you're running 86Box Manager for the first time. Default values will be used.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    //Create the key and reopen it for write access
                    Registry.CurrentUser.CreateSubKey(@"SOFTWARE\86Box");
                    regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
                    regkey.CreateSubKey("Virtual Machines");

                    txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\86Box VMs\";
                    txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box\";
                    cbxMinimize.Checked = false;
                    cbxShowConsole.Checked = true;
                    cbxMinimizeTray.Checked = false;
                    cbxCloseTray.Checked = false;
                    cbxLogging.Checked = false;
                    txtLaunchTimeout.Text = "5000";
                    txtLogPath.Text = "";
                    cbxGrid.Checked = false;
                    btnBrowse3.Enabled = false;
                    txtLogPath.Enabled = false;

                    SaveSettings(); //This will write the default values to the registry
                }
                else
                {
                    txtEXEdir.Text = regkey.GetValue("EXEdir").ToString();
                    txtCFGdir.Text = regkey.GetValue("CFGdir").ToString();
                    txtLaunchTimeout.Text = regkey.GetValue("LaunchTimeout").ToString();
                    txtLogPath.Text = regkey.GetValue("LogPath").ToString();
                    cbxMinimize.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart"));
                    cbxShowConsole.Checked = Convert.ToBoolean(regkey.GetValue("ShowConsole"));
                    cbxMinimizeTray.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeToTray"));
                    cbxCloseTray.Checked = Convert.ToBoolean(regkey.GetValue("CloseToTray"));
                    cbxLogging.Checked = Convert.ToBoolean(regkey.GetValue("EnableLogging"));
                    cbxGrid.Checked = Convert.ToBoolean(regkey.GetValue("EnableGridLines"));
                    txtLogPath.Enabled = cbxLogging.Checked;
                    btnBrowse3.Enabled = cbxLogging.Checked;
                }

                regkey.Close();
            }
            catch (Exception ex)
            {
                txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + @"\86Box VMs";
                txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box";
                cbxMinimize.Checked = false;
                cbxShowConsole.Checked = true;
                cbxMinimizeTray.Checked = false;
                cbxCloseTray.Checked = false;
                cbxLogging.Checked = false;
                txtLaunchTimeout.Text = "5000";
                txtLogPath.Text = "";
                cbxGrid.Checked = false;
                txtLogPath.Enabled = false;
                btnBrowse3.Enabled = false;
            }
        }

19 Source : NpcCommandHandler.cs
with GNU Lesser General Public License v3.0
from 8720826

private bool CheckField(PlayerEnreplacedy player, string field, string strValue, string strRelation)
        {
            try
            {
                var relations = GetRelations(strRelation);// 1 大于,0 等于 ,-1 小于

                var fieldProp = GetFieldPropertyInfo(player, field);
                if (fieldProp == null)
                {
                    return false;
                }

                var objectValue = fieldProp.GetValue(player);
                var typeCode = Type.GetTypeCode(fieldProp.GetType());
                switch (typeCode)
                {
                    case TypeCode.Int32:
                        return relations.Contains(Convert.ToInt32(strValue).CompareTo(Convert.ToInt32(objectValue)));

                    case TypeCode.Int64:
                        return relations.Contains(Convert.ToInt64(strValue).CompareTo(Convert.ToInt64(objectValue)));

                    case TypeCode.Decimal:
                        return relations.Contains(Convert.ToDecimal(strValue).CompareTo(Convert.ToDecimal(objectValue)));

                    case TypeCode.Double:
                        return relations.Contains(Convert.ToDouble(strValue).CompareTo(Convert.ToDouble(objectValue)));

                    case TypeCode.Boolean:
                        return relations.Contains(Convert.ToBoolean(strValue).CompareTo(Convert.ToBoolean(objectValue)));

                    case TypeCode.DateTime:
                        return relations.Contains(Convert.ToDateTime(strValue).CompareTo(Convert.ToDateTime(objectValue)));

                    case TypeCode.String:
                        return relations.Contains(strValue.CompareTo(objectValue));

                    default:
                        throw new Exception($"不支持的数据类型: {typeCode}");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"CheckField Exception:{ex}");
                return false;
            }
        }

19 Source : dlgSettings.cs
with MIT License
from 86Box

private bool CheckForChanges()
        {
            RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box");

            try
            {
                btnApply.Enabled = (
                    txtEXEdir.Text != regkey.GetValue("EXEdir").ToString() ||
                    txtCFGdir.Text != regkey.GetValue("CFGdir").ToString() ||
                    txtLogPath.Text != regkey.GetValue("LogPath").ToString() ||
                    txtLaunchTimeout.Text != regkey.GetValue("LaunchTimeout").ToString() ||
                    cbxMinimize.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart")) ||
                    cbxShowConsole.Checked != Convert.ToBoolean(regkey.GetValue("ShowConsole")) ||
                    cbxMinimizeTray.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeToTray")) ||
                    cbxCloseTray.Checked != Convert.ToBoolean(regkey.GetValue("CloseToTray")) || 
                    cbxLogging.Checked != Convert.ToBoolean(regkey.GetValue("EnableLogging")) ||
                    cbxGrid.Checked != Convert.ToBoolean(regkey.GetValue("EnableGridLines")));

                return btnApply.Enabled;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                return true; //For now let's just return true if anything goes wrong
            }
            finally
            {
                regkey.Close();
            }
        }

19 Source : HookInterceptor.cs
with MIT License
from AdamCarballo

public static object GetParsedParameter(Type type, object param) {
			object parsedParam = null;

			// Ignore object as it doesn't need parsing
			if (type == typeof(bool)) {
				parsedParam = Convert.ToBoolean(param);
			} else if (type == typeof(int)) {
				parsedParam = Convert.ToInt32(param);
			} else if (type == typeof(float)) {
				parsedParam = Convert.ToSingle(param);
			} else if (type == typeof(string)) {
				parsedParam = Convert.ToString(param);
			}

			return parsedParam;
		}

19 Source : Hooks.cs
with MIT License
from adamped

static void _updateUserSettingsData(String jsonData)
        {
            Dictionary<String, Object> data = JsonConvert.DeserializeObject<Dictionary<String, Object>>(jsonData);
            _updateTextScaleFactor(Convert.ToDouble(data["textScaleFactor"]));
            _updateAlwaysUse24HourFormat(Convert.ToBoolean(data["alwaysUse24HourFormat"]));
        }

19 Source : AdColonyInterstitialAd.cs
with Apache License 2.0
from AdColony

public void UpdateValues(Hashtable values)
        {
            if (values != null)
            {
                if (values.ContainsKey("zone_id"))
                {
                    ZoneId = values["zone_id"] as string;
                }
                if (values.ContainsKey("expired"))
                {
                    Expired = Convert.ToBoolean(values["expired"]);
                }
                if (values.ContainsKey("id"))
                {
                    Id = values["id"] as string;
                }
            }
        }

19 Source : AdColonyOptions.cs
with Apache License 2.0
from AdColony

public bool GetBoolOption(string key)
        {
            return _data.ContainsKey(key) ? Convert.ToBoolean(_data[key]) : false;
        }

19 Source : IsPinnedIconConverter.cs
with MIT License
from adenearnshaw

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Device.RuntimePlatform != Device.UWP)
                return default(FileImageSource);

            var isPinned = System.Convert.ToBoolean(value);
            if (isPinned)
                return ImageSource.FromFile("UnpinIcon.png");
            else
                return ImageSource.FromFile("PinIcon.png");
        }

19 Source : IsPinnedTextConverter.cs
with MIT License
from adenearnshaw

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var isPinned = System.Convert.ToBoolean(value);

            if (isPinned)
                return "Unpin";
            else
                return "Pin";
        }

19 Source : IsPinningTextConverter.cs
with MIT License
from adenearnshaw

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var isPinned = System.Convert.ToBoolean(value);

            if (isPinned)
                return "Removing pin";
            else
                return "Adding pin";
        }

19 Source : EntityFormFunctions.cs
with MIT License
from Adoxio

internal static string TryConvertAttributeValueToString(OrganizationServiceContext context, Dictionary<string, AttributeTypeCode?> attributeTypeCodeDictionary, string enreplacedyName, string attributeName, object value)
		{
			if (context == null || string.IsNullOrWhiteSpace(enreplacedyName) || string.IsNullOrWhiteSpace(attributeName))
			{
				return string.Empty;
			}

			var newValue = string.Empty;
			var attributeTypeCode = attributeTypeCodeDictionary.FirstOrDefault(a => a.Key == attributeName).Value;

			if (attributeTypeCode == null)
			{
				ADXTrace.Instance.TraceError(TraceCategory.Application, "Unable to recognize the attribute specified.");
				return string.Empty;
			}

			try
			{
				switch (attributeTypeCode)
				{
					case AttributeTypeCode.BigInt:
						newValue = value == null ? string.Empty : Convert.ToInt64(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Boolean:
						newValue = value == null ? string.Empty : Convert.ToBoolean(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Customer:
						if (value is EnreplacedyReference)
						{
							var enreplacedyref = value as EnreplacedyReference;
							newValue = enreplacedyref.Id.ToString();
						}
						break;
					case AttributeTypeCode.DateTime:
						newValue = value == null ? string.Empty : Convert.ToDateTime(value).ToUniversalTime().ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Decimal:
						newValue = value == null ? string.Empty : Convert.ToDecimal(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Double:
						newValue = value == null ? string.Empty : Convert.ToDouble(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Integer:
						newValue = value == null ? string.Empty : Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Lookup:
						if (value is EnreplacedyReference)
						{
							var enreplacedyref = value as EnreplacedyReference;
							newValue = enreplacedyref.Id.ToString();
						}
						break;
					case AttributeTypeCode.Memo:
						newValue = value as string;
						break;
					case AttributeTypeCode.Money:
						newValue = value == null ? string.Empty : Convert.ToDecimal(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Picklist:
						newValue = value == null ? string.Empty : Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.State:
						newValue = value == null ? string.Empty : Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.Status:
						newValue = value == null ? string.Empty : Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture);
						break;
					case AttributeTypeCode.String:
						newValue = value as string;
						break;
					case AttributeTypeCode.Uniqueidentifier:
						if (value is Guid)
						{
							var id = (Guid)value;
							newValue = id.ToString();
						}
						break;
					default:
						ADXTrace.Instance.TraceWarning(TraceCategory.Application, string.Format("Attribute type '{0}' is unsupported.", attributeTypeCode));
						break;
				}
			}
			catch (Exception ex)
			{
				WebEventSource.Log.GenericWarningException(ex, string.Format("Attribute specified is expecting a {0}. The value provided is not valid.", attributeTypeCode));
			}
			return newValue;
		}

19 Source : EntityFormFunctions.cs
with MIT License
from Adoxio

internal static dynamic TryConvertAttributeValue(OrganizationServiceContext context, string enreplacedyName, string attributeName, object value, Dictionary<string, AttributeTypeCode?> AttributeTypeCodeDictionary)
		{

			if (context == null || string.IsNullOrWhiteSpace(enreplacedyName) || string.IsNullOrWhiteSpace(attributeName)) return null;

			if (AttributeTypeCodeDictionary == null || !AttributeTypeCodeDictionary.Any())
			{
				AttributeTypeCodeDictionary = MetadataHelper.BuildAttributeTypeCodeDictionary(context, enreplacedyName);
			}

			object newValue = null;
			var attributeTypeCode = AttributeTypeCodeDictionary.FirstOrDefault(a => a.Key == attributeName).Value;

			if (attributeTypeCode == null)
			{
				ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("Unable to recognize the attribute '{0}' specified.", attributeName));
				return null;
			}

			try
			{
				switch (attributeTypeCode)
				{
					case AttributeTypeCode.BigInt:
						newValue = value == null ? (object)null : Convert.ToInt64(value);
						break;
					case AttributeTypeCode.Boolean:
						newValue = value == null ? (object)null : Convert.ToBoolean(value);
						break;
					case AttributeTypeCode.Customer:
						if (value is EnreplacedyReference)
						{
							newValue = value as EnreplacedyReference;
						}
						else if (value is Guid)
						{
							var metadata = MetadataHelper.GetEnreplacedyMetadata(context, enreplacedyName);
							var attribute = metadata.Attributes.FirstOrDefault(a => a.LogicalName == attributeName);
							if (attribute != null)
							{
								var lookupAttribute = attribute as LookupAttributeMetadata;
								if (lookupAttribute != null && lookupAttribute.Targets.Length == 1)
								{
									var lookupEnreplacedyType = lookupAttribute.Targets[0];
									newValue = new EnreplacedyReference(lookupEnreplacedyType, (Guid)value);
								}
							}
						}
						break;
					case AttributeTypeCode.DateTime:
						newValue = value == null ? (object)null : Convert.ToDateTime(value).ToUniversalTime();
						break;
					case AttributeTypeCode.Decimal:
						newValue = value == null ? (object)null : Convert.ToDecimal(value);
						break;
					case AttributeTypeCode.Double:
						newValue = value == null ? (object)null : Convert.ToDouble(value);
						break;
					case AttributeTypeCode.Integer:
						newValue = value == null ? (object)null : Convert.ToInt32(value);
						break;
					case AttributeTypeCode.Lookup:
						if (value is EnreplacedyReference)
						{
							newValue = value as EnreplacedyReference;
						}
						else if (value is Guid)
						{
							var metadata = MetadataHelper.GetEnreplacedyMetadata(context, enreplacedyName);
							var attribute = metadata.Attributes.FirstOrDefault(a => a.LogicalName == attributeName);
							if (attribute != null)
							{
								var lookupAttribute = attribute as LookupAttributeMetadata;
								if (lookupAttribute != null && lookupAttribute.Targets.Length == 1)
								{
									var lookupEnreplacedyType = lookupAttribute.Targets[0];
									newValue = new EnreplacedyReference(lookupEnreplacedyType, (Guid)value);
								}
							}
						}
						break;
					case AttributeTypeCode.Memo:
						newValue = value as string;
						break;
					case AttributeTypeCode.Money:
						newValue = value == null ? (object)null : Convert.ToDecimal(value);
						break;
					case AttributeTypeCode.Picklist:
						var plMetadata = MetadataHelper.GetEnreplacedyMetadata(context, enreplacedyName);
						var plAttribute = plMetadata.Attributes.FirstOrDefault(a => a.LogicalName == attributeName);
						if (plAttribute != null)
						{
							var picklistAttribute = plAttribute as PicklistAttributeMetadata;
							if (picklistAttribute != null)
							{
								int picklistInt;
								OptionMetadata picklistValue;
								if (int.TryParse(string.Empty + value, out picklistInt))
								{
									picklistValue = picklistAttribute.OptionSet.Options.FirstOrDefault(o => o.Value == picklistInt);
								}
								else
								{
									picklistValue = picklistAttribute.OptionSet.Options.FirstOrDefault(o => o.Label.GetLocalizedLabelString() == string.Empty + value);
								}

								if (picklistValue != null && picklistValue.Value.HasValue)
								{
									newValue = value == null ? null : new OptionSetValue(picklistValue.Value.Value);
								}
							}
						}
						break;
					case AttributeTypeCode.State:
						ADXTrace.Instance.TraceWarning(TraceCategory.Application, string.Format("Attribute '{0}' type '{1}' is unsupported. The state attribute is created automatically when the enreplacedy is created. The options available for this attribute are read-only.", attributeName, attributeTypeCode));
						break;
					case AttributeTypeCode.Status:
						if (value == null)
						{
							return false;
						}
						var optionSetValue = new OptionSetValue(Convert.ToInt32(value));
						newValue = optionSetValue;
						break;
					case AttributeTypeCode.String:
						newValue = value as string;
						break;
					default:
						ADXTrace.Instance.TraceWarning(TraceCategory.Application, string.Format("Attribute '{0}' type '{1}' is unsupported.", attributeName, attributeTypeCode));
						break;
				}
			}
			catch (Exception ex)
			{
				WebEventSource.Log.GenericWarningException(ex, string.Format("Attribute '{0}' specified is expecting a {1}. The value provided is not valid.", attributeName, attributeTypeCode));
			}
			return newValue;
		}

19 Source : TypeFilters.cs
with MIT License
from Adoxio

public static bool? Boolean(object input)
		{
			if (input == null)
			{
				return null;
			}

			try
			{
				return Convert.ToBoolean(input);
			}
			catch (FormatException) { }
			catch (InvalidCastException) { }
			
			bool parsed;

			if (BooleanValueMappings.TryGetValue(input.ToString(), out parsed))
			{
				return parsed;
			}

			return null;
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected void AddStep(object dataItem, Control container)
		{
			if (dataItem == null)
			{
				return;
			}

			var replacedle = DataBinder.GetPropertyValue(dataItem, replacedleDataPropertyName, null);
			var indexValue = DataBinder.GetPropertyValue(dataItem, IndexDataPropertyName);
			var activeValue = DataBinder.GetPropertyValue(dataItem, ActiveDataPropertyName);
			var completedValue = DataBinder.GetPropertyValue(dataItem, CompletedDataPropertyName);
			var index = Convert.ToInt32(indexValue);
			var active = Convert.ToBoolean(activeValue);
			var completed = Convert.ToBoolean(completedValue);
			var step = new ProgressStep(index, replacedle, active, completed);
			var item = new HtmlGenericControl("li");
			item.AddClreplaced("list-group-item");

			item.InnerHtml = PrependStepIndexToreplacedle ? string.Format("<span clreplaced='number'>{0}</span>{1}", ZeroBasedIndex ? (step.Index + 1) : step.Index, step.replacedle) : step.replacedle;
			
			if (step.IsActive)
			{
				item.AddClreplaced("active");
			} 
			else if (step.IsCompleted)
			{
				item.AddClreplaced("text-muted list-group-item-success");
				item.InnerHtml += "<span clreplaced='glyphicon glyphicon-ok'></span>";
			}
			else
			{
				item.AddClreplaced("incomplete");
			}

			container.Controls.Add(item);
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected int RenderTypeNumeric(IEnumerable dataSource)
		{
			var count = 0;
			var progressIndex = 0;
			var clreplacedName = "progress-numeric";
			
			var e = dataSource.GetEnumerator();

			if (string.IsNullOrWhiteSpace(Position))
			{
				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}
			else
			{
				switch (Position.ToLowerInvariant())
				{
					case "top":
						clreplacedName += " top";
						break;
					case "bottom":
						clreplacedName += " bottom";
						break;
					case "left":
						clreplacedName += " left";
						CssClreplaced += " col-sm-3 col-md-2";
						break;
					case "right":
						clreplacedName += " right";
						CssClreplaced += " col-sm-3 col-sm-push-9 col-md-2 col-md-push-10";
						break;
				}

				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}

			while (e.MoveNext())
			{
				if (e.Current == null)
				{
					continue;
				}

				var indexValue = DataBinder.GetPropertyValue(e.Current, IndexDataPropertyName);
				var activeValue = DataBinder.GetPropertyValue(e.Current, ActiveDataPropertyName);
				var index = Convert.ToInt32(indexValue);
				var active = Convert.ToBoolean(activeValue);

				if (active)
				{
					progressIndex = ZeroBasedIndex ? index + 1 : index;
				}

				count++;
			}

			var literal = new LiteralControl { Text = string.Format("{0} <span clreplaced='number'>{1}</span> of <span clreplaced='number total'>{2}</span>", NumericPrefix, progressIndex, count) };
			
			Controls.Add(literal);

			return count;
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected int RenderTypeProgressBar(IEnumerable dataSource)
		{
			var count = 0;
			var progressIndex = 0;
			var clreplacedName = "progress";
			var controlContainer = new HtmlGenericControl("div");
			
			var e = dataSource.GetEnumerator();

			if (string.IsNullOrWhiteSpace(Position))
			{
				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}
			else
			{
				switch (Position.ToLowerInvariant())
				{
					case "top":
						clreplacedName += " top";
						break;
					case "bottom":
						clreplacedName += " bottom";
						break;
					case "left":
						clreplacedName += " left";
						CssClreplaced += " col-sm-3 col-md-2";
						break;
					case "right":
						clreplacedName += " right";
						CssClreplaced += " col-sm-3 col-sm-push-9 col-md-2 col-md-push-10";
						break;
				}

				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}

			while (e.MoveNext())
			{
				if (e.Current == null)
				{
					continue;
				}

				var indexValue = DataBinder.GetPropertyValue(e.Current, IndexDataPropertyName);
				var activeValue = DataBinder.GetPropertyValue(e.Current, ActiveDataPropertyName);
				var index = Convert.ToInt32(indexValue);
				var active = Convert.ToBoolean(activeValue);
				
				if (active)
				{
					if (ZeroBasedIndex)
					{
						index++;
					}

					progressIndex = index > 0 ? index - 1 : 0;
				}
				
				count++;
			}

			controlContainer.Attributes["clreplaced"] = "bar progress-bar";

			double percent = 0;

			if (count > 0)
			{
				if (!CountLastStepInProgress)
				{
					percent = (double)(progressIndex * 100) / (count - 1);
				}
				else
				{
					percent = (double)(progressIndex * 100) / count;
				}
			}

			var progress = Math.Floor(percent);

			controlContainer.Attributes["style"] = string.Format("width: {0}%;", progress);
			controlContainer.Attributes["role"] = "progressbar";
			controlContainer.Attributes["aria-valuemin"] = "0";
			controlContainer.Attributes["aria-valuemax"] = "100";
			controlContainer.Attributes["aria-valuenow"] = progress.ToString(CultureInfo.InvariantCulture);

			if (progress.CompareTo(0) == 0)
			{
				controlContainer.Attributes["clreplaced"] = controlContainer.Attributes["clreplaced"] + " zero";
			}

			controlContainer.InnerHtml = string.Format("{0}%", progress);

			Controls.Add(controlContainer);

			return count;
		}

19 Source : RegistryHelper.cs
with Mozilla Public License 2.0
from agebullhu

public static bool GetBoolValue(RegistryKey key, string name, bool def)
        {
            var re = key.GetValue(name);
            if (re == null)
            {
                key.SetValue(name, def);
                key.Flush();
                return def;
            }
            return Convert.ToBoolean(re);
        }

19 Source : Database.cs
with GNU General Public License v3.0
from aiportal

public bool IsExist(string tableName, object condition)
		{
			string sql = MakeSelect(tableName, condition, new string[] { "count(*) > 0" });
			object exist = InvokeSingleQuery(sql, condition);
			return Convert.ToBoolean(exist);
		}

19 Source : mainForm.cs
with MIT License
from ajohns6

private void selectedModsButton_Click(object sender, EventArgs e)
        {
            foreach(DataGridViewRow row in onlineGrid.Rows)
            {
                Boolean enable = Convert.ToBoolean(row.Cells[0].Value);

                PAK pak = new PAK();
                pak.modName = row.Cells[1].Value.ToString();
                pak.modCreator = row.Cells[2].Value.ToString();
                pak.modType = row.Cells[3].Value.ToString();
                pak.modDesc = row.Cells[4].Value.ToString();
                pak.modDir = row.Cells[5].Value.ToString();
                pak.modURL = row.Cells[6].Value.ToString();
                pak.modFile = row.Cells[7].Value.ToString();
                pak.modHash = row.Cells[8].Value.ToString();

                if (enable)
                {
                    enablePAK(pak);
                }
                else
                {
                    disablePAK(pak);
                }
            }

            foreach (DataGridViewRow row in localGrid.Rows)
            {
                Boolean enable = Convert.ToBoolean(row.Cells[0].Value);

                PAK pak = new PAK();
                pak.modName = row.Cells[1].Value.ToString();
                pak.modCreator = row.Cells[2].Value.ToString();
                pak.modType = row.Cells[3].Value.ToString();
                pak.modDesc = row.Cells[4].Value.ToString();
                pak.modDir = row.Cells[5].Value.ToString();
                pak.modURL = row.Cells[6].Value.ToString();
                pak.modFile = row.Cells[7].Value.ToString();
                pak.modHash = row.Cells[8].Value.ToString();

                if (enable)
                {
                    enablePAK(pak);
                }
                else
                {
                    disablePAK(pak);
                }
            }

            if (launch())
            {
                saveSettings();
                if (!this.closeCheck.Checked) Application.Exit();
            }
        }

19 Source : mainForm.cs
with MIT License
from ajohns6

private void removeButton_Click(object sender, EventArgs e)
        {
            StringCollection removals = new StringCollection();
            foreach (DataGridViewRow row in localGrid.Rows)
            {
                if (Convert.ToBoolean(row.Cells[0].Value))
                {
                    removals.Add(row.Cells[5].Value.ToString());
                }
            }

            foreach (string pak in removals)
            {
                if (Directory.Exists(Path.Combine(pakDir, pak)))
                {
                    DeleteDirectory(Path.Combine(pakDir, pak));
                }

                if (Directory.Exists(Path.Combine(pakDir, "~" + pak)))
                {
                    DeleteDirectory(Path.Combine(pakDir, "~" + pak));
                }

                gridSelections.Remove(pak);

                string jsonString = File.ReadAllText(mainForm.localJSON);
                var list = JsonConvert.DeserializeObject<List<PAK>>(jsonString);
                list.Remove(list.Single( s => s.modDir == pak));
                var convertedJSON = JsonConvert.SerializeObject(list);
                File.WriteAllText(mainForm.localJSON, convertedJSON);
            }
                
            saveSettings();

            populateGrid(localJSON);
        }

19 Source : ChangeType.cs
with MIT License
from akasarto

public static T ChangeType<T>(this object @this, T defaultValue = default(T))
		{
			try
			{
				if (@this == null)
				{
					return defaultValue;
				}

				if (@this is T)
				{
					return (T)@this;
				}

				Type conversionType = typeof(T);

				// Nullables
				if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
				{
					conversionType = (new NullableConverter(conversionType)).UnderlyingType;
				}

				if (conversionType.IsEnum)
				{
					var enumStr = @this.ToString();

					// Clean the input string before attempting to convert.
					if (!string.IsNullOrWhiteSpace(enumStr))
					{
						enumStr = InvalidEnumValueChars.Replace(enumStr, string.Empty);
					}

					return (T)Enum.Parse(conversionType, enumStr, ignoreCase: true);
				}

				// String
				if (conversionType.Equals(typeof(string)))
				{
					return (T)((object)Convert.ToString(@this));
				}

				// Guid
				if (conversionType.Equals(typeof(Guid)))
				{
					var input = @this.ToString();

					if (string.IsNullOrWhiteSpace(input))
					{
						return defaultValue;
					}

					Guid output;
					if (Guid.TryParse(input, out output))
					{
						return (T)((object)output);
					}
				}

				// Bool
				if (conversionType.Equals(typeof(bool)))
				{
					return (T)((object)Convert.ToBoolean(@this));
				}

				// Datetime
				if (conversionType.Equals(typeof(DateTime)))
				{
					return (T)((object)DateTime.Parse(@this.ToString(), CultureInfo.CurrentCulture));
				}

				// TimeSpan
				if (conversionType.Equals(typeof(TimeSpan)))
				{
					return (T)((object)TimeSpan.Parse(@this.ToString(), CultureInfo.CurrentCulture));
				}

				// General
				return (T)Convert.ChangeType(@this, conversionType);
			}
			catch
			{
				return defaultValue;
			}
		}

19 Source : NodeControl.cs
with MIT License
from AlexGyver

public bool IsVisible(TreeNodeAdv node)
		{
			NodeControlValueEventArgs args = new NodeControlValueEventArgs(node);
			args.Value = true;
			OnIsVisibleValueNeeded(args);
			return Convert.ToBoolean(args.Value);
		}

19 Source : InteractiveControl.cs
with MIT License
from AlexGyver

protected bool IsEditEnabled(TreeNodeAdv node)
		{
			if (EditEnabled)
			{
				NodeControlValueEventArgs args = new NodeControlValueEventArgs(node);
				args.Value = true;
				OnIsEditEnabledValueNeeded(args);
				return Convert.ToBoolean(args.Value);
			}
			else
				return false;
		}

19 Source : IbContractStorageUi.xaml.cs
with Apache License 2.0
from AlexWan

private void SaveSecFromTable()
        {
            if (SecToSubscrible == null ||
                SecToSubscrible.Count == 0)
            {
                return;
            }

            for (int i = 0; i < _grid.Rows.Count; i++)
            {
                SecurityIb security = SecToSubscrible[i];

                security.Symbol = Convert.ToString(_grid.Rows[i].Cells[0].Value);
                security.Exchange = Convert.ToString(_grid.Rows[i].Cells[1].Value);
                security.SecType = Convert.ToString(_grid.Rows[i].Cells[2].Value);
                security.LocalSymbol = Convert.ToString(_grid.Rows[i].Cells[3].Value);
                security.PrimaryExch = Convert.ToString(_grid.Rows[i].Cells[4].Value);
                security.Currency = Convert.ToString(_grid.Rows[i].Cells[5].Value);
                security.CreateMarketDepthFromTrades = Convert.ToBoolean(_grid.Rows[i].Cells[6].Value);
            }
        }

19 Source : OpenEdgeDataReaderExtensions.cs
with Apache License 2.0
from alexwiese

private static object GetValue<T>(object valueRecord)
        {
            switch (typeof(T).Name)
            {
                case nameof(Int32):
                    return Convert.ToInt32(valueRecord);
                case nameof(Boolean):
                    return Convert.ToBoolean(valueRecord);
                default:
                    return valueRecord;
            }
        }

19 Source : CacheAOPbase.cs
with Apache License 2.0
from anjoy8

private static string In(MethodCallExpression expression, object isTrue)
        {
            var Argument1 = (expression.Arguments[0] as MemberExpression).Expression as ConstantExpression;
            var Argument2 = expression.Arguments[1] as MemberExpression;
            var Field_Array = Argument1.Value.GetType().GetFields().First();
            object[] Array = Field_Array.GetValue(Argument1.Value) as object[];
            List<string> SetInPara = new List<string>();
            for (int i = 0; i < Array.Length; i++)
            {
                string Name_para = "InParameter" + i;
                string Value = Array[i].ToString();
                SetInPara.Add(Value);
            }
            string Name = Argument2.Member.Name;
            string Operator = Convert.ToBoolean(isTrue) ? "in" : " not in";
            string CompName = string.Join(",", SetInPara);
            string Result = $"{Name} {Operator} ({CompName})";
            return Result;
        }

19 Source : BoolToVisibilityConverter.cs
with Apache License 2.0
from AnkiUniversal

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isVisible;
            if (value == null)
                isVisible = false;
            else
                isVisible = System.Convert.ToBoolean(value);

            if (isVisible)
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }

19 Source : Converters.cs
with Apache License 2.0
from anmcgrath

public object Convert (object value, Type targetType, object parameter, CultureInfo culture) {
			if ( value != null && value is bool ) {
				bool val =System.Convert.ToBoolean (value) ;
				return (val ? 1.0 : 0.0) ;
			}
			return (null) ;
		}

19 Source : BoolHandler.cs
with GNU General Public License v3.0
from anotak

public override void SetValue(object value)
		{
			// null?
			if(value == null)
			{
				this.value = false;
			}
			// Compatible type?
			else if((value is int) || (value is float) || (value is bool))
			{
				this.value = Convert.ToBoolean(value);
			}
			// string?
			else if(value is string)
			{
				// Try parsing as string
				if(value.ToString().ToLowerInvariant().StartsWith("t"))
					this.value = true;
				else
					this.value = false;
			}
			else
			{
				this.value = false;
			}
		}

19 Source : OpenMapOptionsForm.cs
with GNU General Public License v3.0
from anotak

private int MatchConfiguration(ConfigurationInfo configinfo, WAD wadfile)
        {
            string configfile = configinfo.Filename;
            int score = 0;

            // prefer configs that have a location set
            if (configinfo.Resources.Count <= 0)
            {
                score -= 2;
            }

            // prefer configs that have a port of choice set
            if (string.IsNullOrEmpty(configinfo.TestProgram))
            {
                score -= 1;
            }

            Configuration cfg = General.LoadGameConfiguration(configfile);

            // Get the map lump names
            IDictionary maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());

            HashSet<string> required_map_lump_names = new HashSet<string>();

            int map_lumps_required = 0;
            // Count how many required lumps we have to find
            foreach (DictionaryEntry ml in maplumpnames)
            {
                string name = ml.Key.ToString();
                // Ignore the map header (it will not be found because the name is different)
                if (name != MapManager.CONFIG_MAP_HEADER && ml.Value is IDictionary)
                {
                    // Read lump setting and count it
                    //if (cfg.ReadSetting("maplumpnames." + name + ".required", false))
                    // ano - for the love of god why isnt any of this typed properly
                    IDictionary hml = (IDictionary)ml.Value;

                    if (hml.Contains("required"))
                    {
                        if (Convert.ToBoolean(hml["required"]))
                        {
                            required_map_lump_names.Add(name.ToString());
                            map_lumps_required++;
                        }
                    }
                }
            }

            // Get the lumps to detect just for game
            IDictionary detectlumps = cfg.ReadSetting("gamedetect", new Hashtable());

            HashSet<string> found_lumps = new HashSet<string>();
            bool b_found_map = false;
            int lump_count = wadfile.Lumps.Count;
            int map_lumps_found = 0;
            for (int lump_index = 0; lump_index < lump_count; lump_index++)
            {
                string lumpname = wadfile.Lumps[lump_index].Name;

                if (detectlumps.Contains(lumpname))
                {
                    found_lumps.Add(lumpname);
                }

                if (!b_found_map)
                {
                    if (maplumpnames.Contains(lumpname))
                    {
                        if (required_map_lump_names.Contains(lumpname))
                        {
                            map_lumps_found++;

                            if (map_lumps_found >= map_lumps_required)
                                b_found_map = true;
                        }
                    }
                    else
                    {
                        map_lumps_found = 0;
                    }
                }
            }

            if (!b_found_map)
            {
                score -= 100;
            }

            foreach (DictionaryEntry lmp in detectlumps)
            {
                // Setting not broken?
                if ((lmp.Value is int) && (lmp.Key is string))
                {
                    // ano - lmp.Value == 1 and 3 are ones we want
                    // If this lumps may not exist, and it is found
                    if ((int)lmp.Value == 2 && found_lumps.Contains((string)lmp.Key))
                    {
                        score -= 3;
                    }
                    // If this lumps must exist, and it is missing
                    else if (((int)lmp.Value == 3) && !found_lumps.Contains((string)lmp.Key))
                    {
                        score -= 7;
                    }
                }
            }

            return score;
		}

19 Source : TalkScheduleFileBased.cs
with MIT License
from AntonyCorbett

private static bool? AttributeToNullableBool(XAttribute? attribute, bool? defaultValue)
        {
            return string.IsNullOrEmpty(attribute?.Value)
                ? defaultValue
                : Convert.ToBoolean(attribute.Value);
        }

19 Source : TalkScheduleFileBased.cs
with MIT License
from AntonyCorbett

private static bool AttributeToBool(XAttribute? attribute, bool defaultValue)
        {
            return attribute == null
               ? defaultValue
               : Convert.ToBoolean(attribute.Value);
        }

19 Source : BoolArgumentParser.cs
with Apache License 2.0
from Appdynamics

public override object Parse(object obj)
        {
            if (obj is ExcelDataProvider.IRangeInfo)
            {
                var r = ((ExcelDataProvider.IRangeInfo)obj).FirstOrDefault();
                obj = (r == null ? null : r.Value);
            }
            if (obj == null) return false;
            if (obj is bool) return (bool)obj;
            if (obj.IsNumeric()) return Convert.ToBoolean(obj);
            bool result;
            if (bool.TryParse(obj.ToString(), out result))
            {
                return result;
            }
            return result;
        }

19 Source : ValueMatcher.cs
with Apache License 2.0
from Appdynamics

protected virtual int CompareStringToObject(string o1, object o2)
        {
            double d1;
            if (double.TryParse(o1, out d1))
            {
                return d1.CompareTo(Convert.ToDouble(o2));
            }
            bool b1;
            if (bool.TryParse(o1, out b1))
            {
                return b1.CompareTo(Convert.ToBoolean(o2));
            }
            DateTime dt1;
            if (DateTime.TryParse(o1, out dt1))
            {
                return dt1.CompareTo(Convert.ToDateTime(o2));
            }
            return IncompatibleOperands;
        }

19 Source : PostgreSchema.cs
with MIT License
from aquilahkj

Column CreateColumn(Table table, DataRow dataRow)
        {
            Column column = new Column(table);
            column.AllowNull = Convert.ToBoolean(dataRow["AllowNull"]);
            column.ColumnName = dataRow["ColumnName"].ToString();
            column.ColumnComment = dataRow["ColumnComment"].ToString();
            column.IsPrimaryKey = Convert.ToBoolean(dataRow["ColumnKey"]);
            column.IsIdenreplacedy = Convert.ToBoolean(dataRow["IsIdenreplacedy"]);

            if (DbSetting.CheckIgnoreField(column.TableName + "." + column.ColumnName) || DbSetting.CheckIgnoreField("*." + column.ColumnName)) {
                return null;
            }

            if (DbSetting.GetAliasField(column.TableName + "." + column.ColumnName, out string fieldName) || DbSetting.GetAliasField("*." + column.ColumnName, out fieldName)) {
                column.FieldName = fieldName;
            }
            else {
                column.FieldName = column.ColumnName;
            }

            string dataType = dataRow["DataType"].ToString();
            column.RawType = dataType;

            if (dataType.Equals("bool", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "bool";
            }
            else if (dataType.Equals("timestamp", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("date", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "DateTime";
            }
            else if (dataType.Equals("money", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("numeric", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "decimal";
            }
            else if (dataType.Equals("float8", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "double";
            }
            else if (dataType.Equals("float4", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "float";
            }
            else if (dataType.Equals("char", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("varchar", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("text", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "string";
            }
            else if (dataType.Equals("int2", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "short";
            }
            else if (dataType.Equals("int4", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "int";
            }
            else if (dataType.Equals("int8", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "long";
            }
            else if (dataType.Equals("bytea", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "byte[]";
            }
            else {
                column.DataType = dataType;
            }

            string tmpType = column.DataType;
            if (string.IsNullOrEmpty(column.ColumnComment)) {
                column.ColumnComment = column.ColumnName;
            }

            if (DbSetting.GetSpecifiedType(column.TableName + "." + column.ColumnName, out string specifiedName) || DbSetting.GetSpecifiedType("*." + column.ColumnName, out specifiedName)) {
                column.DataType = specifiedName;
            }

            if (column.AllowNull && !string.Equals(tmpType, "string", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(tmpType, "byte[]", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = string.Format("{0}?", column.DataType);
            }

            if (int.TryParse(dataRow["MaxLength"].ToString(), out int maxLength)) {
                column.MaxLength = maxLength;
            }

            if (column.AllowNull) {
                if (DbSetting.CheckNotNullField(column.TableName + "." + column.ColumnName) || DbSetting.CheckNotNullField(column.TableName + ".*") || DbSetting.CheckNotNullField("*." + column.ColumnName)) {
                    column.AllowNull = false;
                }
            }

            if (DbSetting.GetDefaultValue(column.TableName + "." + column.ColumnName, out string defaultValue) || DbSetting.GetDefaultValue("*." + column.ColumnName, out defaultValue)) {
                if (DbSetting.GetDefaultValueStringMode()) {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "string") {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "DateTime" || column.DataType == "DateTime?") {
                    if (defaultValue.StartsWith("DefaultTime.")) {
                        column.DefaultValue = defaultValue;
                    }
                    else {
                        column.DefaultValue = "\"" + defaultValue + "\"";
                    }
                }
                else {
                    column.DefaultValue = defaultValue;
                }
            }

            if (DbSetting.GetDbType(column.TableName + "." + column.ColumnName, out string dbType) || DbSetting.GetDbType("*." + column.ColumnName, out dbType)) {
                column.DBType = dbType;
            }

            if (DbSetting.GetControl(column.TableName + "." + column.ColumnName, out string control) || DbSetting.GetControl("*." + column.ColumnName, out control)) {
                column.Control = "FunctionControl." + control;
                if (control == "Create" || control == "Read") {
                    column.NoUpdate = true;
                }
            }
            return column;

        }

19 Source : MssqlSchema.cs
with MIT License
from aquilahkj

Column CreateColumn(Table table, DataRow dataRow)
        {
            Column column = new Column(table);
            column.AllowNull = Convert.ToBoolean(dataRow["AllowNull"]);
            column.ColumnName = dataRow["ColumnName"].ToString();
            column.ColumnComment = dataRow["ColumnComment"].ToString();
            column.IsPrimaryKey = Convert.ToBoolean(dataRow["ColumnKey"]);
            column.IsIdenreplacedy = Convert.ToBoolean(dataRow["IsIdenreplacedy"]);

            if (DbSetting.CheckIgnoreField(column.TableName + "." + column.ColumnName) || DbSetting.CheckIgnoreField("*." + column.ColumnName)) {
                return null;
            }

            if (DbSetting.GetAliasField(column.TableName + "." + column.ColumnName, out string fieldName) || DbSetting.GetAliasField("*." + column.ColumnName, out fieldName)) {
                column.FieldName = fieldName;
            }
            else {
                column.FieldName = column.ColumnName;
            }

            string dataType = dataRow["DataType"].ToString();
            column.RawType = dataType;
            if (dataType.Equals("bit", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "bool";
            }
            else if (dataType.Equals("datetime", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("datetime2", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("smalldatetime", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("time", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("timestamp", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("date", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "DateTime";
            }
            else if (dataType.Equals("datetimeoffset", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "DateTimeOffset";
            }
            else if (dataType.Equals("decimal", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("money", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("smallmoney", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("numeric", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "decimal";
            }
            else if (dataType.Equals("float", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "double";
            }
            else if (dataType.Equals("real", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "float";
            }
            else if (dataType.Equals("char", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("nchar", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("varchar", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("nvarchar", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("text", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("ntext", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "string";
            }
            else if (dataType.Equals("smallint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "short";
            }
            else if (dataType.Equals("tinyint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "byte";
            }
            else if (dataType.Equals("int", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "int";
            }
            else if (dataType.Equals("bigint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "long";
            }
            else if (dataType.Equals("binary", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("varbinary", StringComparison.InvariantCultureIgnoreCase)
            ) {
                column.DataType = "byte[]";
            }
            else {
                column.DataType = dataType;
            }
            string tmpType = column.DataType;
            if (string.IsNullOrEmpty(column.ColumnComment)) {
                column.ColumnComment = column.ColumnName;
            }

            if (DbSetting.GetSpecifiedType(column.TableName + "." + column.ColumnName, out string specifiedName) || DbSetting.GetSpecifiedType("*." + column.ColumnName, out specifiedName)) {
                column.DataType = specifiedName;
            }

            if (column.AllowNull && !string.Equals(tmpType, "string", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(tmpType, "byte[]", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = string.Format("{0}?", column.DataType);
            }

            if (int.TryParse(dataRow["MaxLength"].ToString(), out int maxLength)) {
                column.MaxLength = maxLength;
            }

            if (column.AllowNull) {
                if (DbSetting.CheckNotNullField(column.TableName + "." + column.ColumnName) || DbSetting.CheckNotNullField(column.TableName + ".*") || DbSetting.CheckNotNullField("*." + column.ColumnName)) {
                    column.AllowNull = false;
                }
            }

            if (DbSetting.GetDefaultValue(column.TableName + "." + column.ColumnName, out string defaultValue) || DbSetting.GetDefaultValue("*." + column.ColumnName, out defaultValue)) {
                if (DbSetting.GetDefaultValueStringMode()) {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "string") {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "DateTime" || column.DataType == "DateTime?") {
                    if (defaultValue.StartsWith("DefaultTime.")) {
                        column.DefaultValue = defaultValue;
                    }
                    else {
                        column.DefaultValue = "\"" + defaultValue + "\"";
                    }
                }
                else {
                    column.DefaultValue = defaultValue;
                }
            }

            if (DbSetting.GetDbType(column.TableName + "." + column.ColumnName, out string dbType) || DbSetting.GetDbType("*." + column.ColumnName, out dbType)) {
                column.DBType = dbType;
            }


            if (DbSetting.GetControl(column.TableName + "." + column.ColumnName, out string control) || DbSetting.GetControl("*." + column.ColumnName, out control)) {
                column.Control = "FunctionControl." + control;
                if (control == "Create" || control == "Read") {
                    column.NoUpdate = true;
                }
            }
            return column;
        }

19 Source : MysqlSchema.cs
with MIT License
from aquilahkj

Column CreateColumn(Table table, DataRow dataRow)
        {
            Column column = new Column(table);
            column.AllowNull = Convert.ToBoolean(dataRow["AllowNull"]);
            column.ColumnName = dataRow["ColumnName"].ToString();
            column.ColumnComment = dataRow["ColumnComment"].ToString();
            column.IsPrimaryKey = Convert.ToBoolean(dataRow["ColumnKey"]);
            column.IsIdenreplacedy = Convert.ToBoolean(dataRow["IsIdenreplacedy"]);

            if (DbSetting.CheckIgnoreField(column.TableName + "." + column.ColumnName) || DbSetting.CheckIgnoreField("*." + column.ColumnName)) {
                return null;
            }

            if (DbSetting.GetAliasField(column.TableName + "." + column.ColumnName, out string fieldName) || DbSetting.GetAliasField("*." + column.ColumnName, out fieldName)) {
                column.FieldName = fieldName;
            }
            else {
                column.FieldName = column.ColumnName;
            }

            string columnType = dataRow["ColumnType"].ToString();
            string dataType = dataRow["DataType"].ToString();
            column.RawType = dataType;
            if (dataType.Equals("bit", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "bool";
            }
            else if (dataType.Equals("datetime", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("timestamp", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("date", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "DateTime";
            }
            else if (dataType.Equals("decimal", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("money", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "decimal";
            }
            else if (dataType.Equals("double", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "double";
            }
            else if (dataType.Equals("float", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "float";
            }
            else if (dataType.Equals("char", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("varchar", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("text", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("tinytext", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("mediumtext", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("longtext", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "string";
            }
            else if (dataType.Equals("smallint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "short";
            }
            else if (dataType.Equals("tinyint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "sbyte";
            }
            else if (dataType.Equals("mediumint", StringComparison.InvariantCultureIgnoreCase)
                || dataType.Equals("int", StringComparison.InvariantCultureIgnoreCase)
                ) {
                column.DataType = "int";
            }
            else if (dataType.Equals("bigint", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = "long";
            }
            else {
                column.DataType = "byte[]";
            }
            string tmpType = column.DataType;
            if (string.IsNullOrEmpty(column.ColumnComment)) {
                column.ColumnComment = column.ColumnName;
            }

            if (DbSetting.GetSpecifiedType(column.TableName + "." + column.ColumnName, out string specifiedName) || DbSetting.GetSpecifiedType("*." + column.ColumnName, out specifiedName)) {
                column.DataType = specifiedName;
            }
            else if (columnType.Contains("unsigned")) {
                if (column.DataType == "int" || column.DataType == "short" || column.DataType == "long") {
                    column.DataType = string.Format("u{0}", column.DataType);
                }
                else if (column.DataType == "sbyte") {
                    column.DataType = "byte";
                }
            }

            if (column.AllowNull && !string.Equals(tmpType, "string", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(tmpType, "byte[]", StringComparison.InvariantCultureIgnoreCase)) {
                column.DataType = string.Format("{0}?", column.DataType);
            }

            if (int.TryParse(dataRow["MaxLength"].ToString(), out int maxLength)) {
                column.MaxLength = maxLength;
            }

            if (column.AllowNull) {
                if (DbSetting.CheckNotNullField(column.TableName + "." + column.ColumnName) || DbSetting.CheckNotNullField(column.TableName + ".*") || DbSetting.CheckNotNullField("*." + column.ColumnName)) {
                    column.AllowNull = false;
                }
            }

            if (DbSetting.GetDefaultValue(column.TableName + "." + column.ColumnName, out string defaultValue) || DbSetting.GetDefaultValue("*." + column.ColumnName, out defaultValue)) {
                if (DbSetting.GetDefaultValueStringMode()) {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "string") {
                    column.DefaultValue = "\"" + defaultValue + "\"";
                }
                else if (column.DataType == "DateTime" || column.DataType == "DateTime?") {
                    if (defaultValue.StartsWith("DefaultTime.")) {
                        column.DefaultValue = defaultValue;
                    }
                    else {
                        column.DefaultValue = "\"" + defaultValue + "\"";
                    }
                }
                else {
                    column.DefaultValue = defaultValue;
                }
            }

            if (DbSetting.GetDbType(column.TableName + "." + column.ColumnName, out string dbType) || DbSetting.GetDbType("*." + column.ColumnName, out dbType)) {
                column.DBType = dbType;
            }

            if (DbSetting.GetControl(column.TableName + "." + column.ColumnName, out string control) || DbSetting.GetControl("*." + column.ColumnName, out control)) {
                column.Control = "FunctionControl." + control;
                if (control == "Create" || control == "Read") {
                    column.NoUpdate = true;
                }
            }
            return column;

        }

19 Source : WindowsChrome.axaml.cs
with GNU Affero General Public License v3.0
from arklumpus

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is WindowState state && (state == WindowState.Maximized || state == WindowState.FullScreen))
            {
                return true == System.Convert.ToBoolean(parameter);
            }
            else
            {
                return false == System.Convert.ToBoolean(parameter);
            }
        }

19 Source : Configuration.cs
with GNU General Public License v3.0
from ASCOMInitiative

public T GetValue<T>(string KeyName, string SubKey, T DefaultValue)
        {
            if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", string.Format("Getting {0} value '{1}' in subkey '{2}', default: '{3}'", typeof(T).Name, KeyName, SubKey, DefaultValue.ToString()));

            if (typeof(T) == typeof(bool))
            {
                string registryValue;
                if (SubKey == "")
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey is empty so getting value directly");
                    registryValue = (string)baseRegistryKey.GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }
                else
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey has a value so using it...");
                    registryValue = (string)baseRegistryKey.CreateSubKey(SubKey).GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }

                if (registryValue == null)
                {
                    SetValueInvariant<T>(KeyName, SubKey, DefaultValue);
                    bool defaultValue = Convert.ToBoolean(DefaultValue);
                    registryValue = defaultValue.ToString(CultureInfo.InvariantCulture);
                }

                bool RetVal = Convert.ToBoolean(registryValue, CultureInfo.InvariantCulture);
                if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", string.Format("Retrieved {0} = {1}", KeyName, RetVal.ToString()));
                return (T)((object)RetVal);
            }

            if (typeof(T) == typeof(string))
            {
                string RetVal;
                if (SubKey == "")
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey is empty so getting value directly");
                    RetVal = (string)baseRegistryKey.GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + RetVal);
                }
                else
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey has a value so using it...");
                    RetVal = (string)baseRegistryKey.CreateSubKey(SubKey).GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + RetVal);
                }

                if (RetVal == null)
                {
                    SetValue<T>(KeyName, SubKey, DefaultValue);
                    RetVal = DefaultValue.ToString();
                }
                if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", string.Format("Retrieved {0} = {1}", KeyName, RetVal.ToString()));
                return (T)((object)RetVal);
            }

            if (typeof(T) == typeof(decimal))
            {
                string registryValue;
                if (SubKey == "")
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey is empty so getting value directly");
                    registryValue = (string)baseRegistryKey.GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }
                else
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey has a value so using it...");
                    registryValue = (string)baseRegistryKey.CreateSubKey(SubKey).GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }

                if (registryValue == null)
                {
                    SetValueInvariant<T>(KeyName, SubKey, DefaultValue);
                    decimal defaultValue = Convert.ToDecimal(DefaultValue);
                    registryValue = defaultValue.ToString(CultureInfo.InvariantCulture);
                }

                decimal RetVal = Convert.ToDecimal(registryValue, CultureInfo.InvariantCulture);
                if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", string.Format("Retrieved {0} = {1}", KeyName, RetVal.ToString()));
                return (T)((object)RetVal);
            }

            if (typeof(T) == typeof(DateTime))
            {
                string registryValue;
                if (SubKey == "")
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey is empty so getting value directly");
                    registryValue = (string)baseRegistryKey.GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }
                else
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey has a value so using it...");
                    registryValue = (string)baseRegistryKey.CreateSubKey(SubKey).GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }

                if (registryValue == null)
                {
                    SetValueInvariant<T>(KeyName, SubKey, DefaultValue);
                    return DefaultValue;
                }

                if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue DateTime", $"String value prior to Convert: {registryValue}");

                if (DateTime.TryParse(registryValue, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out DateTime RetVal))
                {
                    // The string parsed OK so return the parsed value;
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue DateTime", string.Format("Retrieved {0} = {1}", KeyName, RetVal.ToString()));
                    return (T)((object)RetVal);
                }
                else // If the string fails to parse, overwrite with the default value and return this
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue DateTime", $"Failed to parse registry value, persisting and returning the default value: {DefaultValue}");
                    SetValueInvariant<T>(KeyName, SubKey, DefaultValue);
                    return DefaultValue;
                }
            }

            if ((typeof(T) == typeof(Int32)) | (typeof(T) == typeof(int)))
            {
                string registryValue;
                if (SubKey == "")
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey is empty so getting value directly");
                    registryValue = (string)baseRegistryKey.GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }
                else
                {
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "SubKey has a value so using it...");
                    registryValue = (string)baseRegistryKey.CreateSubKey(SubKey).GetValue(KeyName);
                    if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", "Value retrieved OK: " + registryValue);
                }

                if (registryValue == null)
                {
                    SetValueInvariant<T>(KeyName, SubKey, DefaultValue);
                    int defaultValue = Convert.ToInt32(DefaultValue);
                    registryValue = defaultValue.ToString(CultureInfo.InvariantCulture);
                }

                int RetVal = Convert.ToInt32(registryValue, CultureInfo.InvariantCulture);
                if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "GetValue", string.Format("Retrieved {0} = {1}", KeyName, RetVal.ToString()));
                return (T)((object)RetVal);
            }

            throw new DriverException("GetValue: Unknown type: " + typeof(T).Name);
        }

19 Source : Configuration.cs
with GNU General Public License v3.0
from ASCOMInitiative

public void SetValueInvariant<T>(string KeyName, string SubKey, T Value)
        {
            if (LOG_CONFIGURATION_CALLS) ServerForm.LogMessage(0, 0, 0, "SetValue DateTime", string.Format("Setting {0} value '{1}' in subkey '{2}' to: '{3}'", typeof(T).Name, KeyName, SubKey, Value.ToString()));

            if ((typeof(T) == typeof(Int32)) | (typeof(T) == typeof(int)))
            {
                int intValue = Convert.ToInt32(Value);
                if (SubKey == "") baseRegistryKey.SetValue(KeyName, intValue.ToString(CultureInfo.InvariantCulture));
                else baseRegistryKey.CreateSubKey(SubKey).SetValue(KeyName, intValue.ToString(CultureInfo.InvariantCulture));
                return;
            }

            if (typeof(T) == typeof(bool))
            {
                bool boolValue = Convert.ToBoolean(Value);
                if (SubKey == "") baseRegistryKey.SetValue(KeyName, boolValue.ToString(CultureInfo.InvariantCulture));
                else baseRegistryKey.CreateSubKey(SubKey).SetValue(KeyName, boolValue.ToString(CultureInfo.InvariantCulture));
                return;
            }

            if (typeof(T) == typeof(decimal))
            {
                decimal decimalValue = Convert.ToDecimal(Value);
                if (SubKey == "") baseRegistryKey.SetValue(KeyName, decimalValue.ToString(CultureInfo.InvariantCulture));
                else baseRegistryKey.CreateSubKey(SubKey).SetValue(KeyName, decimalValue.ToString(CultureInfo.InvariantCulture));
                return;
            }

            if (typeof(T) == typeof(DateTime))
            {
                DateTime dateTimeValue = Convert.ToDateTime(Value);
                if (SubKey == "") baseRegistryKey.SetValue(KeyName, dateTimeValue.ToString("HH:mm:ss", CultureInfo.InvariantCulture));
                else baseRegistryKey.CreateSubKey(SubKey).SetValue(KeyName, dateTimeValue.ToString("HH:mm:ss", CultureInfo.InvariantCulture));
                return;
            }

            throw new DriverException("SetValueInvariant: Unknown type: " + typeof(T).Name);
        }

19 Source : InvertedBooleanConverter.cs
with MIT License
from Autodesk

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool boolValue = System.Convert.ToBoolean(value);
            return !boolValue;
        }

19 Source : InvertedBooleanToVisibilityConverter.cs
with MIT License
from Autodesk

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var boolValue = System.Convert.ToBoolean(value);
            return !boolValue ? Visibility.Visible : Visibility.Collapsed;
        }

19 Source : DelcamDesktopPage.cs
with MIT License
from Autodesk

private static void IsSelected_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DelcamDesktopPage objDesktopPage = (DelcamDesktopPage) d;

            objDesktopPage.OnIsSelectedChanged(Convert.ToBoolean(e.OldValue), Convert.ToBoolean(e.NewValue));
        }

19 Source : DelcamNavigationButton.cs
with MIT License
from Autodesk

private static void IsSelected_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DelcamNavigationButton objHeader = (DelcamNavigationButton) d;

            if (objHeader != null)
            {
                objHeader.OnIsSelectedChanged(Convert.ToBoolean(e.OldValue), Convert.ToBoolean(e.NewValue));
            }
        }

19 Source : Popper.cs
with GNU General Public License v3.0
from avishorp

private bool ConvertToBoolSafe(object o)
        {
            try
            {
                return Convert.ToBoolean(o);
            }
            catch(FormatException e)
            {
                return false;
            }
        }

19 Source : ExpressionInterpreter.cs
with GNU Lesser General Public License v2.1
from axiom3d

void VisitArithmeticUnary (UnaryExpression unary)
		{
			Visit (unary.Operand);

			if (IsNullUnaryLifting (unary))
				return;

			var value = Pop ();

			switch (unary.NodeType) {
			case ExpressionType.Not:
				if (unary.Type.GetNotNullableType () == typeof (bool))
					Push (!Convert.ToBoolean (value));
				else
					Push (~Convert.ToInt32 (value));
				return;
			case ExpressionType.Negate:
				Push (Math.Negate (value, Type.GetTypeCode (unary.Type.GetNotNullableType ())));
				return;
			case ExpressionType.NegateChecked:
				Push (Math.NegateChecked (value, Type.GetTypeCode (unary.Type.GetNotNullableType ())));
				return;
			case ExpressionType.UnaryPlus:
				Push (value);
				return;
			}
		}

19 Source : Math.cs
with GNU Lesser General Public License v2.1
from axiom3d

public static object Evaluate (object a, object b, TypeCode tc, ExpressionType et)
		{
			switch (tc) {
			case TypeCode.Boolean:
				return Evaluate (Convert.ToBoolean (a), Convert.ToBoolean (b), et);
			case TypeCode.Char:
				return Evaluate (Convert.ToChar (a), Convert.ToChar (b), et);
			case TypeCode.Byte:
				return unchecked ((Byte) Evaluate (Convert.ToByte (a), Convert.ToByte (b), et));
			case TypeCode.Decimal:
				return Evaluate (Convert.ToDecimal (a), Convert.ToDecimal (b), et);
			case TypeCode.Double:
				return Evaluate (Convert.ToDouble (a), Convert.ToDouble (b), et);
			case TypeCode.Int16:
				return unchecked ((Int16) Evaluate (Convert.ToInt16 (a), Convert.ToInt16 (b), et));
			case TypeCode.Int32:
				return Evaluate (Convert.ToInt32 (a), Convert.ToInt32 (b), et);
			case TypeCode.Int64:
				return Evaluate (Convert.ToInt64 (a), Convert.ToInt64 (b), et);
			case TypeCode.UInt16:
				return unchecked ((UInt16) Evaluate (Convert.ToUInt16 (a), Convert.ToUInt16 (b), et));
			case TypeCode.UInt32:
				return Evaluate (Convert.ToUInt32 (a), Convert.ToUInt32 (b), et);
			case TypeCode.UInt64:
				return Evaluate (Convert.ToUInt64 (a), Convert.ToUInt64 (b), et);
			case TypeCode.SByte:
				return unchecked ((SByte) Evaluate (Convert.ToSByte (a), Convert.ToSByte (b), et));
			case TypeCode.Single:
				return Evaluate (Convert.ToSingle (a), Convert.ToSingle (b), et);

			}

			throw new NotImplementedException ();
		}

19 Source : PCZSceneManager.cs
with GNU Lesser General Public License v2.1
from axiom3d

public bool SetOption(string key, object val)
        {
            if (key == "ShowBoundingBoxes")
            {
                showBoundingBoxes = Convert.ToBoolean(val);
                return true;
            }

            else if (key == "ShowPortals")
            {
                this.showPortals = Convert.ToBoolean(val);
                return true;
            }
            // send option to each zone
            foreach (PCZone zone in this.zones)
            {
                if (zone.SetOption(key, val) == true)
                {
                    return true;
                }
            }

            // try regular scenemanager option
            if (Options.ContainsKey(key))
            {
                Options[key] = val;
            }
            else
            {
                Options.Add(key, val);
            }

            return true;
        }

See More Examples