Пример #1
0
        private void EmitConstants(GenerationContext context)
        {
            var constants      = ComHelpers.GetProperty(globalContext.Metadata, "Константы");
            var constantsCount = Call.Количество(constants);

            for (var i = 0; i < constantsCount; i++)
            {
                var constant       = Call.Получить(constants, i);
                var typeDescriptor = ExtractType(constant, context);
                if (!typeDescriptor.HasValue)
                {
                    continue;
                }
                var configurationName = new ConfigurationName(ConfigurationScope.Константы,
                                                              Call.Имя(constant));
                var template = new ConstantFileTemplate
                {
                    Model = new ConstantFileModel
                    {
                        Type      = typeDescriptor.Value.name,
                        Name      = configurationName.Name,
                        Synonym   = GenerateHelpers.EscapeString(Call.Синоним(constant)),
                        Namespace = GetNamespaceName(configurationName.Scope),
                        MaxLength = typeDescriptor.Value.maxLength
                    }
                };
                context.Write(configurationName, template.TransformText());
            }
        }
Пример #2
0
        private void EmitEnum(ConfigurationItem item, GenerationContext context)
        {
            var model = new EnumFileModel
            {
                Name      = item.Name.Name,
                Namespace = GetNamespaceName(item.Name.Scope)
            };
            var values = ComHelpers.GetProperty(item.ComObject, "ЗначенияПеречисления");
            var count  = Call.Количество(values);

            for (var i = 0; i < count; i++)
            {
                var value = Call.Получить(values, i);
                model.Items.Add(new EnumItemModel
                {
                    Name    = Call.Имя(value),
                    Synonym = GenerateHelpers.EscapeString(Call.Синоним(value))
                });
            }
            var enumFileTemplate = new EnumFileTemplate {
                Model = model
            };

            context.Write(item.Name, enumFileTemplate.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);
            }
        }