private void WriteCSharpImplementationEffective(ICSharpWriter writer, ICSharpEffectiveBody effectiveBody, bool isOverride, string nameString, CSharpExports exportStatus, bool isConstructor, ref bool isFirstFeature, ref bool isMultiline) { CSharpArgument.BuildParameterList(writer, ParameterList, out string ParameterEntityList, out string ParameterNameList); CSharpAssertion.WriteContract(writer, effectiveBody.RequireList, effectiveBody.EnsureList, CSharpContractLocations.Other, true, ref isFirstFeature, ref isMultiline); bool SkipFirstInstruction = false; if (isConstructor) { WriteCSharpImplementationConstructor(writer, isOverride, nameString, exportStatus, ref isFirstFeature, ref isMultiline, ref SkipFirstInstruction); } else { string ExportStatusText = CSharpNames.ComposedExportStatus(isOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} void {nameString}({ParameterEntityList})"); } ICSharpEffectiveBody AsEffectiveBody = Body as ICSharpEffectiveBody; AsEffectiveBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets, string.Empty, SkipFirstInstruction, new List <string>()); isMultiline = true; }
private void WriteCSharpImplementationConstructor(ICSharpWriter writer, bool isOverride, string nameString, CSharpExports exportStatus, ref bool isFirstFeature, ref bool isMultiline, ref bool skipFirstInstruction) { CSharpArgument.BuildParameterList(writer, ParameterList, out string ParameterEntityList, out string ParameterNameList); string ExportStatusText = CSharpNames.ComposedExportStatus(isOverride, false, true, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {nameString}({ParameterEntityList})"); ICSharpEffectiveBody AsEffectiveBody = Body as ICSharpEffectiveBody; ICSharpClass Owner = ParentFeature.Owner; if (Owner.BaseClass != null) { ICSharpClass ParentClass = Owner.BaseClass; if (ParentClass.ClassConstructorType == CSharpConstructorTypes.OneConstructor) { if (AsEffectiveBody.BodyInstructionList.Count > 0) { /*TODO * ICommandInstruction AsCommandInstruction; * if ((AsCommandInstruction = AsEffectiveBody.BodyInstructionList[0] as ICommandInstruction) != null) * { * if (AsCommandInstruction.SelectedFeature.IsAssigned) * { * ICreationFeature AsCreationFeature; * if ((AsCreationFeature = AsCommandInstruction.SelectedFeature.Item as ICreationFeature) != null) * { * ICommandOverloadType SelectedOverload = AsCommandInstruction.SelectedOverload.Item; * ISealableList<Parameter> SelectedParameterList = SelectedOverload.ParameterTable; * string ArgumentListString = CSharpRootOutput.CSharpArgumentList(Context, SelectedParameterList, AsCommandInstruction.ArgumentList, new List<IQualifiedName>()); * * SkipFirstInstruction = true; * CSharpRootOutput.IncreaseIndent(); * writer.WriteIndentedLine(":" + " " + "base" + "(" + ArgumentListString + ")"); * CSharpRootOutput.DecreaseIndent(); * } * } * } */ } } } }
private void WriteCSharpForcedReadWriteProperty(ICSharpWriter writer, bool isOverride, CSharpExports exportStatus, string propertyName, string resultType, ref bool isFirstFeature, ref bool isMultiline) { bool IsDeferred = false; bool IsPrecursor = false; isFirstFeature = false; if (GetterBody != null) { if (GetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (GetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (SetterBody != null) { if (SetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (SetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (GetterBody != null || SetterBody != null) { if (IsDeferred) { bool IsGetterMultiline = isMultiline; bool IsSetterMultiline = isMultiline; if (GetterBody != null) { ICSharpDeferredBody DeferredGetterBody = GetterBody as ICSharpDeferredBody; Debug.Assert(DeferredGetterBody != null); CSharpAssertion.WriteContract(writer, DeferredGetterBody.RequireList, DeferredGetterBody.EnsureList, CSharpContractLocations.Getter, false, ref isFirstFeature, ref IsGetterMultiline); IsSetterMultiline = false; } if (SetterBody != null) { ICSharpDeferredBody DeferredSetterBody = SetterBody as ICSharpDeferredBody; Debug.Assert(DeferredSetterBody != null); CSharpAssertion.WriteContract(writer, DeferredSetterBody.RequireList, DeferredSetterBody.EnsureList, CSharpContractLocations.Setter, false, ref isFirstFeature, ref IsSetterMultiline); } string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ get; set; }}"); isMultiline = IsGetterMultiline || IsSetterMultiline; } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); if (IsPrecursor) { if (Source.PropertyKind != BaseNode.UtilityType.WriteOnly) { writer.WriteIndentedLine($"get {{ return base.{propertyName}; }}"); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (Source.PropertyKind != BaseNode.UtilityType.ReadOnly) { writer.WriteIndentedLine($"set {{ base.{propertyName} = value; }}"); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } } else { if (GetterBody != null) { ICSharpEffectiveBody EffectiveGetterBody = GetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveGetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveGetterBody.RequireList, EffectiveGetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("get"); EffectiveGetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasResult, resultType, false, new List <string>()); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (SetterBody != null) { ICSharpEffectiveBody EffectiveSetterBody = SetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveSetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveSetterBody.RequireList, EffectiveSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); EffectiveSetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasValue, string.Empty, false, new List <string>()); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } } writer.DecreaseIndent(); writer.WriteIndentedLine("}"); isMultiline = true; } } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); if (Source.PropertyKind != BaseNode.UtilityType.WriteOnly) { writer.WriteIndentedLine($"get {{ return _{propertyName}; }}"); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (Source.PropertyKind != BaseNode.UtilityType.ReadOnly) { writer.WriteIndentedLine($"set {{ _{propertyName} = value; }}"); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } writer.DecreaseIndent(); writer.WriteIndentedLine("}"); isMultiline = true; } }
private void WriteCSharpWriteOnlyProperty(ICSharpWriter writer, bool isOverride, CSharpExports exportStatus, string propertyName, string resultType, ref bool isFirstFeature, ref bool isMultiline) { bool IsDeferred = false; bool IsPrecursor = false; isFirstFeature = false; if (SetterBody != null) { if (SetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (SetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (SetterBody != null) { if (IsDeferred) { ICSharpDeferredBody DeferredSetterBody = SetterBody as ICSharpDeferredBody; Debug.Assert(DeferredSetterBody != null); CSharpAssertion.WriteContract(writer, DeferredSetterBody.RequireList, DeferredSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ protected get; set; }}"); isMultiline = false; } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); if (IsPrecursor) { writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"set {{ base.{propertyName} = value; }}"); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else { writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"protected get {{ return _{propertyName}; }}"); ICSharpEffectiveBody EffectiveSetterBody = SetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveSetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveSetterBody.RequireList, EffectiveSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); EffectiveSetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasValue, string.Empty, false, new List <string>()); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } isMultiline = true; } } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ protected get; set; }}"); isMultiline = false; } }