public void ShouldUpdateBodyPrefixAndSuffix() { var format = new ObjectFormat() .ObjectBodyPrefixAndSuffix("{", "}"); Assert.That(format.ObjectPrefixAndSuffix, Is.EqualTo(ValueTuple.Create("{", "}"))); }
private static void ProcessObjectFormat(ObjectFormat of, Utf8JsonWriter jsonw) { jsonw.WritePropertyName("ObjectFormat"); jsonw.WriteStartObject(); jsonw.WriteString("CssClass", of.CssClass); jsonw.WriteString("EnableCanGrow", of.EnableCanGrow.ToStringSafe()); jsonw.WriteString("EnableCloseAtPageBreak", of.EnableCloseAtPageBreak.ToStringSafe()); jsonw.WriteString("EnableKeepTogether", of.EnableKeepTogether.ToStringSafe()); jsonw.WriteString("EnableSuppress", of.EnableSuppress.ToStringSafe()); jsonw.WriteString("HorizontalAlignment", of.HorizontalAlignment.ToStringSafe()); jsonw.WriteString("HyperlinkText", of.HyperlinkText); jsonw.WriteString("HyperlinkType", of.HyperlinkType.ToStringSafe()); jsonw.WriteString("TextRotationAngle", of.TextRotationAngle.ToStringSafe()); jsonw.WriteString("ToolTipText", of.ToolTipText); jsonw.WriteString("VerticalAlignment", of.VerticalAlignment.ToStringSafe()); jsonw.WriteString("CssClassFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeCssClass].Text); jsonw.WriteString("DeltaWidthFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDeltaWidth].Text); jsonw.WriteString("DeltaXFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDeltaX].Text); jsonw.WriteString("DisplayStringFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDisplayString].Text); jsonw.WriteString("EnableCanGrowFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeEnableCanGrow].Text); jsonw.WriteString("EnableCloseAtPageBreakFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeEnableCloseAtPageBreak].Text); jsonw.WriteString("EnableKeepTogetherFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeEnableKeepTogether].Text); jsonw.WriteString("EnableSuppressFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeEnableSuppress].Text); jsonw.WriteString("HorizontalAlignmentFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHorizontalAlignment].Text); jsonw.WriteString("HyperlinkFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHyperlink].Text); jsonw.WriteString("TextRotationAngleFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeRotation].Text); jsonw.WriteString("ToolTipTextFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeToolTipText].Text); jsonw.WriteString("VerticalAlignmentFormula", of.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeVerticalAlignment].Text); jsonw.WriteEndObject(); }
public void ShouldUpdateMemberPrefixAndSuffix() { var format = new ObjectFormat() .ObjectMemberPrefixAndSuffix("<", ">"); Assert.That(format.MemberPrefixAndSuffix, Is.EqualTo(("<", ">"))); }
public void ShouldUpdateMemberNamePrefixAndSuffix() { var format = new ObjectFormat() .ObjectMemberNamePrefixAndSuffix("'", "'"); Assert.That(format.MemberNamePrefixAndSuffix, Is.EqualTo(ValueTuple.Create("'", "'"))); }
public void ShouldUpdateMemberSeparator() { var format = new ObjectFormat() .JoinMembersWith(","); Assert.That(format.MemberSeparator, Is.EqualTo(",")); }
public ObjectFormat UpdateObjectFormatProperties(ObjectFormat objectFormat) { objectFormat.ReplaceUrlsToPlaceHolders(); var format = FormatRepository.UpdateObjectFormatProperties(objectFormat); ManagePageAndObjectModified(format); return(format); }
internal static ObjectFormatViewModel Create(ObjectFormat format, string tabId, int parentId, IFormatService formatService, bool pageOrTemplate) { var model = Create <ObjectFormatViewModel>(format, tabId, parentId); model._service = formatService; model._pageOrTemplate = pageOrTemplate; return(model); }
public void ShouldUpdateMemberValuePrefixAndSuffix() { var format = new ObjectFormat() .ObjectMemberValuePrefixAndSuffix(null, "]"); Assert.That( format.MemberValuePrefixAndSuffix, Is.EqualTo(ValueTuple.Create <string, string>(null, "]")) ); }
private static void ProcessObjectFormat(ObjectFormat of, XmlWriter xmlw) { xmlw.WriteStartElement("ObjectFormat"); xmlw.WriteAttributeString("CssClass", of.CssClass); xmlw.WriteAttributeString("EnableCanGrow", of.EnableCanGrow.ToStringSafe()); xmlw.WriteAttributeString("EnableCloseAtPageBreak", of.EnableCloseAtPageBreak.ToStringSafe()); xmlw.WriteAttributeString("EnableKeepTogether", of.EnableKeepTogether.ToStringSafe()); xmlw.WriteAttributeString("EnableSuppress", of.EnableSuppress.ToStringSafe()); xmlw.WriteAttributeString("HorizontalAlignment", of.HorizontalAlignment.ToStringSafe()); xmlw.WriteEndElement(); }
public void ShouldUseDefaultToStringFunctionWhenOneWasNotProvidedExplicitly() { var toString = ObjectFormat.CreateDefault() .Compile(AccountMembers.Select(am => new MemberContext <Func <object, string> >(am.Member, null, ContextSource.Implicit) )); Assert.That( toString(new Account(42, "James")), Is.EqualTo("Account(Id: \"42\", Name: \"James\", Phones: \"System.String[]\")") ); }
public void ShouldCreateDefaultFormat() { var format = ObjectFormat.CreateDefault(); var toString = format.Compile(AccountMembers); Assert.That(toString, Is.Not.Null); Assert.That( toString(new Account(42, "James", null)), Is.EqualTo("Account(Id: \"42\", Name: \"James\")") ); }
private static void GetObjectFormat(ObjectFormat objectFormat, XmlWriter writer) { WriteAndTraceStartElement(writer, "ObjectFormat"); writer.WriteAttributeString("CssClass", objectFormat.CssClass); writer.WriteAttributeString("EnableCanGrow", objectFormat.EnableCanGrow.ToString()); writer.WriteAttributeString("EnableCloseAtPageBreak", objectFormat.EnableCloseAtPageBreak.ToString()); writer.WriteAttributeString("EnableKeepTogether", objectFormat.EnableKeepTogether.ToString()); writer.WriteAttributeString("EnableSuppress", objectFormat.EnableSuppress.ToString()); writer.WriteAttributeString("HorizontalAlignment", objectFormat.HorizontalAlignment.ToString()); writer.WriteEndElement(); }
public void ShouldSetMultipleDensityFlags() { var format = new ObjectFormat() .AddFlags(IncludeClassName) .AddFlags(IncludeMemberName) .AddFlags(MemberPerLine); Assert.That(format.Options, Is.EqualTo( IncludeClassName | IncludeMemberName | MemberPerLine )); }
public string ShouldFormatObjectAccordingToDensity(ObjectFormatOptions options) { var account = new Account(19, "John", "12-33-19", "66-18-23"); var format = new ObjectFormat() .AddFlags(options) .ObjectBodyPrefixAndSuffix("<", ">") .ObjectMemberNamePrefixAndSuffix("'", "'") .ObjectMemberValuePrefixAndSuffix("\"", "\"") .JoinMemberNameAndValueWith(":") .JoinMembersWith(","); return(format.Compile(AccountMembers)(account)); }
public void ShouldUnsetDensityFlags() { var format = new ObjectFormat() .AddFlags(IncludeClassName) .AddFlags(IncludeMemberName) .AddFlags(MemberPerLine) .RemoveFlags( IncludeClassName | IncludeMemberName | MemberPerLine | IncludeNullValues ); Assert.That(format.Options, Is.EqualTo((ObjectFormatOptions)0)); }
public void EmptyBuilder() { var format = new ObjectFormat(); var toString = format.Compile(AccountMembers); var defaultPrefixAndSuffix = ValueTuple.Create <string, string>(null, null); Assert.That(format.Options, Is.EqualTo((ObjectFormatOptions)0)); Assert.That(format.MemberPrefixAndSuffix, Is.EqualTo(defaultPrefixAndSuffix)); Assert.That(format.MemberSeparator, Is.EqualTo(null)); Assert.That(format.ObjectPrefixAndSuffix, Is.EqualTo(defaultPrefixAndSuffix)); Assert.That(format.MemberNamePrefixAndSuffix, Is.EqualTo(defaultPrefixAndSuffix)); Assert.That(format.MemberValuePrefixAndSuffix, Is.EqualTo(defaultPrefixAndSuffix)); Assert.That(toString(new Account(10, "James", "777")), Is.EqualTo("10James777")); }
public void ObjectFormatterShouldIncludeNullValuesWhenCorrespondingDensityFlagWasSet() { var format = new ObjectFormat() .AddFlags(IncludeNullValues) .AddFlags(IncludeMemberName) .ObjectBodyPrefixAndSuffix("(", ")") .JoinMemberNameAndValueWith(": ") .JoinMembersWith(", "); var toString = format.Compile(AccountMembers); Assert.That(toString(new Account(15, null, null)), Is.EqualTo( "(Id: 15, Name: null, Phones: null)" )); }
internal static void ManagePageAndObjectModified(ObjectFormat format) { var parentObj = ObjectRepository.GetObjectPropertiesById(format.ObjectId); using (var scope = new QPConnectionScope()) { if (parentObj.PageId.HasValue) { Common.UpdatePageAndObjectDateModifiedByObjectId(format.ObjectId, parentObj.PageId.Value, scope.DbConnection); } else { Common.UpdateObjectDateModified(format.ObjectId, scope.DbConnection); } } }
public void ShouldAlwaysCreateNewInstanceOfDefaultFormat() { var firstFormat = ObjectFormat.CreateDefault() .AddFlags(MemberPerLine) .ObjectMemberNamePrefixAndSuffix("<", ">"); var firstToString = firstFormat.Compile(AccountMembers); var secondFormat = ObjectFormat.CreateDefault(); var secondToString = secondFormat.Compile(AccountMembers); Assert.That(firstFormat, Is.Not.SameAs(secondFormat)); Assert.That(firstToString, Is.Not.SameAs(secondToString)); Assert.That(secondToString(new Account(42, "James", null)), Is.EqualTo("Account(Id: \"42\", Name: \"James\")")); }
private int?CreateDefaultFormat(BllObject bllObject, bool isReplayAction) { var template = PageTemplateRepository.GetPageTemplatePropertiesById(bllObject.PageTemplateId); var format = ObjectFormat.Create(bllObject.Id, bllObject.PageOrTemplate, template.SiteIsDotNet); format.Name = "default"; if (template.SiteIsDotNet) { format.NetFormatName = "default"; } else { format.NetLanguageId = template.NetLanguageId; } var netLanguagePrefix = GetLangPrefix(template.NetLanguageId); var pathToCopy = SitePathRepository.GetDirectoryPathToCopy() + "\\default\\"; if (template.NetLanguageId != null && !isReplayAction) { if (bllObject.IsGenericType) { format.CodeBehind = ReadFileAsString(string.Format("{0}generic_code_{1}.txt", pathToCopy, netLanguagePrefix)); } else if (bllObject.IsObjectContainerType) { format.CodeBehind = ReadFileAsString(string.Format("{0}container_code_{1}.txt", pathToCopy, netLanguagePrefix)); format.FormatBody = ReadFileAsString(string.Format("{0}container_presentation.txt", pathToCopy)); } } format = FormatRepository.SaveObjectFormatProperties(format); bllObject.DefaultFormatId = format.Id; ObjectRepository.UpdateDefaultFormatId(bllObject.Id, format.Id); return(format.Id); }
private bool LoadObject(string objectFormatFileName) { objectFormatFileName = SystemConfiguration.ObjectFilePath + objectFormatFileName; try { var lines = File.ReadLines(objectFormatFileName).ToList(); var vertextCountString = lines[0].Split(new char[] { ':' })[1].Trim(); _vertexCount = int.Parse(vertextCountString); IndexCount = _vertexCount; ModelObject = new ObjectFormat[_vertexCount]; for (var i = 4; i < lines.Count && i < 4 + _vertexCount; ++i) { var objectArray = lines[i].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); ModelObject[i - 4] = new ObjectFormat() { x = float.Parse(objectArray[0]), y = float.Parse(objectArray[1]), z = float.Parse(objectArray[2]), tu = float.Parse(objectArray[3]), tv = float.Parse(objectArray[4]), nx = float.Parse(objectArray[5]), ny = float.Parse(objectArray[6]), nz = float.Parse(objectArray[7]), }; } return(true); } catch (Exception ex) { Log.WriteToFile(ErrorLevel.Error, "Object.LoadObject", ex, true); return(false); } }
private static void ManagePageAndObjectModified(ObjectFormat format) { PageTemplateRepository.ManagePageAndObjectModified(format); }
public ObjectFormat NewPageObjectFormatProperties(int parentId, bool isSiteDotNet) => ObjectFormat.Create(parentId, true, isSiteDotNet);
public void ObjectFormatterFactoryMethodShouldThrowArgumentNullExceptionWhenSequenceOfFormattingMembersIsNull() { var factory = new ObjectFormat(); Assert.Throws <ArgumentNullException>(() => factory.Compile(null)); }
public ObjectFormat NewTemplateObjectFormatProperties(int parentId, bool isSiteDotNet) => ObjectFormat.Create(parentId, false, isSiteDotNet);
/// <summary> /// Overrides current <see cref="ObjectFormat"/> controlling how selected object members will rendered to string. /// </summary> /// <param name="setup"> /// Function accepting current <see cref="ObjectFormat"/>. It is expected to return updated or brand new instance /// to be used by <see cref="object.ToString"/> function being built. When it returns null the previously /// used <see cref="ObjectFormat"/> (the one passed to setup function) will be used. /// </param> /// <returns>Updated <see cref="ToStringBuilder{TTarget}"/> instance.</returns> public ToStringBuilder <TTarget> UseObjectFormat(Func <ObjectFormat, ObjectFormat> setup) { _objectFormat = SetupFormat(_objectFormat, setup); return(this); }
internal static ObjectFormat UpdateObjectFormatProperties(ObjectFormat objectFormat) => DefaultRepository.Update <ObjectFormat, ObjectFormatDAL>(objectFormat);