private void EmitTableSections(ClassGenerationContext classContext, string tableSectionsName, ConfigurationItemDescriptor descriptor) { var tableSections = ComHelpers.GetProperty(classContext.comObject, tableSectionsName); foreach (var tableSection in (IEnumerable)tableSections) { var tableSectionName = Call.Имя(tableSection); var nestedClassContext = new ClassGenerationContext { comObject = tableSection, descriptor = descriptor, generationContext = classContext.generationContext, target = new ClassModel { Name = "ТабличнаяЧасть" + tableSectionName } }; EmitClass(nestedClassContext); classContext.EmitNestedClass(nestedClassContext.target); classContext.EmitProperty(new PropertyModel { Type = string.Format("List<{0}>", nestedClassContext.target.Name), PropertyName = tableSectionName }); } }
private void GenerateClass(ConfigurationItem item, GenerationContext context) { var classContext = new ClassGenerationContext { configurationName = item.Name, target = new ClassModel { Name = item.Name.Name, ConfigurationScope = item.Name.Scope }, comObject = item.ComObject, generationContext = context, descriptor = MetadataHelpers.GetDescriptor(item.Name.Scope) }; EmitClass(classContext); var fileTemplate = new ClassFileTemplate { Model = new ClassFileModel { Namespace = GetNamespaceName(item.Name.Scope), MainClass = classContext.target } }; context.Write(item.Name, fileTemplate.TransformText()); }
private void EmitClass(ClassGenerationContext classContext) { if (classContext.target.ConfigurationScope.HasValue) { var synonym = Call.Синоним(classContext.comObject); classContext.target.Synonym = GenerateHelpers.EscapeString(synonym); if (classContext.target.ConfigurationScope.Value != ConfigurationScope.егистрыСведений) { var presentation = Call.StringProp(classContext.comObject, "ObjectPresentation"); classContext.target.ObjectPresentation = GenerateHelpers.EscapeString(presentation); } } var name = classContext.configurationName; var attributes = MetadataHelpers.GetAttributes(classContext.comObject, classContext.descriptor); foreach (var attr in attributes) { var propertyName = Call.Имя(attr); var propertyTypeDescriptor = GetTypeDescriptor(attr, classContext.configurationItemFullName + "." + propertyName, classContext.generationContext); if (!propertyTypeDescriptor.HasValue) { continue; } var propertyModel = new PropertyModel { Type = propertyTypeDescriptor.Value.dotnetType, PropertyName = propertyName, MaxLength = propertyTypeDescriptor.Value.maxLength }; classContext.target.Properties.Add(propertyModel); } if (name.HasValue && name.Value.HasReference) { classContext.EmitProperty(new PropertyModel { Type = "Guid?", PropertyName = EntityHelpers.idPropertyName }); } if (classContext.descriptor.HasStandardTableSections) { EmitTableSections(classContext, "СтандартныеТабличныеЧасти", MetadataHelpers.standardTableSectionDescriptor, false); } if (classContext.descriptor.HasTableSections) { EmitTableSections(classContext, "ТабличныеЧасти", MetadataHelpers.tableSectionDescriptor, true); } }