Mono.CSharp.CSharpCodeGenerator.GenerateProperty C# (CSharp) Method

GenerateProperty() protected method

protected GenerateProperty ( CodeMemberProperty property, CodeTypeDeclaration declaration ) : void
property CodeMemberProperty
declaration CodeTypeDeclaration
return void
		protected override void GenerateProperty (CodeMemberProperty property,
							  CodeTypeDeclaration declaration)
		{
			if (IsCurrentDelegate || IsCurrentEnum) {
				return;
			}

			TextWriter output = Output;

			OutputAttributes (property.CustomAttributes, null, false);

			MemberAttributes attributes = property.Attributes;

			if (!IsCurrentInterface) {
				if (property.PrivateImplementationType == null) {
					OutputMemberAccessModifier (attributes);
					OutputVTableModifier (attributes);
					OutputMemberScopeModifier (attributes);
				}
			} else {
				OutputVTableModifier (attributes);
			}

			OutputType (property.Type);
			output.Write (' ');

			if (!IsCurrentInterface && property.PrivateImplementationType != null) {
				output.Write (property.PrivateImplementationType.BaseType);
				output.Write ('.');
			}

			// only consider property indexer if name is Item (case-insensitive 
			// comparison) AND property has parameters
			if (string.Compare(property.Name, "Item", true, CultureInfo.InvariantCulture) == 0 && property.Parameters.Count > 0) {
				output.Write ("this[");
				OutputParameters(property.Parameters);
				output.Write(']');
			} else {
				output.Write (GetSafeName (property.Name));
			}
			OutputStartBrace ();
			++Indent;

			if (declaration.IsInterface || IsAbstract (property.Attributes))
			{
				if (property.HasGet) output.WriteLine("get;");
				if (property.HasSet) output.WriteLine("set;");
			}
			else
			{
				if (property.HasGet)
				{
					output.Write ("get");
					OutputStartBrace ();
					++Indent;

					GenerateStatements (property.GetStatements);

					--Indent;
					output.WriteLine ('}');
				}

				if (property.HasSet)
				{
					output.Write ("set");
					OutputStartBrace ();
					++Indent;

					GenerateStatements (property.SetStatements);

					--Indent;
					output.WriteLine ('}');
				}
			}

			--Indent;
			output.WriteLine ('}');
		}
CSharpCodeGenerator