public void BeginProperty(AccessLevel accessLevel, VirtualisationLevel virtualisationLevel, string typeName, string name) { WriteLine("{0} {1}{2} {3}", AccessLevelToStr(accessLevel), String.IsNullOrEmpty(VirtualisationLevelToStr(virtualisationLevel)) ? "" : VirtualisationLevelToStr(virtualisationLevel) + " ", typeName, name); BeginScope(); }
public void SimpleProperty(AccessLevel accessLevel, VirtualisationLevel virtualisationLevel, IAttribute attribute, IEnvironmentHelper environment) { SimpleProperty(accessLevel, virtualisationLevel, environment.ToTypeName(attribute, true), attribute.Name, true, !attribute.ReadOnly); }
public string VirtualisationLevelToStr(VirtualisationLevel virtualisationLevel) { switch (virtualisationLevel) { case VirtualisationLevel.None: return(""); case VirtualisationLevel.Virtual: return("virtual"); case VirtualisationLevel.Override: return("override"); case VirtualisationLevel.Abstract: return("abstract"); case VirtualisationLevel.New: return("new"); } return(String.Empty); }
public void WriteProperty(AccessLevel accessLevel, VirtualisationLevel virtualisationLevel, IAttribute attribute, IEnvironmentHelper environment, string propertyAttributes) { string defaultValue = null; if (attribute.Type is IEnumerationType) { defaultValue = String.Format("({0}){1}", environment.ToTypeName(attribute, true), (attribute.Type as IEnumerationType).Enumeration.DefaultItem.Value.ToString()); } else if (attribute.TypeDefinition.HasDefault) { defaultValue = environment.ToDefaultValue(attribute); } if (defaultValue != null || IsAttributeIsStringLimitedLength(attribute)) { StandardProperty(accessLevel, virtualisationLevel, attribute, environment, defaultValue, propertyAttributes); } else { if (!String.IsNullOrEmpty(propertyAttributes)) { WriteLine(propertyAttributes); } SimpleProperty(accessLevel, virtualisationLevel, attribute, environment); } }
public void SimpleProperty(AccessLevel accessLevel, VirtualisationLevel virtualisationLevel, string typeName, string name, bool getter, bool setter) { Write("{0} ", AccessLevelToStr(accessLevel)); if (virtualisationLevel != VirtualisationLevel.None) { Write("{0} ", VirtualisationLevelToStr(virtualisationLevel)); } Write("{0} {1} {2}", typeName, name, ScopeSettings.ScopeBegin); if (getter) { Write(" get;"); } if (setter) { Write(" set;"); } WriteLine(" {0}", ScopeSettings.ScopeEnd); }
public void StandardProperty(AccessLevel accessLevel, VirtualisationLevel virtualisationLevel, IAttribute attribute, IEnvironmentHelper environment, string defaultValue, string propertyAttributes) { if (defaultValue == null || (defaultValue != null && defaultValue.Length == 0)) { DeclareMember(attribute, environment); } else { DeclareMember(attribute, defaultValue, environment); } if (!String.IsNullOrEmpty(propertyAttributes)) { WriteLine(propertyAttributes); } BeginProperty(accessLevel, virtualisationLevel, environment.ToTypeName(attribute, true), attribute.Name); WritePropertyGet(String.Format("return {0};", environment.ToMemberName(attribute))); if (!attribute.ReadOnly) { if (IsAttributeIsStringLimitedLength(attribute)) { WritePropertySet(String.Format("{0} = value != null && value.Length > {1} ? value.Substring(0, {1}) : value;", environment.ToMemberName(attribute), attribute.TypeDefinition.Length)); } else { WritePropertySet(String.Format("{0} = value;", environment.ToMemberName(attribute))); } } EndProperty(); }