Exemple #1
0
        public static string DefaultToString <T>(T @this, ReflectionToStringFlags flags = ReflectionToStringFlags.Default)
        {
            if (@this is null)
            {
                return("null");
            }

            using RentedStringBuilder builder = RentStringBuilder();

            BindingFlags bindingFlags = (BindingFlags)(flags & ReflectionToStringFlags.BindingFlagsMask) | BindingFlags.Instance;

            if (flags.HasFlag(ReflectionToStringFlags.Properties))
            {
                foreach (PropertyInfo prop in @this.GetType().GetProperties(bindingFlags))
                {
                    builder.AppendLine($"{prop.Name}: {prop.GetValue(@this)}");
                }
            }
            else if (flags.HasFlag(ReflectionToStringFlags.Fields))
            {
                foreach (FieldInfo field in @this.GetType().GetFields(bindingFlags))
                {
                    builder.AppendLine($"{field.Name}: {field.GetValue(@this)}");
                }
            }

            return(builder.ToString());
        }
Exemple #2
0
        /// <inheritdoc cref="object"/>
        public override string ToString()
        {
            using RentedStringBuilder val = StringHelpers.RentStringBuilder();

            val.AppendLine($"UnderlyingTextureType: {UnderlyingTextureType}");
            val.AppendLine($"BitData: {Data}");
            val.AppendLine($"ResourceDimension: {Desc.Dimension}");
            val.AppendLine($"Height: {Desc.Height}");
            val.AppendLine($"Width: {Desc.Width}");
            val.AppendLine($"DepthOrArraySize: {Desc.DepthOrArraySize}");
            val.AppendLine($"MipCount: {MipCount}");
            val.AppendLine($"Format: {Desc.Format}");
            val.AppendLine($"LoaderFlags: {LoaderFlags}");
            val.AppendLine($"IsCubeMap: {IsCubeMap}");
            val.AppendLine($"AlphaMode: {AlphaMode}");

            val.AppendLine("\nSubresource Data: ");
            foreach (SubresourceData managedSubresourceData in SubresourceData.Span)
            {
                val.Append('\t').AppendLine(managedSubresourceData.ToString().Replace("\n", "\n\t"));
            }

            val.Append('\n');


            return(val.ToString());
        }
Exemple #3
0
        public override void Build(RentedStringBuilder builder)
        {
            if (Children.Count > 0)
            {
                if (Children.Count == 1)
                {
                    Children[0].Build(builder);
                }
                else
                {
                    builder.Append(" (");

                    for (var i = 0; i < Children.Count; i++)
                    {
                        Children[i].Build(builder);

                        if (i < Children.Count - 1)
                        {
                            builder.Append(" OR");
                        }
                    }

                    builder.Append(")");
                }
            }
        }
Exemple #4
0
        public override void Build(RentedStringBuilder builder)
        {
            if (String.IsNullOrEmpty(Filter))
            {
                return;
            }

            builder.Append(Filter);
        }
Exemple #5
0
        public virtual string ToSqlString()
        {
            if (!String.Equals(_clause, "SELECT", StringComparison.OrdinalIgnoreCase))
            {
                return("");
            }

            if (_skip != null || _count != null)
            {
                _dialect.Page(this, _skip, _count);
            }

            var sb = new RentedStringBuilder(Store.LargeBufferSize);

            sb.Append("SELECT ");

            if (_distinct)
            {
                sb.Append("DISTINCT ");

                if (_order != null)
                {
                    _select = _dialect.GetDistinctOrderBySelectString(_select, _order);
                }
            }

            foreach (var s in _select)
            {
                sb.Append(s);
            }

            if (_from != null)
            {
                sb.Append(" FROM ");

                foreach (var s in _from)
                {
                    sb.Append(s);
                }
            }

            if (_join != null)
            {
                foreach (var s in _join)
                {
                    sb.Append(s);
                }
            }

            if (_where != null)
            {
                sb.Append(" WHERE ");

                foreach (var s in _where)
                {
                    sb.Append(s);
                }
            }

            if (_group != null)
            {
                sb.Append(" GROUP BY ");

                foreach (var s in _group)
                {
                    sb.Append(s);
                }
            }

            if (_having != null)
            {
                sb.Append(" HAVING ");

                foreach (var s in _having)
                {
                    sb.Append(s);
                }
            }

            if (_order != null)
            {
                sb.Append(" ORDER BY ");

                foreach (var s in _order)
                {
                    sb.Append(s);
                }
            }

            if (_trail != null)
            {
                foreach (var s in _trail)
                {
                    sb.Append(s);
                }
            }

            var result = sb.ToString();

            sb.Dispose();

            return(result);
        }
Exemple #6
0
 public static void ReturnStringBuilder(RentedStringBuilder val)
 {
     // If the thread builder is null, we replace it with this. Else, we just discard this
     // It doesn't matter this isn't atomic, as if it overwrites another StringBuilder that is ok
     _perThreadBuilder ??= val.Value;
 }
Exemple #7
0
 public abstract void Build(RentedStringBuilder builder);