public void RecursiveFindByNameIgnoreCase() { MockVSHierarchy hierarchy = new MockVSHierarchy(); MockVsSolution solution = new MockVsSolution(hierarchy); MockVSHierarchy project1 = new MockVSHierarchy("Project1.project"); hierarchy.AddProject(project1); string child1 = "Child1"; project1.AddChild(child1); MockVSHierarchy project2 = new MockVSHierarchy("Project2.project"); hierarchy.AddProject(project2); string child2 = "ChIlD2.cd"; project2.AddChild(child2); string child3 = "ChildThree3"; project2.AddChild(child3); string child4 = "Child4NotAdded"; HierarchyNode node = new HierarchyNode(solution); Assert.IsNull(node.FindByName(child1)); Assert.IsNull(node.FindByName(child2)); Assert.IsNull(node.FindByName(child3)); Assert.IsNull(node.FindByName(child4)); Assert.IsNotNull(node.RecursiveFindByName(child1.ToLowerInvariant())); Assert.IsNotNull(node.RecursiveFindByName(child2.ToUpperInvariant())); Assert.IsNotNull(node.RecursiveFindByName(CodeIdentifier.MakeCamel(child3))); Assert.IsNull(node.RecursiveFindByName(child4)); }
/// <summary> /// Produces a camel-case string from an input string and add the Field postfix in case the current /// culture does not makes a difference in casing. /// </summary> /// <param name="identifier">The name of a code entity, such as a method parameter or property identifier.</param> /// <returns></returns> public static string ToCamelCase(string identifier) { Guard.ArgumentNotNullOrEmptyString(identifier, "identifier"); string camelCase = CodeIdentifier.MakeCamel(identifier); // add Field postfix if the current culture does not dist. lower/upper case return(identifier == camelCase || !csProvider.IsValidIdentifier(camelCase) ? camelCase + "Field" : camelCase); }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public string MakeRightCase(string identifier) { if (_camelCase) { return(CodeIdentifier.MakeCamel(identifier)); } else { return(CodeIdentifier.MakePascal(identifier)); } }
/// <summary> /// The CreateParameterName /// </summary> /// <param name="property">The property<see cref="PropertyInfo"/></param> /// <returns>The <see cref="string"/></returns> private static string CreateParameterName(PropertyInfo property) { var name = CodeIdentifier.MakeCamel(property.Name); if (IsKeyword(name)) { return('@' + name); } return(name); }
private static string GetUniqueVariableName(string name, CodeStatementCollection statements) { name = CodeIdentifier.MakeCamel(name); foreach (CodeStatement statement in statements) { CodeVariableDeclarationStatement statement2 = statement as CodeVariableDeclarationStatement; if ((statement2 != null) && (statement2.Name == name)) { return(name + "_" + statements.Count); } } return(name); }
private CodeExpression BuildProxy(CodeStatementCollection statements, MethodInfo method) { Type type = this.proxy.GetType(); string name = CodeIdentifier.MakeCamel(type.Name); if (this.proxySetting == ProxySettings.AllProperties) { return(this.BuildClass(statements, name, this.proxy)); } CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement(type.Name, name); statement.InitExpression = new CodeObjectCreateExpression(type.FullName, new CodeExpression[0]); statements.Add(statement); CodeExpression targetObject = new CodeVariableReferenceExpression(name); FieldInfo[] soapHeaders = null; if (this.proxySetting == ProxySettings.RequiredHeaders) { soapHeaders = MethodProperty.GetSoapHeaders(method, true); } else { soapHeaders = type.GetFields(); } for (int i = 0; i < soapHeaders.Length; i++) { FieldInfo info = soapHeaders[i]; if (typeof(SoapHeader).IsAssignableFrom(info.FieldType)) { CodeExpression left = new CodeFieldReferenceExpression(targetObject, info.Name); CodeExpression right = this.BuildObject(statements, info.Name, info.GetValue(this.proxy)); statements.Add(new CodeAssignStatement(left, right)); } } return(targetObject); }
private CodeExpression BuildProxy(CodeStatementCollection statements, MethodInfo method) { Type type1 = proxy.GetType(); string text1 = CodeIdentifier.MakeCamel(type1.Name); if (proxySetting == ProxySettings.AllProperties) { return(BuildClass(statements, text1, proxy)); } CodeVariableDeclarationStatement statement1 = new CodeVariableDeclarationStatement(type1.Name, text1); statement1.InitExpression = new CodeObjectCreateExpression(type1.FullName, new CodeExpression[0]); statements.Add(statement1); CodeExpression expression1 = new CodeVariableReferenceExpression(text1); FieldInfo[] infoArray1 = null; if (proxySetting == ProxySettings.RequiredHeaders) { infoArray1 = MethodProperty.GetSoapHeaders(method, true); } else { infoArray1 = type1.GetFields(); } for (int num1 = 0; num1 < infoArray1.Length; num1++) { FieldInfo info1 = infoArray1[num1]; if (typeof(SoapHeader).IsAssignableFrom(info1.FieldType)) { CodeExpression expression2 = new CodeFieldReferenceExpression(expression1, info1.Name); CodeExpression expression3 = BuildObject(statements, info1.Name, info1.GetValue(proxy)); statements.Add(new CodeAssignStatement(expression2, expression3)); } } return(expression1); }
private static string MakeFieldName(string name) { return(CodeIdentifier.MakeCamel(name) + "Field"); }