当前位置: 首页>>代码示例>>C#>>正文


C# IConvertible类代码示例

本文整理汇总了C#中IConvertible的典型用法代码示例。如果您正苦于以下问题:C# IConvertible类的具体用法?C# IConvertible怎么用?C# IConvertible使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IConvertible类属于命名空间,在下文中一共展示了IConvertible类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetOperand

 private void SetOperand(IConvertible operand)
 {
     switch (Instruction)
     {
         case BFInstruction.SetVariable:
         case BFInstruction.PushVariable:
         case BFInstruction.PushUInt16:
         case BFInstruction.JumpIfFalse:
         case BFInstruction.Jump:
         case BFInstruction.CallProcedure:
         case BFInstruction.CallNative:
         case BFInstruction.BeginProcedure:
         case BFInstruction.PushUInt32:
             if (operand == null)
                 throw new ArgumentException("You must specify 1 operand for this instruction.");
             _operand = new BFOperand(Convert.ToInt64(operand));
             break;
         case BFInstruction.PushFloat:
             if (operand == null)
                 throw new ArgumentException("You must specify 1 operand for this instruction.");
             _operand = new BFOperand(Convert.ToSingle(operand));
             break;
         default:
             if (operand != null)
                 _operand = new BFOperand(Convert.ToInt64(operand));
             break;
     }
 }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:28,代码来源:BFOpcode.cs

示例2: DoBinOp

        protected override IConvertible DoBinOp(IConvertible left, IConvertible right)
        {
            Boolean left1 = Convert.ToBoolean(left);
            Boolean right1 = Convert.ToBoolean(right);

            return left1 && right1;
        }
开发者ID:vorsters,项目名称:MyLanguage,代码行数:7,代码来源:MyLogicalAndNode.cs

示例3: SpriteKernel

 protected SpriteKernel(IConvertible initialVersion)
 {
     SourceList = new Dictionary<IConvertible, SpriteSource>();
     Animation = new PeriodicFunction<SpriteTransformation>(stage => new SpriteTransformation(0));
     RegisteredVersion = new Collection<IConvertible>();
     Version = initialVersion;
 }
开发者ID:simonrouse9461,项目名称:CSE_3902_Mario,代码行数:7,代码来源:SpriteKernel.cs

示例4: GetValue

        protected override IConvertible GetValue()
        {
           // if (!isGotValue)
           // {
                if (OnGetValue == null)
                {
                    throw new InvalidOperationException("This variable is not bound to a formula, so it's value cannot be read.");
                }
                VariableReadEventArgs args = new VariableReadEventArgs(Name);
                args.Type = Type;
                OnGetValue(this, args);

                if (Type != typeof(IConvertible))
                {
                    _Value = (IConvertible)Convert.ChangeType(args.Value, Type);
                }
                else
                {
                    _Value = args.Value;
                }
              //  isGotValue = true;
         //   }
            return _Value;
            
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:25,代码来源:Variable.cs

示例5: ValueCell

 public ValueCell(StructField def, IConvertible value, string displayValue, int offset)
     : base(def)
 {
     _value = value;
     _displayValue = displayValue;
     _offset = offset;
 }
开发者ID:thawk,项目名称:structorian,代码行数:7,代码来源:ValueCell.cs

示例6: AddNumber

 public override string AddNumber(IConvertible number, IList<DbParameter> parameters)
 {
     if (number == null)
     {
         throw new ArgumentNullException("number");
     }
     return number.ToString();
 }
开发者ID:Skycweb,项目名称:blqw-Faller,代码行数:8,代码来源:OracleSaw.cs

示例7: ProxyNumber

 public ProxyNumber( IConvertible value )
 {
     if (value is string)
     {
         this.value = Parse( value as string );
     }
     else
     {
         this.value = value;
     }
 }
开发者ID:gregharding,项目名称:TinyJSON,代码行数:11,代码来源:ProxyNumber.cs

示例8: DoBinOp

        protected override IConvertible DoBinOp(IConvertible left, IConvertible right)
        {
            IComparable left1 = (IComparable)left;
            IComparable right1 = (IComparable)right;

            if (left1.CompareTo(right1) > 0)
            {
                return true;
            }
            return false;
        }
开发者ID:vorsters,项目名称:MyLanguage,代码行数:11,代码来源:MyIsGreaterThanNode.cs

示例9: Ignore

 public Tokenizer Ignore(int priority, IConvertible tokenName, String tokenRegex)
 {
     try {
         Regex.Replace("", tokenRegex, "");
         tokenPriorities[tokenName] = priority;
         tokens[tokenName] = new Regex("^" + tokenRegex + "$");
         ignore[tokenName] = true;
     } catch (Exception e) {
         throw (e);
     }
     return (this);
 }
开发者ID:CMertens,项目名称:StrikeVM,代码行数:12,代码来源:Tokenizer.cs

示例10: AddDecimal

 private static object AddDecimal(IConvertible Left, IConvertible Right)
 {
     decimal num = Left.ToDecimal(null);
     decimal num2 = Right.ToDecimal(null);
     try
     {
         return decimal.Add(num, num2);
     }
     catch (OverflowException)
     {
         return (Convert.ToDouble(num) + Convert.ToDouble(num2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:Operators.cs

示例11: Prop

        /// <summary>
        /// Set one or more properties for the set of matched elements.
        /// </summary>
        ///
        /// <param name="name">
        /// The property to set
        /// </param>
        /// <param name="value">
        /// The value
        /// </param>
        ///
        /// <returns>
        /// The current CQ object
        /// </returns>

        public CQ Prop(string name, IConvertible value)
        {
            // Prop actually works on things other than boolean - e.g. SelectedIndex. For now though only use prop for booleans

            if (HtmlData.IsBoolean(name))
            {
                SetProp(name, value);
            }
            else
            {
                Attr(name, value);
            }
            return this;
        }
开发者ID:emrahoner,项目名称:CsQuery,代码行数:29,代码来源:Prop.cs

示例12: DateTimeFormatPartOptionTO

 public DateTimeFormatPartOptionTO(int length, Func<string, bool, bool> predicate, bool isNumeric,
     IConvertible actualValue, Action<IDateTimeResultTO, bool, IConvertible> assignAction, int resultLength = -1)
 {
     Length = length;
     Predicate = predicate;
     IsNumeric = isNumeric;
     ActualValue = actualValue;
     AssignAction = assignAction;
     if (resultLength == -1)
     {
         ResultLength = Length;
     }
     else
     {
         ResultLength = resultLength;
     }
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:17,代码来源:DateTimeFormatPartOptionTO.cs

示例13: AddDecimal

 private static object AddDecimal(IConvertible conv1, IConvertible conv2)
 {
     decimal num;
     if (conv1 != null)
     {
         num = conv1.ToDecimal(null);
     }
     decimal num2 = conv2.ToDecimal(null);
     try
     {
         return decimal.Add(num, num2);
     }
     catch (OverflowException)
     {
         return (Convert.ToDouble(num) + Convert.ToDouble(num2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ObjectType.cs

示例14: Eval

		public override object Eval (DataRow row)
		{
			//TODO: implement a better caching strategy and a mechanism for cache invalidation.
			//for now only aggregation over the table owning 'row' (e.g. 'sum(parts)'
			//in constrast to 'sum(parent.parts)' and 'sum(child.parts)') is cached.
			if (cacheResults && result != null && column.ReferencedTable == ReferencedTable.Self)
				return result;
				
			count = 0;
			result = null;
			
			object[] values;
			if (rows == null)
				values = column.GetValues (column.GetReferencedRows (row));
			else
				values = column.GetValues (rows);
			
			foreach (object val in values) {
				if (val == null)
					continue;
					
				count++;
				Aggregate ((IConvertible)val);
			}
			
			switch (function) {
			case AggregationFunction.StDev:
			case AggregationFunction.Var:
				result = CalcStatisticalFunction (values);
				break;
					
			case AggregationFunction.Avg:
				result = Numeric.Divide (result, count);
				break;
			
			case AggregationFunction.Count:
				result = count;
				break;
			}
			
			if (result == null)
				result = DBNull.Value;
				
			return result;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:45,代码来源:Aggregation.cs

示例15: SetProperty

        public void SetProperty(string property, IConvertible prop_val)
        {
            PropertyInfo prop_info = item.GetType ().GetProperty (property);

            if (prop_info == null)
                throw new ApplicationException (String.Format (
                    "Unable to set property {0}.{1} to \"{2}\"",
                    item.GetType (), property, prop_val));

            Type prop_type = prop_info.PropertyType;
            object param;

            try {
                param = prop_val.ToType (prop_type, NumberFormatInfo.InvariantInfo);
            } catch (FormatException e) {
                throw new ApplicationException (String.Format (
                    "prop_val cannot be converted to a {0}", prop_type), e);
            }

            prop_info.SetValue (item, param, null);
        }
开发者ID:manicolosi,项目名称:questar,代码行数:21,代码来源:ItemBuilder.cs


注:本文中的IConvertible类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。