public OOBNodeTest() { using (ShimsContext.Create()) { fds = new fake.ShimDataSource(); ods = new OOBDataSource(fds, "fake"); } }
public OOBTreeTest() { using (ShimsContext.Create()) { fds = new opsfake.ShimDataSource(); fds.NameGet = () => { return "Friendly Situation - Friendly Equipment"; }; fds.IdGet = () => { return "b8725bd2-1aa2-4a06-895b-d87a8028d75a"; }; ods = new OOBDataSource(fds, "fake"); } }
public OOBNode(String uid, String name, String desc, OOBDataSource ods, String ntype) { _children = new SortedDictionary <String, OOBNode>(); _ctype = childtype.NONE; setNtype(ntype); _key = uid; _name = name; _parent = null; ds = ods; _desc = desc; }
public OOBDataSourceTests() { using (ShimsContext.Create()) { fds = new fake.ShimDataSource(); fds.NameGet = () => { return "Friendly Situation - Friendly Equipment"; }; fds.IdGet = () => { return "b8725bd2-1aa2-4a06-895b-d87a8028d75a"; }; using (FileStream fs = File.OpenRead("C:/Dev/VS/DefenseSolution/OrderOfBattle/OrderOfBattleUnitTests/resources/oobdatasources.txt")) { byte[] b = new byte[1024]; UTF8Encoding temp = new UTF8Encoding(true); while (fs.Read(b, 0, b.Length) > 0) { odsString += (temp.GetString(b)); } } serialized = odsString.Split(';')[1]; ods = OOBDataSource.marshalODS(fds, serialized); } }
public static OOBDataSource marshalODS(DataSource ds, String odsString) { String[] odsFields = odsString.Split(','); String key = null; String name = null; String id = null; String useiconstring = null; Boolean useicon = false; String uid = null; String hf = null; String df = null; String baseDesc = null; String baseLabel = null; String dtstring = null; String[] lflds = null; String[] dflds = null; foreach (String f in odsFields) { String[] vals = f.Split(':'); if (vals[0].Equals("KEY")) { key = vals[1]; } if (vals[0].Equals("NAME")) { name = vals[1]; } if (vals[0].Equals("ID")) { id = vals[1]; } if (vals[0].Equals("USEICON")) { useiconstring = vals[1]; if (useiconstring.ToLower().Equals("true")) { useicon = true; } } if (vals[0].Equals("UIDFLD")) { uid = vals[1]; } if (vals[0].Equals("HFFLD")) { hf = vals[1]; } if (vals[0].Equals("LBLFLDS")) { lflds = vals[1].Split('|'); } if (vals[0].Equals("DESCFLD")) { df = vals[1]; } if (vals[0].Equals("BASEDESC")) { baseDesc = vals[1]; } if (vals[0].Equals("BASELABEL")) { baseLabel = vals[1]; } if (vals[0].Equals("DESCTYPE")) { dtstring = vals[1]; } if (vals[0].Equals("DESCFLDS")) { dflds = vals[1].Split('|'); } } OOBDataSource ods = new OOBDataSource(ds, key); ods.UIDField = uid; ods.HFField = hf; ods.DescField = df; ods.UseIcon = useicon; foreach (KeyValuePair <String, String> p in ods.Tokens) { baseDesc = baseDesc.Replace(p.Key, p.Value); } ods.BaseDescription = baseDesc; foreach (KeyValuePair <String, String> p in ods.Tokens) { baseLabel = baseLabel.Replace(p.Key, p.Value); } ods.BaseLabel = baseLabel; DescriptionType dtype = DescriptionType.None; if (dtstring.Equals("None")) { dtype = DescriptionType.None; } else if (dtstring.Equals("SingleField")) { dtype = DescriptionType.SingleField; } else if (dtstring.Equals("Custom")) { dtype = DescriptionType.Custom; } ods.DescType = dtype; if (lflds != null) { foreach (String l in lflds) { ods.LabelFields.Add(l); } } if (dflds != null) { foreach (String l in dflds) { ods.DescriptionFields.Add(l); } } return(ods); }
public static OOBDataSource marshalODS(DataSource ds, String odsString) { String[] odsFields = odsString.Split(','); String key = null; String name = null; String id = null; String useiconstring = null; Boolean useicon = false; String uid = null; String hf = null; String df = null; String baseDesc = null; String baseLabel = null; String dtstring = null; String[] lflds = null; String[] dflds = null; foreach (String f in odsFields) { String[] vals = f.Split(':'); if (vals[0].Equals("KEY")) { key = vals[1]; } if (vals[0].Equals("NAME")) { name = vals[1]; } if (vals[0].Equals("ID")) { id = vals[1]; } if (vals[0].Equals("USEICON")) { useiconstring = vals[1]; if (useiconstring.ToLower().Equals("true")) { useicon = true; } } if (vals[0].Equals("UIDFLD")) { uid = vals[1]; } if (vals[0].Equals("HFFLD")) { hf = vals[1]; } if (vals[0].Equals("LBLFLDS")) { lflds = vals[1].Split('|'); } if (vals[0].Equals("DESCFLD")) { df = vals[1]; } if (vals[0].Equals("BASEDESC")) { baseDesc = vals[1]; } if (vals[0].Equals("BASELABEL")) { baseLabel = vals[1]; } if (vals[0].Equals("DESCTYPE")) { dtstring = vals[1]; } if (vals[0].Equals("DESCFLDS")) { dflds = vals[1].Split('|'); } } OOBDataSource ods = new OOBDataSource(ds, key); ods.UIDField = uid; ods.HFField = hf; ods.DescField = df; ods.UseIcon = useicon; foreach (KeyValuePair<String, String> p in ods.Tokens) { baseDesc = baseDesc.Replace(p.Key, p.Value); } ods.BaseDescription = baseDesc; foreach (KeyValuePair<String, String> p in ods.Tokens) { baseLabel = baseLabel.Replace(p.Key, p.Value); } ods.BaseLabel = baseLabel; DescriptionType dtype = DescriptionType.None; if (dtstring.Equals("None")) { dtype = DescriptionType.None; } else if (dtstring.Equals("SingleField")) { dtype = DescriptionType.SingleField; } else if (dtstring.Equals("Custom")) { dtype = DescriptionType.Custom; } ods.DescType = dtype; if (lflds != null) { foreach (String l in lflds) { ods.LabelFields.Add(l); } } if (dflds != null) { foreach (String l in dflds) { ods.DescriptionFields.Add(l); } } return ods; }