public override void Serialize( System.Text.StringBuilder text, int indentLevel) { var indent = new string('\t', indentLevel); var indent2 = new string('\t', indentLevel + 1); if (null != this.Name) { text.AppendFormat("{0}{1} /* {2} */ = {{", indent, this.GUID, this.Name); } else { text.AppendFormat("{0}{1} = {{", indent, this.GUID); } text.AppendLine(); text.AppendFormat("{0}isa = {1};", indent2, this.IsA); text.AppendLine(); if (null != this.Dependency) { text.AppendFormat("{0}target = {1} /* {2} */;", indent2, this.Dependency.GUID, this.Dependency.Name); text.AppendLine(); } text.AppendFormat("{0}targetProxy = {1} /* {2} */;", indent2, this.Proxy.GUID, this.Proxy.Name); text.AppendLine(); text.AppendFormat("{0}}};", indent); text.AppendLine(); }
private void appendLineToBuilder(System.Text.StringBuilder builder, string lineFormatter, AnalyziationSummarization summaryEntry) { AnalyziationSummaryEntry incomeSummaryEntry = summaryEntry.IncomeSummaryEntry; AnalyziationSummaryEntry expenseSummaryEntry = summaryEntry.ExpenseSummaryEntry; builder.AppendFormat(lineFormatter, new object[] { summaryEntry.Title, summaryEntry.TotalIncomeAmountInfo, summaryEntry.Spliter, summaryEntry.TotalExpenseAmountInfo }); if (summaryEntry.ShowCompareInfo) { builder.AppendFormat("{0}{1}\t\t\t({2}{3}/{4}{5})", new object[] { LocalizedStrings.GetLanguageInfoByKey("CompareTo"), LocalizedStrings.GetLanguageInfoByKey(summaryEntry.ScopeForSummary.ToString()), incomeSummaryEntry.ComparationInfo.BalanceMovingSymbol, incomeSummaryEntry.ComparationInfo.AmountInfo, expenseSummaryEntry.ComparationInfo.BalanceMovingSymbol, expenseSummaryEntry.ComparationInfo.AmountInfo }).AppendLine().AppendLine(); } }
public override void AppendReport(System.Text.StringBuilder builder) { if (count < 1) return; builder.AppendFormat("擴充背包 {0:#,0} 次\n", count); }
/// <summary> /// Adds extra properties to EditableRoot. /// </summary> /// <param name="code">The source code under generation.</param> /// <param name="process">Current process.</param> public override void AddEditClassProperties(System.Text.StringBuilder code, IProcessDefinition process) { base.AddEditClassProperties(code, process); code.AppendFormat( @" ICrossRefItemList IPerson.Roles {{ get {{ return Role; }} }} "); }
void gridView_OnBuildRow(int index, System.Data.DataRow rowData, bool isAlterRow, string rowTemplate, System.Text.StringBuilder buffer) { string sumAndPoint = Utilities.ToString(rowData[SysCompanyAdsPointSetting.Columns.AdsPoint]); buffer.AppendFormat(rowTemplate, rowData[SysCompanyAd.Columns.AdsID], rowData[SysCompanyAd.Columns.AdsPic], Formatter.SubStr(rowData[SysCompanyAd.Columns.AdsTitle], 30), Utilities.ToDecimal(CompanyAdsBLL.GetMaxOrderSumOrPoint(sumAndPoint, true)).ToString("0.###"), rowData[FIRST_AREA], rowData[SysCompanyAd.Columns.AdsClicked], AreaBLL.GetAreaTag(rowData[SysCompanyAd.Columns.AreaDepth])); }
/// <summary> /// Called when [add editable root additional members]. /// </summary> /// <param name="code">The code.</param> /// <param name="process">The process.</param> public override void OnAddEditableRootAdditionalMembers(System.Text.StringBuilder code, IProcessDefinition process) { base.OnAddEditableRootAdditionalMembers(code, process); var applicationRootUrl = Settings.ApplicationRootUrl; if (string.IsNullOrEmpty(applicationRootUrl) || !applicationRootUrl.EndsWith("/")) applicationRootUrl = applicationRootUrl + "/"; code.AppendFormat(@" public string AbsoluteURI {{ get {{ try {{ Uri result; if (Uri.TryCreate(CurrentURI, UriKind.Absolute, out result)) {{ return result.AbsoluteUri; }} if (Uri.TryCreate(CurrentURI, UriKind.Relative, out result)) {{ return result.AbsoluteUri; }} return new Uri(System.Windows.Browser.HtmlPage.Document.DocumentUri, CurrentURI).ToString(); }} catch {{ return ""http://"" + CurrentURI; }} }} }} public string EscapedURI {{ get {{ if(!string.IsNullOrEmpty(CurrentURI)) {{ return string.Format(""{0}PaperClipHandler.ashx?FileName={{0}}&Location={{1}}"", System.Windows.Browser.HttpUtility.UrlEncode(CurrentURI), Location); }} return string.Empty; }} }} ", applicationRootUrl); }
protected override void GeneratePostInitializationCode(string directiveName, System.Text.StringBuilder codeBuffer, System.CodeDom.Compiler.CodeDomProvider languageProvider, IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments) { if (IsDirectiveSupported(directiveName)) { string ruleName = requiresArguments["RuleName"]; if (String.IsNullOrEmpty(ruleName)) { throw new ArgumentNullException("ruleName"); } codeBuffer.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{{ System.Type ruleType = System.Type.GetType(\"{0}\");", ruleName); codeBuffer.AppendLine("if (ruleType != null) { this.Store.RuleManager.DisableRule(ruleType); } }"); } }
public override void Write(System.Text.StringBuilder sb) { ++IndentCount; Indent(sb); sb.AppendFormat("export interface {0}", TypeDefinition.ToTypeScriptItemName()); if (TypeDefinition.HasGenericParameters) { sb.Append("<"); TypeDefinition.GenericParameters.For((genericParam, i, isLastItem) => { sb.AppendFormat("{0}{1}", genericParam.ToTypeScriptType(), (isLastItem ? "" : ", ")); }); sb.Append(">"); } sb.AppendLine(" {"); IndentCount++; // 'ctor' is at index 0 // 'invoke' is at index 1 var invokeMethod = TypeDefinition.Methods[1]; if (invokeMethod.Parameters.Any()) { var target = invokeMethod.Parameters[0]; Indent(sb); sb.AppendFormatLine("target: {0};", target.ParameterType.ToTypeScriptType()); } else { Indent(sb); sb.AppendFormatLine("target: any;"); } Indent(sb); sb.AppendFormatLine("detail: any[];"); Indent(sb); sb.AppendLine("type: string;"); IndentCount--; Indent(sb); sb.AppendLine("}"); }
public void RecursiveCategory(List<My.Sale.Category> categories, ref System.Text.StringBuilder sb) { using (DataConnection Data = new DataConnection()) { sb.Append("<ul>"); foreach (var item in categories) { sb.AppendFormat("<li><a href='{0}'>{1}</a>", "#", item.CategoryName); var subCategories = Data.Get<My.Sale.Category>().Where(t => t.Parent == item.Id).ToList(); if (subCategories.Count > 0) { RecursiveCategory(subCategories, ref sb); } sb.Append("</li>"); } sb.Append("</ul>"); } }
/// <summary> /// This method is called after generation of all logic code in Editable Root AddBusinessRules method. /// </summary> /// <param name="code">Code holder.</param> /// <param name="process">Generating process definition.</param> public override void OnAfterEditableRootAddBusinessRules(System.Text.StringBuilder code, IProcessDefinition process) { base.OnAfterEditableRootAddBusinessRules(code, process); code.AppendFormat( @" BusinessRules.AddRule(new MustChangeAndDenyChange() {{ PrimaryProperty = MustChangeProperty, AffectedProperties = {{ CannotChangeProperty }} }}); BusinessRules.AddRule(new MustChangeAndDenyChange(true) {{ PrimaryProperty = CannotChangeProperty, AffectedProperties = {{ MustChangeProperty }} }}); BusinessRules.AddRule(new PasswordValidation(PasswordProperty, IdProperty, AuthenticationTypeProperty)); BusinessRules.AddRule(new Csla.Rules.CommonRules.Required(UserNameProperty)); BusinessRules.AddRule(new Csla.Rules.CommonRules.Required(PersonProperty)); BusinessRules.AddRule(new PersonUsedOnceCheck(PersonProperty, IdProperty)); #if SILVERLIGHT BusinessRules.AddRule(new Cebos.Veyron.SharedTypes.Rules.AccountPersonExists(PersonProperty, async (id) => {{ return (Cebos.Veyron.SharedTypes.IPerson)await Dynamic{0}.{0}Edit.Get{0}Async(new Cebos.Veyron.SharedTypes.DetailCriteria {{ Id = id }}); }})); #else BusinessRules.AddRule(new Cebos.Veyron.SharedTypes.Rules.AccountPersonExists(PersonProperty, (id) => {{ return Dynamic{0}.{0}Edit.Get{0}(id); }})); #endif BusinessRules.AddRule(new UsernameUsedOnceCheck(UserNameProperty, IdProperty)); BusinessRules.AddRule(new Csla.Rules.CommonRules.Dependency(AuthenticationTypeProperty, PasswordProperty, LDAPAccountProperty, LdapProfileIdProperty)); BusinessRules.AddRule(new CheckLdapSettingsWhenEnabled(LDAPAccountProperty, new Csla.Rules.CommonRules.Required(LDAPAccountProperty))); BusinessRules.AddRule(new CheckLdapSettingsWhenEnabled(LdapProfileIdProperty, new Csla.Rules.CommonRules.Required(LdapProfileIdProperty))); ", Constants.BasePersonProcessName); }
void AppendArgument(System.Text.StringBuilder sb, string name, Control ctl) { if (ctl is CheckBox) { var cb = ctl as CheckBox; if (cb.Checked) { sb.Append(" /" + name); } return; } if (ctl is TextBox) { var txt = ctl as TextBox; if (!string.IsNullOrEmpty(txt.Text)) { var list = txt.Text.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); list.ForEach(s => sb.AppendFormat(" /{0} \"{1}\"", name, txt.Text)); } return; } }
protected void OutputArgs(System.Text.StringBuilder sb, System.Reflection.MemberInfo mi, System.Boolean isTupled) { System.Reflection.MethodInfo m = (System.Reflection.MethodInfo)mi; Int32 i = 0; System.Reflection.ParameterInfo[] ps = m.GetParameters(); if (isTupled && ps.Length != 1) sb.Append("("); for (i=0; i < ps.Length; i++) { sb.AppendFormat("arg{0}",i); if (isTupled && (i+1) < ps.Length) { sb.Append(","); } else { if (!isTupled) sb.Append(" "); } } if (isTupled && ps.Length != 1) sb.Append(")"); }
void gridView_OnBuildRow(int index, System.Data.DataRow rowData, bool isAlterRow, string rowTemplate, System.Text.StringBuilder buffer) { CompanyType companyType = Formatter.ToEnum<CompanyType>(rowData[SysCompany.Columns.CompanyType]); int count = Utilities.ToInt(rowData[SysCompanyItem.ItemAmountColumn.ColumnName]) - Utilities.ToInt(rowData[SysCompanyItem.ItemClickedColumn.ColumnName]); buffer.AppendFormat(rowTemplate, rowData[SysCompanyItem.Columns.ItemPic], rowData[FIRST_AREA], Formatter.SubStr(rowData[SysCompanyItem.Columns.ItemTitle], 30), Utilities.ToDecimal(rowData[SysCompanyItem.Columns.ItemSum]).ToString("#######.###"), Utilities.ToDecimal(rowData[SysCompanyItem.Columns.ItemPoint]).ToString("#######.###"), rowData[SysCompanyItem.Columns.ItemID], rowData[SysCompanyItem.Columns.ItemClicked], count, AreaBLL.GetAreaTag(rowData[SysCompanyItem.Columns.AreaDepth]), GetClassName(companyType), GetItemType(companyType)); }
protected void OutputMember(System.Text.StringBuilder sb, System.Reflection.MemberInfo mi) { switch (mi.MemberType) { case System.Reflection.MemberTypes.Method: System.String methName = ToHaskellName(mi.Name); System.Reflection.MethodInfo m = (System.Reflection.MethodInfo)mi; sb.Append("foreign import dotnet"); sb.Append(System.Environment.NewLine); // the 'method' bit is really optional. sb.AppendFormat(" \"{0}method {1}.{2}\"", (m.IsStatic ? "static " : ""), mi.DeclaringType, mi.Name); sb.Append(System.Environment.NewLine); sb.AppendFormat(" {0} :: ", methName); OutputMethodSig(sb,mi); // the mind boggles, System.Environment ? sb.Append(System.Environment.NewLine); /* old habit ;) */ break; case System.Reflection.MemberTypes.Constructor: OutputCtor(sb,(System.Reflection.ConstructorInfo)mi); break; case System.Reflection.MemberTypes.Field: System.String fieldName = mi.Name; System.Reflection.FieldInfo f = (System.Reflection.FieldInfo)mi; System.String staticPrefix = (f.IsStatic ? "static " : ""); sb.Append("foreign import dotnet"); sb.Append(System.Environment.NewLine); sb.AppendFormat(" \"{0}field {1}.{2}\"", staticPrefix, mi.DeclaringType, mi.Name); sb.Append(System.Environment.NewLine); sb.AppendFormat(" get_{0} :: ", fieldName); OutputFieldSig(sb,f,false); sb.Append(System.Environment.NewLine); if (!f.IsInitOnly) { sb.Append("foreign import dotnet"); sb.Append(System.Environment.NewLine); sb.AppendFormat(" \"{0}field {1}.{2}\"", staticPrefix, mi.DeclaringType, mi.Name); sb.Append(System.Environment.NewLine); sb.AppendFormat(" set_{0} :: ", fieldName); OutputFieldSig(sb,f,true); sb.Append(System.Environment.NewLine); } break; default: break; } }
protected void OutputMethodSig(System.Text.StringBuilder sb, System.Reflection.MemberInfo mi) { System.Reflection.MethodInfo m = (System.Reflection.MethodInfo)mi; System.Reflection.ParameterInfo[] ps = m.GetParameters(); int i; for (i=0; i < ps.Length; i++) { OutputHaskellType(sb,ps[i].ParameterType,i); sb.Append(" -> "); } if (m.IsStatic) { sb.Append("IO ("); } else { sb.AppendFormat("{0} obj -> IO (", mi.DeclaringType.Name); } OutputHaskellType(sb,m.ReturnType,i); sb.AppendFormat("){0}",System.Environment.NewLine); }
protected void OutputFieldSig(System.Text.StringBuilder sb, System.Reflection.FieldInfo fi, bool isSetter) { /* Note: indexed values are provided via properties */ if (isSetter) { OutputHaskellType(sb,fi.FieldType,0); if (!fi.IsStatic) { sb.AppendFormat(" -> {0} obj", fi.DeclaringType.Name); } sb.AppendFormat(" -> IO (){0}",System.Environment.NewLine); } else { if (fi.IsStatic) { sb.Append("IO ("); } else { sb.AppendFormat("{0} obj -> IO (", fi.DeclaringType.Name); } OutputHaskellType(sb,fi.FieldType,0); sb.AppendFormat("){0}",System.Environment.NewLine); } }
protected void OutputHaskellType(System.Text.StringBuilder sb, System.Type ty, System.Int32 idx) { /* Curiously, &-versions of prim types are showing up (cf. System.Uri.HexUnescape). * Just ignore them. */ if (ty.FullName == "System.Boolean" || ty.FullName == "System.Boolean&" ) { sb.Append("Bool"); return; } if (ty.FullName == "System.String") { sb.Append("String"); return; } if (ty.FullName == "System.Char" || ty.FullName == "System.Char&") { sb.Append("Char"); return; } if (ty.FullName == "System.Double" || ty.FullName == "System.Double&") { sb.Append("Double"); return; } if (ty.FullName == "System.Single" || ty.FullName == "System.Single&") { sb.Append("Double"); return; } if (ty.FullName == "System.SByte" || ty.FullName == "System.SByte&") { AddImport("Data.Int"); sb.Append("Data.Int.Int8"); return; } if (ty.FullName == "System.Int16" || ty.FullName == "System.Int16&") { AddImport("Data.Int"); sb.Append("Data.Int.Int16"); return; } if (ty.FullName == "System.Int32" || ty.FullName == "System.Int32&") { sb.Append("Int"); return; } if (ty.FullName == "System.Int64" || ty.FullName == "System.Int64&") { AddImport("Data.Int"); sb.Append("Data.Int.Int64"); return; } if (ty.FullName == "System.Byte" || ty.FullName == "System.Byte&") { AddImport("Data.Word"); sb.Append("Data.Word.Word8"); return; } if (ty.FullName == "System.UInt16" || ty.FullName == "System.UInt16&") { AddImport("Data.Word"); sb.Append("Data.Word.Word16"); return; } if (ty.FullName == "System.UInt32" || ty.FullName == "System.UInt32&") { AddImport("Data.Word"); sb.Append("Data.Word.Word32"); return; } if (ty.FullName == "System.UInt64" || ty.FullName == "System.UInt64&") { AddImport("Data.Word"); sb.Append("Data.Word.Word64"); return; } if (ty.FullName == "System.Void") { sb.Append("()"); return; } if (ty.FullName == "System.Object") { AddImport("Dotnet.System.Object"); sb.AppendFormat("Dotnet.System.Object.Object a{0}",idx); return; } if (ty.IsArray) { AddImport("Dotnet.System.Array"); sb.Append("Dotnet.System.Array.Array ("); OutputHaskellType(sb, ty.GetElementType(), idx); sb.Append(")"); } else { AddImport("Dotnet." + ty.FullName); sb.AppendFormat("Dotnet.{0}.{1} a{2}", ty.FullName, ty.Name, idx); } }
public override void Print( System.Text.StringBuilder str ) { PrintPre( str ); str.AppendFormat( ",#{0}{1}", m_up ? "" : "-", m_offset ); PrintPost( str ); if(m_Rn == 15) { int address = (int)(m_address_PC + 8); if(m_preIndex) { address += (m_up ? +(int)m_offset : -(int)m_offset); } m_address_Target = (uint)address; } }
protected void OutputCtorSig(System.Text.StringBuilder sb, System.Reflection.ConstructorInfo ci) { System.Reflection.ParameterInfo[] ps = ci.GetParameters(); int i; for (i=0; i < ps.Length; i++) { OutputHaskellType(sb,ps[i].ParameterType,i); sb.Append(" -> "); } sb.AppendFormat("IO ({0} ())", ci.DeclaringType.Name); sb.Append(System.Environment.NewLine); }
void DumpTypeString(TypeDefinitionString tds, int level, System.Text.StringBuilder sb) { sb.AppendFormat("{0," + (level * 3 + tds.type.Length) + "} {1} flags=({2}, {3}, {4}, {5}, x{6:X})\r\n", tds.type, tds.identifier, tds.flags[0], tds.flags[1], tds.flags[2], tds.flags[3], tds.flags[4]); for (int i = 0; i < tds.children.Length; i++) { DumpTypeString(tds.children[i], level + 1, sb); } }
WriteVariables( System.Text.StringBuilder variables) { foreach (var target in this.Targets) { var name = target.VariableName; if (null == name) { continue; } if (target.IsPhony) { variables.AppendFormat(".PHONY: {0}", name); variables.AppendLine(); } // simply expanded variable variables.AppendFormat("{0}:={1}", name, target.Path.Parse()); variables.AppendLine(); } }
public override void Serialize( System.Text.StringBuilder text, int indentLevel) { var indent = new string('\t', indentLevel); var indent2 = new string('\t', indentLevel + 1); var indent3 = new string('\t', indentLevel + 2); if (null != this.Name) { text.AppendFormat("{0}{1} /* {2} */ = {{", indent, this.GUID, this.Name); } else { text.AppendFormat("{0}{1} = {{", indent, this.GUID); } text.AppendLine(); text.AppendFormat("{0}isa = {1};", indent2, this.IsA); text.AppendLine(); if (this.Children.Count > 0) { text.AppendFormat("{0}children = (", indent2); text.AppendLine(); foreach (var child in this.Children.OrderBy(item => item.Name)) { text.AppendFormat("{0}{1} /* {2} */,", indent3, child.GUID, child.Name); text.AppendLine(); } text.AppendFormat("{0});", indent2); text.AppendLine(); } if (null != this.Name) { text.AppendFormat("{0}name = \"{1}\";", indent2, this.Name); text.AppendLine(); } text.AppendFormat("{0}sourceTree = \"{1}\";", indent2, this.SourceTree); text.AppendLine(); text.AppendFormat("{0}}};", indent); text.AppendLine(); }
protected void PrintPre( System.Text.StringBuilder str ) { PrintMnemonic( str, "{0}{1}{2}", m_load ? "LDR" : "STR", DumpCondition(), m_isByte ? "B" : "" ); str.AppendFormat( "{0},[{1}", DumpRegister( m_Rd ), DumpRegister( m_Rn ) ); if(m_preIndex == false) str.Append( "]" ); }
internal override void AppendToBuffer (System.Text.StringBuilder buffer) { buffer.AppendFormat("{0}->{1} ", this.Key, this.Value); }
/// <summary>Flattens the syntax tree into a representation of the source regex.</summary> /// <param name="sb">Buffer for the output string.</param> /// <param name="parent">The tree, if any, containing this syntax tree.</param> public override void Write(System.Text.StringBuilder sb, RegexAST parent) { if (parent is NotTestAST) { if (IsExtended) sb.AppendFormat("\\P{{scx={0}}}", Script.Abbreviation()); else sb.AppendFormat("\\P{{sc={0}}}", Script.Abbreviation()); } else { if (IsExtended) sb.AppendFormat("\\p{{scx={0}}}", Script.Abbreviation()); else sb.AppendFormat("\\p{{sc={0}}}", Script.Abbreviation()); } }
protected void OutputCtor(System.Text.StringBuilder sb, System.Reflection.ConstructorInfo ci) { System.String ctorName = ToHaskellName("new"+ci.DeclaringType.Name); sb.Append("foreign import dotnet"); sb.Append(System.Environment.NewLine); sb.AppendFormat(" \"ctor {0}\"", ci.DeclaringType); sb.AppendFormat("{0}",System.Environment.NewLine); sb.AppendFormat(" {0} :: ", ctorName); OutputCtorSig(sb,ci); sb.Append(System.Environment.NewLine); }
private void DoToString(System.Text.StringBuilder builder, string format, int depth) { switch (format) { case "": case null: case "g": case "G": builder.AppendFormat("{0} {1} {2}", AttributedType.ToString(), AttributedName.ToString(), AttributedValue.ToString()); break; case "f": case "F": builder.Append(' ', 3*depth); builder.AppendFormat("{0} {1} {2} (key = {3})", AttributedType.ToString(), AttributedName.ToString(), AttributedValue.ToString(), Key); if (Parent != null) { builder.AppendLine(); Parent.DoToString(builder, format, depth + 1); } break; default: builder.Append(base.ToString(format, null)); break; } }
public override void Serialize( System.Text.StringBuilder text, int indentLevel) { if (this.BuildFiles.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXBuildFile section */"); text.AppendLine(); foreach (var buildFile in this.BuildFiles.OrderBy(key => key.GUID)) { buildFile.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXBuildFile section */"); text.AppendLine(); } if (this.ContainerItemProxies.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXContainerItemProxy section */"); text.AppendLine(); foreach (var proxy in this.ContainerItemProxies.OrderBy(key => key.GUID)) { proxy.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXContainerItemProxy section */"); text.AppendLine(); } if (this.CopyFilesBuildPhases.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXCopyFilesBuildPhase section */"); text.AppendLine(); foreach (var phase in this.CopyFilesBuildPhases.OrderBy(key => key.GUID)) { phase.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXCopyFilesBuildPhase section */"); text.AppendLine(); } if (this.FileReferences.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXFileReference section */"); text.AppendLine(); foreach (var fileRef in this.FileReferences.OrderBy(key => key.GUID)) { fileRef.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXFileReference section */"); text.AppendLine(); } if (this.FrameworksBuildPhases.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXFrameworksBuildPhase section */"); text.AppendLine(); foreach (var phase in this.FrameworksBuildPhases.OrderBy(key => key.GUID)) { phase.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXFrameworksBuildPhase section */"); text.AppendLine(); } if (this.Groups.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXGroup section */"); text.AppendLine(); foreach (var group in this.Groups.OrderBy(key => key.GUID)) { group.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXGroup section */"); text.AppendLine(); } if (this.ReferenceProxies.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXReferenceProxy section */"); text.AppendLine(); foreach (var proxy in this.ReferenceProxies.OrderBy(key => key.GUID)) { proxy.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXReferenceProxy section */"); text.AppendLine(); } if (this.Targets.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXNativeTarget section */"); text.AppendLine(); foreach (var target in this.Targets.Values.OrderBy(key => key.GUID)) { target.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXNativeTarget section */"); text.AppendLine(); } this.InternalSerialize(text, indentLevel); //this is the PBXProject :) if (this.ShellScriptsBuildPhases.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXShellScriptBuildPhase section */"); text.AppendLine(); foreach (var phase in this.ShellScriptsBuildPhases.OrderBy(key => key.GUID)) { phase.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXShellScriptBuildPhase section */"); text.AppendLine(); } if (this.SourcesBuildPhases.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXSourcesBuildPhase section */"); text.AppendLine(); foreach (var phase in this.SourcesBuildPhases.OrderBy(key => key.GUID)) { phase.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXSourcesBuildPhase section */"); text.AppendLine(); } if (this.TargetDependencies.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin PBXTargetDependency section */"); text.AppendLine(); foreach (var dependency in this.TargetDependencies.OrderBy(key => key.GUID)) { dependency.Serialize(text, indentLevel); } text.AppendFormat("/* End PBXTargetDependency section */"); text.AppendLine(); } if (this.AllConfigurations.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin XCBuildConfiguration section */"); text.AppendLine(); foreach (var config in this.AllConfigurations.OrderBy(key => key.GUID)) { config.Serialize(text, indentLevel); } text.AppendFormat("/* End XCBuildConfiguration section */"); text.AppendLine(); } if (this.ConfigurationLists.Count > 0) { text.AppendLine(); text.AppendFormat("/* Begin XCConfigurationList section */"); text.AppendLine(); foreach (var configList in this.ConfigurationLists.OrderBy(key => key.GUID)) { configList.Serialize(text, indentLevel); } text.AppendFormat("/* End XCConfigurationList section */"); text.AppendLine(); } }
WriteRules( System.Text.StringBuilder rules) { foreach (var target in this.Targets) { var name = target.VariableName; if (null != name) { rules.AppendFormat("$({0}):", name); } else { if (target.IsPhony) { rules.AppendFormat(".PHONY: {0}", target.Path); rules.AppendLine(); } rules.AppendFormat("{0}:", target.Path); } foreach (var pre in this.Prequisities) { rules.AppendFormat("{0} ", pre.Key.GeneratedPaths[pre.Value]); } foreach (var pre in this.PrerequisitePaths) { rules.AppendFormat("{0} ", pre.ParseAndQuoteIfNecessary()); } foreach (var pre in this.PrerequisiteTargets) { var preName = pre.VariableName; if (null == preName) { rules.AppendFormat("{0} ", pre.Path.Parse()); } else { rules.AppendFormat("$({0}) ", preName); } } if (this.OrderOnlyDependencies.Count > 0) { rules.AppendFormat("| {0}", this.OrderOnlyDependencies.ToString(' ')); } rules.AppendLine(); foreach (var command in this.ShellCommands) { // look for text like $ORIGIN, which needs a double $ prefix (and quotes) to avoid being interpreted as an environment variable by Make var escapedCommand = System.Text.RegularExpressions.Regex.Replace(command, @"\$([A-Za-z0-9]+)", @"'$$$$$1'"); // any parentheses that are not associated with MakeFile commands must be escaped if (!System.Text.RegularExpressions.Regex.IsMatch(escapedCommand, @"\$\(.*\)")) { EscapeCharacter(ref escapedCommand, '('); EscapeCharacter(ref escapedCommand, ')'); } rules.AppendFormat("\t{0}", escapedCommand); rules.AppendLine(); } } }
private void InternalSerialize( System.Text.StringBuilder text, int indentLevel) { var indent = new string('\t', indentLevel); var indent2 = new string('\t', indentLevel + 1); var indent3 = new string('\t', indentLevel + 2); var indent4 = new string('\t', indentLevel + 3); text.AppendLine(); text.AppendFormat("/* Begin PBXProject section */"); text.AppendLine(); text.AppendFormat("{0}{1} /* Project object */ = {{", indent, this.GUID); text.AppendLine(); text.AppendFormat("{0}isa = {1};", indent2, this.IsA); text.AppendLine(); text.AppendFormat("{0}attributes = {{", indent2); text.AppendLine(); var clangMeta = Bam.Core.Graph.Instance.PackageMetaData<Clang.MetaData>("Clang"); text.AppendFormat("{0}LastUpgradeCheck = {1};", indent3, clangMeta.LastUpgradeCheck); text.AppendLine(); text.AppendFormat("{0}}};", indent2); text.AppendLine(); // project configuration list is always the first var projectConfigurationList = this.ConfigurationLists[0]; text.AppendFormat("{0}buildConfigurationList = {1} /* Build configuration list for {2} \"{3}\" */;", indent2, projectConfigurationList.GUID, projectConfigurationList.Parent.IsA, projectConfigurationList.Parent.Name); text.AppendLine(); text.AppendFormat("{0}compatibilityVersion = \"{1}\";", indent2, "Xcode 3.2"); // TODO text.AppendLine(); text.AppendFormat("{0}mainGroup = {1};", indent2, this.MainGroup.GUID); text.AppendLine(); text.AppendFormat("{0}productRefGroup = {1} /* {2} */;", indent2, this.ProductRefGroup.GUID, this.ProductRefGroup.Name); text.AppendLine(); text.AppendFormat("{0}projectDirPath = \"\";", indent2); text.AppendLine(); if (this.ProjectReferences.Count > 0) { text.AppendFormat("{0}projectReferences = (", indent2); text.AppendLine(); foreach (var projectRef in this.ProjectReferences) { text.AppendFormat("{0}{", indent3); text.AppendLine(); text.AppendFormat("{0}ProductGroup = {1} /* {2} */;", indent4, projectRef.Key.GUID, projectRef.Key.Name); text.AppendLine(); text.AppendFormat("{0}ProjectRef = {1} /* {2} */;", indent4, projectRef.Value.GUID, projectRef.Value.Name); text.AppendLine(); text.AppendFormat("{0}},", indent3); text.AppendLine(); } text.AppendFormat("{0});", indent2); text.AppendLine(); } text.AppendFormat("{0}targets = (", indent2); text.AppendLine(); foreach (var target in this.Targets.Values) { text.AppendFormat("{0}{1} /* {2} */,", indent3, target.GUID, target.Name); text.AppendLine(); } text.AppendFormat("{0});", indent2); text.AppendLine(); text.AppendFormat("{0}}};", indent); text.AppendLine(); text.AppendFormat("/* End PBXProject section */"); text.AppendLine(); }