/// <summary> /// Sets the <see cref="ICSharpOutputNode.WriteDown"/> flag. /// </summary> public override void SetWriteDown() { if (WriteDown) { return; } WriteDown = true; if (GetterBody is ICSharpEffectiveBody AsEffectiveGetterBody) { AsEffectiveGetterBody.SetWriteDown(); } if (SetterBody is ICSharpEffectiveBody AsEffectiveSetterBody) { AsEffectiveSetterBody.SetWriteDown(); } Owner.SetWriteDown(); }
private void WriteCSharpImplementation(ICSharpWriter writer, CSharpExports exportStatus, bool isLocal, ref bool isFirstFeature, ref bool isMultiline) { writer.WriteDocumentation(Source); string ResultType = EntityType.Type2CSharpString(writer, CSharpTypeFormats.AsInterface, CSharpNamespaceFormats.None); CSharpArgument.BuildParameterList(writer, IndexParameterList, out string ParameterEntityList, out string ParameterNameList); string Accessors; if (!IsForcedReadWrite && SetterBody == null) { Accessors = "{ get; }"; } else if (!IsForcedReadWrite && GetterBody == null) { Accessors = "{ set; }"; } else { Accessors = "{ get; set; }"; } bool IsDeferred = false; if (GetterBody != null) { if (GetterBody is ICSharpDeferredBody) { IsDeferred = true; } else { IsDeferred = false; } } else if (SetterBody != null) { if (SetterBody is ICSharpDeferredBody) { IsDeferred = true; } else { IsDeferred = false; } } if (IsDeferred) { if (GetterBody is ICSharpDeferredBody AsDeferredGetterBody) { CSharpAssertion.WriteContract(writer, AsDeferredGetterBody.RequireList, AsDeferredGetterBody.EnsureList, CSharpContractLocations.Getter, false, ref isFirstFeature, ref isMultiline); isMultiline = false; } if (SetterBody is ICSharpDeferredBody AsDeferredSetterBody) { CSharpAssertion.WriteContract(writer, AsDeferredSetterBody.RequireList, AsDeferredSetterBody.EnsureList, CSharpContractLocations.Setter, false, ref isFirstFeature, ref isMultiline); } string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {ResultType} this[{ParameterEntityList}] {Accessors}"); isMultiline = false; } else { string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {ResultType} this[{ParameterEntityList}]"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); bool IsPrecursor = false; if (GetterBody != null) { if (GetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } else { IsPrecursor = false; } } else if (SetterBody != null) { if (GetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } else { IsPrecursor = false; } } if (IsPrecursor) { if (GetterBody is ICSharpPrecursorBody AsPrecursorGetterBody) { isMultiline = false; CSharpAssertion.WriteContract(writer, AsPrecursorGetterBody.RequireList, AsPrecursorGetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("get"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"return base[{ParameterEntityList}];"); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else if (IsForcedReadWrite) { writer.WriteIndentedLine("get { throw new InvalidOperationException(); }"); } if (SetterBody is ICSharpPrecursorBody AsPrecursorSetterBody) { isMultiline = false; CSharpAssertion.WriteContract(writer, AsPrecursorSetterBody.RequireList, AsPrecursorSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"base[{ParameterEntityList}] = value;"); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else if (IsForcedReadWrite) { writer.WriteIndentedLine("set { throw new InvalidOperationException(); }"); } } else { if (GetterBody != null) { if (GetterBody is ICSharpEffectiveBody AsEffectiveGetterBody) { isMultiline = false; CSharpAssertion.WriteContract(writer, AsEffectiveGetterBody.RequireList, AsEffectiveGetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("get"); AsEffectiveGetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasResult, ResultType, false, new List <string>()); } } else if (IsForcedReadWrite) { writer.WriteIndentedLine("get { throw new InvalidOperationException(); }"); } if (SetterBody != null) { if (SetterBody is ICSharpEffectiveBody AsEffectiveSetterBody) { isMultiline = false; CSharpAssertion.WriteContract(writer, AsEffectiveSetterBody.RequireList, AsEffectiveSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); AsEffectiveSetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasValue, string.Empty, false, new List <string>()); } } else if (IsForcedReadWrite) { writer.WriteIndentedLine("set { throw new InvalidOperationException(); }"); } } writer.DecreaseIndent(); writer.WriteIndentedLine("}"); isMultiline = true; } }