public void TestExtensions() { using (Stream stream = Resources.GetXmlDocumentStream("extensions")) { Assert.IsNotNull(stream); WXMLModel model = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(model); Assert.IsNotNull(model.Extensions[new Extension("x")]); var xdoc = model.Extensions[new Extension("x")]; Assert.IsNotNull(xdoc); Assert.AreEqual("extension", xdoc.Name.LocalName); var greet = xdoc.Element(XName.Get("greeting", xdoc.GetDefaultNamespace().NamespaceName)); Assert.IsNotNull(greet); Assert.AreEqual("greeting", greet.Name.LocalName); Assert.AreEqual("hi!", greet.Value); EntityDefinition e11 = model.GetEntities().Single(e => e.Identifier == "e11"); Assert.IsNotNull(e11.Extensions[new Extension("x")]); xdoc = e11.Extensions[new Extension("x")]; greet = xdoc.Element(XName.Get("greeting", xdoc.GetDefaultNamespace().NamespaceName)); Assert.IsNotNull(greet); Assert.AreEqual("greeting", greet.Name.LocalName); Assert.AreEqual("hi!", greet.Value); } }
public void TestFillTables() { Worm_CodeGen_Core_OrmXmlParserAccessor parser = null; using (XmlReader rdr = XmlReader.Create(GetSampleFileStream())) { object privateParser = Worm_CodeGen_Core_OrmXmlParserAccessor.CreatePrivate(rdr); parser = new Worm_CodeGen_Core_OrmXmlParserAccessor(privateParser); parser.Read(); } parser.FillSourceFragments(); WXMLModel ormObjectDef = parser.Model; Assert.AreEqual <int>(6, ormObjectDef.GetSourceFragments().Count()); Assert.IsTrue(ormObjectDef.GetSourceFragments().Any( match => match.Identifier == "tblAlbums" && match.Name == "albums")); Assert.IsTrue(ormObjectDef.GetSourceFragments().Any( match => match.Identifier == "tblArtists" && match.Name == "artists")); Assert.IsTrue(ormObjectDef.GetSourceFragments().Any( match => match.Identifier == "tblAl2Ar" && match.Name == "al2ar")); Assert.IsTrue(ormObjectDef.GetSourceFragments().Any( match => match.Identifier == "tblSiteAccess" && match.Name == "sites_access")); }
public void TestFillEntityTables() { Worm_CodeGen_Core_OrmXmlParserAccessor parser; parser = null; using (XmlReader rdr = XmlReader.Create(GetSampleFileStream())) { object privateParser = Worm_CodeGen_Core_OrmXmlParserAccessor.CreatePrivate(rdr); parser = new Worm_CodeGen_Core_OrmXmlParserAccessor(privateParser); parser.Read(); } parser.FillSourceFragments(); parser.FindEntities(); WXMLModel ormObjectDef = parser.Model; EntityDefinition entity = ormObjectDef.GetEntities() .Single(match => match.Identifier == "eArtist" && match.Name == "Artist"); Assert.AreEqual <int>(2, entity.GetSourceFragments().Count()); Assert.IsTrue(entity.GetSourceFragments().Any(match => match.Identifier.Equals("tblArtists") && match.Name.Equals("artists"))); Assert.IsTrue(entity.GetSourceFragments().Any(match => match.Identifier.Equals("tblSiteAccess") && match.Name.Equals("sites_access"))); }
public void ApplyModelChanges(WXMLModel changes) { string fileName = Path.Combine(_path, "entities.xml"); WXMLModel model = WXMLModel.LoadFromXml(fileName); model.Merge(changes); string user = "******"; if (System.Web.HttpContext.Current != null && !string.IsNullOrEmpty(System.Web.HttpContext.Current.User.Identity.Name)) { user = System.Web.HttpContext.Current.User.Identity.Name; } lock (typeof(WmsDefinitionManager)) { File.Copy(fileName, Path.GetFullPath(_path + string.Format(@"\EntityArchive\{0}~{1}~{2}.xml", user, DateTime.UtcNow.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture), Math.Round((DateTime.Now - DateTime.Today).TotalSeconds))) ); FileAttributes attr = File.GetAttributes(fileName); if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { File.SetAttributes(fileName, attr & ~FileAttributes.ReadOnly); } XmlDocument xdoc = model.GetXmlDocument(); xdoc.Save(fileName); } }
public void TestExtensionSave() { using (Stream stream = Resources.GetXmlDocumentStream("suppressed")) { Assert.IsNotNull(stream); WXMLModel model = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(model); var xdoc = new XElement("greeting", "hi!"); //xdoc.LoadXml("<greeting>hi!</greeting>"); model.Extensions[new Extension("f")] = xdoc; XmlDocument res = model.GetXmlDocument(); Assert.IsNotNull(res); XmlNamespaceManager nsmgr = new XmlNamespaceManager(res.NameTable); nsmgr.AddNamespace("x", WXMLModel.NS_URI); XmlElement extension = res.SelectSingleNode("/x:WXMLModel/x:extensions/x:extension[@name='f']", nsmgr) as XmlElement; Assert.IsNotNull(extension); Assert.AreEqual("greeting", extension.ChildNodes[0].Name); Assert.AreEqual("hi!", extension.ChildNodes[0].InnerText); } }
public override void GenerateCode(AssemblyBuilder assemblyBuilder) { base.GenerateCode(assemblyBuilder); WXMLModel model = null; using (XmlReader xr = new XmlTextReader(_fileName)) { model = WXMLModel.LoadFromXml(xr); } IRepositoryProvider prov = WmsDefinitionManager.GetRepositoryProvider(); foreach (CodeCompileUnit unit in prov.CreateCompileUnits(model)) { assemblyBuilder.AddCodeCompileUnit(this, unit); } string fn = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(assemblyBuilder.GetTempFilePhysicalPath("dll"))); AssemblyLoadEventHandler d = null; d = delegate(object sender, AssemblyLoadEventArgs args) { if (args.LoadedAssembly.ManifestModule.Name.StartsWith(fn)) { prov.SetRepositoryAssembly(args.LoadedAssembly); AppDomain.CurrentDomain.AssemblyLoad -= d; } }; AppDomain.CurrentDomain.AssemblyLoad += d; }
public void TestGenerateScript() { var p = new MSSQLProvider(GetTestDB(), null); var sv = p.GetSourceView(); var model = new WXMLModel(); var smc = new SourceToModelConnector(sv, model); smc.ApplySourceViewToModel(); Assert.AreEqual(28, model.GetActiveEntities().Count()); Assert.AreEqual(32, model.GetSourceFragments().Count()); var msc = new ModelToSourceConnector(new SourceView(), model); string script = msc.GenerateSourceScript(p, false); Assert.IsFalse(string.IsNullOrEmpty(script)); Assert.AreEqual(32, new Regex("CREATE TABLE ").Matches(script).Count); Console.WriteLine(script); }
public void TestDropProperty() { MSSQLProvider p = new MSSQLProvider(GetTestDB(), null); SourceView sv = p.GetSourceView(null, "aspnet_Applications"); Assert.AreEqual(4, sv.SourceFields.Count); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); Assert.AreEqual(4, model.GetActiveEntities().First().GetActiveProperties().Count()); SourceFieldDefinition fld = sv.SourceFields.Find(item => item.SourceFieldExpression == "[Description]"); sv.SourceFields.Remove(fld); Assert.AreEqual(3, sv.SourceFields.Count); c.ApplySourceViewToModel(true, relation1to1.Default, true, true, false); Assert.AreEqual(3, model.GetActiveEntities().First().GetActiveProperties().Count()); sv.SourceFields.Add(fld); Assert.AreEqual(4, sv.SourceFields.Count); c.ApplySourceViewToModel(true, relation1to1.Default, true, true, false); Assert.AreEqual(4, model.GetActiveEntities().First().GetActiveProperties().Count()); }
public void TestAlterEntities() { MSSQLProvider p = new MSSQLProvider(GetTestDB(), null); SourceView sv = p.GetSourceView(null, "ent1,ent2,1to2"); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); Assert.AreEqual(3, model.GetSourceFragments().Count()); Assert.AreEqual(2, model.GetEntities().Count()); sv = p.GetSourceView(null, "ent1,ent2,1to2"); c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); Assert.AreEqual(3, model.GetSourceFragments().Count()); Assert.AreEqual(2, model.GetEntities().Count()); }
protected override IEnumerable <Pair> GenerateElements(string inputFileContent) { try { //Validate the XML file against the schema WXMLModel ormObjectsDef; using (StringReader contentReader = new StringReader(inputFileContent)) { try { using (XmlReader rdr = XmlReader.Create(contentReader)) { ormObjectsDef = WXMLModel.LoadFromXml(rdr, new XmlUrlResolver()); } } catch (Exception e) { this.GeneratorError(4, e.ToString(), 1, 1); //Returning null signifies that generation has failed return(null); } } return(new Enumer(ormObjectsDef, GetDefaultExtension())); } catch (Exception e) { this.GeneratorError(4, e.ToString(), 1, 1); //Returning null signifies that generation has failed return(null); } }
public void ApplyModelChanges(string script) { using (StringReader sr = new StringReader(script)) { ApplyModelChanges(WXMLModel.LoadFromXml(new XmlTextReader(sr))); } }
public void TestFillModelRelations() { MSSQLProvider p = new MSSQLProvider(GetTestDB(), null); SourceView sv = p.GetSourceView(null, "aspnet_Applications,aspnet_Paths"); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); Assert.AreEqual(2, model.GetSourceFragments().Count()); Assert.AreEqual(2, model.GetEntities().Count()); var aspnet_Applications = model.GetEntity("e_dbo_aspnet_Applications"); Assert.IsNotNull(aspnet_Applications); var aspnet_Paths = model.GetEntity("e_dbo_aspnet_Paths"); Assert.IsNotNull(aspnet_Paths); Assert.IsNotNull(aspnet_Paths.GetProperty("Application")); Assert.IsNotNull(aspnet_Paths.GetProperty("PathId")); Assert.IsNotNull(aspnet_Paths.GetProperty("Path")); Assert.IsNotNull(aspnet_Paths.GetProperty("LoweredPath")); Assert.AreEqual(1, aspnet_Applications.One2ManyRelations.Count()); Assert.AreEqual(aspnet_Paths, aspnet_Applications.One2ManyRelations.First().Entity); }
public void TestGenerateScriptDropConstraint() { var p = new MSSQLProvider(GetTestDB(), null); var sv = p.GetSourceView(); var model = new WXMLModel(); var smc = new SourceToModelConnector(sv, model); smc.ApplySourceViewToModel(false, relation1to1.Hierarchy, true, true, false); Assert.AreEqual(28, model.GetActiveEntities().Count()); Assert.AreEqual(32, model.GetSourceFragments().Count()); EntityPropertyDefinition prop = model.GetActiveEntities().SelectMany(item => item.GetProperties().OfType <EntityPropertyDefinition>()).First(); SourceConstraint c = new SourceConstraint(SourceConstraint.UniqueConstraintTypeName, "xxx"); c.SourceFields.AddRange(prop.SourceFields.Cast <SourceFieldDefinition>()); prop.SourceFragment.Constraints.Add(c); var msc = new ModelToSourceConnector(p.GetSourceView(), model); var tbl = msc.SourceView.GetSourceFragments().Single(item => item.Selector == prop.SourceFragment.Selector && item.Name == prop.SourceFragment.Name); tbl.Constraints.Add(new SourceConstraint(SourceConstraint.UniqueConstraintTypeName, "xxx")); string script = msc.GenerateSourceScript(p, false); Assert.IsFalse(string.IsNullOrEmpty(script), script); Assert.AreEqual(1, new Regex("DROP CONSTRAINT").Matches(script).Count); }
private WXMLModel Normalize(WXMLModel model) { XmlDocument xdoc = model.GetXmlDocument(); Console.WriteLine(xdoc.OuterXml); return(WXMLModel.LoadFromXml(new XmlNodeReader(xdoc))); }
public void TestFillModel() { MSSQLProvider p = new MSSQLProvider(GetTestDB(), null); SourceView sv = p.GetSourceView(null, "ent1,ent2,1to2"); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); Assert.AreEqual(3, model.GetSourceFragments().Count()); Assert.AreEqual(2, model.GetEntities().Count()); Assert.IsNotNull(model.GetEntity("e_dbo_ent1")); Assert.IsNotNull(model.GetEntity("e_dbo_ent2")); Assert.AreEqual(1, model.GetEntity("e_dbo_ent1").GetProperties().Count()); Assert.AreEqual(1, model.GetEntity("e_dbo_ent1").GetPkProperties().Count()); Assert.IsTrue(model.GetEntity("e_dbo_ent1").GetPkProperties().First().HasAttribute(Field2DbRelations.PrimaryKey)); Assert.AreEqual(2, model.GetEntity("e_dbo_ent2").GetProperties().Count()); Assert.AreEqual(1, model.GetRelations().Count()); }
public void TestGenerateComplex() { SourceView sv = TestsSourceModel.TestsSourceModel.CreateComplexSourceView(); var model = new WXMLModel(); var smc = new SourceToModelConnector(sv, model); smc.ApplySourceViewToModel(); Assert.AreEqual(2, model.GetActiveEntities().Count()); Assert.AreEqual(4, model.GetActiveRelations().Count()); model.GetActiveRelations().First().Constraint = RelationConstraint.Unique; var msc = new ModelToSourceConnector(new SourceView(), model); var p = new MSSQLProvider(null, null); string script = msc.GenerateSourceScript(p, false); Assert.IsFalse(string.IsNullOrEmpty(script)); Console.WriteLine(script); Assert.AreEqual(6, new Regex("CREATE TABLE ").Matches(script).Count); Assert.AreEqual(2, new Regex("PRIMARY KEY CLUSTERED").Matches(script).Count); Assert.AreEqual(8, new Regex("FOREIGN KEY").Matches(script).Count); Assert.AreEqual(1, new Regex("UNIQUE CLUSTERED").Matches(script).Count); }
public void TestAlterEntity() { WXMLModel newModel = GetModel("suppressed"); Assert.IsNotNull(newModel); Assert.AreEqual(2, newModel.GetActiveEntities().Count()); EntityDefinition e = newModel.GetActiveEntities().Single(item => item.Identifier == "e1"); EntityDefinition e2 = newModel.GetActiveEntities().Single(item => item.Identifier == "e11"); Assert.AreEqual(e2.BaseEntity, e); Assert.AreEqual("E1", e.Name); e.Name = "xxx"; Assert.AreEqual(e2.BaseEntity, e); WXMLModel model = GetModel("suppressed"); model.Merge(Normalize(newModel)); Assert.AreEqual(2, model.GetActiveEntities().Count()); e = model.GetActiveEntities().Single(item => item.Identifier == "e1"); Assert.AreEqual("xxx", e.Name); }
public void TestAddEntity() { using (Stream stream = Resources.GetXmlDocumentStream("suppressed")) { Assert.IsNotNull(stream); WXMLModel model = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(model); Assert.AreEqual(2, model.GetActiveEntities().Count()); WXMLModel newModel = new WXMLModel(); EntityDefinition newEntity = new EntityDefinition("ee", "ee", string.Empty, string.Empty, newModel); SourceFragmentRefDefinition sf = new SourceFragmentRefDefinition(newModel.GetOrCreateSourceFragment("dbo", "ee")); newEntity.AddSourceFragment(sf); newEntity.AddProperty(new ScalarPropertyDefinition(newEntity, "ID", "ID", Field2DbRelations.None, string.Empty, newModel.GetOrCreateType(typeof(Int32)), new SourceFieldDefinition(sf, "id"), AccessLevel.Private, AccessLevel.Public)); model.Merge(Normalize(newModel)); Assert.AreEqual(3, model.GetActiveEntities().Count()); Assert.AreEqual(1, model.GetActiveEntities().Single(item => item.Identifier == "ee").GetActiveProperties().Count()); } }
public Enumer(WXMLModel model, string ext) { _model = model; //Create the CodeCompileUnit from the passed-in XML file WXMLCodeDomGeneratorSettings settings = new WXMLCodeDomGeneratorSettings(); settings.EntitySchemaDefClassNameSuffix = "SchemaDef"; LinqToCodedom.CodeDomGenerator.Language language; switch (ext) { case ".cs": settings.LanguageSpecificHacks = LanguageSpecificHacks.CSharp; language = LinqToCodedom.CodeDomGenerator.Language.CSharp; break; case ".vb": settings.LanguageSpecificHacks = LanguageSpecificHacks.VisualBasic; language = LinqToCodedom.CodeDomGenerator.Language.VB; break; default: throw new NotSupportedException(ext); //case ".js": // settings.LanguageSpecificHacks = LanguageSpecificHacks.VisualBasic; // break; } settings.PrivateMembersPrefix = "m_"; //settings.Split = false; //ormObjectsDef.GenerateSchemaOnly WormCodeDomGenerator generator = new WormCodeDomGenerator(model, settings); if (model.GenerateSingleFile) { CodeCompileFileUnit compileUnit = generator.GetFullSingleUnit(language); _units = new List <Pair>() { new Pair() { Unit = compileUnit } }; } else { _units = new List <Pair>(); foreach (var entity in model.GetActiveEntities()) { _units.Add(new Pair() { Unit = generator.GetEntityCompileUnits(entity.Identifier, language)[0] }); } } }
public void Init(string tempPath, WXMLModel model) { LinqCodeDomGenerator gen = new LinqCodeDomGenerator(model, new WXML.CodeDom.WXMLCodeDomGeneratorSettings()); Assembly ass = gen.Compile(/*tempPath + "\\Wms.Data.dll", */ LinqToCodedom.CodeDomGenerator.Language.CSharp); _ctxName = model.Namespace + "." + model.LinqSettings.ContextName; _repositoryType = ass.GetType(_ctxName); }
public void TestM2MSimilarRelations() { SourceView sv = CreateComplexSourceView(); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); }
public void TestAdventureWorks() { SourceView view; BinaryFormatter f = new BinaryFormatter { AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple }; ResolveEventHandler d = null; d = (sender, args) => { AppDomain.CurrentDomain.AssemblyResolve -= d; return(typeof(WXMLModel).Assembly); }; AppDomain.CurrentDomain.AssemblyResolve += d; Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream fs = assembly.GetManifestResourceStream( string.Format("{0}.TestFiles.{1}", assembly.GetName().Name, "AdventureWorks.sourceview"))) { Assert.IsNotNull(fs); view = (SourceView)f.Deserialize(fs); } Assert.IsNotNull(view); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(view, model); c.ApplySourceViewToModel(false, relation1to1.Default, true, true, false); Assert.AreEqual(70, model.GetActiveEntities().Count()); Assert.AreEqual(70, model.GetSourceFragments().Count()); model = new WXMLModel(); c = new SourceToModelConnector(view, model); c.ApplySourceViewToModel(false, relation1to1.Unify, true, true, false); Assert.AreEqual(67, model.GetActiveEntities().Count()); Assert.AreEqual(70, model.GetSourceFragments().Count()); model = new WXMLModel(); c = new SourceToModelConnector(view, model); c.ApplySourceViewToModel(false, relation1to1.Hierarchy, true, true, false); Assert.AreEqual(70, model.GetActiveEntities().Count()); Assert.AreEqual(70, model.GetSourceFragments().Count()); }
public void TestAlterEntity_ChangeTable() { using (Stream stream = Resources.GetXmlDocumentStream("suppressed")) { Assert.IsNotNull(stream); WXMLModel newModel = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(newModel); Assert.AreEqual(2, newModel.GetActiveEntities().Count()); EntityDefinition e = newModel.GetActiveEntities().Single(item => item.Identifier == "e1"); Assert.AreEqual(1, e.GetSourceFragments().Count()); Assert.AreEqual(1, newModel.GetSourceFragments().Count()); Assert.AreEqual("tbl1", e.GetSourceFragments().First().Name); Assert.IsTrue(string.IsNullOrEmpty(e.GetSourceFragments().First().Selector)); SourceFragmentRefDefinition sf = new SourceFragmentRefDefinition( newModel.GetOrCreateSourceFragment("dbo", "table")); //foreach (SourceFragmentRefDefinition rsf in e.GetSourceFragments()) //{ // e.MarkAsDeleted(rsf); //} e.ClearSourceFragments(); e.AddSourceFragment(sf); foreach (PropertyDefinition property in e.GetProperties()) { property.SourceFragment = sf; } WXMLModel model = GetModel("suppressed"); model.Merge(Normalize(newModel)); e = model.GetActiveEntities().Single(item => item.Identifier == "e1"); Assert.AreEqual(1, e.GetSourceFragments().Count()); Assert.AreEqual(2, model.GetSourceFragments().Count()); Assert.AreEqual("table", e.GetSourceFragments().First().Name); Assert.AreEqual("dbo", e.GetSourceFragments().First().Selector); e = model.GetActiveEntities().Single(item => item.Identifier == "e11"); Assert.AreEqual(1, e.GetSourceFragments().Count()); Assert.AreEqual("table", e.GetSourceFragments().First().Name); Assert.AreEqual("dbo", e.GetSourceFragments().First().Selector); } }
public void TestO2MSimilarRelations() { SourceView sv = new SourceView(); SourceFragmentDefinition sf1 = new SourceFragmentDefinition("tbl1", "tbl1", "dbo"); SourceFragmentDefinition sf2 = new SourceFragmentDefinition("tbl2", "tbl2", "dbo"); SourceFieldDefinition pkField = new SourceFieldDefinition(sf1, "id", "int") { IsNullable = false }; sv.SourceFields.Add(pkField); sv.SourceFields.Add(new SourceFieldDefinition(sf2, "id", "int") { IsNullable = false }); sv.SourceFields.Add(new SourceFieldDefinition(sf2, "prop1_id", "int")); sv.SourceFields.Add(new SourceFieldDefinition(sf2, "prop2_id", "int")); SourceConstraint pk = new SourceConstraint(SourceConstraint.PrimaryKeyConstraintTypeName, "pk1"); pk.SourceFields.Add(pkField); SourceConstraint pk2 = new SourceConstraint(SourceConstraint.PrimaryKeyConstraintTypeName, "pk2"); pk2.SourceFields.Add(sv.GetSourceFields(sf2).Single(item => item.SourceFieldExpression == "id")); SourceConstraint fk1 = new SourceConstraint(SourceConstraint.ForeignKeyConstraintTypeName, "fk1"); fk1.SourceFields.Add(sv.GetSourceFields(sf2).Single(item => item.SourceFieldExpression == "prop1_id")); SourceConstraint fk2 = new SourceConstraint(SourceConstraint.ForeignKeyConstraintTypeName, "fk2"); fk2.SourceFields.Add(sv.GetSourceFields(sf2).Single(item => item.SourceFieldExpression == "prop2_id")); sf1.Constraints.Add(pk); sf2.Constraints.Add(pk2); sf2.Constraints.Add(fk1); sf2.Constraints.Add(fk2); sv.References.Add(new SourceReferences(pk, fk1, pkField, sv.GetSourceFields(sf2).Single(item => item.SourceFieldExpression == "prop1_id") )); sv.References.Add(new SourceReferences(pk, fk2, pkField, sv.GetSourceFields(sf2).Single(item => item.SourceFieldExpression == "prop2_id") )); WXMLModel model = new WXMLModel(); SourceToModelConnector c = new SourceToModelConnector(sv, model); c.ApplySourceViewToModel(); }
public void TestWriteSchemaBased() { using (Stream stream = Resources.GetXmlDocumentStream("SchemaBased")) { WXMLModel model = WXMLModel.LoadFromXml(XmlReader.Create(stream), new TestXmlUrlResolver()); Assert.IsNotNull(model); var wxmlDocumentSet = model.GetWXMLDocumentSet(new WXMLModelWriterSettings()); Assert.IsNotNull(wxmlDocumentSet); } }
public IEnumerable <System.CodeDom.CodeCompileUnit> CreateCompileUnits(WXMLModel model) { WXMLCodeDomGeneratorSettings settings = new WXML.CodeDom.WXMLCodeDomGeneratorSettings(); CodeCompileUnit modificationTracketUnit = GenerateModificationTracker(model, settings); LinqCodeDomGenerator gen = new LinqCodeDomGenerator(model, settings); LinqToCodedom.CodeDomGenerator.Language lang = LinqToCodedom.CodeDomGenerator.Language.CSharp; return(new CodeCompileUnit[] { gen.GetCompileUnit(lang), modificationTracketUnit }); }
public void TestLinqContext() { using (Stream stream = Resources.GetXmlDocumentStream("linq-context")) { WXMLModel model = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(model); WXMLDocumentSet wxmlDocumentSet = model.GetWXMLDocumentSet(new WXMLModelWriterSettings()); Assert.IsNotNull(wxmlDocumentSet); } }
//public WmsDefinitionManager() //{ // _path = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Meta/"); //} //public static IQueryable GetEntityQuery(string name) //{ // string propName = WXMLCodeDomGeneratorNameHelper.GetMultipleForm(name); // if (_provider == null) // _provider = GetRepositoryProvider(); // PropertyInfo pi = _provider.RepositoryType.GetProperty(propName); // return (IQueryable)pi.GetValue(GetRepository(), null); //} //public static object GetRepository() //{ // return _provider.CreateRepository(); //} public static IRepositoryProvider GetRepositoryProvider(string tempPath, WXMLModel model) { if (_provider == null) { Type pt = Type.GetType(ConfigurationManager.AppSettings["repositoryProvider"]); _provider = (IRepositoryProvider)Activator.CreateInstance(pt); _provider.Init(tempPath, model); } return(_provider); }
private static WXMLModel GetModel(string fileName) { using (Stream stream = Resources.GetXmlDocumentStream(fileName)) { Assert.IsNotNull(stream); WXMLModel model = WXMLModel.LoadFromXml(new XmlTextReader(stream)); Assert.IsNotNull(model); return(model); } }
public void TestCheckCacheRequired() { WXMLModel model; using (Stream stream = Resources.GetXmlDocumentStream("SchemaBased")) { model = WXMLModel.LoadFromXml(XmlReader.Create(stream), new TestXmlUrlResolver()); Assert.IsNotNull(model); } model.GetActiveEntities().Single(item => item.Identifier == "eAlbum").CacheCheckRequired = true; TestCSCodeInternal(model, new WXMLCodeDomGeneratorSettings()); }