public override IDisposable WriteClass(SpecificationDefinition specificationDefinition, string name, string baseClass, params string[] interfaces) { var classLineBuilder = new StringBuilder(1024); classLineBuilder.Append(GetProtectionSpecifications(specificationDefinition)); classLineBuilder.Append(GetDomainSpecifications(specificationDefinition)); classLineBuilder.Append(GetInheritanceSpecifications(specificationDefinition)); var bases = new List <string>(); if (!string.IsNullOrEmpty(baseClass)) { bases.Add(baseClass); } bases.AddRange(interfaces); classLineBuilder.AppendFormat("class {0}", name); if (bases.Count > 0) { classLineBuilder.Append(" : "); classLineBuilder.Append(string.Join(", ", bases.ToArray())); } WriteLine(classLineBuilder.ToString()); return(WriteBrackets()); }
protected virtual string GetProtectionSpecifications(SpecificationDefinition specificationDefinition) { string literalSpecifications = GetSpecifications(specificationDefinition & SpecificationDefinition.ProtectionClass); if (string.IsNullOrEmpty(literalSpecifications)) { literalSpecifications = "public "; } return(literalSpecifications); }
protected void WriteFieldOrProperty(SpecificationDefinition specificationDefinition, string name, string memberType) { var methodLineBuilder = new StringBuilder(1024); methodLineBuilder.Append(GetProtectionSpecifications(specificationDefinition)); methodLineBuilder.Append(GetDomainSpecifications(specificationDefinition)); methodLineBuilder.Append(GetInheritanceSpecifications(specificationDefinition)); methodLineBuilder.Append(GetSpecifications(specificationDefinition & SpecificationDefinition.Event)); methodLineBuilder.AppendFormat("{0} {1}", memberType, GetVariableExpression(name)); Write(methodLineBuilder.ToString()); }
public virtual void WriteEnum(SpecificationDefinition specificationDefinition, string name, IDictionary <string, int> values) { using (WriteEnum(specificationDefinition, name)) { var orderedValues = from nv in values orderby nv.Value select nv; int currentValue = 1; foreach (var nameValue in orderedValues) { if (nameValue.Value == currentValue) { WriteLine(string.Format("{0},", nameValue.Key)); } else { currentValue = nameValue.Value; WriteLine(string.Format("{0} = {1},", nameValue.Key, nameValue.Value)); } currentValue++; } } }
public virtual void WriteEnum(SpecificationDefinition specificationDefinition, string name, IDictionary <string, int> values) { using (WriteEnum(specificationDefinition, name)) { var orderedValues = from nv in values orderby nv.Value select nv; int currentValue = 1, counter = 0; foreach (var nameValue in orderedValues) { var suffix = ++counter < orderedValues.Count() ? "," : ""; if (nameValue.Value == currentValue) { WriteLine(string.Format("{0}{1}", nameValue.Key, suffix)); } else { currentValue = nameValue.Value; WriteLine(string.Format("{0} = {1}{2}", nameValue.Key, nameValue.Value, suffix)); } currentValue++; } } }
public override void WritePropertyWithBackingField(SpecificationDefinition specificationDefinition, string name, string propertyType, bool privateSetter) { WriteFieldOrProperty(specificationDefinition, name, propertyType); WriteLine("{{ get; {0}set; }}", privateSetter ? "private " : string.Empty); }
public override IDisposable WriteMethod(SpecificationDefinition specificationDefinition, string name, Type returnType, params ParameterDefinition[] parameters) { return WriteGeneralMethod(specificationDefinition, name, true, returnType, parameters, null); }
public override IDisposable WriteProperty(SpecificationDefinition specificationDefinition, string name, string propertyType) { WriteFieldOrProperty(specificationDefinition, name, propertyType); WriteLine(); return WriteBrackets(); }
protected virtual string GetDirectionSpecifications(SpecificationDefinition specificationDefinition) { return(GetSpecifications(specificationDefinition & SpecificationDefinition.DirectionClass)); }
protected virtual IDisposable WriteGeneralMethod(SpecificationDefinition specificationDefinition, string name, bool hasReturnType, Type returnType, IList<ParameterDefinition> parameters, IList<string> baseCallParameters) { bool monoStrict = baseCallParameters != null && baseCallParameters.Count > 0 && parameters.Any(p => p.Type == typeof(DbLinq.Vendor.IVendor)); var methodLineBuilder = new StringBuilder(1024); if (monoStrict) methodLineBuilder.Append("#if !MONO_STRICT") .AppendLine(); methodLineBuilder.Append(GetProtectionSpecifications(specificationDefinition)); methodLineBuilder.Append(GetDomainSpecifications(specificationDefinition)); methodLineBuilder.Append(GetInheritanceSpecifications(specificationDefinition)); if (hasReturnType) methodLineBuilder.AppendFormat("{0} {1}(", GetLiteralType(returnType) ?? "void", name); else methodLineBuilder.AppendFormat("{0}(", name); var literalParameters = new List<string>(); foreach (var parameter in parameters) { string literalParameter = string.Format("{0}{3}{1} {2}", parameter.Attribute != null ? GetAttribute(parameter.Attribute) + " " : string.Empty, parameter.LiteralType ?? GetLiteralType(parameter.Type), parameter.Name, GetDirectionSpecifications(parameter.SpecificationDefinition)); literalParameters.Add(literalParameter); } methodLineBuilder.AppendFormat("{0})", string.Join(", ", literalParameters.ToArray())); if (baseCallParameters != null && baseCallParameters.Count > 0) { methodLineBuilder.AppendLine(); bool strictArgs = parameters.Count != baseCallParameters.Count; if (strictArgs) methodLineBuilder.Append("#if MONO_STRICT") .AppendLine() .AppendFormat("\t: base({0})", string.Join(", ", baseCallParameters.Take(parameters.Count).ToArray())) .AppendLine() .Append("#else // MONO_STRICT") .AppendLine(); methodLineBuilder.AppendFormat("\t: base({0})", string.Join(", ", baseCallParameters.ToArray())); if (strictArgs) methodLineBuilder.AppendLine() .Append("#endif // MONO_STRICT"); } WriteLine(methodLineBuilder.ToString()); return monoStrict ? WriteBrackets("#endif // !MONO_STRICT") : WriteBrackets(); }
protected virtual string GetInheritanceSpecifications(SpecificationDefinition specificationDefinition) { return GetSpecifications(specificationDefinition & SpecificationDefinition.InheritanceClass); }
public abstract IDisposable WriteCtor(SpecificationDefinition specificationDefinition, string name, ParameterDefinition[] parameters, IList<string> baseCallParameters);
public abstract void WriteEvent(SpecificationDefinition specificationDefinition, string name, string eventDelegate);
public virtual void WriteEnum(SpecificationDefinition specificationDefinition, string name, IDictionary<string, int> values) { using (WriteEnum(specificationDefinition, name)) { var orderedValues = from nv in values orderby nv.Value select nv; int currentValue = 1, counter = 0; foreach (var nameValue in orderedValues) { var suffix = ++counter < orderedValues.Count() ? "," : ""; if (nameValue.Value == currentValue) WriteLine(string.Format("{0}{1}", nameValue.Key, suffix)); else { currentValue = nameValue.Value; WriteLine(string.Format("{0} = {1}{2}", nameValue.Key, nameValue.Value, suffix)); } currentValue++; } } }
public virtual void WritePropertyWithBackingField(SpecificationDefinition specificationDefinition, string name, string propertyType) { WritePropertyWithBackingField(specificationDefinition, name, propertyType, false); }
public abstract void WriteField(SpecificationDefinition specificationDefinition, string name, string fieldType);
public abstract void WritePropertyWithBackingField(SpecificationDefinition specificationDefinition, string name, string propertyType, bool privateSetter);
public abstract IDisposable WriteProperty(SpecificationDefinition specificationDefinition, string name, string propertyType);
public abstract IDisposable WriteMethod(SpecificationDefinition specificationDefinition, string name, Type returnType, params ParameterDefinition[] parameters);
/// <summary> /// Writes the enum. /// </summary> /// <param name="specificationDefinition">The specification definition.</param> /// <param name="name">The name.</param> /// <returns></returns> public override IDisposable WriteEnum(SpecificationDefinition specificationDefinition, string name) { WriteLine("{0}enum {1}", GetProtectionSpecifications(specificationDefinition), name); return WriteBrackets(); }
protected virtual IDisposable WriteGeneralMethod(SpecificationDefinition specificationDefinition, string name, bool hasReturnType, Type returnType, IList <ParameterDefinition> parameters, IList <string> baseCallParameters) { bool monoStrict = baseCallParameters != null && baseCallParameters.Count > 0 && parameters.Any(p => p.Type == typeof(DbLinq.Vendor.IVendor)); var methodLineBuilder = new StringBuilder(1024); if (monoStrict) { methodLineBuilder.Append("#if !MONO_STRICT") .AppendLine(); } methodLineBuilder.Append(GetProtectionSpecifications(specificationDefinition)); methodLineBuilder.Append(GetDomainSpecifications(specificationDefinition)); methodLineBuilder.Append(GetInheritanceSpecifications(specificationDefinition)); if (hasReturnType) { methodLineBuilder.AppendFormat("{0} {1}(", GetLiteralType(returnType) ?? "void", name); } else { methodLineBuilder.AppendFormat("{0}(", name); } var literalParameters = new List <string>(); foreach (var parameter in parameters) { string literalParameter = string.Format("{0}{3}{1} {2}", parameter.Attribute != null ? GetAttribute(parameter.Attribute) + " " : string.Empty, parameter.LiteralType ?? GetLiteralType(parameter.Type), parameter.Name, GetDirectionSpecifications(parameter.SpecificationDefinition)); literalParameters.Add(literalParameter); } methodLineBuilder.AppendFormat("{0})", string.Join(", ", literalParameters.ToArray())); if (baseCallParameters != null && baseCallParameters.Count > 0) { methodLineBuilder.AppendLine(); bool strictArgs = parameters.Count != baseCallParameters.Count; if (strictArgs) { methodLineBuilder.Append("#if MONO_STRICT") .AppendLine() .AppendFormat("\t: base({0})", string.Join(", ", baseCallParameters.Take(parameters.Count).ToArray())) .AppendLine() .Append("#else // MONO_STRICT") .AppendLine(); } methodLineBuilder.AppendFormat("\t: base({0})", string.Join(", ", baseCallParameters.ToArray())); if (strictArgs) { methodLineBuilder.AppendLine() .Append("#endif // MONO_STRICT"); } } WriteLine(methodLineBuilder.ToString()); return(monoStrict ? WriteBrackets("#endif // !MONO_STRICT") : WriteBrackets()); }
protected virtual string GetSpecifications(SpecificationDefinition specificationDefinition) { var literalSpecifications = new List<string>(); if (HasSpecification(specificationDefinition, SpecificationDefinition.Internal)) literalSpecifications.Add("internal"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Private)) literalSpecifications.Add("private"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Protected)) literalSpecifications.Add("protected"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Abstract)) literalSpecifications.Add("abstract"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Virtual)) literalSpecifications.Add("virtual"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Override)) literalSpecifications.Add("override"); if (HasSpecification(specificationDefinition, SpecificationDefinition.New)) literalSpecifications.Add("new"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Static)) literalSpecifications.Add("static"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Partial)) literalSpecifications.Add("partial"); if (HasSpecification(specificationDefinition, SpecificationDefinition.Out)) { if (HasSpecification(specificationDefinition, SpecificationDefinition.In)) literalSpecifications.Add("ref"); else literalSpecifications.Add("out"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Event)) literalSpecifications.Add("event"); string result = string.Join(" ", literalSpecifications.ToArray()); if (!string.IsNullOrEmpty(result)) result += " "; return result; }
public override IDisposable WriteCtor(SpecificationDefinition specificationDefinition, string name, ParameterDefinition[] parameters, IList <string> baseCallParameters) { return(WriteGeneralMethod(specificationDefinition, name, false, null, parameters, baseCallParameters)); }
public abstract IDisposable WriteEnum(SpecificationDefinition specificationDefinition, string name);
public override IDisposable WriteMethod(SpecificationDefinition specificationDefinition, string name, Type returnType, params ParameterDefinition[] parameters) { return(WriteGeneralMethod(specificationDefinition, name, true, returnType, parameters, null)); }
public virtual void WriteEnum(SpecificationDefinition specificationDefinition, string name, IDictionary<string, int> values) { using (WriteEnum(specificationDefinition, name)) { var orderedValues = from nv in values orderby nv.Value select nv; int currentValue = 1; foreach (var nameValue in orderedValues) { if (nameValue.Value == currentValue) WriteLine(string.Format("{0},", nameValue.Key)); else { currentValue = nameValue.Value; WriteLine(string.Format("{0} = {1},", nameValue.Key, nameValue.Value)); } currentValue++; } } }
public override IDisposable WriteClass(SpecificationDefinition specificationDefinition, string name, string baseClass, params string[] interfaces) { var classLineBuilder = new StringBuilder(1024); classLineBuilder.Append(GetProtectionSpecifications(specificationDefinition)); classLineBuilder.Append(GetDomainSpecifications(specificationDefinition)); classLineBuilder.Append(GetInheritanceSpecifications(specificationDefinition)); var bases = new List<string>(); if (!string.IsNullOrEmpty(baseClass)) bases.Add(baseClass); bases.AddRange(interfaces); classLineBuilder.AppendFormat("class {0}", name); if (bases.Count > 0) { classLineBuilder.Append(" : "); classLineBuilder.Append(string.Join(", ", bases.ToArray())); } WriteLine(classLineBuilder.ToString()); return WriteBrackets(); }
public override IDisposable WriteProperty(SpecificationDefinition specificationDefinition, string name, string propertyType) { WriteFieldOrProperty(specificationDefinition, name, propertyType); WriteLine(); return(WriteBrackets()); }
public override IDisposable WriteCtor(SpecificationDefinition specificationDefinition, string name, ParameterDefinition[] parameters, IList<string> baseCallParameters) { return WriteGeneralMethod(specificationDefinition, name, false, null, parameters, baseCallParameters); }
public override void WriteField(SpecificationDefinition specificationDefinition, string name, string fieldType) { WriteFieldOrProperty(specificationDefinition, name, fieldType); WriteLine(";"); }
public override void WriteEvent(SpecificationDefinition specificationDefinition, string name, string eventDelegate) { WriteFieldOrProperty(specificationDefinition | SpecificationDefinition.Event, name, eventDelegate); WriteLine(";"); }
public abstract IDisposable WriteClass(SpecificationDefinition specificationDefinition, string name, string baseClass, params string[] interfaces);
protected bool HasSpecification(SpecificationDefinition specificationDefinition, SpecificationDefinition test) { return (specificationDefinition & test) != 0; }
protected virtual string GetProtectionSpecifications(SpecificationDefinition specificationDefinition) { string literalSpecifications = GetSpecifications(specificationDefinition & SpecificationDefinition.ProtectionClass); if (string.IsNullOrEmpty(literalSpecifications)) literalSpecifications = "public "; return literalSpecifications; }
protected virtual string GetDirectionSpecifications(SpecificationDefinition specificationDefinition) { return GetSpecifications(specificationDefinition & SpecificationDefinition.DirectionClass); }
/// <summary> /// Writes the enum. /// </summary> /// <param name="specificationDefinition">The specification definition.</param> /// <param name="name">The name.</param> /// <returns></returns> public override IDisposable WriteEnum(SpecificationDefinition specificationDefinition, string name) { WriteLine("{0}enum {1}", GetProtectionSpecifications(specificationDefinition), name); return(WriteBrackets()); }
public abstract IDisposable WriteCtor(SpecificationDefinition specificationDefinition, string name, ParameterDefinition[] parameters, IList <string> baseCallParameters);
protected bool HasSpecification(SpecificationDefinition specificationDefinition, SpecificationDefinition test) { return((specificationDefinition & test) != 0); }
protected virtual string GetSpecifications(SpecificationDefinition specificationDefinition) { var literalSpecifications = new List <string>(); if (HasSpecification(specificationDefinition, SpecificationDefinition.Internal)) { literalSpecifications.Add("internal"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Private)) { literalSpecifications.Add("private"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Protected)) { literalSpecifications.Add("protected"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Abstract)) { literalSpecifications.Add("abstract"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Virtual)) { literalSpecifications.Add("virtual"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Override)) { literalSpecifications.Add("override"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.New)) { literalSpecifications.Add("new"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Static)) { literalSpecifications.Add("static"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Partial)) { literalSpecifications.Add("partial"); } if (HasSpecification(specificationDefinition, SpecificationDefinition.Out)) { if (HasSpecification(specificationDefinition, SpecificationDefinition.In)) { literalSpecifications.Add("ref"); } else { literalSpecifications.Add("out"); } } if (HasSpecification(specificationDefinition, SpecificationDefinition.Event)) { literalSpecifications.Add("event"); } string result = string.Join(" ", literalSpecifications.ToArray()); if (!string.IsNullOrEmpty(result)) { result += " "; } return(result); }
protected virtual string GetInheritanceSpecifications(SpecificationDefinition specificationDefinition) { return(GetSpecifications(specificationDefinition & SpecificationDefinition.InheritanceClass)); }
private void DataToControls() { if (_specification != null) { edtSpecDescription.Value = _specification.Description; edtSpecName.Value = _specification.name; SpecificationDefinition definition = _specification.Definition; if (definition != null) { rbText.Checked = (definition.Item is String); rbDocument.Checked = (definition.Item is Document); if (rbText.Checked) { edtDefinitionText.Value = definition.Item as String; } else if (rbDocument.Checked) { documentControl.Document = definition.Item as Document; } } //-----------------------------------// //--- Load the Limit List Control ---// //-----------------------------------// if (_specification.Limits != null) { limitListControl.Items.Clear(); foreach (Limit limit in _specification.Limits) { AddLimitToListView(limit); } } //---------------------------------------// //--- Load the Condition List Control ---// //---------------------------------------// if (_specification.Conditions != null) { dgConditions.Rows.Clear(); foreach (String condition in _specification.Conditions) { int idx = dgConditions.Rows.Add(); DataGridViewRow row = dgConditions.Rows[idx]; row.Cells["condition"].Value = condition; } } //-----------------------------------------// //--- Load the Required Options Control ---// //-----------------------------------------// if (_specification.RequiredOptions != null) { dgRequiredOptions.Rows.Clear(); foreach (String option in _specification.RequiredOptions) { int idx = dgRequiredOptions.Rows.Add(); DataGridViewRow row = dgRequiredOptions.Rows[idx]; row.Cells["requiredOption"].Value = option; } } //------------------------------------------// //--- Load the Exclusive Options Control ---// //------------------------------------------// if (_specification.ExclusiveOptions != null) { dgExclusiveOptions.Rows.Clear(); foreach (String option in _specification.ExclusiveOptions) { int idx = dgExclusiveOptions.Rows.Add(); DataGridViewRow row = dgExclusiveOptions.Rows[idx]; row.Cells["exclusiveOption"].Value = option; } } //-------------------------------------------------// //--- Load the Supplimental Information Control ---// //-------------------------------------------------// if (_specification.SupplementalInformation != null) { dgSupplimentalInfo.Rows.Clear(); foreach (String information in _specification.SupplementalInformation) { int idx = dgSupplimentalInfo.Rows.Add(); DataGridViewRow row = dgSupplimentalInfo.Rows[idx]; row.Cells["information"].Value = information; } } } }