private AssociationStruct GetAssociation(string data) { AssociationStruct st = new AssociationStruct(); Regex filterName = new Regex(regexPatterns.GetValue); //.......................Dependent........................... //........................................................... var matchValue = regexPatterns.GetMatches(data, regexPatterns.ReferentialConstraint, RegexOptions.Singleline); if (matchValue.Count > 0) { data = matchValue[0].Value; } matchValue = regexPatterns.GetMatches(data, regexPatterns.Principal); if (matchValue.Count > 0) { st.PrincipalTableName = Filter(regexPatterns.GetMatch(matchValue[0].Value, regexPatterns.GetValue).Value); st.PrincipalWithoutRoleTableName = Filter(regexPatterns.GetMatch(matchValue[0].Value, regexPatterns.GetValue).Value); } Regex regPrincipal = new Regex(@".*</Principal>", RegexOptions.Singleline); matchValue = regPrincipal.Matches(data); if (matchValue.Count > 0) { var tMatchValue = regexPatterns.GetMatches(matchValue[0].Value, regexPatterns.PropertyRef); if (tMatchValue.Count > 0) { st.Principal = Filter(regexPatterns.GetMatch(tMatchValue[0].Value, regexPatterns.GetValue).Value); } } //.......................Dependent........................... //........................................................... Regex regTbName = new Regex(@"<Dependent Role=\W?.*\W?>"); matchValue = regTbName.Matches(data); if (matchValue.Count > 0) { st.DependentTableName = Filter(filterName.Match(matchValue[0].Value).Value); st.DependentWithoutRolTableName = Filter(filterName.Match(matchValue[0].Value).Value); } matchValue = regexPatterns.GetMatches(data, regexPatterns.Dependent, RegexOptions.Singleline); if (matchValue.Count > 0) { var tMatchValue = regexPatterns.GetMatches(matchValue[0].Value, regexPatterns.PropertyRef); st.Dependent = Filter(regexPatterns.GetMatch(tMatchValue[0].Value, regexPatterns.GetValue).Value); } return(st); }
private void ProcessAssociation(struc[] data, AssociationStruct[] associatioData) { for (int i = 0; i < data.Length; i++) { var tbName = data[i].TableName; var association = associatioData.Where(p => p.DependentTableName == tbName).Distinct().ToArray(); data[i].Ass = Distinct(association); } }
private AssociationStruct[] Distinct(AssociationStruct[] input) { Queue<AssociationStruct> res = new Queue<AssociationStruct>(); for (int i = 0; i < input.Length; i++) { if (res.Where(p => p.Dependent == input[i].Dependent && p.DependentTableName == input[i].DependentTableName && p.Principal == input[i].Principal && p.PrincipalTableName == input[i].PrincipalTableName).FirstOrDefault() == null) res.Enqueue(input[i]); } return res.ToArray(); }
private AssociationStruct GetAssociation(string data) { AssociationStruct st = new AssociationStruct(); Regex filterName = new Regex(regexPatterns.GetValue); //.......................Dependent........................... //........................................................... var matchValue = regexPatterns.GetMatches(data, regexPatterns.ReferentialConstraint, RegexOptions.Singleline); if (matchValue.Count > 0) data = matchValue[0].Value; matchValue = regexPatterns.GetMatches(data, regexPatterns.Principal); if (matchValue.Count > 0) { st.PrincipalTableName = Filter(regexPatterns.GetMatch(matchValue[0].Value, regexPatterns.GetValue).Value); st.PrincipalWithoutRoleTableName = Filter(regexPatterns.GetMatch(matchValue[0].Value, regexPatterns.GetValue).Value); } Regex regPrincipal = new Regex(@".*</Principal>", RegexOptions.Singleline); matchValue = regPrincipal.Matches(data); if (matchValue.Count > 0) { var tMatchValue = regexPatterns.GetMatches(matchValue[0].Value, regexPatterns.PropertyRef); if (tMatchValue.Count > 0) st.Principal = Filter(regexPatterns.GetMatch(tMatchValue[0].Value, regexPatterns.GetValue).Value); } //.......................Dependent........................... //........................................................... Regex regTbName = new Regex(@"<Dependent Role=\W?.*\W?>"); matchValue = regTbName.Matches(data); if (matchValue.Count > 0) { st.DependentTableName = Filter(filterName.Match(matchValue[0].Value).Value); st.DependentWithoutRolTableName = Filter(filterName.Match(matchValue[0].Value).Value); } matchValue = regexPatterns.GetMatches(data, regexPatterns.Dependent, RegexOptions.Singleline); if (matchValue.Count > 0) { var tMatchValue = regexPatterns.GetMatches(matchValue[0].Value, regexPatterns.PropertyRef); st.Dependent = Filter(regexPatterns.GetMatch(tMatchValue[0].Value, regexPatterns.GetValue).Value); } return st; }