Example #1
0
        internal void PrepareProperties()
        {
            // IMPORT PATH
            ImportPath = Path.GetFullPath(ImportPath);

            // SKIPPED PATHS
            // Skip file will be loaded in the PrepareFileSystemEntries.
            var paths = string.IsNullOrEmpty(SkippedPaths) ? new string[0] : SkippedPaths.Split(',');

            for (var i = 0; i < paths.Length; i++)
            {
                if (!Path.IsPathRooted(paths[i]))
                {
                    paths[i] = Path.GetFullPath(Path.Combine(ImportPath, paths[i]));
                }
                if (!paths[i].StartsWith(ImportPath, StringComparison.CurrentCultureIgnoreCase))
                {
                    throw new ArgumentException("One or more paths are out of the ImportPath");
                }
                paths[i] = paths[i].Substring(ImportPath.Length).Replace("\\", "/");
                paths[i] = paths[i].Length == 0 || paths[i] == "/"
                    ? "/Root"
                    : "/Root" + paths[i];
            }
            SkippedPathArray = paths;

            // OUTPUT DIRECTORY
            if (OutputPath == null)
            {
                OutputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output");
            }

            // DATA FILE: Ensure absolute path. Create parent directory if needed.
            if (DataFileName == null)
            {
                DataFileName = DefaultDataFileName;
            }
            if (!Path.IsPathRooted(DataFileName))
            {
                DataFileName = Path.GetFullPath(Path.Combine(OutputPath, DataFileName));
            }

            // INDEX FILE: Ensure absolute path. Create parent directory if needed.
            if (IndexFileName == null)
            {
                IndexFileName = DefaultIndexFileName;
            }
            if (!Path.IsPathRooted(IndexFileName))
            {
                IndexFileName = Path.GetFullPath(Path.Combine(OutputPath, IndexFileName));
            }

            // NAMESPACES AND CLASS NAMES
            // Split database typename to namespace and class name.
            if (DatabaseTypeName == null)
            {
                DatabaseTypeName = Path.GetFileNameWithoutExtension(DataFileName);
            }

            var segments = DatabaseTypeName.Split('.');

            if (segments.Length > 1)
            {
                DatabaseClassName = segments.Last();
                DatabaseNamespace = string.Join(".", segments.Take(segments.Length - 1));
            }
            else
            {
                DatabaseClassName = segments[0];
            }

            // Split index typename to namespace and class name.
            if (IndexTypeName == null)
            {
                IndexTypeName = Path.GetFileNameWithoutExtension(IndexFileName);
            }

            segments = IndexTypeName.Split('.');
            if (segments.Length > 1)
            {
                IndexClassName = segments.Last();
                IndexNamespace = string.Join(".", segments.Take(segments.Length - 1));
            }
            else
            {
                IndexClassName = segments[0];
            }

            // Ensure namespaces
            if (DatabaseNamespace == null)
            {
                DatabaseNamespace = IndexNamespace;
            }
            if (DatabaseNamespace == null)
            {
                DatabaseNamespace = DefaultNamespace;
            }
            if (IndexNamespace == null)
            {
                IndexNamespace = DatabaseNamespace;
            }
        }
Example #2
0
        public void RegisterPersonAzureSearch(UnityDependencyInjector di, string azureApiKey, string azureSearchIndexName, IndexTypeName type, InstanceLifetime instanceLifetime)
        {
            var mockedIndex = new MockPersonAzureSearch();

            var dataBytes = (byte[])Properties.Resources.ResourceManager.GetObject("indexdata");

            if (dataBytes == null)
            {
                throw new ArgumentException("kunne ikke lese fil");
            }

            bool hasMoreLines = true;
            var  file         = new MemoryStream(dataBytes);
            var  reader       = new StreamReader(file);

            while (!reader.EndOfStream)
            {
                var nextLine = reader.ReadLine();
                var person   = JsonConvert.DeserializeObject <RegisterPersonModel>(nextLine);
                mockedIndex.Db.Add(person.CommonIdentifier, person);
            }

            di.RegisterInstance <IAzureSearch <RegisterPersonModel> >(mockedIndex);
        }
Example #3
0
        public void RegisterBusinessAzureSearch(UnityDependencyInjector di, string azureApiKey, string azureSearchIndexName, IndexTypeName type, InstanceLifetime instanceLifetime)
        {
            var mockedBusinessIndex = new MockBusinessAzureSearch();

            di.RegisterInstance <IAzureSearch <RegisterBusinessModel> >(mockedBusinessIndex);
        }
 public bool EqualsAdvancedIndex(AdvancedIndexIndexMultiKeyPart that)
 {
     return IndexTypeName.Equals(that.IndexTypeName) && IndexExpressions.AreEqual(that.IndexExpressions);
 }