Here are the examples of the csharp api System.Text.StringBuilder.Append(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
30015 Examples
19
View Source File : DatabaseEngine.cs
License : GNU General Public License v3.0
Project Creator : aiportal
License : GNU General Public License v3.0
Project Creator : aiportal
private static string MakeOrder(object order)
{
string sql = string.Empty;
if (order != null)
{
if (order is string)
{
sql = string.IsNullOrEmpty(order as string) ? "" : "ORDER BY " + order;
}
else
{
StringBuilder cols = new StringBuilder();
var props = order.GetType().GetProperties();
foreach (var p in props)
{
string val = p.GetValue(order, null) as string;
if (string.Equals(val, "DESC", StringComparison.OrdinalIgnoreCase))
cols.Append(p.Name).Append(" DESC");
else
cols.Append(p.Name);
};
if (cols.Length > 0)
sql = cols.Insert(0, " ORDER BY ").Append(" ").ToString();
}
}
return sql;
}
19
View Source File : DataQueryService.cs
License : GNU General Public License v3.0
Project Creator : aiportal
License : GNU General Public License v3.0
Project Creator : aiportal
public object[] GetSessions(DateTime start, DateTime end, string user)
{
StringBuilder sbFilter = new StringBuilder();
sbFilter.AppendFormat(" '{0:yyyy-MM-dd}'<=date(CreateTime) AND date(CreateTime)<='{1:yyyy-MM-dd}' ", start, end);
sbFilter.Append(" AND SnapshotCount>0 ");
if (!string.IsNullOrEmpty(user) && ValidUser(user))
{
var domainUser = DomainUser.Create(user);
if (domainUser != null)
sbFilter.AppendFormat(" AND Domain='{0}' AND UserName='{1}'", domainUser.Domain, domainUser.UserName);
}
var sessions = Database.Execute(db => db.SelectObjects<SessionObj>("SessionView", sbFilter.ToString(),
"SessionId", "CreateTime", "LastActiveTime", "UserName", "Domain", "ClientName", "ClientAddress", "IsEnd", "SnapshotCount", "DataLength"));
List<object> objs = new List<object>();
foreach (var s in sessions)
objs.Add(new
{
SID = s.SID,
Date = s.Date,
User = s.User,
Time = s.TimeRange,
Count = s.SnapshotCount,
Length = s.DataLength,
Active = s.IsActive,
Client = s.ClientName,
Address = s.ClientAddress,
});
return objs.ToArray();
}
19
View Source File : NmeaStreamParserSpecsSteps.cs
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
[Given("a line '(.*)'")]
public void GivenALine(string line)
{
this.content.Append(line);
this.content.Append("\n");
}
19
View Source File : NmeaStreamParserSpecsSteps.cs
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
[Given("a CRLF line '(.*)'")]
public void GivenACrlfLine(string line)
{
this.content.Append(line);
this.content.Append("\r\n");
}
19
View Source File : NmeaStreamParserSpecsSteps.cs
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet
[Given("an unterminated line '(.*)'")]
public void GivenAnUnterminatedLine(string line)
{
this.content.Append(line);
}
19
View Source File : OpensslEsiaSigner.cs
License : GNU General Public License v3.0
Project Creator : AISGorod
License : GNU General Public License v3.0
Project Creator : AISGorod
public string Sign(byte[] data)
{
Process a = new Process();
a.StartInfo.FileName = "openssl";
a.StartInfo.Arguments = $"cms -sign -binary -stream -engine gost -inkey {KEY_FILE} -signer {CRT_FILE} -nodetach -outform pem";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
a.StartInfo.FileName = "wsl";
a.StartInfo.Arguments = "openssl " + a.StartInfo.Arguments;
}
a.StartInfo.RedirectStandardInput = true;
a.StartInfo.RedirectStandardOutput = true;
a.StartInfo.UseShellExecute = false;
a.Start();
a.StandardInput.Write(Encoding.UTF8.GetString(data)); // просто передавать массив байтов не получается - ломает подпись
a.StandardInput.Close();
StringBuilder resultData = new StringBuilder();
bool isKeyProcessing = false;
while (!a.StandardOutput.EndOfStream)
{
string line = a.StandardOutput.ReadLine();
if (line == "-----BEGIN CMS-----")
{
isKeyProcessing = true;
}
else if (line == "-----END CMS-----")
{
isKeyProcessing = false;
}
else if (isKeyProcessing)
{
resultData.Append(line);
}
}
return resultData.ToString();
}
19
View Source File : EncryptionHelper.cs
License : MIT License
Project Creator : aishang2015
License : MIT License
Project Creator : aishang2015
public static string MD5Encrypt(string str)
{
using (var md5 = MD5.Create())
{
byte[] buffer = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
var sb = new StringBuilder();
for (int i = 0; i < buffer.Length; i++)
{
sb.Append(buffer[i].ToString("X2"));
}
return sb.ToString();
}
}
19
View Source File : CSVGenerator.cs
License : MIT License
Project Creator : AiursoftWeb
License : MIT License
Project Creator : AiursoftWeb
public byte[] BuildFromCollection<T>(IEnumerable<T> items) where T : new()
{
var csv = new StringBuilder();
var type = typeof(T);
var properties = new List<PropertyInfo>();
var replacedle = new StringBuilder();
foreach (var prop in type.GetProperties().Where(t => t.GetCustomAttributes(typeof(CSVProperty), true).Any()))
{
properties.Add(prop);
var attribute = prop.GetCustomAttributes(typeof(CSVProperty), true).FirstOrDefault();
replacedle.Append($@"""{(attribute as CSVProperty)?.Name}"",");
}
csv.AppendLine(replacedle.ToString().Trim(','));
foreach (var item in items)
{
var newLine = new StringBuilder();
foreach (var prop in properties)
{
var propValue = prop.GetValue(item)?.ToString() ?? "null";
propValue = propValue.Replace("\r", "").Replace("\n", "").Replace("\\", "").Replace("\"", "");
newLine.Append($@"""{propValue}"",");
}
csv.AppendLine(newLine.ToString().Trim(','));
}
return csv.ToString().StringToBytes();
}
19
View Source File : StringExtends.cs
License : MIT License
Project Creator : AiursoftWeb
License : MIT License
Project Creator : AiursoftWeb
public static string SplitStringUpperCase(this string source)
{
string[] split = Regex.Split(source, @"(?<!^)(?=[A-Z])");
var b = new StringBuilder();
bool first = true;
foreach (var word in split)
{
if (first)
{
b.Append(word + " ");
first = false;
}
else
{
b.Append(word.ToLower() + " ");
}
}
return b.ToString();
}
19
View Source File : StringOperation.cs
License : MIT License
Project Creator : AiursoftWeb
License : MIT License
Project Creator : AiursoftWeb
private static string GetMd5Hash(MD5 md5Hash, string input)
{
var data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
var sBuilder = new StringBuilder();
foreach (var c in data)
{
sBuilder.Append(c.ToString("x2"));
}
return sBuilder.ToString();
}
19
View Source File : TestHelper.cs
License : Apache License 2.0
Project Creator : akarnokd
License : Apache License 2.0
Project Creator : akarnokd
private static string replacedtring(object obj)
{
if (obj is IEnumerable en)
{
var sb = new StringBuilder("[");
var i = 0;
foreach (var o in en)
{
if (i != 0)
{
sb.Append(", ");
}
sb.Append(o);
i++;
}
sb.Append("]");
return sb.ToString();
}
return obj != null ? obj.ToString() : "null";
}
19
View Source File : LicenseHeader.cs
License : Apache License 2.0
Project Creator : akarnokd
License : Apache License 2.0
Project Creator : akarnokd
private static void VisitSources(string path)
{
var found = false;
var ci = Environment.GetEnvironmentVariable("CI") != null;
var sb = new StringBuilder();
foreach (var entry in Directory.EnumerateFiles(path, "*.cs", SearchOption.AllDirectories))
{
var entryForward = entry.Replace("\\", "/");
if (entryForward.Contains("replacedemblyInfo")
|| entryForward.Contains("Temporary")
|| entryForward.Contains("/obj/")
|| entryForward.Contains("/Debug/")
|| entryForward.Contains("/Release/"))
{
continue;
}
var text = File.ReadAllText(entry, Encoding.UTF8);
if (!text.Contains("\r\n"))
{
text = text.Replace("\n", "\r\n");
}
if (!text.StartsWith(HeaderLines))
{
sb.Append(entry).Append("\r\n");
found = true;
if (!ci)
{
File.WriteAllText(entry, HeaderLines + text, Encoding.UTF8);
}
}
}
if (found)
{
throw new InvalidOperationException("Missing header found and added. Please rebuild the project of " + path + "\r\n" + sb);
}
}
19
View Source File : TestSubscriber.cs
License : Apache License 2.0
Project Creator : akarnokd
License : Apache License 2.0
Project Creator : akarnokd
public InvalidOperationException Fail(string message)
{
StringBuilder b = new StringBuilder(64);
b.Append(message);
b.Append(" (latch = ").Append(latch.CurrentCount);
b.Append(", values = ").Append(Volatile.Read(ref valueCount));
long ec = Volatile.Read(ref errorCount);
b.Append(", errors = ").Append(ec);
b.Append(", completions = ").Append(Volatile.Read(ref completions));
b.Append(", subscribed = ").Append(Volatile.Read(ref upstream) != null);
b.Append(", cancelled = ").Append(SubscriptionHelper.IsCancelled(ref upstream));
if (tag != null)
{
b.Append(", tag = ").Append(tag);
}
b.Append(")");
InvalidOperationException ex;
if (ec != 0)
{
if (ec == 1)
{
ex = new InvalidOperationException(b.ToString(), errors[0]);
}
else
{
ex = new InvalidOperationException(b.ToString(), new AggregateException(errors));
}
}
else
{
ex = new InvalidOperationException(b.ToString());
}
return ex;
}
19
View Source File : TestSubscriber.cs
License : Apache License 2.0
Project Creator : akarnokd
License : Apache License 2.0
Project Creator : akarnokd
string replacedtring(object item)
{
if (item is IList lst)
{
StringBuilder b = new StringBuilder();
b.Append("[");
for (int i = 0; i < lst.Count; i++)
{
if (i != 0)
{
b.Append(", ");
}
b.Append(replacedtring(lst[i]));
}
b.Append("]");
return b.ToString();
}
return item == null ? "null" : item.ToString();
}
19
View Source File : DateConvertToCustomText.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
protected override void Execute(CodeActivityContext context)
{
var workflowContext = context.GetExtension<IWorkflowContext>();
var service = this.RetrieveOrganizationService(context);
List<OptionSetValue> values = new List<OptionSetValue>() {
this.Part1.Get<OptionSetValue>(context),
this.Part2.Get<OptionSetValue>(context),
this.Part3.Get<OptionSetValue>(context),
this.Part4.Get<OptionSetValue>(context),
this.Part5.Get<OptionSetValue>(context),
this.Part6.Get<OptionSetValue>(context),
this.Part7.Get<OptionSetValue>(context),
this.Part8.Get<OptionSetValue>(context),
this.Part9.Get<OptionSetValue>(context),
this.Part10.Get<OptionSetValue>(context),
this.Part11.Get<OptionSetValue>(context),
this.Part12.Get<OptionSetValue>(context),
this.Part13.Get<OptionSetValue>(context),
this.Part14.Get<OptionSetValue>(context),
this.Part15.Get<OptionSetValue>(context),
this.Part16.Get<OptionSetValue>(context),
this.Part17.Get<OptionSetValue>(context),
this.Part18.Get<OptionSetValue>(context),
this.Part19.Get<OptionSetValue>(context),
this.Part20.Get<OptionSetValue>(context) };
values.RemoveAll(osv => osv == null || osv.Value == 222540025);
TimeZoneSummary timeZone = StaticMethods.CalculateTimeZoneToUse(this.TimeZoneOption.Get(context), workflowContext, service);
DateTime dateToModify = this.DateToModify.Get(context);
if (dateToModify.Kind != DateTimeKind.Utc)
{
dateToModify = dateToModify.ToUniversalTime();
}
LocalTimeFromUtcTimeRequest timeZoneChangeRequest = new LocalTimeFromUtcTimeRequest() { UtcTime = dateToModify, TimeZoneCode = timeZone.MicrosoftIndex };
LocalTimeFromUtcTimeResponse timeZoneResponse = service.Execute(timeZoneChangeRequest) as LocalTimeFromUtcTimeResponse;
DateTime timeZoneSpecificDateTime = timeZoneResponse.LocalTime;
StringBuilder sb = new StringBuilder();
foreach (OptionSetValue osv in values)
{
try
{
switch (osv.Value)
{
case 222540000:
sb.Append(timeZoneSpecificDateTime.ToString("%h"));
break;
case 222540001:
sb.Append(timeZoneSpecificDateTime.ToString("hh"));
break;
case 222540002:
sb.Append(timeZoneSpecificDateTime.ToString("%H"));
break;
case 222540003:
sb.Append(timeZoneSpecificDateTime.ToString("HH"));
break;
case 222540004:
sb.Append(timeZoneSpecificDateTime.ToString("%m"));
break;
case 222540005:
sb.Append(timeZoneSpecificDateTime.ToString("mm"));
break;
case 222540006:
sb.Append(timeZoneSpecificDateTime.ToString("%d"));
break;
case 222540007:
sb.Append(timeZoneSpecificDateTime.ToString("dd"));
break;
case 222540008:
sb.Append(timeZoneSpecificDateTime.ToString("ddd"));
break;
case 222540009:
sb.Append(timeZoneSpecificDateTime.ToString("dddd"));
break;
case 222540010:
sb.Append(timeZoneSpecificDateTime.ToString("%M"));
break;
case 222540011:
sb.Append(timeZoneSpecificDateTime.ToString("MM"));
break;
case 222540012:
sb.Append(timeZoneSpecificDateTime.ToString("MMM"));
break;
case 222540013:
sb.Append(timeZoneSpecificDateTime.ToString("MMMM"));
break;
case 222540014:
sb.Append(timeZoneSpecificDateTime.ToString("%y"));
break;
case 222540015:
sb.Append(timeZoneSpecificDateTime.ToString("yy"));
break;
case 222540016:
sb.Append(timeZoneSpecificDateTime.ToString("yyyy"));
break;
case 222540017:
sb.Append(timeZoneSpecificDateTime.ToString("%t"));
break;
case 222540018:
sb.Append(timeZoneSpecificDateTime.ToString("tt"));
break;
case 222540019:
sb.Append(" ");
break;
case 222540020:
sb.Append(",");
break;
case 222540021:
sb.Append(".");
break;
case 222540022:
sb.Append(":");
break;
case 222540023:
sb.Append("/");
break;
case 222540024:
sb.Append(@"\");
break;
case 222540026:
sb.Append("-");
break;
case 222540027:
sb.Append(timeZone.Id);
break;
case 222540028:
sb.Append(timeZone.FullName);
break;
default:
break;
}
}
catch
{
throw new Exception(osv.Value.ToString());
}
}
FormattedDate.Set(context, sb.ToString());
}
19
View Source File : QueryGetResults.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
protected virtual void BuildResultsAsHtml(DataTable table, CodeActivityContext context, IOrganizationService service)
{
string borderColor = this.Table_BorderColor.Get(context);
StringBuilder sb = new StringBuilder();
sb.Append($"<table style=\"border: 1px solid {borderColor}; border-collapse:collapse;\">");
if (this.IncludeHeader.Get(context))
{
sb.Append("<tr>");
foreach (DataColumn column in table.Columns)
{
if (!column.ColumnName.Contains("_Metadata_"))
{
string fontWeight = this.Header_BoldFont.Get(context) ? "bold" : "normal";
sb.Append($"<td style=\"border: 1px solid {borderColor}; padding: 6px; background-color: {this.Header_BackgroundColor.Get(context)}; color: {this.Header_FontColor.Get(context)}; font-weight: {fontWeight}\">");
sb.Append(column.ColumnName);
sb.Append("</td>");
}
}
sb.Append("</tr>");
}
for (int rowNumber = 0; rowNumber < table.Rows.Count; rowNumber++)
{
string rowBackGroundColor = rowNumber % 2 == 0 ? this.Row_BackgroundColor.Get(context) : AlternatingRow_BackgroundColor.Get(context);
string rowTextColor = rowNumber % 2 == 0 ? this.Row_FontColor.Get(context) : this.AlternatingRow_FontColor.Get(context);
sb.Append($"<tr style=\"background-color: {rowBackGroundColor}; color: {rowTextColor}\">");
for (int i = 0; i < table.Columns.Count; i++)
{
if (!table.Columns[i].ColumnName.Contains("_Metadata_"))
{
sb.Append($"<td style=\"border: 1px solid {borderColor}; padding: 6px; \">");
sb.Append(table.Rows[rowNumber][i].ToString());
sb.Append("</td>");
}
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.HtmlQueryResults.Set(context, sb.ToString());
}
19
View Source File : AuditBase.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
protected virtual void BuildResultsAsHtml(DataTable table, CodeActivityContext context, IOrganizationService service)
{
string borderColor = this.Table_BorderColor.Get(context);
StringBuilder sb = new StringBuilder();
sb.Append($"<table style=\"border: 1px solid {borderColor}; border-collapse:collapse;\">");
if (this.IncludeHeader.Get(context))
{
sb.Append("<tr>");
foreach (DataColumn column in table.Columns)
{
string fontWeight = this.Header_BoldFont.Get(context) ? "bold" : "normal";
sb.Append($"<td style=\"border: 1px solid {borderColor}; padding: 6px; background-color: {this.Header_BackgroundColor.Get(context)}; color: {this.Header_FontColor.Get(context)}; font-weight: {fontWeight}\">");
sb.Append(column.ColumnName);
sb.Append("</td>");
}
sb.Append("</tr>");
}
for (int rowNumber = 0; rowNumber < table.Rows.Count; rowNumber++)
{
string rowBackGroundColor = rowNumber % 2 == 0 ? this.Row_BackgroundColor.Get(context) : AlternatingRow_BackgroundColor.Get(context);
string rowTextColor = rowNumber % 2 == 0 ? this.Row_FontColor.Get(context) : this.AlternatingRow_FontColor.Get(context);
sb.Append($"<tr style=\"background-color: {rowBackGroundColor}; color: {rowTextColor}\">");
for (int i = 0; i < table.Columns.Count; i++)
{
sb.Append($"<td style=\"border: 1px solid {borderColor}; padding: 6px; \">");
sb.Append(table.Rows[rowNumber][i].ToString());
sb.Append("</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.HtmlAuditResults.Set(context, sb.ToString());
}
19
View Source File : WebHook.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
protected override void Execute(CodeActivityContext context)
{
string body = string.Empty;
var workflowContext = context.GetExtension<IWorkflowContext>();
if(!string.IsNullOrEmpty(RequestBody.Get<string>(context)))
{
body = RequestBody.Get<string>(context);
}
List<string> headers = new List<string>();
var requestHeaders = RequestHeaders.Get<string>(context)?.Split(';');
if (requestHeaders != null)
{
headers.AddRange(requestHeaders);
}
using (var client = new HttpClient())
{
foreach(var header in headers)
{
var headerKeyValue = header.Split(':');
client.DefaultRequestHeaders.Add(headerKeyValue[0], headerKeyValue[1]);
}
var content = new StringContent(body, Encoding.UTF8, "application/json");
System.Threading.Tasks.Task<HttpResponseMessage> response = null;
if (this.RequestMethod != null)
{
OptionSetValue value = this.RequestMethod.Get<OptionSetValue>(context);
if (value != null && value.Value != 0)
{
response = SendRequest(context, client, value.Value, content);
}
}
if (response != null)
{
response.Result.EnsureSuccessStatusCode();
StringBuilder delimitedHeaders = new StringBuilder();
foreach (var header in response.Result.Headers)
{
if (delimitedHeaders.Length > 0)
{
delimitedHeaders.Append(";");
}
delimitedHeaders.Append($"{header.Key}:{header.Value}");
}
ResponseHeaders.Set(context, delimitedHeaders.ToString());
var responseString = response.Result.Content.ReadreplacedtringAsync();
ResponseBody.Set(context, responseString.Result);
}
}
}
19
View Source File : MemoryTraceWriter.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public override string ToString()
{
StringBuilder sb = new StringBuilder();
foreach (string traceMessage in _traceMessages)
{
if (sb.Length > 0)
{
sb.AppendLine();
}
sb.Append(traceMessage);
}
return sb.ToString();
}
19
View Source File : MemoryTraceWriter.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public void Trace(TraceLevel level, string message, Exception ex)
{
if (_traceMessages.Count >= 1000)
{
_traceMessages.Dequeue();
}
StringBuilder sb = new StringBuilder();
sb.Append(DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff", CultureInfo.InvariantCulture));
sb.Append(" ");
sb.Append(level.ToString("g"));
sb.Append(" ");
sb.Append(message);
_traceMessages.Enqueue(sb.ToString());
}
19
View Source File : JsonPosition.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
internal void WriteTo(StringBuilder sb)
{
switch (Type)
{
case JsonContainerType.Object:
string propertyName = PropertyName;
if (propertyName.IndexOfAny(SpecialCharacters) != -1)
{
sb.Append(@"['");
sb.Append(propertyName);
sb.Append(@"']");
}
else
{
if (sb.Length > 0)
{
sb.Append('.');
}
sb.Append(propertyName);
}
break;
case JsonContainerType.Array:
case JsonContainerType.Constructor:
sb.Append('[');
sb.Append(Position);
sb.Append(']');
break;
}
}
19
View Source File : Fan.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : akmadian
public string LedsToString() {
StringBuilder sb = new StringBuilder();
foreach (bool LED in _Leds)
{
sb.Append(LED + " ");
}
return sb.ToString();
}
19
View Source File : Extensions.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : akmadian
public static string MultString(this string str, int n) {
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= n; i++) { sb.Append(str); }
return sb.ToString();
}
19
View Source File : Extensions.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : akmadian
public static string ToString(this byte[] thisone) {
StringBuilder sb = new StringBuilder();
foreach (byte thing in thisone) {
sb.Append(thing.ToString() + " ");
}
return sb.ToString();
}
19
View Source File : Extensions.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : akmadian
public static string ColorArrToString(this byte[] thisone, bool asHex = true)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < thisone.Length; i++)
{
if (!(i % 12 == 0) || i == 0)
{
if (asHex)
{
sb.Append(thisone[i].ToString("X2") + " ");
} else
{
sb.Append(thisone[i].ToString("X2") + " ");
}
} else
{
sb.Append("\n");
}
}
return sb.ToString();
}
19
View Source File : HtmlFromXamlConverter.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
private static void AddComplexProperty(XmlTextReader xamlReader, StringBuilder inlineStyle)
{
Debug.replacedert(xamlReader.NodeType == XmlNodeType.Element);
if (inlineStyle != null && xamlReader.Name.EndsWith(".TextDecorations", StringComparison.OrdinalIgnoreCase))
{
inlineStyle.Append("text-decoration:underline;");
}
// Skip the element representing the complex property
WriteElementContent(xamlReader, /*htmlWriter:*/null, /*inlineStyle:*/null);
}
19
View Source File : HtmlLexicalAnalyzer.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
internal void GetNextContentToken()
{
Debug.replacedert(_nextTokenType != HtmlTokenType.EOF);
_nextToken.Length = 0;
if (this.IsAtEndOfStream)
{
_nextTokenType = HtmlTokenType.EOF;
return;
}
if (this.IsAtTagStart)
{
this.GetNextCharacter();
if (this.NextCharacter == '/')
{
_nextToken.Append("</");
_nextTokenType = HtmlTokenType.ClosingTagStart;
// advance
this.GetNextCharacter();
_ignoreNextWhitespace = false; // Whitespaces after closing tags are significant
}
else
{
_nextTokenType = HtmlTokenType.OpeningTagStart;
_nextToken.Append("<");
_ignoreNextWhitespace = true; // Whitespaces after opening tags are insignificant
}
}
else if (this.IsAtDirectiveStart)
{
// either a comment or CDATA
this.GetNextCharacter();
if (_lookAheadCharacter == '[')
{
// cdata
this.ReadDynamicContent();
}
else if (_lookAheadCharacter == '-')
{
this.ReadComment();
}
else
{
// neither a comment nor cdata, should be something like DOCTYPE
// skip till the next tag ender
this.ReadUnknownDirective();
}
}
else
{
// read text content, unless you encounter a tag
_nextTokenType = HtmlTokenType.Text;
while (!this.IsAtTagStart && !this.IsAtEndOfStream && !this.IsAtDirectiveStart)
{
if (this.NextCharacter == '<' && !this.IsNextCharacterEnreplacedy && _lookAheadCharacter == '?')
{
// ignore processing directive
this.SkipProcessingDirective();
}
else
{
if (this.NextCharacter <= ' ')
{
// Respect xml:preserve or its equivalents for whitespace processing
if (_ignoreNextWhitespace)
{
// Changed by Akshin
_nextToken.Append(' ');
// Ignore repeated whitespaces
}
else
{
// Treat any control character sequence as one whitespace
_nextToken.Append(' ');
}
_ignoreNextWhitespace = true; // and keep ignoring the following whitespaces
}
else
{
_nextToken.Append(this.NextCharacter);
_ignoreNextWhitespace = false;
}
this.GetNextCharacter();
}
}
}
}
19
View Source File : HtmlLexicalAnalyzer.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
internal void GetNextTagToken()
{
_nextToken.Length = 0;
if (this.IsAtEndOfStream)
{
_nextTokenType = HtmlTokenType.EOF;
return;
}
this.SkipWhiteSpace();
if (this.NextCharacter == '>' && !this.IsNextCharacterEnreplacedy)
{
// > should not end a tag, so make sure it's not an enreplacedy
_nextTokenType = HtmlTokenType.TagEnd;
_nextToken.Append('>');
this.GetNextCharacter();
// Note: _ignoreNextWhitespace must be set appropriately on tag start processing
}
else if (this.NextCharacter == '/' && _lookAheadCharacter == '>')
{
// could be start of closing of empty tag
_nextTokenType = HtmlTokenType.EmptyTagEnd;
_nextToken.Append("/>");
this.GetNextCharacter();
this.GetNextCharacter();
_ignoreNextWhitespace = false; // Whitespace after no-scope tags are sifnificant
}
else if (IsGoodForNameStart(this.NextCharacter))
{
_nextTokenType = HtmlTokenType.Name;
// starts a name
// we allow character enreplacedies here
// we do not throw exceptions here if end of stream is encountered
// just stop and return whatever is in the token
// if the parser is not expecting end of file after this it will call
// the get next token function and throw an exception
while (IsGoodForName(this.NextCharacter) && !this.IsAtEndOfStream)
{
_nextToken.Append(this.NextCharacter);
this.GetNextCharacter();
}
}
else
{
// Unexpected type of token for a tag. Reprot one character as Atom, expecting that HtmlParser will ignore it.
_nextTokenType = HtmlTokenType.Atom;
_nextToken.Append(this.NextCharacter);
this.GetNextCharacter();
}
}
19
View Source File : HtmlParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
internal static string AddHtmlClipboardHeader(string htmlString)
{
StringBuilder stringBuilder = new StringBuilder();
// each of 6 numbers is represented by "{0:D10}" in the format string
// must actually occupy 10 digit positions ("0123456789")
int startHTML = HtmlHeader.Length + 6 * ("0123456789".Length - "{0:D10}".Length);
int endHTML = startHTML + htmlString.Length;
int startFragment = htmlString.IndexOf(HtmlStartFragmentComment, 0, StringComparison.OrdinalIgnoreCase);
if (startFragment >= 0)
{
startFragment = startHTML + startFragment + HtmlStartFragmentComment.Length;
}
else
{
startFragment = startHTML;
}
int endFragment = htmlString.IndexOf(HtmlEndFragmentComment, 0, StringComparison.OrdinalIgnoreCase);
if (endFragment >= 0)
{
endFragment = startHTML + endFragment;
}
else
{
endFragment = endHTML;
}
// Create HTML clipboard header string
stringBuilder.AppendFormat(CultureInfo.InvariantCulture,HtmlHeader, startHTML, endHTML, startFragment, endFragment, startFragment, endFragment);
// Append HTML body.
stringBuilder.Append(htmlString);
return stringBuilder.ToString();
}
19
View Source File : HtmlCssParser.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
public void DiscoverStyleDefinitions(XmlElement htmlElement)
{
if (htmlElement.LocalName.ToLower(CultureInfo.InvariantCulture) == "link")
{
return;
// Add LINK elements processing for included stylesheets
// <LINK href="http://sc.msn.com/global/css/ptnr/orange.css" type=text/css \r\nrel=stylesheet>
}
if (htmlElement.LocalName.ToLower(CultureInfo.InvariantCulture) != "style")
{
// This is not a STYLE element. Recurse into it
for (XmlNode htmlChildNode = htmlElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
{
if (htmlChildNode is XmlElement)
{
this.DiscoverStyleDefinitions((XmlElement)htmlChildNode);
}
}
return;
}
// Add style definitions from this style.
// Collect all text from this style definition
StringBuilder stylesheetBuffer = new StringBuilder();
for (XmlNode htmlChildNode = htmlElement.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode.NextSibling)
{
if (htmlChildNode is XmlText || htmlChildNode is XmlComment)
{
stylesheetBuffer.Append(RemoveComments(htmlChildNode.Value));
}
}
// CssStylesheet has the following syntactical structure:
// @import declaration;
// selector { definition }
// where "selector" is one of: ".clreplacedname", "tagname"
// It can contain comments in the following form: /*...*/
int nextCharacterIndex = 0;
while (nextCharacterIndex < stylesheetBuffer.Length)
{
// Extract selector
int selectorStart = nextCharacterIndex;
while (nextCharacterIndex < stylesheetBuffer.Length && stylesheetBuffer[nextCharacterIndex] != '{')
{
// Skip declaration directive starting from @
if (stylesheetBuffer[nextCharacterIndex] == '@')
{
while (nextCharacterIndex < stylesheetBuffer.Length && stylesheetBuffer[nextCharacterIndex] != ';')
{
nextCharacterIndex++;
}
selectorStart = nextCharacterIndex + 1;
}
nextCharacterIndex++;
}
if (nextCharacterIndex < stylesheetBuffer.Length)
{
// Extract definition
int definitionStart = nextCharacterIndex;
while (nextCharacterIndex < stylesheetBuffer.Length && stylesheetBuffer[nextCharacterIndex] != '}')
{
nextCharacterIndex++;
}
// Define a style
if (nextCharacterIndex - definitionStart > 2)
{
this.AddStyleDefinition(
stylesheetBuffer.ToString(selectorStart, definitionStart - selectorStart),
stylesheetBuffer.ToString(definitionStart + 1, nextCharacterIndex - definitionStart - 2));
}
// Skip closing brace
if (nextCharacterIndex < stylesheetBuffer.Length)
{
Debug.replacedert(stylesheetBuffer[nextCharacterIndex] == '}');
nextCharacterIndex++;
}
}
}
}
19
View Source File : HtmlFromXamlConverter.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev
private static void WriteFormattingProperties(XmlTextReader xamlReader, XmlTextWriter htmlWriter, StringBuilder inlineStyle)
{
Debug.replacedert(xamlReader.NodeType == XmlNodeType.Element);
// Clear string builder for the inline style
inlineStyle.Remove(0, inlineStyle.Length);
if (!xamlReader.HasAttributes)
{
return;
}
bool borderSet = false;
while (xamlReader.MoveToNextAttribute())
{
string css = null;
switch (xamlReader.Name)
{
// Character fomatting properties
// ------------------------------
case "Background":
css = "background-color:" + ParseXamlColor(xamlReader.Value) + ";";
break;
case "FontFamily":
css = "font-family:" + xamlReader.Value + ";";
break;
case "FontStyle":
css = "font-style:" + xamlReader.Value.ToLower(CultureInfo.InvariantCulture) + ";";
break;
case "FontWeight":
css = "font-weight:" + xamlReader.Value.ToLower(CultureInfo.InvariantCulture) + ";";
break;
case "FontStretch":
break;
case "FontSize":
css = "font-size:" + xamlReader.Value + ";";
break;
case "Foreground":
css = "color:" + ParseXamlColor(xamlReader.Value) + ";";
break;
case "TextDecorations":
css = "text-decoration:underline;";
break;
case "TextEffects":
break;
case "Emphasis":
break;
case "StandardLigatures":
break;
case "Variants":
break;
case "Capitals":
break;
case "Fraction":
break;
// Paragraph formatting properties
// -------------------------------
case "Padding":
css = "padding:" + ParseXamlThickness(xamlReader.Value) + ";";
break;
case "Margin":
css = "margin:" + ParseXamlThickness(xamlReader.Value) + ";";
break;
case "BorderThickness":
css = "border-width:" + ParseXamlThickness(xamlReader.Value) + ";";
borderSet = true;
break;
case "BorderBrush":
css = "border-color:" + ParseXamlColor(xamlReader.Value) + ";";
borderSet = true;
break;
case "LineHeight":
break;
case "TextIndent":
css = "text-indent:" + xamlReader.Value + ";";
break;
case "TextAlignment":
css = "text-align:" + xamlReader.Value + ";";
break;
case "IsKeptTogether":
break;
case "IsKeptWithNext":
break;
case "ColumnBreakBefore":
break;
case "PageBreakBefore":
break;
case "FlowDirection":
break;
// Table attributes
// ----------------
case "Width":
css = "width:" + xamlReader.Value + ";";
break;
case "ColumnSpan":
htmlWriter.WriteAttributeString("COLSPAN", xamlReader.Value);
break;
case "RowSpan":
htmlWriter.WriteAttributeString("ROWSPAN", xamlReader.Value);
break;
// Hyperlink Attributes
case "NavigateUri" :
htmlWriter.WriteAttributeString("HREF", xamlReader.Value);
break;
}
if (css != null)
{
inlineStyle.Append(css);
}
}
if (borderSet)
{
inlineStyle.Append("border-style:solid;mso-element:para-border-div;");
}
// Return the xamlReader back to element level
xamlReader.MoveToElement();
Debug.replacedert(xamlReader.NodeType == XmlNodeType.Element);
}
19
View Source File : IfElse.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public override string GenerateCode()
{
var sb = new StringBuilder();
sb.AppendLine();
sb.Append("if(" + InputPorts[0].Data.Value + "){");
try
{
if (OutExecPorts[1] != null)
sb.Append(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode));
}
catch (Exception)
{
//Ignored
}
sb.Append("}");
sb.Append("else{");
try
{
if (OutExecPorts[1] != null)
sb.Append(CodeMiner.Code(OutExecPorts[2].ConnectedConnectors[0].EndPort.ParentNode));
}
catch (Exception)
{
//Ignored
}
sb.Append("}");
sb.AppendLine();
return sb.ToString();
}
19
View Source File : For.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public override string GenerateCode()
{
var sb = new StringBuilder();
sb.Append($"for({InputPorts?[0].Data.Value} in {InputPorts?[1].Data.Value})"+"{");
sb.AppendLine();
if (OutExecPorts[1].ConnectedConnectors.Count > 0)
sb.AppendLine(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode));
sb.AppendLine();
sb.Append("}");
return sb.ToString();
}
19
View Source File : While.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public override string GenerateCode()
{
var sb = new StringBuilder();
sb.Append($"while({InputPorts?[0].Data.Value})" + "{");
sb.AppendLine();
if (OutExecPorts[1].ConnectedConnectors.Count > 0)
sb.AppendLine(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode));
sb.AppendLine();
sb.Append("}");
return sb.ToString();
}
19
View Source File : CharacterRArray.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public override string GenerateCode()
{
var sb = new StringBuilder();
sb.Append("c(");
foreach (var ip in InputPorts)
sb.Append($"'{ip.Data.Value}',");
sb.Append(')');
var code = sb.ToString().Replace(",)", ")");
OutputPorts[0].Data.Value = code;
return "#Generated a vector of characters : " + code;
}
19
View Source File : NumericRArray.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
public override string GenerateCode()
{
var sb = new StringBuilder();
sb.Append("c(");
foreach (var ip in InputPorts)
sb.Append($"{ip.Data.Value},");
sb.Append(')');
var code = sb.ToString().Replace(",)", ")");
OutputPorts[0].Data.Value = code;
return "#Generated a vector of characters : " + code;
}
19
View Source File : SejilSqlProvider.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
public string GetPagedLogEntriesSql(int page, int pageSize, DateTime? startingTimestamp, LogQueryFilter queryFilter)
{
if (page <= 0)
{
throw new ArgumentOutOfRangeException(nameof(page), "Argument must be greater than zero.");
}
if (pageSize <= 0)
{
throw new ArgumentOutOfRangeException(nameof(pageSize), "Argument must be greater than zero.");
}
var timestampWhereClause = TimestampWhereClause();
var queryWhereClause = QueryWhereClause();
return
$@"SELECT l.*, p.* from
(
SELECT * FROM log
{timestampWhereClause}
{queryWhereClause}{FiltersWhereClause()}
ORDER BY timestamp DESC
LIMIT {pageSize} OFFSET {(page - 1) * pageSize}
) l
LEFT JOIN log_property p ON l.id = p.logId
ORDER BY l.timestamp DESC, p.name";
string TimestampWhereClause()
{
var hreplacedtartingTimestampConstraint = startingTimestamp.HasValue;
var hasDateFilter = queryFilter?.DateFilter != null || queryFilter?.DateRangeFilter != null;
var sql = new StringBuilder();
if (hreplacedtartingTimestampConstraint || hasDateFilter)
{
sql.Append("WHERE (");
}
if (hreplacedtartingTimestampConstraint)
{
sql.Append($@"timestamp <= '{startingTimestamp.Value:yyyy-MM-dd HH:mm:ss.fff}'");
}
if (hreplacedtartingTimestampConstraint && hasDateFilter)
{
sql.Append(" AND ");
}
if (hasDateFilter)
{
sql.Append(BuildDateFilter(queryFilter));
}
if (hreplacedtartingTimestampConstraint || hasDateFilter)
{
sql.Append(')');
}
return sql.ToString();
}
string QueryWhereClause() =>
string.IsNullOrWhiteSpace(queryFilter?.QueryText)
? ""
: timestampWhereClause.Length > 0
? $"AND ({QueryEngine.Translate(queryFilter.QueryText, _nonPropertyColumns)})"
: $"WHERE ({QueryEngine.Translate(queryFilter.QueryText, _nonPropertyColumns)})";
string FiltersWhereClause() =>
string.IsNullOrWhiteSpace(queryFilter?.LevelFilter) && (!queryFilter?.ExceptionsOnly ?? true)
? ""
: timestampWhereClause.Length > 0 || queryWhereClause.Length > 0
? $" AND ({BuildFilterWhereClause(queryFilter.LevelFilter, queryFilter.ExceptionsOnly)})"
: $"WHERE ({BuildFilterWhereClause(queryFilter.LevelFilter, queryFilter.ExceptionsOnly)})";
}
19
View Source File : SejilSqlProvider.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
private static string BuildFilterWhereClause(string levelFilter, bool exceptionsOnly)
{
var sp = new StringBuilder();
if (!string.IsNullOrWhiteSpace(levelFilter))
{
sp.AppendFormat("level = '{0}'", levelFilter);
}
if (exceptionsOnly && sp.Length > 0)
{
sp.Append(" AND ");
}
if (exceptionsOnly)
{
sp.Append("exception is not null");
}
return sp.ToString();
}
19
View Source File : CodeGenerator.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
public void Visit(Expr.Binary expr)
{
CheckPropertyScope(expr);
Resolve(expr.Left);
_sql.Append(expr.IsProperty
? $"value {expr.Operator.NegateIfNonInclusion().ToUpper()} "
: $" {expr.Operator.Text.ToUpper()} ");
Resolve(expr.Right);
if (expr.Left.IsProperty)
{
_sql.Append($") {(expr.Operator.IsExluding() ? "=" : ">")} 0");
}
}
19
View Source File : CodeGenerator.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
public void Visit(Expr.Literal expr) => _sql.Append($"'{expr.Value}'");
19
View Source File : CodeGenerator.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
public void Visit(Expr.Logical expr)
{
Resolve(expr.Left);
if (_insidePropBlock && !expr.Right.IsProperty)
{
_sql.Append(')');
}
_sql.Append($" {expr.Operator.Text.ToUpper()} ");
Resolve(expr.Right);
}
19
View Source File : CodeGenerator.cs
License : Apache License 2.0
Project Creator : alaatm
License : Apache License 2.0
Project Creator : alaatm
private void CheckPropertyScope(Expr expr)
{
if (expr.IsProperty && !_insidePropBlock)
{
_sql.Append("id IN (SELECT logId FROM log_property GROUP BY logId HAVING ");
_insidePropBlock = true;
}
else if (!expr.IsProperty)
{
_insidePropBlock = false;
}
}
19
View Source File : AdvancingFront.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public override string ToString()
{
StringBuilder sb = new StringBuilder();
AdvancingFrontNode node = Head;
while (node != Tail)
{
sb.Append(node.Point.X).Append("->");
node = node.Next;
}
sb.Append(Tail.Point.X);
return sb.ToString();
}
19
View Source File : Vector2.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public override string ToString()
{
StringBuilder sb = new StringBuilder(24);
sb.Append("{X:");
sb.Append(X);
sb.Append(" Y:");
sb.Append(Y);
sb.Append("}");
return sb.ToString();
}
19
View Source File : Vector3.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public override string ToString()
{
StringBuilder sb = new StringBuilder(32);
sb.Append("{X:");
sb.Append(X);
sb.Append(" Y:");
sb.Append(Y);
sb.Append(" Z:");
sb.Append(Z);
sb.Append("}");
return sb.ToString();
}
19
View Source File : ProgramArguments.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
private void AppendValue(StringBuilder builder, object value)
{
if (value is string || value is int || value is uint || value.GetType().IsEnum)
{
builder.Append(value.ToString());
}
else if (value is bool)
{
builder.Append((bool)value ? "+" : "-");
}
else
{
bool first = true;
foreach (object o in (System.Array)value)
{
if (!first)
{
builder.Append(", ");
}
AppendValue(builder, o);
first = false;
}
}
}
19
View Source File : Vertices.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
public override string ToString()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < Count; i++)
{
builder.Append(this[i].ToString());
if (i < Count - 1)
{
builder.Append(" ");
}
}
return builder.ToString();
}
19
View Source File : ProgramArguments.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
private static void AddNewLine(string newLine, StringBuilder builder, ref int currentColumn)
{
builder.Append(newLine);
currentColumn = 0;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
static void Main(string[] args)
{
int depth = 4;
var dels = new List<string>();
var defs = new List<string>();
for (int i = 2; i < depth+2; i++)
{
var typeList = new List<string>();
var parList = new List<string>();
for (int j = 0; j < i-1; j++)
{
typeList.Add($"T{j}");
parList.Add($"ref T{j} component{j}"); //todo linq select
}
string del = "public delegate void ProcessComponent<";
del += String.Join(", ", typeList);
del += ">(int entIdx, ";
del += String.Join(", ", parList);
del += ");";
dels.Add(del);
StringBuilder sb = new StringBuilder();
sb.Append("public void Loop<");
sb.Append(String.Join(", ", typeList));
sb.Append(">(ProcessComponent<");
sb.Append(String.Join(", ", typeList));
sb.Append("> loopAction)\r\n");
sb.Append(String.Join(" ", typeList.Select(x => "where "+x+" : struct"))+"\r\n");
sb.Append("{\r\n");
sb.AppendLine(" ushort typeMask = 0;");
for (int j = 0; j < i-1; j++)
{
sb.AppendLine($" var t{j}Base = componentsManager_.GetBufferSlow<T{j}>();");
sb.AppendLine($" if (t{j}Base.Sparse) typeMask |= 1 << {j};");
}
sb.AppendLine(" switch (typeMask) {");
uint bits = 0;
var fsb = new StringBuilder();
while ((bits & (1 << i-1)) == 0)
{
string binrepr = Convert.ToString(bits, 2).PadLeft(i-1, '0');
sb.AppendLine($" case 0b{binrepr}:");
sb.AppendLine($" Loop{binrepr}(loopAction,");
fsb.AppendLine($"private void Loop{binrepr}<{String.Join(", ", typeList)}>(");
fsb.AppendLine($"ProcessComponent<{String.Join(", ", typeList)}> loopAction,");
for (int j = 0; j < i - 1; j++)
{
bool dense = (bits & (1 << j)) == 0;
string type = dense ? "Dense" : "Sparse";
sb.AppendLine($" (ComponentBuffer{type}<T{j}>)t{j}Base" + ( j == i-2 ? "" : ","));
fsb.AppendLine($"ComponentBuffer{type}<T{j}> t{j}B" + (j == i - 2 ? ")" : ","));
}
sb.AppendLine($" ); return;");
for (int j = 0; j < i - 1; j++)
{
fsb.AppendLine($"where T{j} : struct");
}
fsb.AppendLine("{");
fsb.AppendLine($" var compBuffers = t0B.__GetBuffers();");
fsb.AppendLine($" var lastCompIndex = t0B.ComponentCount-1;");
fsb.AppendLine($" var compIdx2EntIdx = compBuffers.i2EntIdx;");
fsb.AppendLine($" var components = compBuffers.data;");
for (int j = 1; j < i - 1; j++)
{
fsb.AppendLine($" var matcher{j}Flag = t{j}B.Matcher.Flag;");
fsb.AppendLine($" var matcher{j}Buffers = t{j}B.__GetBuffers();");
}
fsb.AppendLine(" for (var i = lastCompIndex; i >= 0; i--) {");
fsb.AppendLine(" ref T0 component0 = ref components[i];");
fsb.AppendLine(" EntIdx entIdx = compIdx2EntIdx[i];");
fsb.AppendLine(" ref EnreplacedyData enreplacedyData = ref data_[entIdx];");
GenerateNestedSelectors(fsb, i, bits);
fsb.AppendLine($"}} // for components");
fsb.AppendLine($"}} // Loop{binrepr}");
bits++;
}
sb.AppendLine(" } // end switch (typeMask)");
sb.AppendLine("} // end function");
sb.AppendLine(fsb.ToString());
defs.Add(sb.ToString());
}
var file = new List<string>();
file.Add("using System.Collections.Generic;\r\n" +
"using System.Linq;\r\n" +
"using EntIdx = System.Int32;\r\n" +
"partial clreplaced EnreplacedyRegistry\r\n{");
file.AddRange(dels);
file.AddRange(defs);
file.Add("\r\n}");
File.WriteAllLines("../../../../minECS/EnreplacedyRegistryGenerated.cs", file);
}
19
View Source File : DebugViewXNA.cs
License : MIT License
Project Creator : Alan-FGR
License : MIT License
Project Creator : Alan-FGR
private void DrawDebugPanel()
{
int fixtureCount = 0;
for (int i = 0; i < World.BodyList.Count; i++)
{
fixtureCount += World.BodyList[i].FixtureList.Count;
}
int x = (int)DebugPanelPosition.X;
int y = (int)DebugPanelPosition.Y;
#if XBOX
_debugPanelSb = new StringBuilder();
#else
_debugPanelSb.Clear();
#endif
_debugPanelSb.AppendLine("Objects:");
_debugPanelSb.Append("- Bodies: ").AppendLine(World.BodyList.Count.ToString());
_debugPanelSb.Append("- Fixtures: ").AppendLine(fixtureCount.ToString());
_debugPanelSb.Append("- Contacts: ").AppendLine(World.ContactList.Count.ToString());
_debugPanelSb.Append("- Joints: ").AppendLine(World.JointList.Count.ToString());
_debugPanelSb.Append("- Controllers: ").AppendLine(World.ControllerList.Count.ToString());
_debugPanelSb.Append("- Proxies: ").AppendLine(World.ProxyCount.ToString());
DrawString(x, y, _debugPanelSb.ToString());
#if XBOX
_debugPanelSb = new StringBuilder();
#else
_debugPanelSb.Clear();
#endif
_debugPanelSb.AppendLine("Update time:");
_debugPanelSb.Append("- Body: ").AppendLine(string.Format("{0} ms", World.SolveUpdateTime / TimeSpan.TicksPerMillisecond));
_debugPanelSb.Append("- Contact: ").AppendLine(string.Format("{0} ms", World.ContactsUpdateTime / TimeSpan.TicksPerMillisecond));
_debugPanelSb.Append("- CCD: ").AppendLine(string.Format("{0} ms", World.ContinuousPhysicsTime / TimeSpan.TicksPerMillisecond));
_debugPanelSb.Append("- Joint: ").AppendLine(string.Format("{0} ms", World.Island.JointUpdateTime / TimeSpan.TicksPerMillisecond));
_debugPanelSb.Append("- Controller: ").AppendLine(string.Format("{0} ms", World.ControllersUpdateTime / TimeSpan.TicksPerMillisecond));
_debugPanelSb.Append("- Total: ").AppendLine(string.Format("{0} ms", World.UpdateTime / TimeSpan.TicksPerMillisecond));
DrawString(x + 110, y, _debugPanelSb.ToString());
}
See More Examples