Ejemplo n.º 1
0
        private static CodeMemberProperty CreateProperty(CodeTypeDeclaration targetClass, ShellployCommandProperty property)
        {
            var type = property.Type;

            if (type == typeof(Boolean))
            {
                type = typeof(SwitchParameter);
            }

            var codeProperty = new CodeMemberProperty()
            {
                Name       = property.PropertyName ?? property.Name,
                Type       = new CodeTypeReference(type),
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
            };

            codeProperty.GenerateBackingField(targetClass, property.DefaultValue);

            foreach (var parameterAttribute in property.ParameterAttributes)
            {
                codeProperty.CustomAttributes.Add(
                    typeof(SMA.ParameterAttribute),
                    parameterAttribute.GetAttributeArguments()
                    );
            }

            return(codeProperty);
        }