Catel.ReSharper.CatelProperties.CSharp.ClassLikeDeclarationExtensions.GetCSharpRegisterPropertyNames C# (CSharp) Method

GetCSharpRegisterPropertyNames() public static method

Get the registered property names.
The name of the property is retrieved from the first argument of the invoke expression of RegisterProperty. Register the Name property so it is known in the class. public static readonly PropertyData NameProperty = RegisterProperty("Name", typeof(string), default(string), (s, e) => ((PersonViewModel)s).OnNameChanged()); Register the LastName property so it is known in the class. public static readonly PropertyData LastNameProperty = RegisterProperty("LastName", typeof(string), default(string), (s, e) => ((PersonViewModel)s).OnLastNameChanged()); } ]]> The result of this examples the result is {"Name", "LastName"}. If the property is not registered on the declaration statement expression then the property name is not detected.
/// The is null. ///
public static GetCSharpRegisterPropertyNames ( this classLikeDeclaration ) : List
classLikeDeclaration this /// The class like declaration instance. ///
return List
        public static List<string> GetCSharpRegisterPropertyNames(this IClassLikeDeclaration classLikeDeclaration)
        {
            Argument.IsNotNull(() => classLikeDeclaration);

            return
                (from argument in
                     (from fieldDeclaration in
                          classLikeDeclaration.Body.FieldDeclarations.Where(
                              multipleFieldDeclaration => multipleFieldDeclaration != null)
                                              .SelectMany(
                                                  multipleFieldDeclaration => multipleFieldDeclaration.Declarators)
                                              .OfType<IFieldDeclaration>()
                      select fieldDeclaration
                      into declaration 
                      where declaration.Initial is IExpressionInitializer
                      select declaration.Initial as IExpressionInitializer
                      into invocationExpression 
                      where invocationExpression.Value is IInvocationExpression
                      select invocationExpression.Value as IInvocationExpression
                      into expression 
                      where expression.InvokedExpression is IReferenceExpression
                      let referenceExpression = expression.InvokedExpression as IReferenceExpression
                      where
                          referenceExpression.NameIdentifier != null
                          && referenceExpression.NameIdentifier.GetText()
                          == RegisterPropertyExpressionHelper.RegisterPropertyMethodName
                      select expression.Arguments[0].Value).OfType<ICSharpLiteralExpression>()
                 select argument into sharpLiteralExpression 
                 select sharpLiteralExpression.ConstantValue
                 into constantValue 
                 where constantValue != null && constantValue.Type.IsString()
                 select (string)constantValue.Value).ToList();
        }
ClassLikeDeclarationExtensions