Exemplo n.º 1
0
        public static CSharpInterfaceDefinition RefactInterface(this CSharpClassDefinition classDefinition, params string[] exclusions)
        {
            var interfaceDefinition = new CSharpInterfaceDefinition
            {
                AccessModifier = classDefinition.AccessModifier,
                Namespaces     = classDefinition.Namespaces,
                Name           = NamingConvention.GetInterfaceName(classDefinition.Name)
            };

            foreach (var @event in classDefinition.Events.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name)))
            {
                interfaceDefinition.Events.Add(new EventDefinition(@event.AccessModifier, @event.Type, @event.Name));
            }

            foreach (var property in classDefinition.Properties.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name)))
            {
                interfaceDefinition.Properties.Add(new PropertyDefinition(property.AccessModifier, property.Type, property.Name)
                {
                    IsAutomatic = property.IsAutomatic,
                    IsReadOnly  = property.IsReadOnly
                });
            }

            foreach (var method in classDefinition.Methods.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name)))
            {
                interfaceDefinition.Methods.Add(new MethodDefinition(method.AccessModifier, method.Type, method.Name, method.Parameters.ToArray()));
            }

            return(interfaceDefinition);
        }
 public static string GetInterfaceRepositoryName(this ProjectFeature <DapperProjectSettings> projectFeature)
 => CodeNamingConvention.GetInterfaceName(string.Format("{0}Repository", projectFeature.Name));
 public static string GetInterfaceRepositoryName(this ProjectFeature projectFeature)
 => namingConvention.GetInterfaceName(string.Format("{0}Repository", projectFeature.Name));