public override object Evaluate(BaseIterator iter) { IHasXmlNode hasXmlNode = iter.Current as IHasXmlNode; if (hasXmlNode == null) { return(string.Empty); } XmlNode node = hasXmlNode.GetNode(); if (node.OwnerDocument == null) { return(string.Empty); } XmlDocumentType documentType = node.OwnerDocument.DocumentType; if (documentType == null) { return(string.Empty); } XmlEntity xmlEntity = documentType.Entities.GetNamedItem(this.arg0.EvaluateString(iter)) as XmlEntity; if (xmlEntity == null) { return(string.Empty); } return((xmlEntity.SystemId == null) ? string.Empty : xmlEntity.SystemId); }
private XElement GetGatewayProcessElement(XmlEntity <WorkflowGatewayEntity> g) { return(new XElement(bpmn + WorkflowGatewayTypes.GetOrThrow(g.Entity.Type), new XAttribute("id", g.bpmnElementId), g.Entity.Name.HasText() ? new XAttribute("name", g.Entity.Name) : null !, GetConnections(g.Entity.ToLite()))); }
protected override void AddConstraints(XmlEntity xmlEntity, ITobascoContext tobascoContext) { Builder.AppendLine($"CREATE NONCLUSTERED INDEX IX_{xmlEntity.Name}_historie_Id"); Builder.AppendLine($"ON[dbo].{xmlEntity.Name}_historie"); Builder.AppendLine("(Id ASC)"); Builder.AppendLine("INCLUDE(ModifiedOn);"); }
public override object Evaluate(BaseIterator iter) { IHasXmlNode xn = iter.Current as IHasXmlNode; if (xn == null) { return(String.Empty); } XmlNode n = xn.GetNode(); if (n.OwnerDocument == null) { return(String.Empty); } XmlDocumentType doctype = n.OwnerDocument.DocumentType; if (doctype == null) { return(String.Empty); } XmlEntity ent = doctype.Entities.GetNamedItem(arg0.EvaluateString(iter)) as XmlEntity; if (ent == null) { return(String.Empty); } return(ent.SystemId != null ? ent.SystemId : String.Empty); }
private void Stream(XmlEntity entity) { Data.Add(new ClassSeparatorData(typeof(XmlEntity))); Data.Add(new StringData("Notation name", entity.NotationName)); Data.Add(new StringData("Public ID", entity.PublicId)); Data.Add(new StringData("System ID", entity.SystemId)); }
private XElement GetActivityProcessElement(XmlEntity <WorkflowActivityEntity> a) { return(new XElement(bpmn + WorkflowActivityTypes.GetOrThrow(a.Entity.Type), new XAttribute("id", a.bpmnElementId), new XAttribute("name", a.Entity.Name), GetConnections(a.Entity.ToLite()))); }
internal override void AddMethods(XmlEntity entityContext, ITobascoContext tobascoContext) { var entityParameter = entityContext.Name.GetParameterName(); Builder.StartMethod("public", entityContext.Name, "Save", entityContext.Name.GetObjectWithParamaterName()); foreach (var child in entityContext.GetChilds()) { Builder.AddMethodBody($"if (var {entityContext.Name}.{child.Name} != null)"); Builder.AddMethodBody("{"); Builder.AppendLine($"{entityContext.Name}.{child.Name} = {child.Name.GetFieldName()}.Save({child.Name});", Indent.ForEachBody); Builder.AddMethodBody("}"); } Builder.AddMethodBody($"{entityParameter} = _genericRepository.Save({entityParameter});"); foreach (var childCollection in entityContext.GetChildCollections()) { Builder.AddMethodBody($"foreach (var itemToSave = {entityContext.Name}.{childCollection.Name})"); Builder.AddMethodBody("{"); Builder.AppendLine($"itemToSave.{entityContext.Name}Id = {entityContext.Name.GetObjectWithParamaterName()};", Indent.ForEachBody); Builder.AppendLine($"{childCollection.Name.GetParameterName()}.Save(itemToSave);", Indent.ForEachBody); Builder.AddMethodBody("}"); } Builder.AddMethodBody($"return {entityParameter};"); Builder.EndMethod(); Builder.AppendLine(string.Empty); Builder.StartMethod("public", entityContext.Name, "GetById", "long id"); Builder.AddMethodBody("return _genericRepository.GetById(id);"); Builder.EndMethod(); }
private bool IsIfcProperty(string elementName, out int index, out IfcMetaProperty prop) { IfcType ifcType; XmlEntity xmlEntity = _currentNode as XmlEntity; if (xmlEntity != null && !IfcMetaData.TryGetIfcType(elementName.ToUpper(), out ifcType)) { IfcType t = IfcMetaData.IfcType(xmlEntity.Entity); foreach (KeyValuePair <int, IfcMetaProperty> p in t.IfcProperties) { int propIndex = p.Key; if (p.Value.PropertyInfo.Name == elementName) //this is the property to set { prop = p.Value; index = p.Key; return(true); } } } prop = null; index = -1; return(false); }
protected override void AddTriggers(XmlEntity xmlEntity, ITobascoContext tobascoContext) { Builder.StartUpdateTrigger(xmlEntity.Name); Builder.AddTriggerBody("Id"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("[RowVersion]"); foreach (var prop in xmlEntity.Properties.Where(x => x.PropertyType.Name != Enums.Datatype.ChildCollection)) { Builder.Append <SqlStringBuilder>(",").AddTriggerBody(prop.Name.GetParameterName()); } Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedOn"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedOnUTC"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("DeletedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("DeletedAt"); Builder.AddTriggerBody(")"); Builder.AddTriggerBody("SELECT"); Builder.AddTriggerBody("Deleted.Id"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.[RowVersion]"); foreach (var prop in xmlEntity.Properties.Where(x => x.PropertyType.Name != Enums.Datatype.ChildCollection)) { Builder.Append <SqlStringBuilder>(",").AddTriggerBody($"Deleted.{prop.Name.GetParameterName()}"); } Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedOn"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedOnUTC"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("NULL"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("NULL"); Builder.AddTriggerBody("FROM Deleted;"); Builder.EndTrigger(); Builder.StartDeleteTrigger(xmlEntity.Name); Builder.AddTriggerBody("Id"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("[RowVersion]"); foreach (var prop in xmlEntity.Properties.Where(x => x.PropertyType.Name != Enums.Datatype.ChildCollection)) { Builder.Append <SqlStringBuilder>(",").AddTriggerBody(prop.Name.GetParameterName()); } Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedOn"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ModifiedOnUTC"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("DeletedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("DeletedAt"); Builder.AddTriggerBody(")"); Builder.AddTriggerBody("SELECT"); Builder.AddTriggerBody("Deleted.Id"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.[RowVersion]"); foreach (var prop in xmlEntity.Properties.Where(x => x.PropertyType.Name != Enums.Datatype.ChildCollection)) { Builder.Append <SqlStringBuilder>(",").AddTriggerBody($"Deleted.{prop.Name.GetParameterName()}"); } Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedBy"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedOn"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("Deleted.ModifiedOnUTC"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("ISNULL(LTRIM(RTRIM(CONVERT(varchar(128), CONTEXT_INFO()))), CAST(SUSER_SNAME() AS varchar(128)))"); Builder.Append <SqlStringBuilder>(",").AddTriggerBody("SYSDATETIME()"); Builder.AddTriggerBody("FROM Deleted;"); Builder.EndTrigger(); }
private void Stream(XmlEntity ent) { MDataObjs.Add(new ClassSeparator(typeof(XmlEntity))); MDataObjs.Add(new String("Notation name", ent.NotationName)); MDataObjs.Add(new String("Public ID", ent.PublicId)); MDataObjs.Add(new String("System ID", ent.SystemId)); }
private async Task <XmlDocument> GetXmlAsync(string url) { var xmlDoc = new XmlDocument(); var xmlString = await GetJsonAsync(url); xmlDoc.LoadXml(XmlEntity.ReplaceAll(xmlString)); return(xmlDoc); }
private XElement GetEventProcessElement(XmlEntity <WorkflowEventEntity> e) { return(new XElement(bpmn + WorkflowEventTypes.GetOrThrow(e.Entity.Type), new XAttribute("id", e.bpmnElementId), e.Entity.Name.HasText() ? new XAttribute("name", e.Entity.Name) : null, e.Entity.Type.IsTimerStart() ? new XElement(bpmn + (((WorkflowEventModel)e.Entity.GetModel()).Task.TriggeredOn == TriggeredOn.Always ? "timerEventDefinition" : "conditionalEventDefinition")) : null, GetConnections(e.Entity.ToLite()))); }
private XmlNode GetXmlNodeEntity(XmlEntity xmlEntity) { XmlNode xmlNode = xmlDocument.CreateElement("entity"); xmlNode.AppendChild(xmlDocument.CreateElement("name")).InnerText = xmlEntity.name.ToString(); xmlNode.AppendChild(xmlDocument.CreateElement("posX")).InnerText = xmlEntity.pos.X.ToString(); xmlNode.AppendChild(xmlDocument.CreateElement("posY")).InnerText = xmlEntity.pos.Y.ToString(); return(xmlNode); }
private static string GetBaseClass(XmlEntity entityContext, ITobascoContext tobascoContext) { if (string.IsNullOrEmpty(entityContext.BaseClass) && string.IsNullOrEmpty(tobascoContext.BaseClass)) { return(string.Empty); } else if (string.IsNullOrEmpty(entityContext.BaseClass)) { return(tobascoContext.BaseClass); } return(entityContext.BaseClass); }
internal override void AddMethods(XmlEntity entityContext, ITobascoContext tobascoContext) { Builder.StartMethod("public override", "ExpandoObject", "ToAnonymous"); Builder.AddMethodBody("dynamic anymonous = base.ToAnonymous();"); entityContext.Properties.ForEach(property => { Builder.AddMethodBody($"anymonous.{property.Name} = {property.Name};"); }); Builder.AddMethodBody("return anymonous"); Builder.EndMethod(); Builder.AppendLine(string.Empty); }
public void Save() { List <XmlEntity> xmlentities = new List <XmlEntity>(); XmlLevel xmllevel = new XmlLevel(name, id, xmlentities); for (int i = 0; i < entities.Count; i++) { Entity entity = entities[i]; XmlEntity xmlentity = new XmlEntity(); xmlentity.position = entity.position; xmlentity.rotation = entity.rotation; xmlentity.size = entity.size; if (entity is StaticModelEntity) { StaticModelEntity modelentity = entity as StaticModelEntity; xmlentity.asset = Resources.GetName(modelentity.GetModel()); xmlentity.type = "static_model"; } if (entity is AnimatedModelEntity) { AnimatedModelEntity modelentity = entity as AnimatedModelEntity; xmlentity.asset = Resources.GetName(modelentity.GetModel()); xmlentity.type = "animated_model"; } if (entity is WallModelEntity) { WallModelEntity wallentity = entity as WallModelEntity; xmlentity.asset = Resources.GetName(wallentity.GetModel()); xmlentity.type = "wall_model"; } if (entity is Billboard) { Billboard billboard = entity as Billboard; xmlentity.asset = Resources.GetName(billboard.region.texture); xmlentity.type = "billboard"; xmlentity.color = billboard.color; } xmlentities.Add(xmlentity); } XmlHelper.Save(xmllevel); }
protected virtual void AddDescriptions(XmlEntity xmlEntity, ITobascoContext tobascoContext) { Builder.AppendLine($"EXEC sp_addextendedproperty N'Description', '{xmlEntity.Name}', 'SCHEMA', N'dbo', 'TABLE', N'{xmlEntity.Name}', NULL, NULL"); Builder.AppendLine("GO"); foreach (var prop in xmlEntity.Properties) { if (!string.IsNullOrEmpty(prop.Description)) { Builder.AppendLine($"EXEC sp_addextendedproperty N'Description', '{prop.Name}', 'SCHEMA', N'dbo', 'TABLE', N'{prop.Description}', NULL, NULL"); Builder.AppendLine("GO"); } } }
public static void DisplayEntities(XmlNamedNodeMap nMap) { for (int i = 0; i < nMap.Count; i++) { XmlEntity ent = (XmlEntity)nMap.Item(i); Console.Write("{0} ", ent.NodeType); Console.Write("{0} ", ent.Name); Console.Write("{0} ", ent.NotationName); Console.Write("{0} ", ent.PublicId); Console.Write("{0} ", ent.SystemId); Console.WriteLine(); } }
private XmlEntity GetEntityContext() { var entityContext = new XmlEntity { EntityLocation = new FileLocation() }; entityContext.EntityLocation.Folder = "Entities"; entityContext.EntityLocation.Project = "TobascoV2Test"; entityContext.BaseClass = ""; return(entityContext); }
internal override void AddFields(XmlEntity entityContext, ITobascoContext tobascoContext) { var lastProperty = entityContext.Properties.Last(); entityContext.Properties.ForEach(property => { Builder.AppendLine($"private {property.PropertyType.Name.GetDescription()} {property.GetFieldName()}"); if (property.Equals(lastProperty)) { Builder.AppendLine(string.Empty); } }); }
private XElement GetEventProcessElement(XmlEntity <WorkflowEventEntity> e) { var activity = e.Entity.BoundaryOf?.Let(lite => this.activities.Values.SingleEx(a => lite.Is(a.Entity))).Entity; return(new XElement(bpmn + WorkflowEventTypes.GetOrThrow(e.Entity.Type), new XAttribute("id", e.bpmnElementId), activity != null ? new XAttribute("attachedToRef", activity.BpmnElementId) : null !, e.Entity.Type == WorkflowEventType.BoundaryForkTimer ? new XAttribute("cancelActivity", false) : null !, e.Entity.Name.HasText() ? new XAttribute("name", e.Entity.Name) : null !, e.Entity.Type.IsScheduledStart() || e.Entity.Type.IsTimer() ? new XElement(bpmn + ((((WorkflowEventModel)e.Entity.GetModel()).Task?.TriggeredOn == TriggeredOn.Always || (e.Entity.Type.IsTimer() && e.Entity.Timer !.Duration != null)) ? "timerEventDefinition" : "conditionalEventDefinition")) : null !, GetConnections(e.Entity.ToLite()))); }
public LaneBuilder(WorkflowLaneEntity l, IEnumerable <WorkflowActivityEntity> activities, IEnumerable <WorkflowEventEntity> events, IEnumerable <WorkflowGatewayEntity> gateways, IEnumerable <XmlEntity <WorkflowConnectionEntity> > connections) { this.lane = new XmlEntity <WorkflowLaneEntity>(l); this.events = events.Select(a => new XmlEntity <WorkflowEventEntity>(a)).ToDictionary(x => x.bpmnElementId); this.activities = activities.Select(a => new XmlEntity <WorkflowActivityEntity>(a)).ToDictionary(x => x.bpmnElementId); this.gateways = gateways.Select(a => new XmlEntity <WorkflowGatewayEntity>(a)).ToDictionary(x => x.bpmnElementId); this.connections = connections.ToDictionary(a => a.bpmnElementId); this.outgoing = this.connections.Values.GroupToDictionary(a => a.Entity.From.ToLite()); this.incoming = this.connections.Values.GroupToDictionary(a => a.Entity.To.ToLite()); }
public void Load() { entities.Clear(); XmlLevel xmllevel = XmlHelper.Load(id); List <XmlEntity> xmlentities = xmllevel.entities; for (int i = 0; i < xmlentities.Count; i++) { XmlEntity xmlentity = xmlentities[i]; Entity entity = null; if (xmlentity.type == "static_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new StaticModelEntity(model); } if (xmlentity.type == "animated_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new AnimatedModelEntity(model); } if (xmlentity.type == "wall_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new WallModelEntity(model); } if (xmlentity.type == "billboard") { Texture2D texture = (Texture2D)Resources.GetObject(xmlentity.asset); entity = new Billboard(texture); ((Billboard)entity).color = xmlentity.color; } if (entity == null) { continue; } entity.position = xmlentity.position; entity.rotation = xmlentity.rotation; entity.size = xmlentity.size; Add(entity); } }
public override void Scaffold(XmlEntity entityContext, ITobascoContext tobascoContext, string appRoot) { AddUsingNamespaces(entityContext, tobascoContext); Builder.StartNamesspace(tobascoContext.EntityContext.EntityLocation.GetNamespace()); AddClass(entityContext, tobascoContext); Builder.EndNamespace(); CreateOrOverwriteFile( $"{appRoot}//" + $"{FileLocationHelper.GetFileLocation(entityContext.EntityLocation, tobascoContext.EntityContext.EntityLocation)}//" + $"{entityContext.Name}.cs"); }
protected override void AddHistoryTable(XmlEntity xmlEntity, ITobascoContext tobascoContext) { Builder.StartTable($"{xmlEntity.Name}_historie"); Builder.AddTableBody("[Id]", "bigint", true); Builder.Append <SqlStringBuilder>(",").AddTableBody("[RowVersion]", "binary(8)", true); foreach (var prop in xmlEntity.Properties.Where(x => x.PropertyType.Name != Enums.Datatype.ChildCollection)) { Builder.Append <SqlStringBuilder>(",").AddTableBody($"{prop.Name}", prop.PropertyType.GetSqlDataType(), prop.Required); } Builder.Append <SqlStringBuilder>(",").AddModifiedByTableDefinition(); Builder.Append <SqlStringBuilder>(",").AddModifiedOnTableDefinition(); Builder.Append <SqlStringBuilder>(",").AddModifiedOnUTCTableDefinition(); Builder.Append <SqlStringBuilder>(",").AddTableBody("[DeletedBy]", "nvarchar(256)", false); Builder.Append <SqlStringBuilder>(",").AddTableBody("[DeletedAt]", "datetime2(7)", false); Builder.EndTable(); }
public override void Scaffold(XmlEntity xmlEntity, ITobascoContext tobascoContext, string appRoot) { AddInsert(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddUpdate(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddDelete(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddGetById(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddGetByParentId(xmlEntity, tobascoContext); Builder.AppendLine("GO"); CreateOrOverwriteFile( $"{appRoot}//" + $"{FileLocationHelper.GetFileLocation(xmlEntity.DatabaseContext.StoredProcedureLocation, tobascoContext.DatabaseContext.StoredProcedureLocation)}//" + $"{xmlEntity.Name}.sql"); }
public void DescendantsRecursively() { string dtd = "<!DOCTYPE root [<!ELEMENT root (#PCDATA)*>" + "<!ENTITY ent 'value'>" + "<!ENTITY ent2 'my &ent; string'>" + "]>"; string xml = dtd + "<root>&ent;</root>"; XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null); XmlDocument doc = new XmlDocument(); doc.Load(xtr); XmlEntity ent = (XmlEntity)doc.DocumentType.Entities.GetNamedItem("ent2"); Assert.AreEqual("ent2", ent.Name); Assert.AreEqual("my ", ent.FirstChild.Value); Assert.IsNotNull(ent.FirstChild.NextSibling.FirstChild); Assert.AreEqual("value", ent.FirstChild.NextSibling.FirstChild.Value); }
public void TestValue() { XmlTextReader xtr = new XmlTextReader("<!DOCTYPE x:foo [<!ENTITY foo 'fooent'><!ENTITY bar 'test &foo;'>]><x:foo xmlns:x='hoge' />", XmlNodeType.Document, null); document.Load(xtr); xtr.Close(); docType = document.DocumentType; Assert.AreEqual(2, docType.Entities.Count); XmlEntity foo = docType.Entities.Item(0) as XmlEntity; XmlEntity bar = docType.Entities.Item(1) as XmlEntity; Assert.AreEqual("foo", foo.Name); Assert.IsNull(bar.Value); Assert.AreEqual(1, foo.ChildNodes.Count); Assert.AreEqual("bar", bar.Name); Assert.IsNull(bar.Value); Assert.AreEqual(1, foo.ChildNodes.Count); }
public override void Scaffold(XmlEntity xmlEntity, ITobascoContext tobascoContext, string appRoot) { AddTable(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddIndexes(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddConstraints(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddHistoryTable(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddTriggers(xmlEntity, tobascoContext); Builder.AppendLine("GO"); AddDescriptions(xmlEntity, tobascoContext); CreateOrOverwriteFile( $"{appRoot}//" + $"{FileLocationHelper.GetFileLocation(xmlEntity.DatabaseContext.TableLocation, tobascoContext.DatabaseContext.TableLocation)}//" + $"{xmlEntity.Name}.sql"); }
public void LoadLevel() { if (!isLoadead) { XmlNode root = xmlDocument.DocumentElement; Func <XmlNode, bool> LoadBlocks = (XmlNode node) => { foreach (XmlNode xmlNode in node.ChildNodes) { XmlBlock xmlBlock = GetXmlBlock(xmlNode); SetBlock(xmlBlock.name, xmlBlock.pos); } return(true); }; Func <XmlNode, bool> LoadEntities = (XmlNode node) => { foreach (XmlNode xmlNode in node.ChildNodes) { XmlEntity xmlEntity = GetXmlEntity(xmlNode); SpawnEntity(xmlEntity.name, xmlEntity.pos); } return(true); }; foreach (XmlNode xmlNode in root) { if (xmlNode.Name == "blocks") { LoadBlocks(xmlNode); } if (xmlNode.Name == "entities") { LoadEntities(xmlNode); } } isLoadead = true; } }