Exemplo n.º 1
0
        private PropertyDefinition CreateProperty(ICommonAssembly assembly, ICommonType viewModelType, string executeMethodName)
        {
            var propertyName = nameRulesService.ConvertName(executeMethodName, UseNameRulesFor.CommandExecuteMethod, UseNameRulesFor.CommandProperty);

            log.Debug($"Create property with name '{propertyName}'");
            var property = new PropertyDefinition(propertyName, PropertyAttributes.None, assembly.MonoCecil.MainModule.ImportReference(commandType.GetValue(assembly).MonoCecil));

            viewModelType.MonoCecil.Properties.Add(property);

            return(property);
        }
        private FieldDefinition CreateField(ICommonType viewModelType, ICommonProperty property)
        {
            var fieldName = nameRulesService.ConvertName(property.Name, UseNameRulesFor.Property, UseNameRulesFor.Field);

            log.Debug($"Create field with name '{fieldName}'");
            var field = new FieldDefinition(fieldName, FieldAttributes.Private, property.MonoCecil.PropertyType);

            viewModelType.MonoCecil.Fields.Add(field);

            return(field);
        }
Exemplo n.º 3
0
        private FieldDefinition CreateField(ICommonAssembly assembly, ICommonType frameworkElementType, ICommonProperty property)
        {
            var fieldName = nameRulesService.ConvertName(property.Name, UseNameRulesFor.DependencyProperty, UseNameRulesFor.DependencyField);

            log.Debug($"Create field with name '{fieldName}'");
            var field = new FieldDefinition(fieldName, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.InitOnly, assembly.MonoCecil.MainModule.ImportReference(dependencyPropertyType.GetValue(assembly).MonoCecil));

            frameworkElementType.MonoCecil.Fields.Add(field);

            InitializeInStaticConstructor(assembly, frameworkElementType, property, field);

            return(field);
        }
Exemplo n.º 4
0
 private void CheckConvertNames(IEnumerable <string> names, UseNameRulesFor from, UseNameRulesFor to, IEnumerable <string> expectedNames)
 {
     names.Select(name => nameRulesService.ConvertName(name, from, to)).SequenceEqual(expectedNames).Should().Be(true);
 }