protected override void LoadContent() { SystemFont = Content.Load <SpriteFont>("SystemFont"); Player.LoadAssets(Content); PlainField.LoadAssets(Content); SolidField.LoadAssets(Content); DestructibleField.LoadAssets(Content); Layers.Push(new GameLayer(GraphicsDevice)); }
private void FillPlainField(PlainField plain) { if (SkipCData) { plain.CustomProperties[XmlProductService.RenderTextFieldAsXmlName] = true; } if (LoadLikeImage) { plain.CustomProperties[XmlProductService.RenderFileFieldAsImage] = true; } }
public Field GetFieldByPath(string path, Content definition, out bool hasFilter, out Content parent) { var articleData = DPathProcessor.VerifyAndParseExpression(path).ToList(); hasFilter = articleData.Any(ad => ad.FiltersData.Any()); parent = definition; Field currentField = null; foreach (var fieldName in articleData.Select(ad => ad.FieldName)) { if (currentField != null) { var currentEntityField = currentField as EntityField; if (currentEntityField == null) { throw new Exception("Schema generator requires virtual field to relate to EntityField type or its descendant"); } parent = currentEntityField.Content; } var nonVirtualFields = parent.Fields.Where(x => !(x is BaseVirtualField)).ToArray(); if (nonVirtualFields.All(x => x.FieldName != fieldName) && parent.LoadAllPlainFields) { var allPlainFields = _fieldService.List(parent.ContentId).Where(x => x.RelationType == RelationType.None); currentField = new PlainField { FieldId = allPlainFields.Single(x => x.Name == fieldName).Id, FieldName = fieldName }; } else { currentField = nonVirtualFields.Single(x => x.FieldName == fieldName); } } return(currentField); }
/// <summary> /// /// </summary> /// <param name="rootContent"></param> /// <param name="notFoundInDef"></param> /// <param name="entityIds">int c id поля для невиртуальных полей и string с именем поля для виртуальных</param> /// <returns></returns> private object GetObjectFromDef(Content rootContent, out bool notFoundInDef, IEnumerable <object> entityIds) { object[] entityIdsToSearch = entityIds .Skip(1) //корень ровно один поэтому первый компонент пути нам не нужен .ToArray(); object currentPositionObj = rootContent; notFoundInDef = false; foreach (object entityId in entityIdsToSearch) { if (currentPositionObj is Content) { var currContent = (Content)currentPositionObj; if (entityId is int) { currentPositionObj = currContent.Fields.SingleOrDefault(x => x.FieldId == (int)entityId); } else { currentPositionObj = currContent.Fields.SingleOrDefault(x => x.FieldName == (string)entityId && x is BaseVirtualField); } if (currentPositionObj == null) { //дурацкая система что Dictionaries это поле с id=0 if (entityId is int && (int)entityId == 0) { notFoundInDef = true; return(new Dictionaries()); } if (entityId is int) { int enitityIdInt = (int)entityId; var qpField = _fieldService.Read(enitityIdInt); if (qpField == null) { notFoundInDef = true; return(null); } if (qpField.RelationType == RelationType.None && !qpField.IsClassifier) { currentPositionObj = new PlainField { FieldId = enitityIdInt, FieldName = qpField.Name }; notFoundInDef = !currContent.LoadAllPlainFields; } else { using (_fieldService.CreateQpConnectionScope()) { if (qpField.ContentId == currContent.ContentId) { if (!qpField.IsClassifier) { currentPositionObj = new EntityField { FieldId = enitityIdInt, FieldName = qpField.Name, CloningMode = CloningMode.UseExisting, Content = new Content { ContentId = qpField.RelateToContentId.Value, ContentName = qpField.RelatedToContent.Name } } } } ; else { currentPositionObj = new ExtensionField { FieldId = qpField.Id, FieldName = qpField.Name, CloningMode = CloningMode.UseExisting }; var classifierContents = _fieldService.ListRelated(qpField.ContentId) .Where(x => x.Aggregated) .Select(x => x.Content); foreach (var classifierContent in classifierContents) { ((ExtensionField)currentPositionObj).ContentMapping.Add( classifierContent.Id, new Content { ContentId = classifierContent.Id, ContentName = classifierContent.Name }); } } else { currentPositionObj = new BackwardRelationField { FieldId = qpField.Id, FieldName = qpField.Name, Content = new Content { ContentId = qpField.ContentId, ContentName = qpField.Content.Name }, CloningMode = CloningMode.UseExisting }; } } notFoundInDef = !qpField.IsClassifier || !currContent.LoadAllPlainFields; } }
private void InitPlainField(PlainField pf) { SkipCData = pf.CustomProperties.ContainsKey(XmlProductService.RenderTextFieldAsXmlName); LoadLikeImage = pf.CustomProperties.ContainsKey(XmlProductService.RenderFileFieldAsImage); FieldType = FieldDefinitionType.PlainField; }