Inheritance: Modifier
        public object BusinessCreateLight(List<BusinessLight> businesses, Converter converter, object dataObject)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ExternalId", typeof(string));
            dt.Columns.Add("BusinessId", typeof(int));
            dt.Columns.Add("GenderFCheckIns", typeof(int));
            dt.Columns.Add("GenderMCheckIns", typeof(int));

            Random rnd = new Random();
            int icount = 0;
            businesses.ForEach(x =>
                {
                    DataRow dr = dt.NewRow();
                    dr["ExternalId"] = x.ExternalID;
                    dr["BusinessId"] = rnd.Next();
                    dr["GenderFCheckIns"] = icount;
                    dr["GenderMCheckIns"] = icount;
                    icount = icount + 10;
                    dt.Rows.Add(dr);
                });
            DataTableReader dtr = dt.CreateDataReader();
            while(dtr.Read())
            {
                converter(dtr, dataObject);
            }
            //dt.Select().ToList().ForEach(x=> converter(x,dataObject));

            return dt;
        }
Exemple #2
0
		static AndroidPlatform ()
		{
			var t = Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", throwOnError:true);
#if SECURITY_DEP
			trustEvaluateSsl = (Converter<List<byte[]>, bool>)
				Delegate.CreateDelegate (typeof (Converter<List<byte[]>, bool>),
							t,
							"TrustEvaluateSsl",
							ignoreCase:false,
							throwOnBindFailure:true);
#endif  // SECURITY_DEP
			getDefaultProxy = (Func<IWebProxy>)Delegate.CreateDelegate (
				typeof (Func<IWebProxy>), t, "GetDefaultProxy",
				ignoreCase:false,
				throwOnBindFailure:true);

			getInterfaceAddresses = (GetInterfaceAddressesDelegate)Delegate.CreateDelegate (
				typeof (GetInterfaceAddressesDelegate), t, "GetInterfaceAddresses",
				ignoreCase: false,
				throwOnBindFailure: false);
			
			freeInterfaceAddresses = (FreeInterfaceAddressesDelegate)Delegate.CreateDelegate (
				typeof (FreeInterfaceAddressesDelegate), t, "FreeInterfaceAddresses",
				ignoreCase: false,
				throwOnBindFailure: false);
		}
        public void Execute(IGraphDS myGraphDS, long myIterations, Converter.WriteLineToConsole MyWriteLine)
        {
            var transactionID = myGraphDS.BeginTransaction(null);

            var vertexType = myGraphDS.GetVertexType<IVertexType>(null, transactionID, new RequestGetVertexType("City"), (stats, vType) => vType);
            var inCountryProperty = vertexType.GetOutgoingEdgeDefinition("InCountry");
            var nameProperty = vertexType.GetPropertyDefinition("Name");

            List<double> timeForCityCountryTraversal = new List<double>();

            for (int i = 0; i < myIterations; i++)
            {
                Stopwatch sw = Stopwatch.StartNew();

                foreach (var aCity in myGraphDS.GetVertices<IEnumerable<IVertex>>(null, transactionID, new RequestGetVertices("City"), (stats, v) => v))
                {
                    var UK_Vertex = aCity.GetOutgoingSingleEdge(inCountryProperty.ID).GetTargetVertex();
                }

                sw.Stop();

                timeForCityCountryTraversal.Add(sw.Elapsed.TotalMilliseconds);
            }

            myGraphDS.CommitTransaction(null, transactionID);

            String result =  GenerateTable(timeForCityCountryTraversal) + Environment.NewLine + String.Format("Average: {0}ms Median: {1}ms StandardDeviation {2}ms ", Statistics.Average(timeForCityCountryTraversal), Statistics.Median(timeForCityCountryTraversal), Statistics.StandardDeviation(timeForCityCountryTraversal));
            Console.WriteLine(result);

            MyWriteLine(result);
        }
        /// <summary>
        /// 将value转换为目标类型
        /// 并将转换所得的值放到result
        /// 如果不支持转换,则返回false
        /// </summary>
        /// <param name="converter">转换器实例</param>
        /// <param name="value">要转换的值</param>
        /// <param name="targetType">转换的目标类型</param>
        /// <param name="result">转换结果</param>
        /// <returns>如果不支持转换,则返回false</returns>
        public virtual bool Convert(Converter converter, object value, Type targetType, out object result)
        {
            var dic = value as IDictionary<string, object>;
            if (dic == null)
            {
                result = null;
                return false;
            }

            var instance = Activator.CreateInstance(targetType);
            var setters = PropertySetter.GetPropertySetters(targetType);

            foreach (var set in setters)
            {
                var key = dic.Keys.FirstOrDefault(k => string.Equals(k, set.Name, StringComparison.OrdinalIgnoreCase));
                if (key != null)
                {
                    var targetValue = converter.Convert(dic[key], set.Type);
                    set.SetValue(instance, targetValue);
                }
            }

            result = instance;
            return true;
        }
Exemple #5
0
		public Text(Converter converter)
			: base(converter)
		{
			/*
			this._escapedKeyChars.Add("\\",@"\\");
			this._escapedKeyChars.Add("`",@"\`");
			this._escapedKeyChars.Add("*",@"\*");
			this._escapedKeyChars.Add("_",@"\_");
			this._escapedKeyChars.Add("{",@"\{");
			this._escapedKeyChars.Add("}",@"\}");
			this._escapedKeyChars.Add("[",@"\[");
			this._escapedKeyChars.Add("]",@"\]");
			this._escapedKeyChars.Add("(",@"\)");
			this._escapedKeyChars.Add("#",@"\#");
			this._escapedKeyChars.Add("+",@"\+");
			this._escapedKeyChars.Add("-",@"\-");
			this._escapedKeyChars.Add(".",@"\.");
			this._escapedKeyChars.Add("!",@"\!");
			 */

			this._escapedKeyChars.Add("*", @"\*");
			this._escapedKeyChars.Add("_", @"\_");

			this.Converter.Register("#text", this);
		}
 /// <summary>
 /// Document visitor that handles generic dictionary properties
 /// </summary>
 /// <param name="mapper"></param>
 /// <param name="parser"></param>
 public GenericDictionaryDocumentVisitor(IReadOnlyMappingManager mapper, ISolrFieldParser parser)
 {
     this.mapper = mapper;
     this.parser = parser;
     memoCanHandleType = Memoizer.Memoize<Type, bool>(CanHandleType);
     memoGetThisField = Memoizer.Memoize2<Type, string, SolrFieldModel>(GetThisField);
 }
Exemple #7
0
		/// <summary>
		/// Extracts a list of <see cref="HqlCondition"/> objects from the specified <see cref="SearchCriteria"/>
		/// </summary>
		/// <param name="qualifier">The HQL qualifier to prepend to the criteria variables</param>
		/// <param name="criteria">The search criteria object</param>
		/// <param name="remapHqlExprFunc"></param>
		/// <returns>A list of HQL conditions that are equivalent to the search criteria</returns>
		public static HqlCondition[] FromSearchCriteria(string qualifier, SearchCriteria criteria, Converter<string, string> remapHqlExprFunc)
		{
			var hqlConditions = new List<HqlCondition>();
			if (criteria is SearchConditionBase)
			{
				var sc = (SearchConditionBase)criteria;
				if (sc.Test != SearchConditionTest.None)
				{
					hqlConditions.Add(GetCondition(remapHqlExprFunc(qualifier), sc.Test, sc.Values));
				}
			}
			else
			{
				// recur on subCriteria
				foreach (var subCriteria in criteria.EnumerateSubCriteria())
				{
					// use a different syntax for "extended properties" than regular properties
					var subQualifier = criteria is ExtendedPropertiesSearchCriteria ?
						string.Format("{0}['{1}']", qualifier, subCriteria.GetKey()) :
						string.Format("{0}.{1}", qualifier, subCriteria.GetKey());

					hqlConditions.AddRange(FromSearchCriteria(subQualifier, subCriteria, remapHqlExprFunc));
				}
			}

			return hqlConditions.ToArray();
		}
 public void MenuHandler(Converter<ThreadItem, object> selector, MenuItem menu, PopupTargetInfo pti)
 {
     using (ViewList vl = this.js.ViewList())
     using (DisposableList<ViewItem> views = new DisposableList<ViewItem>(vl))
     using (DisposableList<ThreadItem> threads = new DisposableList<ThreadItem>()) {
         //スレッドを抽出
         foreach (ViewItem view in views) {
             ThreadItem t = view.Thread();
             if (t != null) threads.Add(t);
         }
         //スレッドを全部閉じる
         foreach (ThreadItem t in threads) {
             this.js.Close(t);
         }
         //スレッドのソートキー取得
         List<ThreadKeyPair> pairs = new List<ThreadKeyPair>(threads.Count);
         foreach (ThreadItem t in threads) {
             pairs.Add(new ThreadKeyPair() {
                 Thread = t,
                 SortKey = (IComparable)selector(t),
             });
         }
         //スレッドソート
         if (this.ascending) {
             pairs.Sort(this.AscendingComparison);
         } else {
             pairs.Sort(this.DescendingComparison);
         }
         //全部開く
         foreach (var p in pairs) {
             this.js.Open(p.Thread, 0, OpenOperation.Local, true, false, true);
         }
     }
 }
        /// <summary>
        /// 将value转换为目标类型
        /// 并将转换所得的值放到result
        /// 如果不支持转换,则返回false
        /// </summary>
        /// <param name="converter">转换器实例</param>
        /// <param name="value">要转换的值</param>
        /// <param name="targetType">转换的目标类型</param>
        /// <param name="result">转换结果</param>
        /// <returns>如果不支持转换,则返回false</returns>
        public virtual bool Convert(Converter converter, object value, Type targetType, out object result)
        {
            var valueString = value.ToString();
            if (targetType.IsEnum == true)
            {
                result = Enum.Parse(targetType, valueString, true);
                return true;
            }

            var convertible = value as IConvertible;
            if (convertible != null && typeof(IConvertible).IsAssignableFrom(targetType) == true)
            {
                result = convertible.ToType(targetType, null);
                return true;
            }

            if (typeof(Guid) == targetType)
            {
                result = Guid.Parse(valueString);
                return true;
            }
            else if (typeof(string) == targetType)
            {
                result = valueString;
                return true;
            }

            result = null;
            return false;
        }
Exemple #10
0
        public void LoginCreate(string userName, string password, SourceType UserSourceType, string ExternalID, Converter converter, object dataObject)
        {
            using (DBAccess dbaccess = new DBAccess())
            {

                SqlParameter parameter1 = new SqlParameter();
                parameter1.ParameterName = "@UserName";
                parameter1.Value = userName;
                parameter1.SqlDbType = SqlDbType.VarChar;

                SqlParameter parameter2 = new SqlParameter();
                parameter2.ParameterName = "@UserPassword";
                parameter2.Value = password;
                parameter2.SqlDbType = SqlDbType.VarChar;

                SqlParameter parameter3 = new SqlParameter();
                parameter3.ParameterName = "@ExternalID";
                parameter3.Value = ExternalID;
                parameter3.SqlDbType = SqlDbType.NVarChar;

                SqlParameter parameter4 = new SqlParameter();
                parameter4.ParameterName = "@SourceID";
                parameter4.Value = UserSourceType;
                parameter4.SqlDbType = SqlDbType.Int;

                SqlParameter[] parameters = new SqlParameter[4] { parameter1, parameter2, parameter3, parameter4 };

                SqlDataReader reader = dbaccess.ExecuteProcedure("LoginCreate", this.connectionString, parameters);
                while (reader.Read())
                {
                    converter(reader, dataObject);
                }

            }
        }
Exemple #11
0
        public void When_given_expr_refers_object_array_return_multiple_rows_with_multiple_columns_based_on_first_row()
        {
            var searchResult = JSONQuery.GetValue(jsonTestData, "Messages.Receives");

            Converter converter = new Converter();
            var data = converter.ConvertToRecord(searchResult);

            Assert.AreEqual(data.Length, 3, "Wrong number of results");
            Assert.AreEqual(data[0].FieldCount, 3, "Wrong field count of result");
            // Validate column names
            Assert.AreEqual(data[0].GetName(0), "Content", "1. field has invalid name");
            Assert.AreEqual(data[0].GetName(1), "SendDate", "2. field has invalid name");
            Assert.AreEqual(data[0].GetName(2), "AttachmentCount", "3. field has invalid name");
            // 1. row data validation
            Assert.AreEqual(data[0].GetString(0), "Great you?", "Invalid data on 1. column of 1. row");
            Assert.AreEqual(data[0].GetDateTime(1), new DateTime(2013, 1, 21), "Invalid data on 2. column of 1. row");
            Assert.AreEqual(data[0].GetDouble(2), 0, "Invalid data on 3. column of on 1. row");
            // 2. row data validation
            Assert.AreEqual(data[1].GetString(0), "Ok bye", "Invalid data on 1. column of 2. row");
            Assert.AreEqual(data[1].GetDateTime(1), new DateTime(2013, 1, 25), "Invalid data on 2. column of 2. row");
            Assert.AreEqual(data[1].GetDouble(2), 1, "Invalid data on 3. column of on 2. row");
            // 3. row data validation
            Assert.AreEqual(data[2].GetString(0), "Fine. Nothing new yet! You?", "Invalid data on 1. column of 3. row");
            Assert.AreEqual(data[2].GetDateTime(1), new DateTime(2013, 3, 12), "Invalid data on 2. column of 3. row");
            Assert.IsTrue(data[2].GetSqlDouble(2).IsNull, "Invalid data on 3. column of on 3. row");
        }
Exemple #12
0
        public object BusinessCreateLight(List<BusinessLight> businesses, Converter converter, object dataObject)
        {
            // returns the externalid, internalid and the count

            DataTable businessDT = new DataTable("BusinessLight");

            businessDT.Columns.Add("ExternalId", typeof(string));
            businessDT.Columns.Add("SourceId", typeof(Int32));

            businesses.ForEach(x =>
                {
                    DataRow dr = businessDT.NewRow();
                    dr[0] = x.ExternalID;
                    dr[1] = x.Source;
                    businessDT.Rows.Add(dr);
                });

            using (DBAccess dbaccess = new DBAccess())
            {
                SqlParameter parameter = new SqlParameter();
                parameter.ParameterName = "@BusinessLight";
                parameter.SqlDbType = SqlDbType.Structured;
                parameter.Value = businessDT;
                SqlParameter[] parameters = new SqlParameter[1] { parameter };

                SqlDataReader reader = dbaccess.ExecuteProcedure("CreateBusinessLight", this.sConn, parameters);
                while (reader.Read())
                {
                    converter(reader, dataObject);
                }

            }
            return dataObject;
        }
 public void TestWebmConversion()
 {
     Converter converter = new Converter();
     ConvertSettings VideoSettings = new ConvertSettings();
     bool result = converter.ConvertFile(currentPath + "\\SampleVideo.mp4", 7, 1, false, VideoSettings);
     Assert.AreEqual(true, result);
 }
Exemple #14
0
 public XmlSerializer()
 {
     Culture = Framework.CultureInfo;
     TypeInstantiator = Framework.TypeInstantiator;
     //Converter = Framework.Converter;
     Converter = new Converter(TypeInstantiator);
 }
Exemple #15
0
        public object BusinessGetByLocation(string latitude, string longitude,string distance, Converter converter, object dataObject)
        {
            // returns the externalid, internalid and the count

            using (DBAccess dbaccess = new DBAccess())
            {
                SqlParameter parameter1 = new SqlParameter();
                parameter1.ParameterName = "@latitude";
                parameter1.SqlDbType = SqlDbType.Float;
                parameter1.Value = latitude;

                SqlParameter parameter2 = new SqlParameter();
                parameter2.ParameterName = "@longitude";
                parameter2.SqlDbType = SqlDbType.Float;
                parameter2.Value = longitude;

                SqlParameter parameter3 = new SqlParameter();
                parameter3.ParameterName = "@distance";
                parameter3.SqlDbType = SqlDbType.Int;
                parameter3.Value = distance;

                SqlParameter[] parameters = new SqlParameter[3] { parameter1, parameter2, parameter3 };

                SqlDataReader reader = dbaccess.ExecuteProcedure("BusinessByLocationGet", this.sConn, parameters);
                while (reader.Read())
                {
                    converter(reader, dataObject);
                }

            }
            return dataObject;
        }
        /// <summary>
        /// 将value转换为目标类型
        /// 并将转换所得的值放到result
        /// 如果不支持转换,则返回false
        /// </summary>
        /// <param name="converter">转换器实例</param>
        /// <param name="value">要转换的值</param>
        /// <param name="targetType">转换的目标类型</param>
        /// <param name="result">转换结果</param>
        /// <returns>如果不支持转换,则返回false</returns>
        public virtual bool Convert(Converter converter, object value, Type targetType, out object result)
        {
            var dynamicObject = value as DynamicObject;
            if (dynamicObject == null)
            {
                result = null;
                return false;
            }

            var instance = Activator.CreateInstance(targetType);
            var setters = PropertySetter.GetPropertySetters(targetType);

            foreach (var set in setters)
            {
                object targetValue;
                if (this.TryGetValue(dynamicObject, set.Name, out targetValue) == true)
                {
                    targetValue = converter.Convert(targetValue, set.Type);
                    set.SetValue(instance, targetValue);
                }
            }

            result = instance;
            return true;
        }
        public SetupForm(Converter aRound)
        {
            mRound = aRound;
            InitializeComponent();

            okCancelButton.setOkOnlyStyle();
            spinEdit_Round.Value = mRound.Round;
        }
Exemple #18
0
            public BarMapper(string name, Converter<Bar, double> converter)
            {
                if (converter == null)
                    throw new ArgumentNullException("converter");

                this.Name = name;
                this.converter = converter;
            }
		public LayoutPartPresenter(Guid uid, string name, string iconName, Converter<ILayoutProperties, BaseViewModel> factory)
		{
			UID = uid;
			Name = name;
			if (!string.IsNullOrEmpty(iconName))
				IconSource = IconPath + iconName;
			Factory = factory;
		}
		/// <summary>
		/// Changes all instances of a property in the <paramref name="project"/> by applying a method to its value.
		/// </summary>
		protected void FixProperty(MSBuildBasedProject project, string propertyName, Converter<string, string> method)
		{
			lock (project.SyncRoot) {
				foreach (MSBuild.BuildProperty p in project.GetAllProperties(propertyName)) {
					p.Value = method(p.Value);
				}
			}
		}
 public ConversionDistance(MathIdentifier canConvertFrom, int cost, bool lossless, ConversionRouter nextHop, Converter<ValueStructure, ValueStructure> convert)
 {
     this.CanConvertFrom = canConvertFrom;
     this.Cost = cost;
     this.Lossless = lossless;
     this.NextHop = nextHop;
     this.Convert = convert;
 }
        public void Converts()
        {
            Converter converter = new Converter(new MarkdownWriter());

            string result = converter.Convert(Input);

            Approvals.Verify(result);
        }
 public void VsTextViewCreated(IVsTextView textViewAdapter)
 {
     IWpfTextView textView = editorFactory.GetWpfTextView(textViewAdapter);
     if (textView == null)
         return;
     Converter<IWpfTextView,UIElement> f = new Converter<IWpfTextView,UIElement>((v) => new FSharpJumpList(v));
     FSharpFunc<IWpfTextView, UIElement> ff = FSharpFunc<IWpfTextView, UIElement>.FromConverter(f);
     AddCommandFilter(textViewAdapter, new FSharpJumpCore.FSharpJumpCommandFilter(textView, ff));
 }
Exemple #24
0
        private IFile CacheTransform(IFile imageFile, IFile cacheFile, Converter<IImage, IImage> transform)
        {
            using (var original = LoadOriginalImage(imageFile))
            using (var result = transform(original)) {
                this.CacheFormat.Save(result, cacheFile);
            }

            return cacheFile;
        }
        private NumberImporter(Type type, Converter converter)
        {
            Debug.Assert(type != null);
            Debug.Assert(type.IsValueType);
            Debug.Assert(converter != null);

            _type = type;
            _converter = converter;
        }
        public void RegisterConverter( Converter converter )
        {
            if( converter == null )
            {
                throw new ArgumentNullException( "converter" );
            }

            _converters.Add( converter );
        }
        internal OutgoingMessage( IncomingMessage req, Converter converter, uint flags, object payload )
        {
            InitializeForSend( req.Parent, converter, req.Header.m_cmd, flags, payload );

            m_base.m_header.m_seqReply  = req.Header.m_seq;
            m_base.m_header.m_flags    |= Flags.c_Reply;

            UpdateCRC( converter );
        }
        public void CanConvert_Heading_And_Formating_To_NiceHtml()
        {
            var source = TestResources.Headings_And_Formating;

            var converter = new Converter();

            var result = converter.Convert(source);

            Assert.Inconclusive();
        }
        public void CanConvert_JustHeading_To_NiceHtml()
        {
            var source = TestResources.JustHeadings;

            var converter = new Converter();

            var result = converter.Convert(source);

            Assert.Inconclusive();
        }
Exemple #30
0
 private List<int> FindModelId(List<IModel> delModelList)
 {
     if (CS9__CachedAnonymousMethodDelegate1 == null)
     {
         CS9__CachedAnonymousMethodDelegate1 = delegate (IModel model) {
             return model.ID;
         };
     }
     return delModelList.ConvertAll<int>(CS9__CachedAnonymousMethodDelegate1);
 }
Exemple #31
0
 public OptionSet(Converter <string, string> localizer)
 {
     MessageLocalizer = localizer;
 }
Exemple #32
0
 public DateTime QueryParaObtenerLaHoraDelServer()
 {
     DataTable dt = EjecutarConsulta("select NOW() as fechaHoraServidor");
     return (DateTime)Converter.ParseType(dt.Rows[0]["fechaHoraServidor"], typeof(DateTime));
 }
 public RSExtension[] ListRenderingExtensions()
 {
     Extension[] extensions = rs.ListRenderingExtensions();
     return((RSExtension[])Converter.Convert(extensions));
 }
Exemple #34
0
 /// <summary>
 /// Performs the action on list.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="action">The action.</param>
 /// <param name="collectionChangedArgs">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
 /// <param name="converter">The converter.</param>
 private void PerformActionOnList(IList list, ChangeListAction action, NotifyCollectionChangedEventArgs collectionChangedArgs, Converter <object, object> converter)
 {
     StopListeningForChangeEvents(list);
     action(list, collectionChangedArgs, converter);
     ListenForChangeEvents(list);
 }
Exemple #35
0
        //private void add(string name, Value v)
        //{
        //    var box = env.Add(name, v);

        //    //if (frozenEnv.Value.ContainsKey(name))
        //    //    frozenEnv.Value[name].Value = v;
        //    //else
        //    //    frozenEnv.Value = frozenEnv.Value.Add(name, box);
        //}

        //Binds symbols of the given string to the given External Function.
        public void DefineExternal(string name, Converter <FSharpList <Value>, Value> func)
        {
            DefineExternal(
                name,
                Utils.ConvertToFSchemeFunc(func));
        }
 public void ConvertFromUInt64()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(ulong.MaxValue));
     TestHelper.AreEqual(0, Converter.Convert <sbyte>(ulong.MinValue));
 }
 public void ConvertFromSingle()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>((float)sbyte.MaxValue));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>((float)sbyte.MinValue));
 }
 public void ConvertFromString()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(int.MaxValue.ToString()));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>(int.MinValue.ToString()));
 }
 internal static TTo Convert <TFrom, TTo>(TFrom value) => Converter <TFrom, TTo> .Convert(value);
Exemple #40
0
        public void ConvertFrom_DestinationType_Success()
        {
            Assert.All(ConvertFromTestData(), convertTest =>
            {
                // We need to duplicate this test code as RemoteInvoke can't
                // create "this" as the declaring type is an abstract class.
                if (convertTest.RemoteInvokeCulture == null)
                {
                    if (convertTest.Source != null)
                    {
                        Assert.Equal(convertTest.CanConvert, Converter.CanConvertFrom(convertTest.Context, convertTest.Source.GetType()));
                    }

                    if (convertTest.NetCoreExceptionType == null)
                    {
                        object actual = Converter.ConvertFrom(convertTest.Context, convertTest.Culture, convertTest.Source);
                        Assert.Equal(convertTest.Expected, actual);
                    }
                    else
                    {
                        AssertExtensions.Throws(convertTest.NetCoreExceptionType, convertTest.NetFrameworkExceptionType, () => Converter.ConvertFrom(convertTest.Context, convertTest.Culture, convertTest.Source));
                    }
                }
                else
                {
                    RemoteExecutor.Invoke((typeName, testString) =>
                    {
                        // Deserialize the current test.
                        TypeConverterTestBase testBase = (TypeConverterTestBase)Activator.CreateInstance(Type.GetType(typeName));
                        ConvertTest test = ConvertTest.FromSerializedString(testString);

                        CultureInfo.CurrentCulture = test.RemoteInvokeCulture;
                        if (test.Source != null)
                        {
                            Assert.Equal(test.CanConvert, testBase.Converter.CanConvertFrom(test.Context, test.Source.GetType()));
                        }

                        if (test.NetCoreExceptionType == null)
                        {
                            object actual = testBase.Converter.ConvertFrom(test.Context, test.Culture, test.Source);
                            Assert.Equal(test.Expected, actual);
                        }
                        else
                        {
                            AssertExtensions.Throws(test.NetCoreExceptionType, test.NetFrameworkExceptionType, () => testBase.Converter.ConvertFrom(test.Context, test.Culture, test.Source));
                        }

                        return(RemoteExecutor.SuccessExitCode);
                    }, this.GetType().AssemblyQualifiedName, convertTest.GetSerializedString()).Dispose();
                }
            });
        }
Exemple #41
0
 public void CanConvertTo_NullDestinationType_ReturnsFalse()
 {
     Assert.False(Converter.CanConvertTo(null));
 }
Exemple #42
0
 public void ConvertTo_NullDestinationType_ThrowsArgumentNullException()
 {
     AssertExtensions.Throws <ArgumentNullException>("destinationType", () => Converter.ConvertTo(TypeConverterTests.s_context, null, "", null));
 }
 public void ConvertFromTimeSpan()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(TimeSpan.MaxValue));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>(TimeSpan.MinValue));
 }
 public void ConvertFromChar()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(char.MaxValue));
     TestHelper.AreEqual(0, Converter.Convert <sbyte>(char.MinValue));
 }
 public void ConvertFromBoolean()
 {
     TestHelper.AreEqual(1, Converter.Convert <sbyte>(true));
     TestHelper.AreEqual(0, Converter.Convert <sbyte>(false));
 }
 public void ConvertFromInt64()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>((long)sbyte.MaxValue));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>((long)sbyte.MinValue));
 }
 public void ConvertFromUInt16()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(ushort.MaxValue));
     TestHelper.AreEqual(0, Converter.Convert <sbyte>(ushort.MinValue));
 }
 public void ConvertFromInt32()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(int.MaxValue));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>(int.MinValue));
 }
Exemple #49
0
 /// <summary>
 /// Replaces the items.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
 /// <param name="converter">The converter.</param>
 private void ReplaceItems(IList list, NotifyCollectionChangedEventArgs e, Converter <object, object> converter)
 {
     RemoveItems(list, e, converter);
     AddItems(list, e, converter);
 }
 public void ConvertFromDouble()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>((double)sbyte.MaxValue));
     TestHelper.AreEqual(-128, Converter.Convert <sbyte>((double)sbyte.MinValue));
 }
        public RSExecutionInfo LoadReport(string Report, string HistoryID)
        {
            ExecutionInfo outval = rs.LoadReport(Report, HistoryID);

            return((RSExecutionInfo)Converter.Convert(outval));
        }
Exemple #52
0
 public int ToInt()
 {
     return(Converter.BinaryToInt(binary));
 }
        public int Sort(string SortItem, RSSortDirectionEnum Direction, bool Clear, out string ReportItem, out int NumPages)
        {
            SortDirectionEnum direction = (SortDirectionEnum)Converter.Convert(Direction);

            return(rs.Sort(SortItem, direction, Clear, out ReportItem, out NumPages));
        }
        public RSDocumentMapNode GetDocumentMap()
        {
            DocumentMapNode outval = rs.GetDocumentMap();

            return((RSDocumentMapNode)Converter.Convert(outval));
        }
        public RSExecutionInfo2 LoadDrillthroughTarget2(string DrillthroughID)
        {
            ExecutionInfo2 outval = rs.LoadDrillthroughTarget2(DrillthroughID);

            return((RSExecutionInfo2)Converter.Convert(outval));
        }
Exemple #56
0
        // Requires condition to be atomic
        private void CacheNormalizedImplication(
            DomainTermExpr condition, DomainBoolExpr implies)
        {
            // Check that we do not have a rule with an inconsistent condition yet
            // such rules cannot be accommodated: we require rule premises to be pair wise
            // variable disjoint (note that the rules with coinciding conditions are merged)
            // rules with inconsistent conditions may make the chase incomplete:
            // For instance, consider the KB {c->a, b->c, !b->a} and the condition "!a".
            // chase(!a, KB) = !a, but !a ^ KB is unsatisfiable.

            foreach (var premise in _implications.Keys)
            {
                if (premise.Identifier.Variable.Equals(condition.Identifier.Variable)
                    &&
                    !premise.Identifier.Range.SetEquals(condition.Identifier.Range))
                {
                    CacheResidualFact(new OrExpr <DomainConstraint>(new NotExpr <DomainConstraint>(condition), implies));
                    return;
                }
            }

            // We first chase the implication with all the existing facts, and then
            // chase implications of all existing rules, and all residual facts with the
            // resulting enhanced rule

            var dnfImpl = new Converter <DomainConstraint>(
                Chase(implies),
                IdentifierService <DomainConstraint> .Instance.CreateConversionContext()).Dnf.Expr;

            // Now chase all our knowledge with the rule "condition => dnfImpl"

            // Construct a fake knowledge base for this sake
            var kb = new FragmentQueryKBChaseSupport();

            kb._implications[condition] = dnfImpl;

            var newKey = true;

            foreach (var key in new Set <TermExpr <DomainConstraint> >(_implications.Keys))
            {
                var chasedRuleImpl = kb.Chase(_implications[key]);

                if (key.Equals(condition))
                {
                    newKey         = false;
                    chasedRuleImpl = new AndExpr <DomainConstraint>(chasedRuleImpl, dnfImpl);
                }

                // Simplify using the solver
                _implications[key] = new Converter <DomainConstraint>(
                    chasedRuleImpl,
                    IdentifierService <DomainConstraint> .Instance.CreateConversionContext()).Dnf.Expr;
            }

            if (newKey)
            {
                _implications[condition] = dnfImpl;
            }

            // Invalidate residue
            _residueSize = -1;
        }
 public void ConvertFromDateTime()
 {
     TestHelper.AreEqual(127, Converter.Convert <sbyte>(DateTime.MaxValue));
     TestHelper.AreEqual(0, Converter.Convert <sbyte>(DateTime.MinValue));
 }
Exemple #58
0
 private int[] IntToArray(int Num, int size)
 {
     return(Converter.IntToArray(Num, size));
 }
        protected override List <ColumnSchema> GetProcedureResultColumns(DataTable resultTable)
        {
            return
                ((
                     from r in resultTable.AsEnumerable()

                     let systemType = r.Field <Type>("DataType")
                                      let columnName = r.Field <string>("ColumnName")
                                                       let providerType = Converter.ChangeTypeTo <int>(r["ProviderType"])
                                                                          let dataType = DataTypes.FirstOrDefault(t => t.ProviderDbType == providerType)
                                                                                         let columnType = dataType == null ? null : dataType.TypeName
                                                                                                          let length = r.Field <int> ("ColumnSize")
                                                                                                                       let precision = Converter.ChangeTypeTo <int> (r["NumericPrecision"])
                                                                                                                                       let scale = Converter.ChangeTypeTo <int> (r["NumericScale"])
                                                                                                                                                   let isNullable = Converter.ChangeTypeTo <bool>(r["AllowDBNull"])

                                                                                                                                                                    select new ColumnSchema
            {
                ColumnType = GetDbType(columnType, dataType, length, precision, scale, null, null, null),
                ColumnName = columnName,
                IsNullable = isNullable,
                MemberName = ToValidName(columnName),
                MemberType = ToTypeName(systemType, isNullable),
                SystemType = systemType ?? typeof(object),
                DataType = GetDataType(columnType, null, length, precision, scale),
                ProviderSpecificType = GetProviderSpecificType(columnType),
            }
                     ).ToList());
        }
        public string ConverPara(WithDrivingOrderEntity para)
        {
            StringBuilder sbWhere = new StringBuilder();
            //当前用户对象
            var loginOperater = OperatorProvider.Provider.Current();

            if (loginOperater != null)
            {
                List <string> userDataAuthorize = loginOperater.UserDataAuthorize;
                if (userDataAuthorize != null && userDataAuthorize.Count > 0)
                {
                    var str = "";
                    foreach (var item in userDataAuthorize)
                    {
                        str += string.Format("'{0}',", item);
                    }
                    str = str.Substring(0, str.Length - 1);
                    sbWhere.AppendFormat(" and SchoolId in({0})", str);
                }
            }
            if (para == null)
            {
                return(sbWhere.ToString());
            }

            if (para.MemberName != null)
            {
                sbWhere.AppendFormat(" and (charindex('{0}',MemberName)>0)", para.MemberName);
            }
            if (para.MemberMobile != null)
            {
                sbWhere.AppendFormat(" and (charindex('{0}',MemberMobile)>0)", para.MemberMobile);
            }
            if (para.TeacherName != null)
            {
                sbWhere.AppendFormat(" and (charindex('{0}',TeacherName)>0)", para.TeacherName);
            }
            if (para.SchoolName != null)
            {
                sbWhere.AppendFormat(" and (charindex('{0}',SchoolName)>0)", para.SchoolName);
            }
            if (para.DrivingOrderNo != null)
            {
                sbWhere.AppendFormat(" and (charindex('{0}',DrivingOrderNo)>0)", para.DrivingOrderNo);
            }
            if (para.SchoolId != null)
            {
                sbWhere.AppendFormat(" and SchoolId='{0}'", para.SchoolId);
            }
            if (para.TeacherId != null)
            {
                sbWhere.AppendFormat(" and TeacherId='{0}'", para.TeacherId);
            }
            if (para.StartTime != null)
            {
                sbWhere.Append(base.FormatParameter(" AND ServiceDate>='{0} 00:00:00'", Converter.ParseDateTime(para.StartTime).ToString("yyyy-MM-dd")));
            }
            if (para.EndTime != null)
            {
                sbWhere.Append(base.FormatParameter(" AND ServiceDate<='{0} 23:59:59'", Converter.ParseDateTime(para.EndTime).ToString("yyyy-MM-dd")));
            }

            if (para.Status != null)
            {
                sbWhere.AppendFormat(" and Status='{0}'", para.Status);
            }
            if (para.ServiceDate != null)
            {
                sbWhere.Append(base.FormatParameter(" AND ServiceDate='{0}'", Converter.ParseDateTime(para.ServiceDate).ToString("yyyy-MM-dd")));
            }
            if (para.MemberId != null)
            {
                sbWhere.AppendFormat(" and MemberId='{0}'", para.MemberId);
            }
            if (para.CheckIds != null)
            {
                var str = "";
                foreach (var item in para.CheckIds)
                {
                    str += string.Format("'{0}',", item);
                }
                str = str.Substring(0, str.Length - 1);
                sbWhere.AppendFormat(" and DrivingOrderId in({0})", str);
            }
            return(sbWhere.ToString());
        }