2
// CodebehindTemplateBase.cs
5
// Michael Hutchinson <m.j.hutchinson@gmail.com>
7
// Copyright (c) 2011 Michael Hutchinson
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.Collections.Generic;
30
namespace MonoDevelop.MacDev.ObjCIntegration
32
public abstract class CodebehindTemplateBase
34
StringBuilder builder;
35
ToStringHelperClass toStringHelper = new ToStringHelperClass ();
37
public StringBuilder GenerationEnvironment {
38
get { return builder ?? (builder = new StringBuilder ()); }
39
set { builder = value; }
42
public void Write (string textToAppend)
44
this.GenerationEnvironment.Append (textToAppend);
47
public void Write (string format, params object[] args)
49
this.GenerationEnvironment.AppendFormat (format, args);
52
public void WriteLine (string textToAppend)
54
this.GenerationEnvironment.AppendLine (textToAppend);
57
public void WriteLine (string format, params object[] args)
59
this.GenerationEnvironment.AppendFormat (format, args);
60
this.GenerationEnvironment.AppendLine ();
63
protected ToStringHelperClass ToStringHelper {
65
return toStringHelper;
69
protected class ToStringHelperClass
71
public string ToStringWithCulture (object objectToConvert)
73
return (string) objectToConvert;
77
protected virtual void Initialize ()
81
public abstract string TransformText ();
83
public string WrapperNamespace { get; set; }
84
public System.CodeDom.Compiler.CodeDomProvider Provider { get; set; }
85
public List<NSObjectTypeInfo> Types { get; set; }
86
public NSObjectTypeInfo Type { get; set; }
88
protected string GetNs (string fullname)
90
var dotIdx = fullname.LastIndexOf ('.');
92
return fullname.Substring (0, dotIdx);
97
protected string GetName (string fullname)
99
var dotIdx = fullname.LastIndexOf ('.');
101
return fullname.Substring (dotIdx + 1);
107
protected string EscapeIdentifier (string unescaped)
109
return Provider.CreateEscapedIdentifier (unescaped);
112
protected void BlankLine (ref bool first)
117
GenerationEnvironment.AppendLine ();
b'\\ No newline at end of file'