System.Convert.ToString(object)

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

706 Examples 7

19 Source : AssetBundleLoader.cs
with MIT License
from DonnYep

public void UnLoadreplacedet(object customData, bool unloadAllLoadedObjects = false)
        {
            var replacedetBundleName = Convert.ToString(customData);
            if (replacedetBundleDict.ContainsKey(replacedetBundleName))
            {
                replacedetBundleDict[replacedetBundleName].Unload(unloadAllLoadedObjects);
                replacedetBundleDict.Remove(replacedetBundleName);
            }
            if (replacedetBundleHashDict.ContainsKey(replacedetBundleName))
            {
                replacedetBundleHashDict.Remove(replacedetBundleName);
            }
        }

19 Source : NavigationUrlParameterSerializer.cs
with MIT License
from dotnet-ad

public string Serialize(object arg) => Convert.ToString(arg);

19 Source : NorthwindDb.cs
with MIT License
from dotnet-presentations

public static string GetData()
        {
            string result = "";
            DataSet dataSet = new DataSet();
            dataSet.ReadXml("northwind.xml");

            DataTable employeeTable = dataSet.Tables["Employees"];

            foreach (DataRow row in employeeTable.Rows)
            {
                string firstName = Convert.ToString(row["FirstName"]);
                string lastName = Convert.ToString(row["LastName"]);
                DateTime birthdate = Convert.ToDateTime(row["Birthdate"]);
                DateTime retirementDate = birthdate.AddYears(65);

                var isRetired = retirementDate < DateTime.Now;
                if (!isRetired)
                    continue;

                result += $"{firstName} {lastName}: {retirementDate}\r\n";
            }

            return result;
        }

19 Source : Helpers.cs
with MIT License
from Dre-Tas

internal static string DecryptToken(string stringFromCredManager)
        {
            // This happens only after checking if ini and dll exist
            replacedemblyName replacedemblyName = replacedemblyName.GetreplacedemblyName(IniConfigInfo.GetDllPath());
            replacedembly replacedembly = replacedembly.Load(replacedemblyName);
            // Get Decrypting method from dll
            Type type = null;
            if (IniConfigInfo.GetDllClreplaced() != null)
                type = replacedembly.GetType(IniConfigInfo.GetDllClreplaced());

            MethodInfo method = null;
            if (IniConfigInfo.GetDllMethod() != null && type != null)
                    method = type.GetMethod(IniConfigInfo.GetDllMethod());

            if (method != null)
            {
                return Convert.ToString(method.Invoke(null,
                    new object[] { stringFromCredManager }));
            }
            else
            {
                return null;
            }
        }

19 Source : Logging.cs
with GNU General Public License v3.0
from dumplin233

public static bool LogSocketException(string remarks, string server, Exception e)
        {
            UpdateLogFile();
            // just log useful exceptions, not all of them
            if (e is ObfsException)
            {
                ObfsException oe = (ObfsException)e;
                Error("Proxy server [" + remarks + "(" + server + ")] "
                    + oe.Message);
                return true;
            }
            else if (e is NullReferenceException)
            {
                return true;
            }
            else if (e is ObjectDisposedException)
            {
                // ignore
                return true;
            }
            else if (e is SocketException)
            {
                SocketException se = (SocketException)e;
                if ((uint)se.SocketErrorCode == 0x80004005)
                {
                    // already closed
                    return true;
                }
                else if (se.ErrorCode == 11004)
                {
                    Logging.Log(LogLevel.Warn, "Proxy server [" + remarks + "(" + server + ")] "
                        + "DNS lookup failed");
                    return true;
                }
                else if (se.SocketErrorCode == SocketError.HostNotFound)
                {
                    Logging.Log(LogLevel.Warn, "Proxy server [" + remarks + "(" + server + ")] "
                        + "Host not found");
                    return true;
                }
                else if (se.SocketErrorCode == SocketError.ConnectionRefused)
                {
                    Logging.Log(LogLevel.Warn, "Proxy server [" + remarks + "(" + server + ")] "
                        + "connection refused");
                    return true;
                }
                else if (se.SocketErrorCode == SocketError.NetworkUnreachable)
                {
                    Logging.Log(LogLevel.Warn, "Proxy server [" + remarks + "(" + server + ")] "
                        + "network unreachable");
                    return true;
                }
                else if (se.SocketErrorCode == SocketError.TimedOut)
                {
                    //Logging.Log(LogLevel.Warn, "Proxy server [" + remarks + "(" + server + ")] "
                    //    + "connection timeout");
                    return true;
                }
                else if (se.SocketErrorCode == SocketError.Shutdown)
                {
                    return true;
                }
                else
                {
                    Logging.Log(LogLevel.Info, "Proxy server [" + remarks + "(" + server + ")] "
                        + Convert.ToString(se.SocketErrorCode) + ":" + se.Message);

                    Debug(ToString(new StackTrace().GetFrames()));

                    return true;
                }
            }
            return false;
        }

19 Source : PulsarFunction.cs
with Apache License 2.0
from eaba

private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value == null)
            {
                return "";
            }
        
            if (value is System.Enum)
            {
                var name = System.Enum.GetName(value.GetType(), value);
                if (name != null)
                {
                    var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name);
                    if (field != null)
                    {
                        var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) 
                            as System.Runtime.Serialization.EnumMemberAttribute;
                        if (attribute != null)
                        {
                            return attribute.Value != null ? attribute.Value : name;
                        }
                    }
        
                    var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo));
                    return converted == null ? string.Empty : converted;
                }
            }
            else if (value is bool) 
            {
                return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant();
            }
            else if (value is byte[])
            {
                return System.Convert.ToBase64String((byte[]) value);
            }
            else if (value.GetType().IsArray)
            {
                var array = System.Linq.Enumerable.OfType<object>((System.Array) value);
                return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo)));
            }
        
            var result = System.Convert.ToString(value, cultureInfo);
            return result == null ? "" : result;
        }

19 Source : _CodeModule.cs
with Mozilla Public License 2.0
from ehsan2022002

[SupportByVersion("VBIDE", 12, 14, 5.3)]
        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public string get_ProcOfLine(Int32 line, out NetOffice.VBIDEApi.Enums.vbext_ProcKind procKind)
        {
            ParameterModifier[] modifiers = Invoker.CreateParamModifiers(false, true);
            procKind = 0;
            object[] paramsArray = Invoker.ValidateParamsArray(line, procKind);
            object returnItem = Invoker.PropertyGet(this, "ProcOfLine", paramsArray, modifiers);
            procKind = (NetOffice.VBIDEApi.Enums.vbext_ProcKind)paramsArray[1];
            return NetRuntimeSystem.Convert.ToString(returnItem);
        }

19 Source : SinkHelper.cs
with Mozilla Public License 2.0
from ehsan2022002

protected static string ToString(object value)
        {
            try
            {
                return Convert.ToString(value);
            }
            catch
            {
                return String.Empty;
            }
        }

19 Source : CommonUtils.cs
with Mozilla Public License 2.0
from ehsan2022002

protected internal double? TryGetApplicationVersion()
        {
            try
            {
                if (_ownerApplication.EnreplacedyIsAvailable("Version"))
                {
                    object result = _ownerApplication.Invoker.PropertyGet(_ownerApplication, "Version");
                    string[] version = Convert.ToString(result).Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                    if (version.Length > 1)
                    {
                        return Convert.ToDouble(version[0] + "." + version[1], CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        return Convert.ToDouble(version[0], CultureInfo.InvariantCulture);
                    }
                }
                else
                {
                    return null;
                }
            }
            catch
            {
                return null;
            }
        }

19 Source : ColumnDetails.cs
with MIT License
from elastacloud

public string GetFormattedValue(object rawValue, ViewPort viewPort, bool displayNulls, string verticalSeperator)
      {
         string value = Convert.ToString(rawValue);
         var formatted = new StringBuilder();
         int targetWidth = columnWidth > viewPort.Width ? viewPort.Width - ((verticalSeperator.Length*2)+1) : columnWidth;

         if (displayNulls && rawValue == null)
         {

            for (int k = 0; k < targetWidth - 6; k++)
            {
               formatted.Append(" ");
            }
            formatted.Append("[null]");

            return formatted.ToString();
         }

         int padReq = targetWidth - value.Length;
         if (padReq > 0)
         {
            for (int k = 0; k < padReq; k++)
            {
               formatted.Append(" ");
            }
            formatted.Append(value);
         }
         else if (padReq < 0)
         {
            if (columnWidth > 3)
            {
               formatted.Append(value.Substring(0, targetWidth - 3));
               formatted.Append("...");
            }
            else
            {
               formatted.Append(value.Substring(0, targetWidth));
            }
         }
         else
         {
            formatted.Append(value);
         }
         return formatted.ToString();
      }

19 Source : SqlEventListener.cs
with Apache License 2.0
from elastic

private void ProcessBeginExecute(IReadOnlyList<object> payload)
		{
			if (payload.Count != 4)
			{
				_logger?.Debug()
					?.Log("BeginExecute event has {PayloadCount} payload items instead of 4. Event processing is skipped.", payload.Count);
				return;
			}

			var id = Convert.ToInt32(payload[0]);
			var dataSource = Convert.ToString(payload[1]);
			var database = Convert.ToString(payload[2]);
			var commandText = Convert.ToString(payload[3]);
			var start = Stopwatch.GetTimestamp();

			_logger?.Trace()
				?.Log("Process BeginExecute event. Id: {Id}. Data source: {DataSource}. Database: {Database}. CommandText: {CommandText}.", id,
					dataSource, database, commandText);

			var spanName = !string.IsNullOrWhiteSpace(commandText)
				? commandText.Replace(Environment.NewLine, "")
				: database;

			var span = ExecutionSegmentCommon.StartSpanOnCurrentExecutionSegment(_apmAgent, spanName, ApiConstants.TypeDb, ApiConstants.SubtypeMssql,
				InstrumentationFlag.SqlClient, isExitSpan: true);

			if (span == null) return;

			if (_processingSpans.TryAdd(id, (span, start)))
			{
				span.Context.Db = new Database
				{
					Statement = !string.IsNullOrWhiteSpace(commandText)
						? commandText.Replace(Environment.NewLine, "")
						: string.Empty,
					Instance = database,
					Type = Database.TypeSql
				};

				span.Context.Destination = _apmAgent.TracerInternal.DbSpanCommon.GetDestination($"Data Source={dataSource}", null);

				// At the moment only System.Data.SqlClient and Microsoft.Data.SqlClient spread events via EventSource with Microsoft-AdoNet-SystemData name
				span.Subtype = ApiConstants.SubtypeMssql;
			}
		}

19 Source : EasyComparer.cs
with MIT License
from Elem8100

protected virtual string OutputNodeValue(string fullPath, object value, int col, string outputDir)
        {

            if (value == null)
                return null;

            Wz_Png png;
            Wz_Uol uol;
            Wz_Sound sound;
            Wz_Vector vector;
            
            if ((png = value as Wz_Png) != null)
            {
                if (OutputPng)
                {
                    char[] invalidChars = Path.GetInvalidFileNameChars();
                    string colName = col == 0 ? "new" : (col == 1 ? "old" : col.ToString());
                    string filePath = fullPath.Replace('\\', '.') + "_" + colName + ".png";

                    for (int i = 0; i < invalidChars.Length; i++)
                    {
                        filePath = filePath.Replace(invalidChars[i].ToString(), null);
                    }

                    Bitmap bmp = png.ExtractPng();
                    if (bmp != null)
                    {
                        bmp.Save(Path.Combine(outputDir, filePath), System.Drawing.Imaging.ImageFormat.Png);
                        bmp.Dispose();
                    }
                    return string.Format("<img src=\"{0}\" />", Path.Combine(new DirectoryInfo(outputDir).Name, filePath));
                }
                else
                {
                    return string.Format("png {0}*{1} ({2} bytes)", png.Width, png.Height, png.DataLength);
                }

            }
            else if ((uol = value as Wz_Uol) != null)
            {
                return uol.Uol;
            }
            else if ((vector = value as Wz_Vector) != null)
            {
                return string.Format("({0}, {1})", vector.X, vector.Y);
            }
            else if ((sound = value as Wz_Sound) != null)
            {
                return string.Format("sound {0}ms", sound.Ms);
            }
            else if (value is Wz_Image)
            {
                return "{ img }";
            }
            return Convert.ToString(value);

        }

19 Source : DBConnection.cs
with MIT License
from Elem8100

public void OutputCsv(StreamWriter sw, DataTable dt)
        {
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                DataColumn col = dt.Columns[i];
                sw.Write(ConvertCell(col.ColumnName));

                if (i < dt.Columns.Count - 1)
                    sw.Write(",");
                else
                    sw.WriteLine();
            }

            foreach (DataRow row in dt.Rows)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    sw.Write(ConvertCell(Convert.ToString(row[i])));

                    if (i < dt.Columns.Count - 1)
                        sw.Write(",");
                    else
                        sw.WriteLine();
                }
            }
        }

19 Source : ImageDragHandler.cs
with MIT License
from Elem8100

void OwnerControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && OwnerControl.Image != null
                && this.dragBox != Rectangle.Empty && !this.dragBox.Contains(e.Location))
            {
                string fileName = Convert.ToString(OwnerControl.Tag);
                ImageDataObject dataObj = new ImageDataObject(OwnerControl.Image, fileName);
                var dragEff = this.OwnerControl.DoDragDrop(dataObj, DragDropEffects.Copy);
            }
        }

19 Source : BDynamicComponent.cs
with MIT License
from Element-Blazor

protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            var render = Component as IControlRender;
            if (render != null)
            {
                if (Config == null)
                {
                    throw new BlazuiException("Component 类型为 IControlRender 时,必须指定 Config 参数");
                }

                render.Render(builder, Config);
                return;
            }
            else if (Component is Type type)
            {
                builder.OpenComponent(0, type);
                var seq = 1;
                foreach (var key in Parameters.Keys)
                {
                    builder.AddAttribute(seq++, key, Parameters[key]);
                }
                builder.CloseComponent();
                return;
            }
            if (Component is RenderFragment renderFragment)
            {
                builder.AddContent(0, renderFragment);
                return;
            }
            builder.AddMarkupContent(0, Convert.ToString(Component));
        }

19 Source : DataStreamManager.cs
with MIT License
from Emotiv

private void OnFacialExpressionReceived(object sender, ArrayList data)
        {
            if (_facLists == null || _facLists.Count != data.Count) {
                UnityEngine.Debug.Logreplacedertion("OnFacialExpressionReceived: Mismatch between data and label");
                return;
            }
            double time     = Convert.ToDouble(data[0]);
            string eyeAct   = Convert.ToString(data[1]);
            string uAct     = Convert.ToString(data[2]);
            double uPow     = Convert.ToDouble(data[3]);
            string lAct     = Convert.ToString(data[4]);
            double lPow     = Convert.ToDouble(data[5]);
            FacEventArgs facEvent = new FacEventArgs(time, eyeAct,
                                                    uAct, uPow, lAct, lPow);
            string facListsStr = "";
            foreach (var ele in _facLists) {
                facListsStr += ele + " , ";
            }
            UnityEngine.Debug.Log("Fac labels: " +facListsStr);
            UnityEngine.Debug.Log("Fac datas : " +facEvent.Time.ToString() + " , " + facEvent.EyeAct+ " , " +
                                facEvent.UAct + " , " + facEvent.UPow.ToString() + " , " +
                                facEvent.LAct + " , " + facEvent.LPow.ToString());
            
            // TODO: emit event to other modules
            // FacialExpReceived(this, facEvent);
        }

19 Source : DataStreamManager.cs
with MIT License
from Emotiv

private void OnMentalCommandReceived(object sender, ArrayList data)
        {
            if (_mentalCommandLists == null || _mentalCommandLists.Count != data.Count) {
                UnityEngine.Debug.Logreplacedertion("OnMentalCommandReceived: Mismatch between data and label");
                return;
            }
            double time     = Convert.ToDouble(data[0]);
            string act      = Convert.ToString(data[1]);
            double pow      = Convert.ToDouble(data[2]);
            MentalCommandEventArgs comEvent = new MentalCommandEventArgs(time, act, pow);
            string comListsStr = "";
            foreach (var ele in _mentalCommandLists) {
                comListsStr += ele + " , ";
            }
            UnityEngine.Debug.Log("MentalCommand labels: " +comListsStr);
            UnityEngine.Debug.Log("MentalCommand datas : " +comEvent.Time.ToString() + " , " 
                                + comEvent.Act+ " , " + comEvent.Pow);
            
            // TODO: emit event to other modules
            //MentalCommandReceived(this, comEvent);
        }

19 Source : DataStreamManager.cs
with MIT License
from Emotiv

private void OnSysEventReceived(object sender, ArrayList data)
        {
            if (_sysLists == null || _sysLists.Count != data.Count) {
                UnityEngine.Debug.Logreplacedertion("OnSysEventReceived: Mismatch between data and label");
                return;
            }
            double time         = Convert.ToDouble(data[0]);
            string detection    = Convert.ToString(data[1]);
            string eventMsg     = Convert.ToString(data[2]);
            SysEventArgs sysEvent = new SysEventArgs(time, detection, eventMsg);
            string SysListsStr = "";
            foreach (var ele in _sysLists) {
                SysListsStr += ele + " , ";
            }
            UnityEngine.Debug.Log("MentalCommand labels: " +SysListsStr);
            UnityEngine.Debug.Log("MentalCommand datas : " +sysEvent.Time.ToString() + " , " 
                                + sysEvent.Detection+ " , " + sysEvent.EventMessage);
            
            // TODO: emit event to other modules
            SysEventReceived(this, sysEvent);
        }

19 Source : ReadFromFile.cs
with MIT License
from ENGworks-DEV

public List<List<string>> ExcelInfo (string path)
        {

            List<string> output = new List<string>();

            try
            {

            
            var excelApp = new Microsoft.Office.Interop.Excel.Application();

            //Dont show Excel when open
            excelApp.Visible = false;

            Microsoft.Office.Interop.Excel.Workbooks books = excelApp.Workbooks;

            //Open Excel file by Path provided by the user
            Microsoft.Office.Interop.Excel.Workbook sheet = books.Open(path);

            //Select worksheet by the name provided by the user
            //Microsoft.Office.Interop.Excel.Worksheet indsheet = sheet.Sheets[worksheet];
            Microsoft.Office.Interop.Excel.Worksheet indsheet = sheet.Worksheets[1];

            //Microsoft.Office.Interop.Excel.Range range = indsheet.get_Range(CellStart, CellEnd);

            //Get the used cell range in Excel
            Microsoft.Office.Interop.Excel.Range range = indsheet.UsedRange;


            object[,] cellValues = (object[,])range.Value2;
            output = cellValues.Cast<object>().ToList().ConvertAll(x => Convert.ToString(x));

            //Get number of used columns
            int columnCount = range.Columns.Count;

            //Split list by column count
            List<List<string>> list = new List<List<string>>();
            for (int i = 0; i < output.Count; i += columnCount)
            { 
                list.Add(output.GetRange(i, Math.Min(columnCount, output.Count - i)));
            }
            

            sheet.Close(true);
            excelApp.Quit();

                return list;
            }
            catch 
            {
                return null;
            }
            
            
        }

19 Source : DomainObjectMemento.cs
with MIT License
from evelasco85

string ComputeHash(IDictionary<string, Tuple<PropertyInfo, object>> properties)
        {
            StringBuilder hashSet = new StringBuilder();
            IHashService service = HashService.GetInstance();

            foreach (KeyValuePair<string, Tuple<PropertyInfo, object>> kvp in properties)
            {
                object value = kvp.Value.Item2;

                if(value == null)
                    continue;

                string hashValue = Convert.ToString(value);

                hashSet.AppendLine(service.ComputeHashValue(hashValue));
            }

            //Merkel tree???
            string acreplacedulatedHash = service.ComputeHashValue(hashSet.ToString());

            return acreplacedulatedHash;
        }

19 Source : IdentityMap.cs
with MIT License
from evelasco85

public IIdenreplacedyMapQuery<TEnreplacedy> SetFilter<TEnreplacedyPropertyType>(Expression<Func<TEnreplacedy, TEnreplacedyPropertyType>> keyToSearch, object keyValue)
        {
            string enreplacedyFieldName = ((MemberExpression)keyToSearch.Body).Member.Name;
            string searchValue = Convert.ToString(keyValue);

            if(!_idenreplacedyFields.Any(field => field.Name == enreplacedyFieldName))
                throw new ArgumentException(string.Format("Field '{0}' is not marked with 'IdenreplacedyFieldAttribute'", enreplacedyFieldName));

            _currentSearchDictionary.Add(enreplacedyFieldName, searchValue);

            return this;
        }

19 Source : IdentityMap.cs
with MIT License
from evelasco85

string CreateHash(IList<object> values)
        {
            StringBuilder hashSet = new StringBuilder();
            IHashService service = HashService.GetInstance();

            for (int index = 0; index < values.Count; index++)
            {
                object valueObj = values[index];

                hashSet.AppendLine(service.ComputeHashValue(Convert.ToString(valueObj)));
            }

            string acreplacedulatedHash = service.ComputeHashValue(hashSet.ToString());

            return acreplacedulatedHash;
        }

19 Source : EmptyStringToVisibilityConverter.cs
with GNU General Public License v2.0
from evgeny-nadymov

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var visibility = value == null;

            var s = value as string;
            if (s != null)
            {
                visibility = string.IsNullOrEmpty(s);
            }

            if (string.Equals(System.Convert.ToString(parameter), "invert", StringComparison.OrdinalIgnoreCase))
            {
                visibility = !visibility;
            }

            return visibility ? Visibility.Visible : Visibility.Collapsed;
        }

19 Source : EmptyStringToVisibilityConverter.cs
with GNU General Public License v2.0
from evgeny-nadymov

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var visibility = value == null;

            var s = value as TLString;
            if (s != null)
            {
                visibility = string.IsNullOrEmpty(s.ToString());
            }

            if (string.Equals(System.Convert.ToString(parameter), "invert", StringComparison.OrdinalIgnoreCase))
            {
                visibility = !visibility;
            }

            return visibility ? Visibility.Visible : Visibility.Collapsed;
        }

19 Source : EvoDB.cs
with GNU Affero General Public License v3.0
from evoluteur

static internal string GetDataScalar(string SQL, string mySqlConnection, ref string ErrorMsg)
		{
			string ReturnValue = null;

#if DB_MySQL
			MySqlConnection myConnection = new MySqlConnection(mySqlConnection);
			MySqlCommand myCommand = new MySqlCommand(SQL, myConnection);
#else
			SqlConnection myConnection = new SqlConnection(mySqlConnection);
			SqlCommand myCommand = new SqlCommand(SQL, myConnection); 
#endif

			try
			{
				myConnection.Open();
				ReturnValue = Convert.ToString(myCommand.ExecuteScalar());
			}
			catch (Exception DBerror)
			{
				ErrorMsg += HTMLtextMore(QueryError, DBerror.Message);
				ReturnValue = string.Empty;
			}
			finally
			{
				myCommand.Dispose();
				myConnection.Close();
			} 
			return ReturnValue;
		}

19 Source : UIServerCom.cs
with GNU Affero General Public License v3.0
from evoluteur

private string FormComments(int nbComments) 
		{ 
			//display comments list and new comment form 

			int PanelID = -1; 
			StringBuilder myHTML = new StringBuilder(); 

			myHTML.Append("<div clreplaced=\"PanelComments\">"); 
			bool YesNo = _DBAllowComments.Equals(EvolCommentsMode.Logged_Users) && _UserID > 0; 
			if (YesNo) 
			{ 
				string linkLabel;
				if (nbComments > 0)
				{
					myHTML.AppendFormat(EvoLang.ucNb, nbComments.ToString(), def_Data.enreplacedy).Append(" ");
					linkLabel = EvoLang.ucAdd; 
				} 
				else 
				{ 
					myHTML.AppendFormat(EvoLang.ucNoComments, def_Data.enreplacedy).Append(" ");
					linkLabel = EvoLang.ucPost; 
				}
				myHTML.Append(FormCommentPost(linkLabel));
				//'list of comments 
				if (!noCommentsHere && nbComments > 0 && ds2 != null)
				{
					PanelID = ds2.Tables.Count - 1;
					if (PanelID > -1)
					{
						DataTable t = ds2.Tables[PanelID];
						if (t.Rows.Count < nbComments)
							nbComments = t.Rows.Count;
						for (int i = 0; i < nbComments; i++)
						{
							myHTML.Append("<div clreplaced=\"evoSep\"></div>");
							DataRow r = t.Rows[i];
							myHTML.Append(EvoUI.HTMLPixCommentUser);
							try
							{
								//myHTML.Append(EvoLang.ucFrom);
								if (String.IsNullOrEmpty(def_Data.userpage))
									myHTML.Append(r["login"]);
								else
									myHTML.Append("<a href=\"").Append(def_Data.userpage).Append("?ID=").Append(r["userid"]).Append("\">").Append(r["login"]).Append("</a>");
								myHTML.Append(EvoLang.ucOn).Append(EvoTC.formatedDateTime((System.DateTime)r["creationdate"]))
									.Append(".<div clreplaced=\"FieldComments\">")
									.Append(EvoTC.Text2HTMLwBR(Convert.ToString(r["message"])))
									.Append("</div>");
							}
							catch
							{
								myHTML.Append("<div clreplaced=\"evoSep\"></div><div clreplaced=\"FieldReadOnly\">")
									.Append(EvoLang.ucMissing).Append("</div>");
								break;
							}
						}
					} 
				} 
			} 
			myHTML.Append("</div>"); 
			return myHTML.ToString(); 
		}

19 Source : UIServerGrid.cs
with GNU Affero General Public License v3.0
from evoluteur

private string HTMLDataset(XmlNodeList aNodeList, string sql, string replacedle, int ListMode, string LinkDetailNew, bool InsidePanel, int PanelDetailsIndex, int PanelDetailsID)
		{
			// Generates HTML for paging grid, details grid, and edit grid.
			//ListMode: 0=list, 1=details, 2 details edit 

			string ctable, iconEnreplacedyDetails;
			bool UseComments = false, YesNo = false;
			string fieldType, fieldValue;
			string endTD = " </td>";
			int nbCommentsRow = 0, MaxLoopXML, MaxLoopSQL, MinLoop, TotalNbRecords = 0;
			string htmlRecCount = String.Empty, buffer, buffer1, buffer2;
			StringBuilder myHTML = new StringBuilder();
			StringBuilder myHTML2 = new StringBuilder();
			string[,] fieldFormats;
			DataSet ds;
			DataTable t = null;
			string myLabel;

			if (!_DBAllowUpdateDetails && ListMode == 2)
				ListMode = 1;
			//set record counts values 
			MaxLoopSQL = -1;
			if (string.IsNullOrEmpty(sql))
			{
				// PanelDetailsID??? bug qqq 
				if (detailsLoaded && PanelDetailsIndex > -1 && ds2 != null)
				{
					t = ds2.Tables[PanelDetailsIndex];
					MaxLoopSQL = t.Rows.Count - 1;
				}
			}
			else
			{
				ds = EvoDB.GetData(sql, SqlConnection, ref ErrorMsg);
				if (ds != null)
				{
					t = ds.Tables[0];
					MaxLoopSQL = t.Rows.Count - 1;
				}
			}
			if (sql.Length > 0)
			{
				if (string.IsNullOrEmpty(ErrorMsg))
				{
					if (ListMode == 0 && !string.IsNullOrEmpty(def_Data.sppaging))
					{
						int nbRows = 0;
						if (MaxLoopSQL == _RowsPerPage - 1)
						{
							try
							{
								nbRows = Convert.ToInt32(t.Rows[0]["MoreRecords"]);
							}
							catch
							{ }
						}
						if (MaxLoopSQL > -1)
							TotalNbRecords = _RowsPerPage * (pageID - 1) + nbRows + MaxLoopSQL + 1;
						else
							TotalNbRecords = 0;
					}
					else
						TotalNbRecords = MaxLoopSQL + 1;
					htmlRecCount = HTMLrecordCount(TotalNbRecords, MaxLoopSQL);
				}
				else
				{
					MaxLoopSQL = -1;
					TotalNbRecords = MaxLoopSQL + 1;
					htmlRecCount = string.Empty;
				}
			}
			if (MaxLoopSQL > -1 || ListMode == 2)
			{
				MaxLoopXML = aNodeList.Count - 1;
				//display result 
				if (InsidePanel)
				{
					myHTML.Append("<table clreplaced=\"Holder\" cellpadding=\"4\"");
					if (PanelDetailsID > -1)
						myHTML.AppendFormat(" ID=\"{0}{1}P\">", UID, PanelDetailsID);
					else
						myHTML.Append(">");
				}
				if (ListMode == 0)
				{
					//If dbcolumnlead <> String.Empty Then myHTML.Append("<tr><td colspan=""2"">").Append(HTMLAlphabetLinks).Append("</td></tr>") 
					myHTML.Append("<tr valign=\"top\" clreplaced=\"RowInfo\"><td><p>").Append(replacedle);
					if (_ShowDesigner && _FormID > 0)
						myHTML.Append(EvoUI.LinkDesigner(EvoUI.DesType.src, _FormID, replacedle, _PathDesign));
					myHTML.Append("</p></td><td><p clreplaced=\"Right\">");
					if (TotalNbRecords > 0 && (_DBAllowExport  || _DBAllowMreplacedUpdate))
					{
						if (_DBAllowExport)
							htmlRecCount += String.Format(" - {0}", EvoUI.HTMLLinkEventRef("70", EvoLang.Export));
#if !DB_MySQL
						if (_DBAllowMreplacedUpdate)
							htmlRecCount += String.Format(" - {0}", EvoUI.HTMLLinkEventRef("80", EvoLang.MreplacedUpdate));
#endif
						myHTML.Append(htmlRecCount);
					}
					myHTML.Append("</p></td></tr><tr><td colspan=\"2\">");
				}
				else if (InsidePanel)
					myHTML.Append("<tr><td>");
				if (MaxLoopSQL > -1 || (ListMode == 2 && _DBAllowInsertDetails))
				{
					myHTML.AppendFormat("<span id=\"{0}{1}p\"><table id=\"EvoEditGrid{1}\"", UID, PanelDetailsID);
					myHTML.Append(" clreplaced=\"EvoEditGrid\" rules=\"all");
					if (ListMode == 0 && ColorTranslator.ToHtml(BackColorRowMouseOver) != string.Empty)
						myHTML.Append("\" style=\"behavior:url(").Append(_PathPixToolbar).Append("tablehl.htc);\" slcolor=\"#FFFFCC\" hlcolor=\"").Append(ColorTranslator.ToHtml(BackColorRowMouseOver));
					myHTML.Append("\">");
					//1 field only 
					if (MaxLoopXML == 0)
					{
						if (aNodeList[0].Attributes[xAttribute.labelList] == null)
							myLabel = aNodeList[0].Attributes[xAttribute.label].Value;
						else
							myLabel = aNodeList[0].Attributes[xAttribute.labelList].Value;
					}
					else
						myLabel = Tilda;

//##### table header 
#region "header"

					MaxLoopXML = aNodeList.Count - 1;
					fieldFormats = new string[MaxLoopXML + 1, 3];
					myHTML2.Append("<THEAD><tr clreplaced=\"RowHeader\">");
					//edit details 
					if (ListMode == 2)
					{
						myHTML2.Append("<td width=\"1%\">ID</td>");
						endTD = "</td>";
					}
					for (int j = 0; j <= MaxLoopXML; j++)
					{
						XmlNode cn = aNodeList[j];
						if (cn.NodeType == XmlNodeType.Element)
						{
							//cache field format 
							ctable = string.Format(".{0}", cn.Attributes[xAttribute.dbColumnRead].Value);
							switch (cn.Attributes[xAttribute.type].Value)
							{
								case EvoDB.t_text:
								case EvoDB.t_pix:
									if (ListMode < 2)
									{
										if (cn.Attributes[xAttribute.link] == null)
											fieldFormats[j, 0] = string.Empty;
										else
											fieldFormats[j, 0] = cn.Attributes[xAttribute.link].Value;
										if (cn.Attributes[xAttribute.linkTarget] == null)
											fieldFormats[j, 1] = string.Empty;
										else
											fieldFormats[j, 1] = cn.Attributes[xAttribute.linkTarget].Value;
									}
									else
										fieldFormats[j, 0] = string.Empty;
									break;
								case EvoDB.t_lov:
									if (ListMode < 2)
									{
										ctable = string.Format("@{0}", cn.Attributes[xAttribute.dbColumn].Value);
										if (cn.Attributes[xAttribute.link] == null)
											buffer = string.Empty;
										else
										{
											buffer = cn.Attributes[xAttribute.link].Value;
											if (buffer.Length > 0)
											{
												if (cn.Attributes[xAttribute.linkTarget] == null)
													fieldFormats[j, 1] = string.Empty;
												else
													fieldFormats[j, 1] = cn.Attributes[xAttribute.linkTarget].Value;
												if (cn.Attributes[xAttribute.linkLabel] == null)
													fieldFormats[j, 2] = string.Empty;
												else
													fieldFormats[j, 2] = cn.Attributes[xAttribute.linkLabel].Value;
											}
										}
									}
									else
										buffer = string.Empty;
									fieldFormats[j, 0] = buffer;
									break;
								case EvoDB.t_int:
								case EvoDB.t_dec:
									if (ListMode == 2)
									{
										if (cn.Attributes[xAttribute.dbReadOnly] == null)
											YesNo = false;
										else
											YesNo = cn.Attributes[xAttribute.dbReadOnly].Value.Equals(s1);
									}
									else
										YesNo = true;
									if (YesNo)
									{
										if (cn.Attributes[xAttribute.format] == null)
											fieldFormats[j, 0] = string.Empty;
										else
											fieldFormats[j, 0] = cn.Attributes[xAttribute.format].Value;
									}
									else
										fieldFormats[j, 0] = string.Empty;
									break;
								case EvoDB.t_date:
								case EvoDB.t_time:
								case EvoDB.t_datetime:
									if (cn.Attributes[xAttribute.format] == null)
										fieldFormats[j, 0] = EvoTC.DefaultDateFormat(cn.Attributes[xAttribute.type].Value);
									else
									{
										fieldFormats[j, 0] = cn.Attributes[xAttribute.format].Value;
										if (string.IsNullOrEmpty(fieldFormats[j, 0]))
											fieldFormats[j, 0] = EvoTC.DefaultDateFormat(cn.Attributes[xAttribute.type].Value);
										else if (fieldFormats[j, 0].IndexOf("{") < 0)
											fieldFormats[j, 0] = "{0:" + fieldFormats[j, 0] + "}";
									}
									break;
								case EvoDB.t_bool:
									if (cn.Attributes[xAttribute.imgList] != null)
										fieldFormats[j, 0] = cn.Attributes[xAttribute.imgList].Value;
									if (string.IsNullOrEmpty(fieldFormats[j, 0]))
									{
										if (cn.Attributes[xAttribute.img] == null)
											fieldFormats[j, 0] = EvoUI.PixCheck;
										else
										{
											fieldFormats[j, 0] = cn.Attributes[xAttribute.img].Value;
											if (fieldFormats[j, 0].Length == 0)
												fieldFormats[j, 0] = EvoUI.PixCheck;
										}
									}
									break;
								case EvoDB.t_url:
									buffer = string.Empty;
									if (cn.Attributes[xAttribute.imgList] != null)
										buffer = cn.Attributes[xAttribute.imgList].Value;
									if (buffer.Length == 0 && (cn.Attributes[xAttribute.img] != null))
										buffer = cn.Attributes[xAttribute.img].Value;
									if (buffer.Length > 0)
										buffer = _PathPixToolbar + buffer;
									fieldFormats[j, 0] = buffer;
									break;
								case EvoDB.t_formula:
									ctable = Tilda + cn.Attributes[xAttribute.dbColumnRead].Value;
									if (cn.Attributes[xAttribute.format] == null)
										fieldFormats[j, 0] = string.Empty;
									else
										fieldFormats[j, 0] = cn.Attributes[xAttribute.format].Value;
									break;
								default:
									fieldFormats[j, 0] = string.Empty;
									break;
							}
							// built header 
							if (cn.Attributes[xAttribute.labelList] == null)
								myLabel = cn.Attributes[xAttribute.label].Value;
							else
								myLabel = cn.Attributes[xAttribute.labelList].Value;
							myHTML2.Append("<td>");
							if (j == 0 && string.IsNullOrEmpty(myLabel))
								myHTML2.Append(HTMLlov(cn, cn.Attributes[xAttribute.dbColumnRead].Value, s0, LOVFormat.HTML, 0));
							else
							{
								// Label + Flag & Actions (required, designer, sorting)
								myHTML2.Append(myLabel);
								if (ListMode == 2 && cn.Attributes[xAttribute.required] != null && cn.Attributes[xAttribute.required].Value == s1)
									myHTML2.Append(EvoUI.HTMLFlagRequired);
								if (_ShowDesigner)
									myHTML2.Append(EvoUI.LinkDesigner(EvoUI.DesType.fld, Convert.ToInt32(cn.Attributes[xAttribute.id].Value), myLabel, _PathDesign));
								if (_AllowSorting && ListMode == 0 && TotalNbRecords > 2)
									myHTML2.Append(HTMLSortingArrows(ctable));
							}
							myHTML2.Append("</td>");
						}

					}
					myHTML2.Append("</tr></THEAD>");
					if (MaxLoopSQL == 0 || MaxLoopXML > 0 || !String.IsNullOrEmpty(myLabel))
						myHTML.Append(myHTML2);

#endregion 

					//##### table body 
					myHTML.Append("<TBODY>");
					if (ListMode == 2 && (_DBAllowInsertDetails || _DBAllowUpdateDetails) && !_DBReadOnly)
						genJS.Append(JSEditDetails(aNodeList, PanelDetailsID));     //sets nbFieldEditable 
					if (ListMode == 2 && MaxLoopSQL < 0)
						myHTML.Append(EvoUI.HTMLemptyRowEdit(MaxLoopXML + 2));
					else
						UseComments = EvoDB.ColumnExists(t, SQLColNbComments);
					iconEnreplacedyDetails = string.IsNullOrEmpty(icon) ? string.Empty : EvoUI.HTMLIcon(_PathPixToolbar, icon);
					for (int i = 0; i <= MaxLoopSQL; i++)
					{
						myHTML.Append(EvoUI.TRcssEvenOrOdd(YesNo));
						YesNo = !YesNo;
						DataRow ri = t.Rows[i];
						buffer2 = (ri[dbPrimaryKey].ToString());
						if (UseComments)
						{
							if (ri[SQLColNbComments] != null)
								try
								{
									nbCommentsRow = Convert.ToInt32(ri[SQLColNbComments]);
								}
								catch
								{
									nbCommentsRow = -1;
								}
							else
								nbCommentsRow = -1;
						}
						switch (ListMode)
						{
							case 2:
								//details edit 
								myHTML.AppendFormat("<td>{0}</td>", buffer2);
								MinLoop = 0;
								break;
							case 0:
								//search result (master) 
								myHTML.AppendFormat("<td><a href=\"javascript:EvPost('-{0}')\">", buffer2);
								//0=ID 
								fieldValue = Convert.ToString(ri[aNodeList[0].Attributes[xAttribute.dbColumnRead].Value]);
								if (string.IsNullOrEmpty(icon))
								{
									if (!String.IsNullOrEmpty(dbcolumnicon))
									{
										buffer = Convert.ToString(ri[dbcolumnicon]);
										if (!String.IsNullOrEmpty(buffer))
											myHTML.Append(EvoUI.HTMLIcon(_PathPix, buffer));
									}
								}
								else
									myHTML.Append(icon);
								if (String.IsNullOrEmpty(fieldValue))
									myHTML.AppendFormat("({0})</a>", buffer2);
								else
									myHTML.Append(HttpUtility.HtmlEncode(fieldValue)).Append("</a>");
								if (nbCommentsRow > 0)
									myHTML.Append(EvoUI.HTMLCommentFlag(nbCommentsRow));
								myHTML.Append(" </td>");
								//If EditLink Then .Append(" <small>[<a href=""Javascript:").Append(Page.GetPostBackEventReference(Me, "e" & buffer2)).Append(""">Edit</a>]<small>") 
								MinLoop = 1;
								break;
							default:
								//details list=1 
								MinLoop = 0;
								if (string.IsNullOrEmpty(icon) && dbcolumnicon.Length > 0)
								{
									if (object.ReferenceEquals(ri[dbcolumnicon], DBNull.Value))
										iconEnreplacedyDetails = string.Empty;
									else
										iconEnreplacedyDetails = EvoUI.HTMLIcon(_PathPix, Convert.ToString(ri[dbcolumnicon]));
								}
								break;
						}
						for (int j = MinLoop; j <= MaxLoopXML; j++)
						{
							XmlNode cn = aNodeList[j];
							if (cn.NodeType == XmlNodeType.Element)
							{
								myHTML.Append("<td>");
								string dbColumnReadName = cn.Attributes[xAttribute.dbColumnRead].Value;
								try
								{
									if (ri[dbColumnReadName] != null)
										fieldValue = ri[dbColumnReadName].ToString();
									else
										fieldValue = string.Empty;
								}
								catch
								{
									string newError = string.Format(EvoLang.err_NoDBColumn, dbColumnReadName);
									AddError(newError);
									fieldValue = string.Empty;
								}
								fieldType = cn.Attributes[xAttribute.type].Value;
								if (!String.IsNullOrEmpty(fieldValue))
								{
									switch (fieldType)
									{
										case EvoDB.t_text:
											fieldValue = HttpUtility.HtmlEncode(fieldValue);
											if (j == MinLoop)
											{
												if (ListMode == 1 && fieldFormats[j, 0].Length > 0)
												{
													if (!String.IsNullOrEmpty(iconEnreplacedyDetails))
														fieldValue = iconEnreplacedyDetails + fieldValue;
													myHTML.Append(EvoUI.HTMLLink(EvoUI.Link4itemid(fieldFormats[j, 0], ri[dbPrimaryKey].ToString()), fieldValue));
												}
												else
													myHTML.Append(fieldValue);
												if (UseComments && ListMode > 0 && ri[dbColumnReadName] != null)
												{
													nbCommentsRow = Convert.ToInt32(ri[SQLColNbComments]);
													if (nbCommentsRow > 0)
														myHTML.Append(EvoUI.HTMLCommentFlag(nbCommentsRow));
												}
											}
											else if (ListMode == 1 && fieldFormats[j, 0].Length > 0)
												myHTML.Append(EvoUI.HTMLLink(EvoUI.Link4itemid(fieldFormats[j, 0], ri[dbPrimaryKey].ToString()), fieldValue, fieldFormats[j, 1], null));
											else
												myHTML.Append(fieldValue);
											break;
										case EvoDB.t_lov:
											if (ListMode != 2)
											{
												if (fieldFormats[j, 0].Length > 0)
												{
													if (fieldFormats[j, 2].Length > 0)
														fieldValue = fieldFormats[j, 2];
													//linklabel 
													fieldValue = EvoUI.HTMLLink(EvoUI.Link4itemid(fieldFormats[j, 0], ri[cn.Attributes[xAttribute.dbColumn].Value].ToString()), fieldValue, fieldFormats[j, 1], null);
												}
												else if (cn.Attributes[xAttribute.dbColumnIcon] != null)
												{
													buffer1 = cn.Attributes[xAttribute.dbColumnIcon].Value;
													if (buffer1.Length > 0)
													{
														buffer2 = Convert.ToString(ri[buffer1]);
														if (!String.IsNullOrEmpty(buffer2))
															fieldValue = EvoUI.HTMLImg(_PathPix + buffer2) + EvoUI.HTMLSpace + fieldValue;
													}
												}
											}
											myHTML.Append(fieldValue);
											break;
										case EvoDB.t_bool: // format is a picture name here
											if (fieldValue.Equals(s1) || fieldValue.Equals("True"))
											{
												if (fieldFormats[j, 0].Length > 0)
													myHTML.Append(EvoUI.HTMLSpace).Append(EvoUI.HTMLImg(_PathPixToolbar + fieldFormats[j, 0], EvoLang.Checked));
												else
													myHTML.Append(EvoUI.HTMLImgCheckMark(IEbrowser, _PathPixToolbar));
											}
											break;
										case EvoDB.t_int:
											if (fieldFormats[j, 0].Length > 0 && EvoTC.isInteger(fieldValue))
												myHTML.Append(EvoUI.noBR(EvoTC.String2Int(fieldValue).ToString(fieldFormats[j, 0])));
											else
												myHTML.Append(fieldValue);
											break;
										case EvoDB.t_dec:
											if (fieldFormats[j, 0].Length > 0 && EvoTC.isDecimal(fieldValue))
												myHTML.Append(EvoUI.noBR(EvoTC.String2Dec(fieldValue).ToString(fieldFormats[j, 0])));
											else
												myHTML.Append(fieldValue);
											break;
										case EvoDB.t_date:
										case EvoDB.t_time:
										case EvoDB.t_datetime:
											if (fieldFormats[j, 0].Length > 0 && EvoTC.isDate(fieldValue))
												myHTML.Append(EvoUI.noBR(string.Format(fieldFormats[j, 0], EvoTC.String2DateTime(fieldValue))));
											else
												myHTML.Append(HttpUtility.HtmlEncode(fieldValue));
											break;
										case EvoDB.t_url:
											fieldValue = HttpUtility.HtmlEncode(fieldValue);
											if (fieldFormats[j, 0].Length > 0)
												myHTML.Append(EvoUI.HTMLLink(fieldValue, string.Empty, inNewBrowser, fieldFormats[j, 0]));
											else
												myHTML.Append(EvoUI.HTMLLink(fieldValue, fieldValue, inNewBrowser, null));
											break;
										case EvoDB.t_txtm:
											myHTML.Append(EvoTC.Text2HTMLwBR(fieldValue));
											break;
										case EvoDB.t_doc:
											myHTML.Append(EvoUI.HTMLLink(_PathPix + fieldValue, fieldValue, inNewBrowser, null));
											break;
										case EvoDB.t_pix:
											if (ListMode < 2 && fieldFormats[j, 0].Length > 0)
												myHTML.Append(EvoUI.HTMLLink(EvoUI.Link4itemid(fieldFormats[j, 0], ri[dbPrimaryKey].ToString()), String.Empty, fieldFormats[j, 1], _PathPix + fieldValue));
											else
												myHTML.Append(EvoUI.HTMLImg(_PathPix + fieldValue));
											break;
										case EvoDB.t_formula:
											if (fieldFormats[j, 0].Length > 0 && EvoTC.isDecimal(fieldValue))
												myHTML.Append(EvoUI.noBR(EvoTC.String2Dec(fieldValue).ToString(fieldFormats[j, 0])));
											else
												myHTML.Append(HttpUtility.HtmlEncode(fieldValue));
											break;
										case  EvoDB.t_html: // no escaping for html content
											// warning: using html fields may expose to cross-site scripting
											myHTML.Append(fieldValue);
											break;
										default:
											myHTML.Append(HttpUtility.HtmlEncode(fieldValue));
											break;
									}
								}
								myHTML.Append(endTD);
							}
						}
						myHTML.Append("</tr>");
					}
					myHTML.Append("</TBODY></table></span>");

					//--- FOOTER : buttons + summary + paging navigation --------------------------------- 
					if (ListMode == 2 & nbFieldEditable > 0)
						myHTML.Append(HTMLAddDeleteRows(PanelDetailsID));
					if (ListMode == 0)
						myHTML.Append("</td></tr><tr clreplaced=\"RowFoot\"><td colspan=\"2\">");
					if (!string.IsNullOrEmpty(def_Data.sppaging))
					{
						if (ListMode == 0)
							myHTML.Append(HTMLPagingFullNav(MaxLoopSQL, TotalNbRecords, htmlRecCount));
					}
					else if (TotalNbRecords > 0)
						myHTML.AppendFormat("<div> {0}</div>", htmlRecCount);
					if (ListMode == 1 && !(string.IsNullOrEmpty(LinkDetailNew) || _DBReadOnly))
						myHTML.Append("<p>").Append(EvoUI.HTMLLink(LinkDetailNew.Replace(EvoDB.p_itemid, s0) + "&tdLOVE=1N", EvoLang.NewItem)).Append("</p>");
				}
				if (InsidePanel)
					myHTML.Append(TdTrTableEnd);
			}
			else
			{
				myHTML.Append(HTMLNoGrid(ListMode, replacedle, LinkDetailNew));
			}
			ds = null;
			return myHTML.ToString();
		}

19 Source : Wizard.cs
with GNU Affero General Public License v3.0
from evoluteur

private string BuildApplication(bool pBuildDB, bool pBuildFiles) 
		{ 
			string FullSQL = null; 
			string sqlbuffer; 
			bool YesNo = false; 
			string tablename, columnname, pk = "ID"; 
			//, dbcolumnlead As String 
			StringBuilder myHTML = new StringBuilder(); 
			string sql, buffer; 
			int i, j, k; 
			string buildError = "";

			string strAppID = AppID.ToString();
			//########### SQL - CREATE DB TABLES ######################################################## 
			if (_ShowSQL)
			{ 
				StringBuilder sbSQL = new StringBuilder();
				sbSQL.AppendLine(EvoDB.BuildSQL("replacedle, dbtable, dbcolumnpk", "EvoDico_form", "id=" + strAppID, String.Empty, 0)); 
				sbSQL.Append(EvoDB.BuildSQL("f.*", "EvoDico_field f, EvoDico_panel p", "f.formID=" + strAppID + " AND p.formID=f.formID AND f.panelid=p.id", "p.ppos,f.fpos,f.id", 0));
				ErrorMsg = String.Empty;
				ds = EvoDB.GetData(sbSQL.ToString(), _SqlConnectionDico, ref ErrorMsg);
				if (ErrorMsg != string.Empty || ds == null || ds.Tables[0].Rows.Count == 0)
				{
					buildError = string.Format("<p>{0}<br/>{1}</p>", ErrorMsg, sbSQL.ToString()); 
				} 
				else 
				{ 
					AppName = ds.Tables[0].Rows[0]["replacedle"].ToString(); 
					tablename = ds.Tables[0].Rows[0]["dbtable"].ToString(); 
					//dbcolumnlead = CStr(ds.Tables[0].Rows(0).Item("dbcolumnlead"))  
					YesNo = false; 
					//create driving table 
					sbSQL = new StringBuilder();
					sbSQL.AppendFormat("CREATE TABLE [{0}] (\n", tablename);
					if (ds.Tables[0].Rows[0]["dbcolumnpk"] != null)
					{
						pk = ds.Tables[0].Rows[0]["dbcolumnpk"].ToString();
						if (pk.Trim() == "")
							pk = "ID";
					}
					sbSQL.AppendFormat("[{0}]", pk).Append(EvoDDL.intIdenreplacedy); 
					sbSQL.Append(",\n [UserID] [int] NULL,\n [Publish] [int] NULL,\n [CommentCount] [smallint] NULL"); 
					DataTable t1 = ds.Tables[1];
					for (i = 0; i < t1.Rows.Count; i++) 
					{ 
						k = Convert.ToInt32(t1.Rows[i]["typeid"]); 
						sqlbuffer = t1.Rows[i]["dbcolumn"].ToString().Replace(" ", "_"); 
						if ("-ID-USERID-PUBLISH".IndexOf(string.Format("-{0}-", sqlbuffer.ToUpper())) < 0)
						{
							sbSQL.AppendFormat(",\n [{0}] ", sqlbuffer); 
							switch (k)
							{ 
								case 5: 
								case 3: 
								case 7: 
								case 11: 
								case 12:  
									k = EvoTC.String2Int(t1.Rows[i][xAttribute.maxLength].ToString()); 
									if (k > 0)
										sbSQL.AppendFormat("[nvarchar] ({0})", k); 
									else
										sbSQL.Append(EvoDDL.dbNvarchar100); 
									break;  
								case 6: 
								case 8: //big text 
									k = EvoTC.String2Int(t1.Rows[i][xAttribute.maxLength].ToString()); 
									if (k > 500) 
										sbSQL.Append(" [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL "); 
									else 
									{  
										if (k > 0) 
											sbSQL.AppendFormat("[nvarchar] ({0})", k); 
										else
											sbSQL.Append(EvoDDL.dbNvarchar100); 
									} 
									break; 
								case 4: //lov 
									sbSQL.Append(EvoDDL.dbInt); 
									YesNo = true; 
									break; 
								case 1: //bool 
									sbSQL.Append("[bit]");  
									break; 
								case 2: 
								case 17: 
								case 18: //date time 
									sbSQL.Append("[datetime]"); 
									break; 
								case 9: //dec 
									sbSQL.Append("[money]");  
									break; 
								case 10: //int 
									sbSQL.Append(EvoDDL.dbInt);  
									break; 
								default: 
									sbSQL.Append(EvoDDL.dbNvarchar100); 
									break; 
							} 
						} 
					} 
					sbSQL.Append("\n);\n\n"); 
					//keys and defaults 
					sbSQL.Append(EvoDDL.SQLAlterTable(tablename)); 
					for (i = 0; i < t1.Rows.Count; i++)
					{ 
						k = Convert.ToInt32(t1.Rows[i]["typeid"]); 
						columnname = t1.Rows[i][xAttribute.dbColumn].ToString(); 
						switch (k) 
						{ 
							case 5: 
							case 3: 
							case 7: 
							case 11: 
							case 12: 
								sbSQL.Append(EvoDDL.SQLconstraint(tablename, columnname, "''", true)); 
								break; 
							case 4: 
								sbSQL.Append(EvoDDL.SQLconstraint(tablename, columnname, "1", true)); 
								break; 
							//Case 6 
							// sql += "[bit] NOT NULL" 
							//Case 7 
							// sql += "[datetime]" 
							case 1: 
								sbSQL.Append(EvoDDL.SQLconstraint(tablename, columnname, "0", true)); 
								break; 
						} 
					} 
					sbSQL.Append(EvoDDL.SQLconstraint(tablename, "UserID", "1", true)); 
					sbSQL.Append(EvoDDL.SQLconstraint(tablename, "Publish", "1", true)); 
					sbSQL.Append(EvoDDL.SQLconstraint(tablename, "CommentCount", "0", true)); 
					if (sbSQL.Length > 0 && pBuildDB)
					{ 
						sql = sbSQL.ToString();
						sql = sql.Substring(0, sql.Length - 1) + "\n"; 
						EvoDB.RunSQL(sql, _SqlConnection, true); 
						FullSQL = sql; 
					} 
					//LOVs tables 
					if (YesNo) 
					{ 
						for (i = 0; i < t1.Rows.Count; i++)
						{
							sbSQL = new StringBuilder();
							k = Convert.ToInt32(t1.Rows[i]["typeid"]); 
							//LOV 
							if (k == 4)
							{ 
								columnname = t1.Rows[i][xAttribute.dbColumn].ToString(); 
								columnname = columnname.Substring(0, columnname.Length - 2); 
								if(t1.Rows[i]["dbtablelov"] != null)
									buffer = t1.Rows[i]["dbtablelov"].ToString(); 
								else
									buffer = string.Format("{0}_{1}", tablename, columnname); 
								sbSQL.Append("\n").Append(EvoDDL.SQLCreateTable(buffer)); 
								sqlbuffer = Convert.ToString(t1.Rows[i]["dbcolumnreadlov"]); 
								if (string.IsNullOrEmpty(sqlbuffer)) 
									sqlbuffer = "name"; 
								sbSQL.Append("\n [").Append(sqlbuffer).Append("] nvarchar(255) not null)\n\n"); 
								sbSQL.Append(EvoDDL.SQLAlterTable(buffer));
								sbSQL.Append(" CONSTRAINT [PK_").Append(buffer).Append("] PRIMARY KEY CLUSTERED ([ID]) ON [PRIMARY]\n\n\n");
								string[] myArray = t1.Rows[i]["options"].ToString().Split(new char[] { ',' }); 
								for (j = 0; j < myArray.Length; j++) 
								{ 
									sbSQL.Append("INSERT INTO [").Append(buffer).Append("] (").Append(sqlbuffer);
									sbSQL.Append(")\n VALUES ('").Append(myArray[j].Trim().Replace("'", "''")).Append("')\n"); 
								} 
							} 
							if (sbSQL.Length>0 && pBuildDB)
							{ 
								sql = sbSQL.ToString();
								EvoDB.RunSQL(sql, _SqlConnection, true); 
								FullSQL += sql; 
							} 
						} 
					} 
					sqlbuffer = String.Format("/*** {0} database - {1} ***/\n", AppName, EvoTC.TextNow());
					sqlbuffer += "/*** generated by evolutility - http://www.evolutility.org ***/\n\n"; 
					appSQL = sqlbuffer + FullSQL + "\n"; 
					if (pBuildFiles) 
					{ 
						StreamWriter sw = new StreamWriter(_PathWeb + AppName + "-" + strAppID + ".sql"); 
						sw.WriteLine(appSQL); 
						sw.Close(); 
					} 
				} 
				
				//########### XML - CREATE XML DEFINITION ######################################################## 
				//EvoDico.dicoDB2XML(AppID, 0, _SqlConnectionDico); 
				if (_ShowXML) 
				{ 
					myHTML.Append(myDOM.InnerXml);
					myHTML.Append(EvoDico.dicoDB2XML(AppID, 0, false, _SqlConnectionDico)); 
					appXML = myHTML.Replace("\"True\"", "\"1\"").Replace("\"False\"", "\"0\"").Replace(" dbtablelov=\"\"", "").ToString(); 
					if (pBuildFiles)
					{ 
						myDOM.LoadXml(myHTML.ToString());
						myDOM.Save(string.Format("{0}{1}-{2}.xml", _PathXML, AppName, strAppID)); 
					} 
				}  
				
				//########### ASPX - CREATE WEB PAGE ######################################################## 
				if (_ShowASPX)
				{
					appASPX = ASPXNestingPage(AppName, strAppID); 
					if (pBuildFiles)
					{ 
						StreamWriter sw = new StreamWriter(string.Format("{0}{1}-{2}.aspx", _PathWeb, AppName, strAppID)); 
						sw.WriteLine(appASPX); 
						sw.Close(); 
					} 
				} 
			} 
			return buildError; 
		}

19 Source : ErrorHandler.cs
with MIT License
from Excel-projects

public static bool IsTime(object expression)
        {
            try
            {
                string timeValue = Convert.ToString(expression);
                TimeSpan time1;
                return TimeSpan.TryParse(timeValue, out time1);
            }
            catch (Exception)
            {
                return false;
            }
        }

19 Source : ErrorHandler.cs
with MIT License
from Excel-projects

public static bool IsTime(object expression)
        {
            try
            {
                string timeValue = Convert.ToString(expression);
                //timeValue = String.Format("{0:" + Properties.Settings.Default.Table_ColumnFormatTime + "}", expression);
                //timeValue = timeValue.ToString(Properties.Settings.Default.Table_ColumnFormatTime, System.Globalization.CultureInfo.InvariantCulture);
                //timeValue = timeValue.ToString(Properties.Settings.Default.Table_ColumnFormatTime);
                //string timeValue = expression.ToString().Format(Properties.Settings.Default.Table_ColumnFormatTime);
                TimeSpan time1;
                //return TimeSpan.TryParse((string)expression, out time1);
                return TimeSpan.TryParse(timeValue, out time1);
            }
            catch (Exception)
            {
                return false;
            }
        }

19 Source : GeneralRecordWrapper.cs
with GNU General Public License v3.0
from faib920

public virtual string GetString(IDataRecord reader, int i)
        {
            if (reader.IsDBNull(i))
            {
                return string.Empty;
            }

            var type = reader.GetFieldType(i);
            if (type == typeof(string))
            {
                return reader.GetString(i);
            }

            return Convert.ToString(GetValue(reader, i));
        }

19 Source : EntityRowMapper.cs
with GNU General Public License v3.0
from faib920

private PropertyValue GetSupportedValue(bool isNull, PropertyMapping mapper, DataRow row)
        {
            if (mapper.Property.Type == typeof(Guid))
            {
                return isNull ? new Guid?() : new Guid(row[mapper.Index].ToString());
            }

            var typeCode = Type.GetTypeCode(mapper.Property.Type.GetNonNullableType());
            switch (typeCode)
            {
                case TypeCode.Boolean:
                    return isNull ? new bool?() : Convert.ToBoolean(row[mapper.Index]);
                case TypeCode.Char:
                    return isNull ? new char?() : Convert.ToChar(row[mapper.Index]);
                case TypeCode.Byte:
                    return isNull ? new byte?() : Convert.ToByte(row[mapper.Index]);
                case TypeCode.Int16:
                    return isNull ? new short?() : Convert.ToInt16(row[mapper.Index]);
                case TypeCode.Int32:
                    return isNull ? new int?() : Convert.ToInt32(row[mapper.Index]);
                case TypeCode.Int64:
                    return isNull ? new long?() : Convert.ToInt64(row[mapper.Index]);
                case TypeCode.Decimal:
                    return isNull ? new decimal?() : Convert.ToDecimal(row[mapper.Index]);
                case TypeCode.Double:
                    return isNull ? new double?() : Convert.ToDouble(row[mapper.Index]);
                case TypeCode.String:
                    return isNull ? string.Empty : Convert.ToString(row[mapper.Index]);
                case TypeCode.DateTime:
                    return isNull ? new DateTime?() : Convert.ToDateTime(row[mapper.Index]);
                case TypeCode.Single:
                    return isNull ? new float?() : Convert.ToSingle(row[mapper.Index]);
                default:
                    return PropertyValueHelper.NewValue(row[mapper.Index]);
            }
        }

19 Source : PropertyValueHelper.cs
with GNU General Public License v3.0
from faib920

internal static PropertyValue NewValue(object value, Type valueType)
        {
            Guard.ArgumentNull(valueType, "valueType");

            var nonNullType = valueType.GetNonNullableType();

            //如果是受支持的类型
            if (IsSupportedType(valueType))
            {
                //枚举
                if (nonNullType.IsEnum)
                {
                    return value == null && valueType.IsNullableType() ? null : (Enum)Enum.Parse(nonNullType, value.ToString());
                }
                //字节数组
                if (nonNullType.IsArray && valueType.GetElementType() == typeof(byte))
                {
                    return value == null ? new byte[0] : (byte[])value;
                }
                var isNull = value.IsNullOrEmpty();
                switch (nonNullType.FullName)
                {
                    case "System.Boolean": return isNull ? new bool?() : Convert.ToBoolean(value);
                    case "System.Byte": return isNull ? new byte?() : Convert.ToByte(value);
                    case "System.Char": return isNull ? new char?() : Convert.ToChar(value);
                    case "System.DateTime": return isNull ? new DateTime?() : Convert.ToDateTime(value);
                    case "System.Decimal": return isNull ? new decimal?() : Convert.ToDecimal(value);
                    case "System.Double": return isNull ? new double?() : Convert.ToDouble(value);
                    case "System.Guid": return isNull ? new Guid?() : new Guid(value.ToString());
                    case "System.Int16": return isNull ? new short?() : Convert.ToInt16(value);
                    case "System.Int32": return isNull ? new int?() : Convert.ToInt32(value);
                    case "System.Int64": return isNull ? new long?() : Convert.ToInt64(value);
                    case "System.Single": return isNull ? new float?() : Convert.ToSingle(value);
                    case "System.String": return isNull ? null : Convert.ToString(value);
                    case "System.Time": return isNull ? new TimeSpan?() : TimeSpan.Parse(value.ToString());
                    default: return null;
                }
            }
            return new PropertyValue(StorageType.Object) { Object = value };
        }

19 Source : GeneralRecordWrapper.cs
with GNU Lesser General Public License v3.0
from faib920

public virtual string GetString(IDataRecord reader, int i)
        {
            if (reader.IsDBNull(i))
            {
                return string.Empty;
            }

            var type = reader.GetFieldType(i);
            return type == typeof(string) ? reader.GetString(i) :
                Convert.ToString(GetValue(reader, i));
        }

19 Source : EntityRowMapper.cs
with GNU Lesser General Public License v3.0
from faib920

private PropertyValue GetSupportedValue(bool isNull, PropertyMapping mapper, DataRow row)
        {
            if (mapper.Property.Type == typeof(Guid))
            {
                return isNull ? new Guid?() : new Guid(row[mapper.Index].ToString());
            }

            var typeCode = Type.GetTypeCode(mapper.Property.Type.GetNonNullableType());
            return typeCode switch
            {
                TypeCode.Boolean => isNull ? new bool?() : Convert.ToBoolean(row[mapper.Index]),
                TypeCode.Char => isNull ? new char?() : Convert.ToChar(row[mapper.Index]),
                TypeCode.Byte => isNull ? new byte?() : Convert.ToByte(row[mapper.Index]),
                TypeCode.Int16 => isNull ? new short?() : Convert.ToInt16(row[mapper.Index]),
                TypeCode.Int32 => isNull ? new int?() : Convert.ToInt32(row[mapper.Index]),
                TypeCode.Int64 => isNull ? new long?() : Convert.ToInt64(row[mapper.Index]),
                TypeCode.Decimal => isNull ? new decimal?() : Convert.ToDecimal(row[mapper.Index]),
                TypeCode.Double => isNull ? new double?() : Convert.ToDouble(row[mapper.Index]),
                TypeCode.String => isNull ? string.Empty : Convert.ToString(row[mapper.Index]),
                TypeCode.DateTime => isNull ? new DateTime?() : Convert.ToDateTime(row[mapper.Index]),
                TypeCode.Single => isNull ? new float?() : Convert.ToSingle(row[mapper.Index]),
                _ => PropertyValue.NewValue(row[mapper.Index], null),
            };

19 Source : BaseService.cs
with MIT License
from FISCO-BCOS

public string DeployContract(string binCode, string abi = null, params object[] values)
        {
            var blockNumber = GetBlockNumber();
            var resultData = "";
            ConstructorCallEncoder _constructorCallEncoder = new ConstructorCallEncoder();

            var des = new ABIDeserialiser();
            var contract = des.DeserialiseContract(abi);
            if (contract.Constructor != null)
            {
                if (values != null)
                {
                    resultData = _constructorCallEncoder.EncodeRequest(binCode,
         contract.Constructor.InputParameters, values);
                }
                else
                {
                    resultData = _constructorCallEncoder.EncodeRequest(binCode, "");
                }
            }
            else
            {
                resultData = binCode;
            }
            var transParams = BuildTransactionParams(resultData, blockNumber, "");
            var tx = BuildRLPTranscation(transParams);
            tx.Sign(new EthECKey(this._privateKey.HexToByteArray(), true));
            var result = SendRequest<object>(tx.Data, tx.Signature);
            return Convert.ToString(result);

        }

19 Source : RedisExtensions.cs
with Apache License 2.0
from FoundatioFx

public static RedisValue ToRedisValue<T>(this T value, ISerializer serializer) {
            var redisValue = _nullValue;
            if (value == null)
                return redisValue;

            var t = typeof(T);
            if (t == TypeHelper.StringType)
                redisValue = value.ToString();
            else if (t == TypeHelper.BoolType)
                redisValue = Convert.ToBoolean(value);
            else if (t == TypeHelper.ByteType)
                redisValue = Convert.ToInt16(value);
            else if (t == TypeHelper.Int16Type)
                redisValue = Convert.ToInt16(value);
            else if (t == TypeHelper.Int32Type)
                redisValue = Convert.ToInt32(value);
            else if (t == TypeHelper.Int64Type)
                redisValue = Convert.ToInt64(value);
            else if (t == TypeHelper.DoubleType)
                redisValue = Convert.ToDouble(value);
            else if (t == TypeHelper.StringType)
                redisValue = value.ToString();
            else if (t == TypeHelper.CharType)
                redisValue = Convert.ToString(value);
            else if (t == TypeHelper.SByteType)
                redisValue = Convert.ToSByte(value);
            else if (t == TypeHelper.UInt16Type)
                redisValue = Convert.ToUInt32(value);
            else if (t == TypeHelper.UInt32Type)
                redisValue = Convert.ToUInt32(value);
            else if (t == TypeHelper.UInt64Type)
                redisValue = Convert.ToUInt64(value);
            else if (t == TypeHelper.SingleType)
                redisValue = Convert.ToSingle(value);
            //else if (type == TypeHelper.DecimalType)
            //    redisValue = Convert.ToDecimal(value);
            //else if (type == TypeHelper.DateTimeType)
            //    redisValue = Convert.ToDateTime(value);
            else if (t == TypeHelper.ByteArrayType)
                redisValue = value as byte[];
            else
                redisValue = serializer.SerializeToBytes(value);

            return redisValue;
        }

19 Source : HardwareInfo.cs
with GNU General Public License v3.0
from foyzulkarim

public static string GetHDDSerialNo()
        {
            ManagementClreplaced mangnmt = new ManagementClreplaced("Win32_LogicalDisk");
            ManagementObjectCollection mcol = mangnmt.GetInstances();
            string result = "";
            foreach (ManagementObject strt in mcol)
            {
                result += Convert.ToString(strt["VolumeSerialNumber"]);
            }
            return result;
        }

19 Source : Helpers.cs
with GNU General Public License v3.0
from FromDarkHell

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            if (value != null) {
                Color clr = (Color)value;

                Vec3 vecClr = new Vec3() {
                    X = clr.R / 255f,
                    Y = clr.G / 255f,
                    Z = clr.B / 255f
                };

                CustomPlayerColorSaveGameData colorData = new CustomPlayerColorSaveGameData() {
                    ColorParameter = System.Convert.ToString(parameter),
                    AppliedColor = vecClr,
                    SplitColor = vecClr,
                    UseDefaultColor = false,
                    UseDefaultSplitColor = false
                };

                return colorData;
            }
            return null;
        }

19 Source : CommandContextImpl.cs
with Apache License 2.0
from fujiihiroaki

public ICommandContext AddSql(string sql, object[] bindVariables,
            Type[] bindVariableTypes, string[] bindVariableNames)
        {
            _sqlBuf.Append(sql);

            var after = sql;
            for (var i = 0; i < bindVariableTypes.Length; i++)
            {
                var o = bindVariables[i];
                var pos = after.IndexOf(bindVariableNames[i]);
                if (pos > 0)
                {
                    string quote;
                    if (o is decimal || o is byte || o is double || o is float || o is int || o is long || o is short ||
                        o is sbyte || o is uint || o is ulong || o is ushort)
                        quote = "";
                    else
                        quote = "'";

                    after = after.Substring(0, pos - 1) + quote + Convert.ToString(o) + quote +
                            after.Substring(pos + bindVariableNames[i].Length);
                }
            }

            _sqlBufWithValue.Append(after);

            for (var i = 0; i < bindVariables.Length; ++i)
            {
                _bindVariables.Add(bindVariables[i]);
                _bindVariableTypes.Add(bindVariableTypes[i]);
                _bindVariableNames.Add(bindVariableNames[i]);
            }

            return this;
        }

19 Source : CommandContextImpl.cs
with Apache License 2.0
from fujiihiroaki

public ICommandContext AddSql(string sql, object bindVariable,
            Type bindVariableType, string bindVariableName)
        {
            string Func(object o)
            {
                if (o is decimal || o is byte || o is double || o is float || o is int || o is long || o is short ||
                    o is sbyte || o is uint || o is ulong || o is ushort)
                    return Convert.ToString(o);
                else if (o == null)
                    return "null";
                else
                    return "'" + Convert.ToString(o) + "'";
            }

            var after = sql;
            if (BindVariableType == BindVariableType.AtmarkWithParam)
                after = sql.Replace("?", "@" + bindVariableName);
            if (BindVariableType == BindVariableType.ColonWithParam)
                after = sql.Replace("?", ":" + bindVariableName);
            if (BindVariableType == BindVariableType.QuestionWithParam)
                after = sql + bindVariableName;

            _sqlBuf.Append(after);
            _sqlBufWithValue.Append(sql.Replace("?", Func(bindVariable)));
            _bindVariables.Add(bindVariable);
            _bindVariableTypes.Add(bindVariableType);
            _bindVariableNames.Add(bindVariableName);
            return this;
        }

19 Source : Formatter.cs
with MIT License
from fuse-open

static string FormattedMessage(object message)
		{
			try
			{
				return OnSingleLine(Convert.ToString(message));
			}
			catch (Exception e)
			{
				return "(The log message was non-null, but '" + message.GetType().Name + ".ToString()' threw an exception: " + FormattedException(e) + ")";
			}
		}

19 Source : GlobalAuthUtil.cs
with GNU Affero General Public License v3.0
from fuwei54321

public static string parseMapToString(Dictionary<string, object> dicParams)
        {
            StringBuilder builder = new StringBuilder();
            if (dicParams.Count > 0)
            {
                builder.Append("");
                int i = 0;
                foreach (KeyValuePair<string, object> item in dicParams)
                {
                    if (i > 0)
                        builder.Append("&");
                    builder.AppendFormat("{0}={1}", item.Key, Convert.ToString(item.Value));
                    i++;
                }
            }
            return builder.ToString();
        }

19 Source : GlobalAuthUtil.cs
with GNU Affero General Public License v3.0
from fuwei54321

public static string spellParams(this Dictionary<string, object> dicParams)
        {
            StringBuilder builder = new StringBuilder();
            if (dicParams.Count > 0)
            {
                builder.Append("");
                int i = 0;
                foreach (KeyValuePair<string, object> item in dicParams)
                {
                    if (i > 0)
                        builder.Append("&");
                    builder.AppendFormat("{0}={1}", item.Key, Convert.ToString(item.Value));
                    i++;
                }
            }
            return builder.ToString();
        }

19 Source : HttpUtils.cs
with GNU Affero General Public License v3.0
from fuwei54321

public static void ComeSetRequestHeader(HttpWebRequest request, Dictionary<string, object> header = null)
        {
            if (header != null && header.Count > 0)
            {
                foreach (var item in header)
                {
                    switch (item.Key.ToUpper())
                    {
                        case "HOST":
                            request.Host = Convert.ToString(item.Value);
                            break;
                        case "CONTENT-TYPE":
                            request.ContentType = Convert.ToString(item.Value);
                            break;
                        case "CONNECTION":
                            SetSpecialHeaderValue(request.Headers, item.Key, Convert.ToString(item.Value));
                            break;
                        default:
                            request.Headers.Add(item.Key, Convert.ToString(item.Value));
                            break;
                    }
                }
            }
        }

19 Source : GlobalAuthUtil.cs
with GNU Affero General Public License v3.0
from fuwei54321

public static string getString(this Dictionary<string, object> dic, string key)
        {
            if (dic == null)
                return "";
            if (dic.ContainsKey(key))
            {
                return Convert.ToString(dic[key]);
            }
            else
            {
                return "";
            }
        }

19 Source : UrlBuilder.cs
with GNU Affero General Public License v3.0
from fuwei54321

public UrlBuilder queryParam(string key, object value)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new Exception("参数名不能为空");
            }

            string valuereplacedtring = (value != null ? Convert.ToString(value) : null);
            this.paramDic.Add(key, valuereplacedtring);
            return this;
        }

19 Source : MainWindow.xaml.cs
with MIT License
from fyr77

private async void Load()
        {
            //Check if updater disabled
            if (!File.Exists(Path.Combine(GlobalVars.exepath, "disable_updater.envy")))
                await Util.DoUpdateAsync();

            int psid = 0;
            int pfid = 0;
            int osid = 0;
            int dtcid = 0;
            int dtid = 0;
            //TODO: Make a list of languages and match OS language to driver
            //int langid;

            if (File.Exists(GlobalVars.exepath + "sd.envy"))
                radioSD.IsChecked = true;

            // This little bool check is necessary for debug mode on systems without an Nvidia GPU. 
            if (!isDebug)
            {
                psid = Util.GetIDs("psid");
                pfid = Util.GetIDs("pfid");
                osid = Util.GetIDs("osid");
                dtcid = Util.GetDTCID();
                //dtid = Util.GetDTID();
            }
            else
            {
                psid = Debug.LoadFakeIDs("psid");
                pfid = Debug.LoadFakeIDs("pfid");
                osid = Debug.LoadFakeIDs("osid");
                dtcid = Debug.LoadFakeIDs("dtcid");
                dtid = Debug.LoadFakeIDs("dtid");
                localDriv = Debug.LocalDriv();
                textblockGPU.Text = localDriv;
                textblockGPUName.Text = Debug.GPUname();
            }

            //Temporary Studio Driver override logic until I have figured out how to detect it automatically
            try
            {
                if (radioSD.IsChecked == true)
                    dtid = 18;
                else
                    dtid = 1;
            }
            catch (NullReferenceException)
            { }

            gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&dtcid=" + dtcid.ToString() + "&dtid=" + dtid.ToString(); // + "&lid=" + langid.ToString();
            WebClient c = new WebClient();
            gpuURL = c.DownloadString(gpuURL);
            string pContent = c.DownloadString(gpuURL);
            var pattern = @"Windows\/\d{3}\.\d{2}";
            Regex rgx = new Regex(pattern);
            var matches = rgx.Matches(pContent);
            onlineDriv = Regex.Replace(Convert.ToString(matches[0]), "Windows/", "");
            textblockOnline.Text = onlineDriv;
            c.Dispose();

            try
            {
                if (float.Parse(localDriv) < float.Parse(onlineDriv))
                {
                    textblockOnline.Foreground = Brushes.Red;
                    buttonDL.IsEnabled = true;
                    Notify.ShowDrivUpdatePopup();
                }
                else
                    textblockOnline.Foreground = Brushes.Green;
            }
            catch (FormatException)
            {
                //Thank you locales. Some languages need , instead of .
                string cLocalDriv = localDriv.Replace('.', ',');
                string cOnlineDriv = onlineDriv.Replace('.', ',');
                if (float.Parse(cLocalDriv) < float.Parse(cOnlineDriv))
                {
                    textblockOnline.Foreground = Brushes.Red;
                    buttonDL.IsEnabled = true;
                    Notify.ShowDrivUpdatePopup();
                }
                else
                    textblockOnline.Foreground = Brushes.Green;
            }
        }

19 Source : SimpleNaturalStringOrder.cs
with MIT License
from garora

public int CompareTo(object obj)
        {
            string firstStringToCompare = ItemValue
                , secondStringToCompare = Convert.ToString(obj);

            if (firstStringToCompare == null) { return 0; }

            var firstStringPosition = 0;
            var secondStringPosition = 0;

            while ((firstStringPosition < firstStringToCompare.Length)
                || (secondStringPosition < secondStringToCompare.Length))
            {
                if (firstStringPosition >= firstStringToCompare.Length) { return -1; }
                if (secondStringPosition >= secondStringToCompare.Length) { return 1; }

                var firstCharInString = firstStringToCompare[firstStringPosition];
                var secondCharInString = secondStringToCompare[secondStringPosition];

                var firstStringBuilder = new StringBuilder();
                var secondStringBuilder = new StringBuilder();

                StringChecks(firstStringToCompare, ref firstStringPosition, ref firstCharInString, firstStringBuilder);
                StringChecks(secondStringToCompare, ref secondStringPosition, ref secondCharInString, secondStringBuilder);

                var result = 0;

                if (char.IsDigit(firstStringBuilder[0])
                    && char.IsDigit(secondStringBuilder[0]))
                {
                    var firstNumericString = Convert.ToInt32(firstStringBuilder.ToString());
                    var secondNumericString = Convert.ToInt32(secondStringBuilder.ToString());

                    if (firstNumericString < secondNumericString) { result = -1; }
                    if (firstNumericString > secondNumericString) { result = 1; }
                }
                else { result = firstStringBuilder.ToString().CompareTo(secondStringBuilder.ToString()); }

                if (result != 0) { return result; }
            }

            return 0;
        }

19 Source : ClientDriver.cs
with GNU Lesser General Public License v3.0
from GavinYellow

public int BatchWrite(SortedDictionary<ITag, object> items, bool isSync = true)
        {
            if (_tcpSend == null || !_tcpSend.Connected) return -1;
            List<byte> list = new List<byte>(new byte[] { FCTCOMMAND.fctHead, FCTCOMMAND.fctWriteMultiple });
            list.AddRange(BitConverter.GetBytes((short)items.Count));
            foreach (var item in items)
            {
                ITag tag = item.Key;
                list.AddRange(BitConverter.GetBytes(tag.ID));
                var addr = tag.Address;
                if (addr.VarType != DataType.STR)
                    list.Add((byte)(addr.DataSize));//此处存疑
                switch (addr.VarType)
                {
                    case DataType.BOOL:
                        list.Add(Convert.ToBoolean(item.Value) ? (byte)1 : (byte)0);
                        break;
                    case DataType.BYTE:
                        list.Add(Convert.ToByte(item.Value));
                        break;
                    case DataType.WORD:
                    case DataType.SHORT:
                        list.AddRange(BitConverter.GetBytes(Convert.ToInt16(item.Value)));
                        break;
                    case DataType.INT:
                        list.AddRange(BitConverter.GetBytes(Convert.ToInt32(item.Value)));
                        break;
                    case DataType.FLOAT:
                        list.AddRange(BitConverter.GetBytes(Convert.ToSingle(item.Value)));
                        break;
                    case DataType.STR:
                        var bts = Encoding.ASCII.GetBytes(Convert.ToString(item.Value));
                        list.Add((byte)bts.Length);
                        list.AddRange(bts);
                        break;
                }
            }
            SocketError error;
            lock (sendasync)
            {
                _tcpSend.Send(list.ToArray(), 0, list.Count, SocketFlags.None, out error);
                _tcpSend.Receive(tcpBuffer, 0, 2, SocketFlags.None, out error);
            }
            if (error == SocketError.Success)
                return tcpBuffer[1];
            else
            {
                return (int)error;
            }
        }

See More Examples