internal static Schema GetSchema(Guid guid, string schemaName, IDictionary <string, ISet <string> > values) { // Ensure that the schema being generated is unique - // - otherwise, return the existing one. Schema schema = Schema.Lookup(guid); if (schema == null) { // 1. Create and name a new schema SchemaBuilder schemaBuilder = new SchemaBuilder(guid); schemaBuilder.SetSchemaName(schemaName); // 2. Set the read/write access schemaBuilder.SetReadAccessLevel(AccessLevel.Public); schemaBuilder.SetWriteAccessLevel(AccessLevel.Vendor); schemaBuilder.SetVendorId(VENDOR_ID); // 3. Define one or more fields of data foreach (string key in values.Keys) { if (schemaBuilder.AcceptableName(key)) { schemaBuilder.AddArrayField(key, typeof(string)); } else { System.Diagnostics.Trace.Write($"{key}"); } } schema = schemaBuilder.Finish(); } return(schema); }
public void testNames() { string test; string testA; string testB; SchemaBuilder sb = new SchemaBuilder(Guid.NewGuid()); // failed - the "." is no good testA = Util.GetVendorId(); w.WriteLineAligned($"is ok?| {testA}| ", $"{sb.AcceptableName(testA)}"); // worked testA = Util.GetVendorId().Replace(".", "_"); w.WriteLineAligned($"is ok?| {testA}| ", $"{sb.AcceptableName(testA)}"); // this worked (but see below) testB = AppRibbon.Doc.Title; test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); // this worked (but see below) testB = AppRibbon.Doc.Title.Replace(' ', '_'); test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); // this worked (but see below) testB = AppRibbon.Doc.Title.Replace(" ", null); test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); // this failed because the spaces are no-good // the above titles worked because the model's title already has no spaces testB = "this is a test"; test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); // worked (eliminated the spaces) testB = "this is a test".Replace(" ", null); test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); // worked (eliminate the spaces) testB = "this is a test".Replace(" ", ""); test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); testB = "this is a test TEST+123-456&789 =0"; testB = Regex.Replace(testB, @"[^0-9a-zA-Z]", ""); test = (testA + "_" + testB); w.WriteLineAligned($"is ok?| {test}| ", $"{sb.AcceptableName(test)}"); w.ShowMsg(); }