public ArgumentInformation Create(BotArgumentInformation argument) { var defaultDescription = new List <Description> { new Description() }; return(new ArgumentInformation(argument.Name, argument.ExpectedType.Name, defaultDescription, argument.IsOptional)); }
public BotCommandInformation Create(Type botCommand) { var properties = botCommand .GetProperties() .Where(prop => prop.CustomAttributes.Any(x => x.AttributeType.IsAssignableTo <CommandPropertyAttribute>())); var arguments = new List <BotArgumentInformation>(); foreach (var property in properties) { var attributes = property.GetCustomAttributes(typeof(CommandPropertyAttribute), inherit: true) .Select(x => x as CommandPropertyAttribute) .ToList(); var expectedType = attributes.First(x => x.GetType() != typeof(Optional)).GetType(); var isOptional = attributes.Any(x => x is Optional); var botArgumentInfo = new BotArgumentInformation(property.Name, expectedType, isOptional); arguments.Add(botArgumentInfo); } var areaName = this.GetAreaName(botCommand.Namespace); return(new BotCommandInformation(botCommand.Name, areaName, arguments)); }