public IConstructor Construct() { var Parts = _Decompositor.GetParts(); var PrimePart = ClassPart.Create(ClassPartType.Object, ClassPartDataType.Object, "", "", Parts); _Class = PrintCommonObject(PrimePart); return(this); }
public static object GetFragmentValue(string Fragment) { if (string.IsNullOrEmpty(Fragment)) { return(null); } object resultObj = null; if (Fragment.Contains(":")) { string[] parts = Fragment.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 1) { var culture = CultureInfo.GetCultureInfo(CultureInfo.CurrentCulture.Name); if (Fragment.Contains("{") && Fragment.Contains("}")) { var listChars = Fragment.ToList().FindIndex(x => x == '{'); int indexStartObject = listChars; string obj = Fragment.Substring(indexStartObject); IDecompositor decompositor = Decompositor.Create().SetJSONString(obj).Go(); var localParts = decompositor.GetParts(); return(localParts); } else if (parts[1].Contains("\"")) { var cleanPart = parts[1].Trim().Trim(new char[] { '\t', '\r', '\n', '\"' }); return(cleanPart); } else if ((parts[1].Contains(".") || parts[1].Contains(",")) && !(parts[1].Contains("[") || parts[1].Contains("]")) && !(parts[1].Contains("\""))) { var cleanPart = parts[1].Trim(new char[] { '\t', '\r', '\n' }); if (culture.Name == "ru-RU") { cleanPart = cleanPart.Replace('.', ','); } resultObj = Convert.ToDouble(cleanPart); return(resultObj); } else if (parts[1].Contains("[") || parts[1].Contains("]")) { var cleanPart = parts[1].Trim(new char[] { '\t', '\r', '\n' }); cleanPart = cleanPart.Replace('[', ' ').Replace(']', ' '); var numbers = cleanPart.Split(new char[] { ',' }); if (numbers.Length > 0) { if (numbers[0].Contains('.')) { if (culture.Name == "ru-RU") { for (int i = 0; i < numbers.Length; i++) { numbers[i] = numbers[i].Replace('.', ','); } } var doubleArray = new double[numbers.Length]; for (int i = 0; i < numbers.Length; i++) { doubleArray[i] = Convert.ToDouble(numbers[i]); } return(doubleArray); } else { var array = new int[numbers.Length]; for (int i = 0; i < numbers.Length; i++) { array[i] = Convert.ToInt32(numbers[i]); } return(array); } } else { return(resultObj); } } else { var cleanPart = parts[1].Trim(new char[] { '\t', '\r', '\n' }); return(Convert.ToInt32(cleanPart)); } } else { return(null); } } else { return(null); } }