public static string GetInitialization(string variableName, int membersCount) { var membersStringBuilder = new StringBuilder(); var keyInitialization = ObjectInitializationFactory.CreateObjectInitialization(String.Concat(variableName, ".Keys.ElementAt(0)")); var valueInitialization = ObjectInitializationFactory.CreateObjectInitialization(String.Concat(variableName, ".Values.ElementAt(0)")); Indentation.Level++; for (int i = 0; i < membersCount; i++) { keyInitialization.VariableName = String.Concat(variableName, ".Keys.ElementAt(", i.ToString(), ")"); valueInitialization.VariableName = String.Concat(variableName, ".Values.ElementAt(", i.ToString(), ")"); if (membersStringBuilder.Length > 0) { membersStringBuilder.AppendLine(","); } membersStringBuilder.Append(String.Concat(Indentation.ToString(), "{", keyInitialization.Initialization, ",", valueInitialization.Initialization, "}")); } Indentation.Level--; return(membersStringBuilder.ToString()); }
public static List <ObjectInitialization> GetClassProperties(string variableName) { var classProperties = new List <ObjectInitialization>(); var type = DebuggerHelper.GetValue(ExpressionsHelper.TypeFullName(variableName)).Replace("\"", String.Empty).Replace("+", "."); ////Need to cast it to specific type when enumeration contains abstract types foreach (string propertyName in DebuggerHelper.GetMembersName(ExpressionsHelper.Cast(variableName, type))) { if (IsPropertyInitializable(variableName, propertyName)) { var propertyInitialization = ObjectInitializationFactory.CreateObjectInitialization(String.Concat(variableName, ".", propertyName)); if (propertyInitialization != null) { classProperties.Add(propertyInitialization); } } } return(classProperties); }
public static string GetMembersInitialization(string variableName, int membersCount) { var membersStringBuilder = new StringBuilder(); Indentation.Level++; for (int i = 0; i < membersCount; i++) { if (membersStringBuilder.Length > 0) { membersStringBuilder.AppendLine(","); } var memberInitialization = ObjectInitializationFactory.CreateObjectInitialization(ExpressionsHelper.Item(variableName, i)); membersStringBuilder.Append(string.Concat(Indentation.ToString(), memberInitialization.Initialization)); } Indentation.Level--; return(membersStringBuilder.ToString()); }