protected void SetUp() { Common.Testing = true; //_styleName = new Styles(); //_util = new Utility(); _projInfo = new PublicationInformation(); _progressBar = new ProgressBar(); string testPath = PathPart.Bin(Environment.CurrentDirectory, "/OpenOfficeConvert/TestFiles"); _inputPath = Common.PathCombine(testPath, "input"); _outputPath = Common.PathCombine(testPath, "output"); _expectedPath = Common.PathCombine(testPath, "expected"); _expectedlinuxPath = Common.PathCombine(testPath, "expectedlinux"); Common.DeleteDirectory(_outputPath); Directory.CreateDirectory(_outputPath); FolderTree.Copy(FileInput("Pictures"), FileOutput("Pictures")); _projInfo.ProgressBar = _progressBar; _projInfo.OutputExtension = "odt"; _projInfo.ProjectInputType = "Dictionary"; _projInfo.IsFrontMatterEnabled = false; _projInfo.FinalOutput = "odt"; Common.SupportFolder = ""; Common.ProgInstall = PathPart.Bin(Environment.CurrentDirectory, "/../../DistFIles"); Common.ProgBase = PathPart.Bin(Environment.CurrentDirectory, "/../../DistFiles"); // for masterDocument Common.UseAfterBeforeProcess = false; _styleFile = "styles.xml"; _contentFile = "content.xml"; _isLinux = Common.IsUnixOS(); if (!_isLinux) { LoadParam("Dictionary", "false"); } }
protected void SetUpAll() { Common.Testing = true; Common.ProgInstall = PathPart.Bin(Environment.CurrentDirectory, @"/../../DistFiles"); Common.SupportFolder = ""; Common.ProgBase = Common.ProgInstall; _projInfo = new PublicationInformation(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/OpenOfficeConvert/TestFiles"); _inputPath = Common.PathCombine(_testFolderPath, "input"); _outputPath = Common.PathCombine(_testFolderPath, "output"); if (Directory.Exists(_outputPath)) { Directory.Delete(_outputPath, true); } Directory.CreateDirectory(_outputPath); _projInfo.ProjectPath = _testFolderPath; _projInfo.OutputExtension = "odt"; string pathwayDirectory = Path.GetDirectoryName(Common.AssemblyPath); string styleSettingFile = Common.PathCombine(pathwayDirectory, "StyleSettings.xml"); ValidateXMLVersion(styleSettingFile); Common.ProgInstall = pathwayDirectory; Param.LoadSettings(); Param.SetValue(Param.InputType, "Scripture"); Param.LoadSettings(); }
private PathPart ParseVariable(string variable) { string[] parts = variable.Split(':'); if (parts.Length > 2) { throw new ArgumentException("More than one ':' in variable declaration."); } string variableName = parts[0]; PathPartKind kind = PathPartKind.UserItem; Type variableType = null; if (parts.Length == 2) { if (parts[1].Equals("path", StringComparison.OrdinalIgnoreCase)) { kind = PathPartKind.VariablePath; variableType = typeof(string); } else { variableType = ParseType(parts[1]); } } else { variableType = typeof(String); } PathPart pp = new PathPart(kind, variableName, variableType); return(pp); }
protected void SetUp() { Common.ProgInstall = PathPart.Bin(Environment.CurrentDirectory, @"/../../DistFiles"); Common.SupportFolder = ""; Common.ProgBase = Common.ProgInstall; Common.Testing = true; _projInfo = new PublicationInformation(); string testPath = PathPart.Bin(Environment.CurrentDirectory, "/GoBibleConvert/TestFiles"); _inputPath = Common.PathCombine(testPath, "Input"); _outputPath = Common.PathCombine(testPath, "output"); string pathwayDirectory = Common.AssemblyPath; string styleSettingFile = Common.PathCombine(pathwayDirectory, "StyleSettings.xml"); if (!File.Exists(styleSettingFile)) { styleSettingFile = Path.GetDirectoryName(Common.AssemblyPath); styleSettingFile = Common.PathCombine(styleSettingFile, "StyleSettings.xml"); } Common.Testing = true; ValidateXMLVersion(styleSettingFile); InputType = "Scripture"; Common.ProgInstall = pathwayDirectory; Param.LoadSettings(); Param.SetValue(Param.InputType, InputType); Param.LoadSettings(); }
protected void SetUp() { _stylesXML = new InStyles(); _storyXML = new InStory(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputStyles = Common.PathCombine(_outputPath, "Resources"); _outputSpread = Common.PathCombine(_outputPath, "Spreads"); projInfo.TempOutputFolder = _outputPath; _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); _inputCSS1 = Common.DirectoryPathReplace(_testFolderPath + "/input/Page1.css"); _inputCSS2 = Common.DirectoryPathReplace(_testFolderPath + "/input/Page2.css"); _facingPages.Add("Spread_1.xml"); _facingPages.Add("Spread_2.xml"); _facingPages.Add("Spread_3.xml"); _singlePages.AddRange(_facingPages); _singlePages.Add("Spread_4.xml"); _singlePages.Add("Spread_5.xml"); _columnClass.Add("t1"); _columnClass.Add("t2"); _columnClass.Add("t3"); }
protected void SetUp() { CommonTestMethod.DisableDebugAsserts(); string currentFolder = PathPart.Bin(Environment.CurrentDirectory, "/CssDialog/TestFiles"); _inputBasePath = Common.PathCombine(currentFolder, "Input"); _expectBasePath = Common.PathCombine(currentFolder, "Expected"); }
protected void SetUp() { string currentFolder = PathPart.Bin(Environment.CurrentDirectory, "/CssParser/TestFiles"); _inpPath = Common.PathCombine(currentFolder, "gramInput"); _expPath = Common.PathCombine(currentFolder, "gramExpect"); _outPath = Common.PathCombine(currentFolder, "gramOutput"); }
private bool ParseRouteHelper(string route, Dictionary <string, object> variables) { int pos = 0; for (int i = 0; i < mParts.Count; ++i) { PathPart pp = mParts[i]; switch (pp.Kind) { case PathPartKind.StaticPath: { string path = pp.Name; for (int subPos = 0; subPos < path.Length; ++subPos) { if (pos + subPos >= route.Length || route[pos + subPos] != path[subPos]) { return(false); } } pos += path.Length; } break; case PathPartKind.UserItem: { StringBuilder value = new StringBuilder(); while (pos < route.Length && route[pos] != '/') { value.Append(route[pos]); ++pos; } Object arg = CreateArgForType(value.ToString(), pp.Type); if (arg == null) { return(false); } if (variables?.ContainsKey(pp.Name) == true) { throw new ArgumentException($"Duplicately named variable {pp.Name} in route {route}"); } variables?.Add(pp.Name, arg); } break; // TODO: implement this case PathPartKind.VariablePath: default: throw new InvalidOperationException("Unknown type in ParseRouteHelper."); } } return(pos == route.Length); }
protected void SetUp() { _cssTree = new CssTree(); _stylesXML = new InStyles(); _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputResourcePath = Common.PathCombine(_outputPath, "Resources"); }
private static string GetPartFromPath(string destinationPath, PathPart part) { if (destinationPath != null) { var parts = destinationPath.Split('/'); return(parts[(int)part]); } return(""); }
public string GetUndoString(object obj) { PathPart pathPart = obj as PathPart; if (!(pathPart != (PathPart)null)) { return(""); } return(string.Format((IFormatProvider)CultureInfo.CurrentCulture, "{0} {1} {2}", (object)pathPart.SceneElement.Name, (object)pathPart.PathPartType, (object)pathPart.PartIndex)); }
public void FontFamily9() { _input.Name = "font-family"; _input.StringValue = "dummyfont, fantasy"; _makeProperty.PsSupportPath = PathPart.Bin(Environment.CurrentDirectory, "/../../DistFiles"); _output = _makeProperty.CreateProperty(_input); _expected.Clear(); _expected.Add("font-family", "Modern"); Assert.IsTrue(CompareDictionary(), CompareMessage()); }
protected void SetUp() { _graphicXML = new InGraphic(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); ClassProperty = _expected; //Note: All Reference address initialized here _output = Common.PathCombine(_testFolderPath, "output"); _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); }
[DataRow("{id}", null, false)] // Normalisation coalesces nulls, they do not match anything public void MatchesRequestPathPart_Returns_Correct_Response(string ctorPathPart, string matchPathPart, bool expected) { var methodInfo = GetType().GetMethod(nameof(MatchesRequestPathPartExampleParameters)); var methodParameters = MethodParameter_Tests.CreateMethodParameters(methodInfo, null); var pathPart = PathPart.Create(ctorPathPart, methodParameters); var actual = pathPart.MatchesRequestPathPart(matchPathPart); Assert.AreEqual(expected, actual); }
protected void SetUp() { _stylesXML = new InStyles(); _storyXML = new InStory(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); ClassProperty = _expected; //Note: All Reference address initialized here _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputStyles = Common.PathCombine(_outputPath, "Resources"); projInfo.TempOutputFolder = _outputPath; _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); }
public void MethodParameter_Ctor_Fills_Optional_Parameter_Details_Correctly() { var param = new MethodParameter(_ExampleMethod_optionalInt, null); Assert.AreEqual("optionalInt", param.Name); Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName); Assert.AreEqual(typeof(int), param.ParameterType); Assert.AreEqual(true, param.IsOptional); Assert.AreEqual(123, param.DefaultValue); Assert.AreEqual(null, param.TypeParserResolver); Assert.IsNull(param.ElementType); Assert.IsFalse(param.IsArray); }
public void Normalise_Returns_Normalised_String(string pathPart, string expected) { var actual = PathPart.Normalise(pathPart); if (expected == null) { Assert.IsNull(actual); } else { Assert.AreEqual(expected, actual); } }
public void MethodParameter_Ctor_Fills_Mandatory_Parameter_Details_Correctly() { var param = new MethodParameter(_ExampleMethod_string, null); Assert.AreEqual("stringParameter", param.Name); Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName); Assert.AreEqual(typeof(string), param.ParameterType); Assert.AreEqual(false, param.IsOptional); Assert.AreEqual(System.DBNull.Value, param.DefaultValue); Assert.AreEqual(null, param.TypeParserResolver); Assert.IsNull(param.ElementType); Assert.IsFalse(param.IsArray); }
public override bool Equals(object obj) { if (obj == null || obj.GetType() != this.GetType()) { return(false); } PathPart other = (PathPart)obj; return(mKind == other.mKind && mName == other.mName && mType == other.mType); }
protected void SetUp() { _stylesXML = new InStyles(); _expectedList = new ArrayList(); _designmapXML = new InDesignMap(); _idAllClass = new Dictionary <string, Dictionary <string, string> >(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/InDesignConvert/TestFiles"); ClassProperty = _expected; _outputPath = Common.PathCombine(_testFolderPath, "output"); _outputStyles = Common.PathCombine(_outputPath, "Resources"); _outputMasterSpreads = Common.PathCombine(_outputPath, "MasterSpreads"); _cssProperty = new Dictionary <string, Dictionary <string, string> >(); _cssTree = new CssTree(); }
public static FunnelPortals ConstructFunnelPortals(List <GraphNode> nodes, PathPart part) { if (nodes == null || nodes.Count == 0) { return new FunnelPortals { left = ListPool <Vector3> .Claim(0), right = ListPool <Vector3> .Claim(0) } } ; if (part.endIndex < part.startIndex || part.startIndex < 0 || part.endIndex > nodes.Count) { throw new System.ArgumentOutOfRangeException(); } // Claim temporary lists and try to find lists with a high capacity var left = ListPool <Vector3> .Claim(nodes.Count + 1); var right = ListPool <Vector3> .Claim(nodes.Count + 1); // Add start point left.Add(part.startPoint); right.Add(part.startPoint); // Loop through all nodes in the path (except the last one) for (var i = part.startIndex; i < part.endIndex; i++) { // Get the portal between path[i] and path[i+1] and add it to the left and right lists var portalWasAdded = nodes[i].GetPortal(nodes[i + 1], left, right, false); if (!portalWasAdded) { // Fallback, just use the positions of the nodes left.Add((Vector3)nodes[i].position); right.Add((Vector3)nodes[i].position); left.Add((Vector3)nodes[i + 1].position); right.Add((Vector3)nodes[i + 1].position); } } // Add end point left.Add(part.endPoint); right.Add(part.endPoint); return(new FunnelPortals { left = left, right = right }); }
protected void SetUp() { Common.Testing = true; string testPath = PathPart.Bin(Environment.CurrentDirectory, "/GoBibleConvert/TestFiles"); _inputPath = Common.PathCombine(testPath, "Input"); _outputPath = Common.PathCombine(testPath, "output"); _expectedPath = Common.PathCombine(testPath, "Expected"); if (!Directory.Exists(_outputPath)) { Directory.CreateDirectory(_outputPath); Thread.Sleep(1000); } }
private static void BuildPathPart(PathPart pathPart, int pos, string[] pathParts, string final) { if (pathParts.Length == pos) { pathPart.FinalName = final; return; } PathPart part; if (pathPart.Items.TryGetValue(pathParts[pos], out part) == false) { pathPart.Items[pathParts[pos]] = part = new PathPart { Name = pathParts[pos] }; } BuildPathPart(part, pos + 1, pathParts, final); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values[0] is string path) { if (!(values[1] is FileLister)) { if (values[1] is ILister lister) { var p = new[] { new PathPart(lister.ProtocolPrefix, path) { First = true, Highlighted = true, }, new PathPart(path, path) }; return(p); } return(new[] { new PathPart(path, path) }); } var currentPath = ""; var parts = new List <PathPart>(); foreach (var p in path.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries)) { if (string.IsNullOrEmpty(currentPath) && path.StartsWith(@"\\")) { parts.Add(new PathPart("Network", null)); currentPath = @"\\"; } currentPath += p + "\\"; var part = new PathPart(p, currentPath); parts.Add(part); } var first = parts.FirstOrDefault(); if (first != null) { first.First = true; parts.Last().Highlighted = true; } return(parts); } return(new[] { new PathPart(Constants.RootName, null) }); }
[DataRow("{a?}", typeof(PathPartText), "{a?}", "{a?}")] // You cannot mark non-default parameters with a question mark. public void Create_Fills_Properties(string inputText, Type expectedType, string part, string normalisedPart) { var methodInfo = GetType().GetMethod(nameof(ValidExampleParameterNames)); var methodParameters = MethodParameter_Tests.CreateMethodParameters(methodInfo, null); var actual = PathPart.Create(inputText, methodParameters); Assert.IsInstanceOfType(actual, expectedType); // they got the parameters the wrong way round... all other calls are expected then actual Assert.AreEqual(part, actual.Part); Assert.AreEqual(normalisedPart, actual.NormalisedPart); if (expectedType == typeof(PathPartParameter)) { var expectedMethodParameter = methodParameters.First(r => r.NormalisedName == normalisedPart); var actualPathPartParameter = (PathPartParameter)actual; Assert.AreSame(expectedMethodParameter, actualPathPartParameter.MethodParameter); } }
public void MethodParameter_Ctor_Fills_TypeParserResolver_Property_When_No_Default_Passed() { var param = new MethodParameter(_ExampleMethod_byteArrayWithExpect, null); Assert.AreEqual("byteArrayWithExpect", param.Name); Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName); Assert.AreEqual(typeof(byte[]), param.ParameterType); Assert.AreEqual(false, param.IsOptional); Assert.AreEqual(System.DBNull.Value, param.DefaultValue); Assert.AreEqual(typeof(byte), param.ElementType); Assert.IsTrue(param.IsArray); Assert.IsNotNull(param.TypeParserResolver); var parsers = param.TypeParserResolver.GetParsers(); Assert.AreEqual(1, parsers.Length); Assert.IsInstanceOfType(parsers[0], typeof(ByteArray_Mime64_Parser)); }
protected void SetUpAll() { Common.Testing = true; _projInfo = new PublicationInformation(); _testFolderPath = PathPart.Bin(Environment.CurrentDirectory, "/PdfConvert/TestFiles"); _inputPath = Common.PathCombine(_testFolderPath, "input"); _outputPath = Common.PathCombine(_testFolderPath, "output"); _expectedPath = Common.PathCombine(_testFolderPath, "Expected"); const bool recursive = true; if (Directory.Exists(_outputPath)) { Directory.Delete(_outputPath, recursive); } Directory.CreateDirectory(_outputPath); _projInfo.ProjectPath = _testFolderPath; Common.SupportFolder = ""; }
private void generateAdditionDataString(List <PathPart> motionPath) { double wholeDistance = 0.0; PathPoint lastPoint = null; foreach (PathPart part in motionPath) { wholeDistance += part.Distance(lastPoint); lastPoint = part.LastPoint(); } PathPart previousPart = null; String result = ""; foreach (PathPart part in motionPath) { result += "|" + part.typeCharacter + " "; bool needsComma = false; if (previousPart != null && previousPart.LastPoint() != null) { needsComma = true; result += previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); } foreach (PathPoint point in part.points) { result += (needsComma ? "," : "") + point.X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + point.Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); needsComma = true; } if (previousPart != null) //First part doesn't have timing { double timing = (part.Distance(previousPart.LastPoint()) / wholeDistance) * ((double)Length / (double)1000); result += "," + timing.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); } previousPart = part; } result += "|E " + previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); AdditionalData = "'" + result + "'"; }
private static void CreatePath(Expression expression, PathPart lastPart, ref string path) { if (expression is BinaryExpression indexExpression) { if (lastPart == PathPart.Check) { throw new PathCreatorException("Cannot have index filter and compound check after each other."); } path = CreateIndexPathPart(indexExpression.Right) + path; CreatePath(indexExpression.Left, PathPart.Filter, ref path); } else if (expression is MemberExpression propertyExpression) { path = CreatePropertyPathPart(propertyExpression.Member as PropertyInfo, propertyExpression) + path; CreatePath(propertyExpression.Expression, PathPart.Path, ref path); } else if (expression is MethodCallExpression methodExpression) { GeneratePathAttribute[] generators = methodExpression.Method.GetCustomAttributes(typeof(GeneratePathAttribute)).Select(a => (a as GeneratePathAttribute) !).ToArray(); if (!(methodExpression.Method.GetCustomAttribute(typeof(PathArrayGetterAttribute)) is null)) { CreatePath(methodExpression.Object, lastPart, ref path); } else if (generators.Length != 0) { path = CreateGeneratorString(methodExpression, generators) + path; CreatePath(methodExpression.Object, PathPart.Path, ref path); } else { if (methodExpression.Arguments.Count != 2) { throw new PathCreatorException("Methods are not supported."); } path = CreateParameterPathPart(methodExpression.Method, methodExpression.Arguments[1]) + path; if (lastPart == PathPart.Check) { throw new PathCreatorException("Cannot have 2 compound checks after each other."); } CreatePath(methodExpression.Arguments[0], PathPart.Check, ref path); } }
public static RavenJObject SelectTokenWithRavenSyntax(this RavenJToken self, string[] paths) { var parts = new PathPart(); foreach (var path in paths) { var pathParts = path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); BuildPathPart(parts, 0, pathParts, path); } var obj = new RavenJObject(); foreach (var currentPart in parts.Items) { currentPart.Value.ForEach(obj, self.SelectToken(currentPart.Key), (part, item, result) => { ((RavenJObject)result)[part.Name] = item; }); } return(obj); }
public static RavenJObject SelectTokenWithRavenSyntax(this RavenJToken self, string[] paths) { var parts = new PathPart(); foreach (var path in paths) { var pathParts = path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); BuildPathPart(parts, 0, pathParts, path); } var obj = new RavenJObject(); foreach (var currentPart in parts.Items) { currentPart.Value.ForEach(obj, self.SelectToken(currentPart.Key), (part, item, result) => { ((RavenJObject)result)[part.Name] = item; }); } return obj; }
/// <summary> /// Normalizes the path, i.e., resolves any root operator and any relative path jumps (like '..' and '.'). /// Its purpose is to be able to determine pathes's equality /// </summary> /// <returns></returns> public virtual VirtualPathBuilder Normalize() { if (_builder.Length == 0){ return this; } if (_builder.Length > 1) RemoveTrailingSlash(); if (_builder[0] == '~') { _builder.Remove(0, 1); if (_builder.Length > 0 && _builder[0] == '/') _builder.Remove(0, 1); _builder.Insert(0, ApplicationRoot); } if (_builder[0] != '/' && _builder[0] != '.') { _builder.Insert(0, ApplicationRoot); return this; } if (_builder.Length == 1 && _builder[0] == '/') return this; const int maxPartCount = 100; // you will never ever exceed this value... there is a max count value because we are working here with a fixed array size for performance reasons var parts = new PathPart[maxPartCount]; var partIndex = -1; var dotCount = 0; var charCount = 0; var anySkip = false; // resolve relative jumps (like ../ and ./) for (var i = 0; i < _builder.Length; i++ ) { var ch = _builder[i]; charCount++; if (ch == '/' || i == _builder.Length - 1) { if (partIndex == maxPartCount - 1) { // ... so this will never happen throw new InvalidOperationException(string.Format(string.Format("Path '{0}' contains too many parts (max = {0}) and cannot be normalized.",maxPartCount), _builder)); } if (ch == '.') dotCount++; anySkip = anySkip || dotCount > 0; parts[++partIndex] = new PathPart {Length = charCount, Start = i - charCount+1, Skip = dotCount > 0}; if (dotCount == 2 ) { var index = partIndex - 1; while (index > 0 && parts[index].Skip) index--; if (index >= 0) parts[index].Skip = true; else { throw new InvalidOperationException(string.Format("Path '{0}' is invalid and cannot be normalized.", _builder)); } } dotCount = 0; charCount = 0; } else if (ch == '.') { dotCount++; if (dotCount > 2) throw new InvalidOperationException(string.Format("Path '{0}' is invalid and cannot be normalized.", _builder)); } else { dotCount = 0; } } if (anySkip){ var sb = new StringBuilder(); for (var i = 0; i <= partIndex; i++){ if (parts[i].Skip) continue; sb.Append(_builder.ToString(parts[i].Start, parts[i].Length)); } _builder.Clear(); _builder.Append(sb); } if (_builder.Length > 1) RemoveTrailingSlash(); return this; }