Example #1
0
 public abstract IDisposable DeclareInterface(CodeItem info, string[] implements);
        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));
                }
            }
        }
Example #3
0
 public abstract IDisposable DeclareProperty(CodeItem info, string type);
Example #4
0
 public virtual IDisposable DeclareProperty(CodeItem info, FieldType type)
 {
     return DeclareProperty(info, GetTypeName(type));
 }
Example #5
0
 public abstract void DeclareField(CodeItem info, string type, string defaultValue);
Example #6
0
 public virtual void DeclareField(CodeItem info, FieldType type, string defaultValue)
 {
     DeclareField(info, GetTypeName(type), defaultValue == null ? null : MakeConstant(type, defaultValue));
 }
Example #7
0
 public abstract IDisposable DeclareEnum(CodeItem info);
Example #8
0
 public abstract IDisposable DeclareStruct(CodeItem info, string[] implements);
Example #9
0
 public override void DeclareField(CodeItem info, string type, string defaultValue)
 {
     WriteLine("{0} {1} {2}{3};",
         info.Access.ToString().ToLower(),
         type,
         info.Name,
         defaultValue == null ? "" : " = " + defaultValue
         );
 }
Example #10
0
        public override IDisposable DeclareProperty(CodeItem info, string type)
        {
            WriteSummaryXml(info.Description);
            WriteLineIf(info.Obsolete, "[" + Global + "System.Obsolete]");
            SetClsCompliant(info.ClsCompliant || info.Access == FieldAccess.Private);

            WriteLineIf(info.DefaultValue != null && info.DefaultValue.IndexOf("global::") < 0, 
                "[" + Global + "System.ComponentModel.DefaultValueAttribute({0})]", info.DefaultValue);
            
            return WriteBlock("{0} {1} {2}",
                info.Access.ToString().ToLower(),
                type, info.Name
                );
        }
Example #11
0
 public override IDisposable DeclareStruct(CodeItem info, string[] implements)
 {
     WriteSummaryXml(info.Description);
     WriteLineIf(info.Obsolete, "[" + Global + "System.Obsolete]");
     WriteLineIf(info.XmlName != null, "[" + Global + "System.Xml.Serialization.XmlType({0})]", MakeString(info.XmlName));
     SetClsCompliant(info.ClsCompliant);
     WriteNonUserCode();
     return WriteBlock("{0}partial struct {1}{2}",
         info.Access == FieldAccess.Private ? null : info.Access.ToString().ToLower() + " ",
         info.Name,
         implements == null || implements.Length == 0 ? null : " : " + String.Join(", ", implements));
 }
Example #12
0
 public override IDisposable DeclareInterface(CodeItem info, string[] implements)
 {
     WriteSummaryXml(info.Description);
     WriteLineIf(info.Obsolete, "[" + Global + "System.Obsolete]");
     SetClsCompliant(info.ClsCompliant);
     WriteGenerated();
     return WriteBlock("{0}partial interface {1}{2}",
         info.Access == FieldAccess.Private ? null : info.Access.ToString().ToLower() + " ", 
         info.Name,
         implements == null || implements.Length == 0 ? null : " : " + String.Join(", ", implements));
 }
Example #13
0
 public override IDisposable DeclareEnum(CodeItem info)
 {
     WriteSummaryXml(info.Description);
     WriteLineIf(info.Obsolete, "[" + Global + "System.Obsolete]");
     WriteLineIf(info.XmlName != null, "[" + Global + "System.Xml.Serialization.XmlType({0})]", MakeString(info.XmlName));
     WriteGenerated();
     return WriteBlock("{0}{1}enum {2}",
         info.Access == FieldAccess.Private ? null : info.Access.ToString().ToLower() + " ",
         info.HidesBase ? "new " : "",
         info.Name);
 }