public static TargetField TryLoad(CSProperty csProperty) { TargetField returnValue = null; var uiClientPropertyAttribute = csProperty.AttributeList.SingleOrDefault(i => i.TypeName == typeof(UIClientPropertyAttribute).Name && i.TypeNamespace == typeof(UIClientPropertyAttribute).Namespace); if (uiClientPropertyAttribute != null) { returnValue = new TargetField { SourceFieldName = Convert.ToString(uiClientPropertyAttribute.GetAttributeParameter(0, "SourceFieldName", true)), SourceClassFullName = Convert.ToString(uiClientPropertyAttribute.GetAttributeParameter(1, "SourceFieldTypeFullName", true)) }; } return returnValue; }
internal static void BuildClass(CSClass classObject, TypeDeclaration typeDefinitionNode, string relativeFilePath) { var fieldList = typeDefinitionNode.Children.Where(i => i is FieldDeclaration); if ((typeDefinitionNode.Modifiers & Modifiers.Public) == Modifiers.Public) { classObject.ProtectionLevel = EnumProtectionLevel.Public; } else if ((typeDefinitionNode.Modifiers & Modifiers.Private) == Modifiers.Private) { classObject.ProtectionLevel = EnumProtectionLevel.Private; } else if ((typeDefinitionNode.Modifiers & Modifiers.Protected) == Modifiers.Protected) { classObject.ProtectionLevel = EnumProtectionLevel.Protected; } else if ((typeDefinitionNode.Modifiers & Modifiers.Internal) == Modifiers.Internal) { classObject.ProtectionLevel = EnumProtectionLevel.Internal; } foreach (FieldDeclaration fieldNode in fieldList) { var fieldObjectList = CSField.Parse(fieldNode); classObject.FieldList.AddRange(fieldObjectList); } var propertyList = typeDefinitionNode.Children.Where(i => i is PropertyDeclaration); foreach (PropertyDeclaration propertyNode in propertyList) { var propertyObject = CSProperty.Parse(propertyNode); classObject.PropertyList.Add(propertyObject); } var attributeSectionList = typeDefinitionNode.Children.Where(i => i is AttributeSection); foreach (AttributeSection attributeSectionNode in attributeSectionList) { foreach (var attributeNode in attributeSectionNode.Attributes) { var attribute = CSAttribute.Parse(attributeNode); classObject.AttributeList.Add(attribute); } } if (!classObject.FileRelativePathList.Contains(relativeFilePath, StringComparer.CurrentCultureIgnoreCase)) { classObject.FileRelativePathList.Add(relativeFilePath); } }
public TargetField TryLoadField(CSProperty csProperty) { TargetField returnValue = null; var uiClientPropertyAttribute = csProperty.AttributeList.SingleOrDefault(i => i.TypeFullName == typeof(UIClientPropertyAttribute).FullName); if (uiClientPropertyAttribute != null) { string sourceFieldName = Convert.ToString(uiClientPropertyAttribute.GetAttributeParameter(0, "sourceFieldName", true)); string sourceClassFullName = Convert.ToString(uiClientPropertyAttribute.GetAttributeParameter(1, "sourceFieldTypeFullName", true)); returnValue = new TargetField { SourceFieldName = sourceFieldName, SourceClassFullName = sourceClassFullName, TargetFieldName = csProperty.PropertyName, TargetControlType = GetTargetControlType(sourceClassFullName) }; } return returnValue; }
public static CSProperty Parse(PropertyDeclaration propertyNode) { CSProperty returnValue = new CSProperty(); returnValue.ProtectionLevel = EnumProtectionLevel.Private; if ((propertyNode.Modifiers & Modifiers.Public) == Modifiers.Public) { returnValue.ProtectionLevel = EnumProtectionLevel.Public; } else if ((propertyNode.Modifiers & Modifiers.Private) == Modifiers.Private) { returnValue.ProtectionLevel = EnumProtectionLevel.Private; } else if ((propertyNode.Modifiers & Modifiers.Protected) == Modifiers.Protected) { returnValue.ProtectionLevel = EnumProtectionLevel.Protected; } else if ((propertyNode.Modifiers & Modifiers.Internal) == Modifiers.Internal) { returnValue.ProtectionLevel = EnumProtectionLevel.Internal; } string typeName; string typeNamespace; DotNetParserHelper.SplitType(propertyNode.ReturnType.ToString(), out typeName, out typeNamespace); returnValue.TypeName = typeName; returnValue.TypeNamespace = typeNamespace; returnValue.PropertyName = propertyNode.Name; foreach (var attributeSectionNode in propertyNode.Attributes) { foreach (var attributeNode in attributeSectionNode.Attributes) { var attribute = CSAttribute.Parse(attributeNode); returnValue.AttributeList.Add(attribute); } } return(returnValue); }
public static CSProperty Parse(PropertyDeclaration propertyNode) { CSProperty returnValue = new CSProperty(); returnValue.ProtectionLevel = EnumProtectionLevel.Private; if ((propertyNode.Modifiers & Modifiers.Public) == Modifiers.Public) { returnValue.ProtectionLevel = EnumProtectionLevel.Public; } else if ((propertyNode.Modifiers & Modifiers.Private) == Modifiers.Private) { returnValue.ProtectionLevel = EnumProtectionLevel.Private; } else if ((propertyNode.Modifiers & Modifiers.Protected) == Modifiers.Protected) { returnValue.ProtectionLevel = EnumProtectionLevel.Protected; } else if ((propertyNode.Modifiers & Modifiers.Internal) == Modifiers.Internal) { returnValue.ProtectionLevel = EnumProtectionLevel.Internal; } string typeName; string typeNamespace; DotNetParserHelper.SplitType(propertyNode.ReturnType.ToString(), out typeName, out typeNamespace); returnValue.TypeName = typeName; returnValue.TypeNamespace = typeNamespace; returnValue.PropertyName = propertyNode.Name; foreach (var attributeSectionNode in propertyNode.Attributes) { foreach (var attributeNode in attributeSectionNode.Attributes) { var attribute = CSAttribute.Parse(attributeNode); returnValue.AttributeList.Add(attribute); } } return returnValue; }