public override void WriteMember(CsCodeWriter code) { CodeItem prop = new CodeItem(PropertyName) { Access = _generator.FieldAccess, //ClsCompliant = _generator.IsClsCompliant, Obsolete = _generator.Obsolete, XmlName = _generator.Name, }; using (code.DeclareProperty(prop, GetPublicType(code))) { using (code.WriteBlock(IsWriteOnly && FieldAccess != FieldAccess.Private ? "private get" : "get")) { if (IsReadOnly) code.WriteLine("if (!IsReadOnly()) return new {0}System.Collections.ObjectModel.ReadOnlyCollection<{1}>({2});", CsCodeWriter.Global, _generator.GetPublicType(code), FieldBackingName); code.WriteLine("return {0};", FieldBackingName); } using (code.WriteBlock(IsReadOnly && FieldAccess != FieldAccess.Private ? "private set" : "set")) { code.WriteLine("if (IsReadOnly()) throw new {0}System.InvalidOperationException();", CsCodeWriter.Global); code.WriteLine("{0} = new {1}(value, false);", FieldBackingName, GetStorageType(code)); } } }