Ejemplo n.º 1
0
        public void AddAttribute(Type attributeType, Type[] ctorParamTypes, object[] paramArguments)
        {
            var internalAttributeCtor = attributeType.GetConstructor(ctorParamTypes);
            var internalAttributeCtorRef = TargetModule.Import(internalAttributeCtor);
            var internalAttribute = new CustomAttribute(internalAttributeCtorRef);

            for (int i = 0; i < ctorParamTypes.Count(); i++)
            {
                var paramType = internalAttributeCtorRef.Parameters[i].ParameterType;
                var internalAttributeArgument = new CustomAttributeArgument(paramType, paramArguments[i]);
                internalAttribute.ConstructorArguments.Add(internalAttributeArgument);
            }

            TargetModule.Assembly.CustomAttributes.Add(internalAttribute);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ジェネリック型のインスタンスを生成します。
        /// </summary>
        /// <param name="genericDefinitionType">生成するジェネリック型</param>
        /// <param name="genericArgumentTypeArray">ジェネリック型の型引数の配列</param>
        /// <param name="args">生成時に使用するコンストラクタのパラメタの配列リスト</param>
        /// <returns>ジェネリック型のインスタンス</returns>
        public static object CreateGenericTypeInstance(Type genericDefinitionType, Type[] genericArgumentTypeArray, params object[] args)
        {
            // 引数チェック
            if (false == genericDefinitionType.IsGenericTypeDefinition)
            {
                throw new ArgumentException("指定されたgenericTypeは、ジェネリック型定義ではありません。");
            }

            if (genericDefinitionType.GetGenericArguments().Count() != genericArgumentTypeArray.Count())
            {
                throw new ArgumentOutOfRangeException("生成するジェネリック型の引数の数と、genericArgumentTypeArrayの数が異なります。");
            }

            // インスタンス生成
            Type genericType = genericDefinitionType.MakeGenericType(genericArgumentTypeArray);
            return Activator.CreateInstance(genericType, args);
        }
Ejemplo n.º 3
0
        private static void ValidateThatOnlyOneServiceIsPresent(Type[] serviceTypes)
        {
            if (!serviceTypes.Any())
            {
                throw new TypeLoadException("Unable to locate any concrete implementations of IService");
            }

            if (serviceTypes.Count() != 1)
            {
                var services = new StringBuilder("Only one service is allowed per service host. The following services were detected:\n");

                foreach (var serviceType in serviceTypes)
                {
                    services.AppendLine(serviceType.FullName);
                }

                throw new InvalidOperationException(services.ToString());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Unregisters all the services. Any "on remove" actions are executed.
        /// </summary>
        /// <returns>This object to enable fluent syntax.</returns>
        public ISimpleServiceContainer Clear()
        {
            Type[] entries = new Type[ _services.Count ];
            _services.Keys.CopyTo( entries, 0 );

            for (int i = 0 ; i < entries.Count() ; i++)
            {
                Remove( entries[i] );
            }

            return this;
        }
Ejemplo n.º 5
0
        private void loadFiles(Type[] types)
        {
            foreach(Type type in types) 
            {

                if(this.isInInterfaceList(type))
                {
                    this.values.Add(type);
                }
            }


            if(!com.OB.Facebook.Settings.FacebookSettings.load().IgnoreMissingFilesOnVersion)
            {
                if(types.Count() != values.Count())
                {
                    throw new Exception("Missing implementation of some files. If you want to continue, set the IgnoreMissingFilesOnVersion to true in the settings file"); 
                }
            }

        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            Debug.WriteLine("ConvertBack");
            object[] values = new object[targetTypes.Count()];
            values[0] = slider.Minimum;
            values[1] = slider.Maximum;
            values[2] = slider.TickFrequency;

            double doubleValue;

            if (value != null && double.TryParse(value.ToString(), out doubleValue))
                values[3] = MathHelpers.ValueInTickFrequencyAndRange(slider.Minimum, slider.Maximum, slider.TickFrequency, doubleValue);
            else
                values[3] = MathHelpers.ValueInTickFrequencyAndRange(slider.Minimum, slider.Maximum, slider.TickFrequency, slider.Value);

            return values;

            //return Array.ConvertAll<Type, Object>(targetTypes, t => value);
        }
Ejemplo n.º 7
0
        static string addIndices(Type[] components)
        {
            const string FIELD_FORMAT = "    public const int {0} = {1};\n";
            const string TOTAL_FORMAT = "    public const int TotalComponents = {0};";
            var code = string.Empty;
            for (int i = 0; i < components.Length; i++) {
                var type = components[i];
                if (type != null) {
                    code += string.Format(FIELD_FORMAT, type.RemoveComponentSuffix(), i);
                }
            }

            return code + "\n" + string.Format(TOTAL_FORMAT, components.Count(type => type != null));
        }
Ejemplo n.º 8
0
		protected override object CoreEvaluateExpression(ITemplatingContext templatingContext)
		{
			DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy;
			object leftObj = null, rightObj = null;
			Type leftType, rightType;
			Func<object> onDemandRightExpressionEvaluator;

			Type[] numericTypes = new Type[]
								{
									typeof(Byte),
									typeof(Int16),
									typeof(Int32),
									typeof(Int64),
									typeof(SByte),
									typeof(UInt16),
									typeof(UInt32),
									typeof(UInt64),
									typeof(Single),
									typeof(Double),
									typeof(Decimal),
									typeof(Byte?),
									typeof(Int16?),
									typeof(Int32?),
									typeof(Int64?),
									typeof(SByte?),
									typeof(UInt16?),
									typeof(UInt32?),
									typeof(UInt64?),
									typeof(Single?),
									typeof(Double?),
									typeof(Decimal?)
								};

			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			// *** THIS MUST USE THIS OVERLOAD OR CODE WILL FAIL ***
			dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(false);

			if ((object)this.LeftExpression != null)
				leftObj = this.LeftExpression.EvaluateExpression(templatingContext);

			onDemandRightExpressionEvaluator = () =>
												{
													if ((object)this.RightExpression != null)
														return this.RightExpression.EvaluateExpression(templatingContext);
													else
														return null;
												};

			if ((object)leftObj == null)
				return null;

			leftType = leftObj.GetType();

			switch (this.BinaryOperator)
			{
				case BinaryOperator.Eq:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs == rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs == rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs == rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs == rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs == rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs == rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs == rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs == rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv == 0;
					}

					break;
				}
				case BinaryOperator.Ne:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs != rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs != rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs != rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs != rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs != rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs != rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs != rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs != rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv != 0;
					}

					break;
				}
				case BinaryOperator.Lt:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs < rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs < rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs < rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs < rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs < rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs < rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs < rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs < rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv < 0;
					}

					break;
				}
				case BinaryOperator.Le:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs <= rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs <= rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs <= rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs <= rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs <= rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs <= rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs <= rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs <= rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv <= 0;
					}

					break;
				}
				case BinaryOperator.Gt:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs > rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs > rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs > rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs > rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs > rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs > rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs > rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs > rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv > 0;
					}

					break;
				}
				case BinaryOperator.Ge:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs >= rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs >= rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs >= rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs >= rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs >= rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs >= rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs >= rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs >= rhs;
						}
					}
					else if (typeof(IComparable).IsAssignableFrom(leftType) &&
							typeof(IComparable).IsAssignableFrom(rightType) &&
							rightType.IsAssignableFrom(leftType) &&
							leftType.IsAssignableFrom(rightType))
					{
						IComparable lhs, rhs;
						int crv;

						lhs = leftObj.ChangeType<IComparable>();
						rhs = rightObj.ChangeType<IComparable>();

						if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))");

						return crv >= 0;
					}

					break;
				}
				case BinaryOperator.Add:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs + rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs + rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs + rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs + rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs + rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs + rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs + rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs + rhs;
						}
					}

					break;
				}
				case BinaryOperator.Sub:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs - rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs - rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs - rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs - rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs - rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs - rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs - rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs - rhs;
						}
					}

					break;
				}
				case BinaryOperator.Mul:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs * rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs * rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs * rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs * rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs * rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs * rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs * rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs * rhs;
						}
					}

					break;
				}
				case BinaryOperator.Div:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs / rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs / rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs / rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs / rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs / rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs / rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs / rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs / rhs;
						}
					}

					break;
				}
				case BinaryOperator.Mod:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) ||
							rightType == typeof(Decimal) || rightType == typeof(Decimal?))
						{
							if (leftType != typeof(Single) && leftType != typeof(Single?) &&
								rightType != typeof(Single) && rightType != typeof(Single?) &&
								leftType != typeof(Double) && leftType != typeof(Double?) &&
								rightType != typeof(Double) && rightType != typeof(Double?))
							{
								Decimal lhs, rhs;

								lhs = leftObj.ChangeType<Decimal>();
								rhs = rightObj.ChangeType<Decimal>();

								return lhs % rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Double) || leftType == typeof(Double?) ||
								rightType == typeof(Double) || rightType == typeof(Double?))
						{
							Double lhs, rhs;

							lhs = leftObj.ChangeType<Double>();
							rhs = rightObj.ChangeType<Double>();

							return lhs % rhs;
						}
						else if (leftType == typeof(Single) || leftType == typeof(Single?) ||
								rightType == typeof(Single) || rightType == typeof(Single?))
						{
							Single lhs, rhs;

							lhs = leftObj.ChangeType<Single>();
							rhs = rightObj.ChangeType<Single>();

							return lhs % rhs;
						}
						else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
								rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs % rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs % rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs % rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs % rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs % rhs;
						}
					}

					break;
				}
				case BinaryOperator.Band:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
							rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs & rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs & rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs & rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs & rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs & rhs;
						}
					}

					break;
				}
				case BinaryOperator.Bor:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
							rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs | rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs | rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs | rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs | rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs | rhs;
						}
					}

					break;
				}
				case BinaryOperator.Bxor:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) ||
							rightType == typeof(UInt64) || rightType == typeof(UInt64?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?) &&
								leftType != typeof(Int64) && leftType != typeof(Int64?) &&
								rightType != typeof(Int64) && rightType != typeof(Int64?))
							{
								UInt64 lhs, rhs;

								lhs = leftObj.ChangeType<UInt64>();
								rhs = rightObj.ChangeType<UInt64>();

								return lhs ^ rhs;
							}
							else
							{
								// bad
							}
						}
						else if (leftType == typeof(Int64) || leftType == typeof(Int64?) ||
								rightType == typeof(Int64) || rightType == typeof(Int64?))
						{
							Int64 lhs, rhs;

							lhs = leftObj.ChangeType<Int64>();
							rhs = rightObj.ChangeType<Int64>();

							return lhs ^ rhs;
						}
						else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) ||
								rightType == typeof(UInt32) || rightType == typeof(UInt32?))
						{
							if (leftType != typeof(SByte) && leftType != typeof(SByte?) &&
								rightType != typeof(SByte) && rightType != typeof(SByte?) &&
								leftType != typeof(Int16) && leftType != typeof(Int16?) &&
								rightType != typeof(Int16) && rightType != typeof(Int16?) &&
								leftType != typeof(Int32) && leftType != typeof(Int32?) &&
								rightType != typeof(Int32) && rightType != typeof(Int32?))
							{
								UInt32 lhs, rhs;

								lhs = leftObj.ChangeType<UInt32>();
								rhs = rightObj.ChangeType<UInt32>();

								return lhs ^ rhs;
							}
							else
							{
								Int64 lhs, rhs;

								lhs = leftObj.ChangeType<Int64>();
								rhs = rightObj.ChangeType<Int64>();

								return lhs ^ rhs;
							}
						}
						else
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs ^ rhs;
						}
					}

					break;
				}
				case BinaryOperator.Bls:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) &&
							(rightType == typeof(Int32) || rightType == typeof(Int32?)))
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs << rhs;
						}
					}

					break;
				}
				case BinaryOperator.Brs:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) &&
							(rightType == typeof(Int32) || rightType == typeof(Int32?)))
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs >> rhs;
						}
					}

					break;
				}
				case BinaryOperator.Bsr:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) &&
							(rightType == typeof(Int32) || rightType == typeof(Int32?)))
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs >> rhs;
						}
					}

					break;
				}
				case BinaryOperator.Bur:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1)
					{
						if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) &&
							(rightType == typeof(Int32) || rightType == typeof(Int32?)))
						{
							Int32 lhs, rhs;

							lhs = leftObj.ChangeType<Int32>();
							rhs = rightObj.ChangeType<Int32>();

							return lhs >> rhs;
						}
					}

					break;
				}
				case BinaryOperator.StrLk:
				{
					if (leftType == typeof(String))
					{
						rightObj = onDemandRightExpressionEvaluator();

						if ((object)rightObj == null)
							return false;

						rightType = rightObj.GetType();

						if (rightType == typeof(String))
						{
							string lhs, rhs;

							lhs = leftObj.ChangeType<string>();
							rhs = rightObj.ChangeType<string>();

							return lhs.Contains(rhs);
						}
						/*else
						{
							string lhs, rhs;

							lhs = leftObj.SafeToString();
							rhs = rightObj.SafeToString();

							return lhs.Contains(rhs);
						}*/
					}

					break;
				}
				case BinaryOperator.And:
				{
					if (leftType == typeof(Boolean) || leftType == typeof(Boolean?))
					{
						bool lhs;

						lhs = leftObj.ChangeType<bool>();

						// short circuit evaluate
						if (!lhs)
							return false;

						rightObj = onDemandRightExpressionEvaluator();

						if ((object)rightObj == null)
							return null;

						rightType = rightObj.GetType();

						if (rightType == typeof(Boolean) || rightType == typeof(Boolean?))
						{
							bool rhs;

							rhs = rightObj.ChangeType<bool>();

							return rhs;
						}
					}

					break;
				}
				case BinaryOperator.Or:
				{
					if (leftType == typeof(Boolean) || leftType == typeof(Boolean?))
					{
						bool lhs;

						lhs = leftObj.ChangeType<bool>();

						// short circuit evaluate
						if (lhs)
							return true;

						rightObj = onDemandRightExpressionEvaluator();

						if ((object)rightObj == null)
							return null;

						rightType = rightObj.GetType();

						if (rightType == typeof(Boolean) || rightType == typeof(Boolean?))
						{
							bool rhs;

							rhs = rightObj.ChangeType<bool>();

							return rhs;
						}
					}

					break;
				}
				case BinaryOperator.Xor:
				{
					if (leftType == typeof(Boolean) || leftType == typeof(Boolean?))
					{
						bool lhs;

						lhs = leftObj.ChangeType<bool>();

						// no short circuit evaluate possible here

						rightObj = onDemandRightExpressionEvaluator();

						if ((object)rightObj == null)
							return null;

						rightType = rightObj.GetType();

						if (rightType == typeof(Boolean) || rightType == typeof(Boolean?))
						{
							bool rhs;

							rhs = rightObj.ChangeType<bool>();

							return (lhs && !rhs) || (rhs && !lhs);
						}
					}

					break;
				}
				case BinaryOperator.ObjAs:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (rightType == typeof(String))
					{
						string rhs;

						rhs = rightObj.ChangeType<string>();

						if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)");

						rightType = Type.GetType(rhs, false);

						if ((object)rightType == null)
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType");

						return SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.ChangeType(leftObj, rightType);
					}

					break;
				}
				case BinaryOperator.Parse:
				{
					if (leftType == typeof(String))
					{
						rightObj = onDemandRightExpressionEvaluator();

						if ((object)rightObj == null)
							return null;

						rightType = rightObj.GetType();

						if (rightType == typeof(String))
						{
							string lhs, rhs;
							object result;

							lhs = leftObj.ChangeType<string>();
							rhs = rightObj.ChangeType<string>();

							if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs))
								throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)");

							rightType = Type.GetType(rhs, false);

							if ((object)rightType == null)
								throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType");

							if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.TryParse(rightType, lhs, out result))
								throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.TryParse");

							return result;
						}
					}

					break;
				}
				case BinaryOperator.ObjIs:
				{
					rightObj = onDemandRightExpressionEvaluator();

					if ((object)rightObj == null)
						return null;

					rightType = rightObj.GetType();

					if (rightType == typeof(String))
					{
						string rhs;

						rhs = rightObj.ChangeType<string>();

						if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs))
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)");

						rightType = Type.GetType(rhs, false);

						if ((object)rightType == null)
							throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType");

						return rightType.IsAssignableFrom(leftType);
					}

					break;
				}
				case BinaryOperator.VarPut:
				{
					if (typeof(AspectConstruct).IsAssignableFrom(leftType))
					{
						AspectConstruct lhs;
						IExpressionContainerConstruct expressionContainerConstruct;
						ValueConstruct valueConstruct;

						rightObj = onDemandRightExpressionEvaluator();

						rightType = (object)rightObj != null ? rightObj.GetType() : null;

						lhs = leftObj.ChangeType<AspectConstruct>();

						expressionContainerConstruct = new ExpressionContainerConstruct();

						valueConstruct = new ValueConstruct()
										{
											Type = (object)rightType != null ? rightType.FullName : null,
											__ = rightObj
										};

						((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct;

						this.Assign(lhs.Name, expressionContainerConstruct, templatingContext);

						return rightObj;
					}

					break;
				}
				default:
				{
					throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | binary operator is not recognized");
				}
			}

			throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | type is not supported by the binary operator");
		}
Ejemplo n.º 9
0
 private static void CallBaseMethod(MethodInfo method, Type[] types, ILGenerator iLGenerator) {
     switch (types.Count()) {
         case 0:
             CallBaseMethodNoParms(method, iLGenerator);
             break;
         case 1:
             CallBaseMethodOneParm(method, iLGenerator);
             break;
         default:
             throw new NakedObjectSystemException(string.Format("Error when proxying method {0} on type {1} unexpected number of parms {2}", method.Name, method.DeclaringType.Name, types.Count()));
     }
 }
Ejemplo n.º 10
0
		public static void WriteClass (Type includeType, Type exludeType)
		{
			var interfaces = includeType.GetInterfaces().Where(x=> x.IsPublic);
			interfaces = new Type[]{};
			if(includeType.Name == "Form")
				Console.WriteLine("Form");
			
			//if delegate
			if(typeof(Delegate).IsAssignableFrom(includeType))
					WriteDelegate(includeType);
			// If static with no constructors
			else if (includeType.GetConstructors().Count() == 0)
				WriteNonInherit(includeType,exludeType);
			else
			{
				if(includeType.IsSealed)
					WriteSealedClass(includeType,exludeType);
				else	
				{
					
					BeginBlock("public " + ( includeType.IsAbstract ? "abstract" : "") +  " partial class " + includeType.Name + " : " + includeType.Namespace + "." + includeType.Name + (interfaces.Count() > 0 ? ("," + string.Join(",",interfaces.Select(x=> (x.Namespace + "." + x.Name)).ToArray())): ""));
					WriteConstructors(includeType,exludeType);
					WriteClassFields(includeType,exludeType);
					WriteClassProperties(includeType,exludeType);
					WriteClassEvents(includeType,exludeType);
					WriteClassMethods(includeType,exludeType);
					EndBlock();
				}
			}
		}
Ejemplo n.º 11
0
 static bool IsSkipedType(Widget w, Type[] skipTypes)
 {
     return skipTypes.Count (t => w.GetType ().IsSubclassOf (t)) > 0;
 }
Ejemplo n.º 12
0
        private void AddWidgetToPageAndInvokeIt(Type[] widgetControllerTypes)
        {
            if (widgetControllerTypes == null || widgetControllerTypes.Count() == 0)
                return;

            string pageNamePrefix = "testpage";
            string pageTitlePrefix = "Precompiled Page";
            string urlNamePrefix = "test-page";
            int pageIndex = 1;
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + pageIndex);

            var mvcProxy = this.CreateMvcProxy(widgetControllerTypes[0]);

            var pageId = this.pagesOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, pageIndex);

            for (var i = 0; i < widgetControllerTypes.Count(); i++)
            {
                Telerik.Sitefinity.Frontend.TestUtilities.CommonOperations.FeatherServerOperations.Pages().AddMvcWidgetToPage(pageId, widgetControllerTypes[i].FullName, "Widget" + i, "Body");
            }

            PageInvoker.ExecuteWebRequest(url);
        }
Ejemplo n.º 13
0
        private static void VerifyTypeEquality(Type[] t1, Type[] t2)
        {
            if (TestHelper.AreNotNull(t1, t2))
            {
                Assert.AreEqual(t1.Count(), t2.Count());
                foreach (Type type1 in t1)
                {
                    Type type2 = t2.First(e => e.FullName == type1.FullName);

                    TestHelper.VerifyAttributesEquality(type1.GetCustomAttributesData(), type2.GetCustomAttributesData());
                    TestHelper.VerifyPropertiesEquality(type1.GetProperties(), type2.GetProperties());
                    TestHelper.VerifyMethodsEquality(type1.GetMethods(), type2.GetMethods());
                    TestHelper.VerifyTypeEquality(type1.GetNestedTypes(), type2.GetNestedTypes());
                    TestHelper.VerifyFieldsEquality(type1.GetFields(), type2.GetFields());
                }
            }
        }
Ejemplo n.º 14
0
        private void AssertTree(IEnumerable<TokenBase> BuiltTreeToTest, double ExpectedLiteralNumberValue, Type[] ExpectedTokens)
        {
            //make sure we have the same amount of nodes
            Assert.Equal(BuiltTreeToTest.Count(), ExpectedTokens.Count());

            //current tree node
            int i = 0;

            //make sure we have the expected tokens
            foreach (var TokenFound in BuiltTreeToTest)
            {
                //make sure its the correct type
                Assert.IsAssignableFrom(ExpectedTokens[i], TokenFound);

                //increase the tally
                i++;
            }

            //go make sure the number literal token is correct.
            Assert.Equal(ExpectedLiteralNumberValue, BuiltTreeToTest.OfType<NumberLiteralToken>().Single().Value);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Tries to find the implementation of the base repo object from the given project.  
        /// Will return NULL if more than one is found.  The name can be passed in if the repo name is known, (required if multiple repos in same project).
        /// </summary>
        /// <param name="projectPath"></param>
        /// <param name="optionalRepoName"></param>
        /// <returns></returns>
        internal static RepoSearchResult FindSingleRepo(string projectPath, string optionalRepoName)
        {
            LoggerBase.Log(string.Format("Starting to find single Repo: '{0}, {1}", optionalRepoName, projectPath), isDebugMessage: true);

            var loadedProject = new ProjectEvalutionHelper().LoadEvalutionProject(projectPath);

            LoggerBase.Log("LoadedProject: " + loadedProject.FullName, isDebugMessage: true);

            var repoTypes = new Type[0];
            try
            {
                 repoTypes = loadedProject
                        .GetTypes()
                        .Where(t =>
                            t.IsSubclassOf(typeof(BaseRepo))
                            && !t.IsGenericType
                        )
                        .ToArray();
            }
            catch (ReflectionTypeLoadException ex)
            {
                LoggerBase.Log("Error whilst getting all classes that inherit from baserepo within loadedproject");

                Exception[] loaderExceptions = ex.LoaderExceptions;
                LoggerBase.Log("Logger exceptions:", isDebugMessage: true);
                foreach (var exception in loaderExceptions)
                {
                    LoggerBase.Log(exception, isDebugMessage: true);
                }

                LoggerBase.Log(ex, isDebugMessage: true);
                throw;
            }

            if (!string.IsNullOrWhiteSpace(optionalRepoName))
            {
                var repos = repoTypes.Where(r => r.Name.Equals(optionalRepoName, StringComparison.InvariantCultureIgnoreCase)).ToArray();
                if (!repos.Any())
                {
                    LoggerBase.Log("No repo class found with name: " + optionalRepoName);
                    return null;
                }

                if (repos.Count() > 1)
                {
                    LoggerBase.Log("More than one repo with same name found, please ensure repo is uniquely named in repo project.");
                    return null;
                }

                return new RepoSearchResult(loadedProject, repos.Single());
            }

            if (!repoTypes.Any())
            {
                LoggerBase.Log("No repo class found");
                return null;
            }

            if (repoTypes.Count() > 1)
            {
                LoggerBase.Log("More than one repo found, please specify which repo to use.");
                return null;
            }

            return new RepoSearchResult(loadedProject, repoTypes.Single());
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Gets a method.
 /// </summary>
 /// <param name="t"></param>
 /// <param name="methodName"></param>
 /// <param name="flags"></param>
 /// <param name="p1"></param>
 /// <param name="parameterTypes"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public static System.Reflection.MethodInfo GetMethod(this Type t, string methodName, BindingFlags flags, object p1, Type[] parameterTypes, object p2)
 {
   var ti = t.GetTypeInfo();
   System.Reflection.MethodInfo result = null;
   while (ti != null)
   {
     var potentials = ti.DeclaredMethods.
       Where(r => r.Name == methodName &&
                  r.GetParameters().Count() == parameterTypes.Count());
     foreach (var item in potentials)
     {
       result = item;
       var resultParameters = result.GetParameters();
       for (int i = 0; i < resultParameters.Count(); i++)
       {
         if (resultParameters[i].ParameterType != parameterTypes[i])
         {
           result = null;
           break;
         }
       }
       if (result != null)
         break;
     }
     if (result != null)
       break;
     if (ti.BaseType == null)
       break;
     ti = ti.BaseType.GetTypeInfo();
   }
   return result;
 }
        /// <summary>
        /// Method that implements parameter binding hookup to the global configuration object's
        /// ParameterBindingRules collection delegate.
        /// 
        /// This routine filters based on POST/PUT method status and simple parameter
        /// types.
        /// </summary>
        /// <example>
        /// GlobalConfiguration.Configuration.
        ///       .ParameterBindingRules
        ///       .Insert(0,SimplePostVariableParameterBinding.HookupParameterBinding);
        /// </example>    
        /// <param name="descriptor"></param>
        /// <returns></returns>
        public static HttpParameterBinding HookupParameterBinding(HttpParameterDescriptor descriptor)
        {
            var supportedMethods = descriptor.ActionDescriptor.SupportedHttpMethods;

            //Here添加Code--------

            if (descriptor.ActionDescriptor.GetCustomAttributes<MultiParameterSupportAttribute>().Count <= 0)
                return null;

            //--------------------

            // Only apply this binder on POST and PUT operations
            if (supportedMethods.Contains(HttpMethod.Post) ||
                supportedMethods.Contains(HttpMethod.Put))
            {
                var supportedTypes = new Type[] { typeof(string), 
                                                typeof(int), 
                                                typeof(int?), 
                                                typeof(decimal), 
                                                typeof(decimal?), 
                                                typeof(double), 
                                                typeof(double?), 
                                                typeof(long), 
                                                typeof(long?), 
                                                typeof(bool),
                                                typeof(bool?),
                                                typeof(DateTime),
                                                typeof(DateTime?),
                                                typeof(byte[])
                                            };

                if (supportedTypes.Count(typ => typ == descriptor.ParameterType) > 0)
                    return new SimplePostVariableParameterBinding(descriptor);
            }

            return null;
        }
Ejemplo n.º 18
0
        private void EmitMethodWithParameterCombo(int thissIdx, MethodInfo realMethod, Type[] parameters, MethodBuilder methodBuilder, ParameterInfo[] realParams)
        {
            var gen = methodBuilder.GetILGenerator();
              if (!realMethod.IsStatic)
              {
            // Set 'this' to the result of JishProxy.GetInstance. This allows one
            // class to proxy to methods from different source classes.
            SetReferenceToAppropriateThis(gen, thissIdx);
              }
              for (int i = 0; i < parameters.Length; i++)
              {
            if (IsParamsArray(realParams[i]))
            {
              break;  // Break as this is the last parameter (params must always be last)
            }
            // if (IsParamDelegate(realParams[i])) // TODO: This is in the wrong place
            // {
            // If the param is a delegate it needs to be replaced with a string which
            // will be used to find the 'real' delegate in the jish_internal scope.

            // }
            // Else add standard inline arg
            gen.Emit(OpCodes.Ldarg, i + 1);
              }

              for (int i = parameters.Count(); i < realParams.Length; i++)
              {
            if (IsParamsArray(realParams[i])) break;

            gen.Emit(OpCodes.Ldarg_0);
            gen.Emit(OpCodes.Ldc_I4, thissIdx); // Load the this index into the stack for GetInstance param
            gen.Emit(OpCodes.Ldc_I4, i);
            MethodInfo getLastOptional = typeof (JishProxy).GetMethod("GetOptionalParameterDefaultValue");
            getLastOptional = getLastOptional.MakeGenericMethod(new[] {realParams[i].ParameterType});
            gen.Emit(OpCodes.Callvirt, getLastOptional);
              }
              ParameterInfo last = realParams.Any() ? realParams.Last() : null;
              if (last != null && IsParamsArray(last))
              {
            CovertRemainingParametersToArray(parameters, gen, realParams.Count() - 1, last.ParameterType.GetElementType());
              }
              // Call the real method
              gen.Emit(realMethod.IsStatic ? OpCodes.Call : OpCodes.Callvirt, realMethod);
              gen.Emit(OpCodes.Ret);
        }