Example #1
0
        public void enumerating_aggregates_the_dependencies()
        {
            var child1 = new DependencyCollection();

            child1.Add(new Dependency("Bottles"));
            child1.Add(new Dependency("FubuCore"));

            var child2 = new DependencyCollection();

            child2.Add(new Dependency("Bottles"));
            child2.Add(new Dependency("FubuCore"));
            child2.Add(new Dependency("FubuTestingSupport", "0.9.2.4"));
            child2.Add(new Dependency("RhinoMocks", "3.6.1"));

            theSolutionDependencies.Add(new Dependency("Bottles", "1.0.1.2"));
            theSolutionDependencies.Add(new Dependency("FubuCore", "1.0.1.5"));

            theSolutionDependencies.AddChild(child1);
            theSolutionDependencies.AddChild(child2);

            var expected = new[]
            {
                new Dependency("Bottles", "1.0.1.2"),
                new Dependency("FubuCore", "1.0.1.5"),
                new Dependency("FubuTestingSupport", "0.9.2.4"),
                new Dependency("RhinoMocks", "3.6.1")
            };

            theSolutionDependencies.ShouldHaveTheSameElementsAs(expected);
        }
Example #2
0
        private void BuildDependencies(Namespace space, DependencyCollection <UserSymbol, Unit> dependencies)
        {
            foreach (var s in space.Symbols)
            {
                if (s.Kind != SymbolKind.ConSymb && s.Kind != SymbolKind.MapSymb)
                {
                    continue;
                }
                else if (s.Kind == SymbolKind.ConSymb && !((ConSymb)s).IsNew)
                {
                    continue;
                }

                dependencies.Add(s);

                for (int i = 0; i < s.Arity; ++i)
                {
                    var app = s.CanonicalForm[i];
                    foreach (var t in app.NonRangeMembers)
                    {
                        if (t.Kind == SymbolKind.UserSortSymb)
                        {
                            dependencies.Add(((UserSortSymb)t).DataSymbol, s, default(Unit));
                        }
                    }
                }
            }

            foreach (var c in space.Children)
            {
                BuildDependencies(c, dependencies);
            }
        }
Example #3
0
        static void ReadDependencies(DependencyCollection deps, DependencyCollection opDeps, XmlElement elem)
        {
            foreach (XmlElement dep in elem.SelectNodes("Dependencies/Addin"))
            {
                AddinDependency adep = new AddinDependency();
                adep.AddinId = dep.GetAttribute("id");
                string v = dep.GetAttribute("version");
                if (v.Length != 0)
                {
                    adep.Version = v;
                }
                deps.Add(adep);
            }

            foreach (XmlElement dep in elem.SelectNodes("Dependencies/Assembly"))
            {
                AssemblyDependency adep = new AssemblyDependency();
                adep.FullName = dep.GetAttribute("name");
                adep.Package  = dep.GetAttribute("package");
                deps.Add(adep);
            }

            foreach (XmlElement mod in elem.SelectNodes("Module"))
            {
                ReadDependencies(opDeps, opDeps, mod);
            }
        }
        public void enumerating_aggregates_the_dependencies()
        {
            var child1 = new DependencyCollection();
            child1.Add(new Dependency("Bottles"));
            child1.Add(new Dependency("FubuCore"));

            var child2 = new DependencyCollection();
            child2.Add(new Dependency("Bottles"));
            child2.Add(new Dependency("FubuCore"));
            child2.Add(new Dependency("FubuTestingSupport", "0.9.2.4"));
            child2.Add(new Dependency("RhinoMocks", "3.6.1"));

            theSolutionDependencies.Add(new Dependency("Bottles", "1.0.1.2"));
            theSolutionDependencies.Add(new Dependency("FubuCore", "1.0.1.5"));

            theSolutionDependencies.AddChild(child1);
            theSolutionDependencies.AddChild(child2);

            var expected = new[]
            {
                new Dependency("Bottles", "1.0.1.2"),
                new Dependency("FubuCore", "1.0.1.5"),
                new Dependency("FubuTestingSupport", "0.9.2.4"),
                new Dependency("RhinoMocks", "3.6.1")
            };

            theSolutionDependencies.ShouldHaveTheSameElementsAs(expected);
        }
        public void set_optional_properties_and_the_values_should_be_set()
        {
            theDependencies.Add("FirstName", "Jeremy");
            theDependencies.Add("LastName", "Miller");

            TheTarget.FirstName.ShouldBe("Jeremy");
            TheTarget.LastName.ShouldBe("Miller");
        }
Example #6
0
        public void items_with_circular_dependencies_can_be_added()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test", "test2");
            collection.Add("test2", "test");

            Assert.ThrowsException <Exception>(() => collection.ToList());
        }
Example #7
0
        public void SetUp()
        {
            theCollection = new DependencyCollection();

            theCollection.Add(new Dependency("Bottles", "1.0.0.1"));
            theCollection.Add(new Dependency("structuremap", "2.6.3", UpdateMode.Fixed));

            theCollection.MarkRead();
        }
        public void can_override_and_last_one_in_wins()
        {
            var collection = new DependencyCollection();
            collection.Add("foo", typeof(IGateway), gateway1);
            collection.Add("foo", typeof(IGateway), gateway2);

            collection.FindByTypeOrName(typeof(IGateway), "foo")
                .ShouldBeTheSameAs(gateway2);
        }
Example #9
0
        public void can_override_and_last_one_in_wins()
        {
            var collection = new DependencyCollection();

            collection.Add("foo", typeof(IGateway), gateway1);
            collection.Add("foo", typeof(IGateway), gateway2);

            collection.FindByTypeOrName(typeof(IGateway), "foo")
            .ShouldBeTheSameAs(gateway2);
        }
        public void see_the_description_of_class_with_only_ctor_with_inline_depencencies()
        {
            var dependencies = new DependencyCollection();
            dependencies.Add(typeof(Rule), new ColorRule("Red"));
            dependencies.Add(typeof(IWidget), new AWidget());

            var build = ConcreteType.BuildSource(typeof(GuyWithOnlyCtor), null, dependencies,
                Policies.Default());

            Debug.WriteLine(build.Description);
        }
Example #11
0
        public void can_sort_types()
        {
            var collection = new DependencyCollection <Type>();

            collection.Add(typeof(UserService), typeof(ConfigurationService));
            collection.Add(typeof(ConfigurationService));

            var list = collection.ToList();

            CollectionAssert.AreEqual(new [] { typeof(ConfigurationService), typeof(UserService) }, list);
        }
        public void add_and_retrieve_by_type_only()
        {
            var collection = new DependencyCollection();
            collection.Add(typeof (IService), service1);
            collection.Add(typeof (IGateway), gateway3);

            collection.FindByTypeOrName(typeof (IGateway), "foo")
                .ShouldBe(gateway3);

            collection.FindByTypeOrName(typeof (IService), "anything")
                .ShouldBe(service1);
        }
        public void has_missing_primitives_negative()
        {
            var ctor = typeof(GuyWithPrimitiveArgs).GetConstructors().Single();

            var dependencies = new DependencyCollection();

            dependencies.Add("name", "Jeremy");
            dependencies.Add(typeof(int), 41);

            // One is still missing
            GreediestConstructorSelector.HasMissingPrimitives(ctor, dependencies).ShouldBeFalse();
        }
Example #14
0
        public void dependencies_should_be_sorted()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test2", "test");
            collection.Add("test");

            var list = collection.ToList();

            Assert.AreEqual(2, list.Count);
            CollectionAssert.AreEqual(list, new [] { "test", "test2" });
        }
Example #15
0
        public void see_the_description_of_class_with_only_ctor_with_inline_depencencies()
        {
            var dependencies = new DependencyCollection();

            dependencies.Add(typeof(Rule), new ColorRule("Red"));
            dependencies.Add(typeof(IWidget), new AWidget());

            var build = ConcreteType.BuildSource(typeof(GuyWithOnlyCtor), null, dependencies,
                                                 new Policies());

            Debug.WriteLine(build.Description);
        }
        public void is_valid_sad_path_with_setter_checks()
        {
            // This class needs all three of these things
            var dependencies = new DependencyCollection();

            dependencies.Add("Name", "Jeremy");
            dependencies.Add("Age", 40);
            //dependencies.Add("IsAwake", true);

            ConcreteType.BuildSource(typeof(GuyWithPrimitiveSetters), null, dependencies, Policies.Default())
            .IsValid().ShouldBeFalse();
        }
        public void has_missing_primitives_negative()
        {
            var ctor = typeof(GuyWithPrimitiveArgs).GetConstructors().Single();

            var dependencies = new DependencyCollection();

            dependencies.Add("name", "Jeremy");
            dependencies.Add(typeof(int), 41);

            // One is still missing
            GreediestConstructorSelector.HasMissingPrimitives(ctor, dependencies).ShouldBeFalse();
        }
        public void is_valid_happy_path_with_ctor_checks()
        {
            // This class needs all three of these things
            var dependencies = new DependencyCollection();

            dependencies.Add("name", "Jeremy");
            dependencies.Add("age", 40);
            dependencies.Add("isAwake", true);

            ConcreteType.BuildSource(typeof(GuyWithPrimitives), null, dependencies, Policies.Default())
            .IsValid().ShouldBeTrue();
        }
        public void add_and_retrieve_by_name_only()
        {
            var collection = new DependencyCollection();
            collection.Add("foo", gateway1);
            collection.Add("bar", gateway2);

            collection.FindByTypeOrName(typeof (IGateway), "foo")
                .ShouldBeTheSameAs(gateway1);

            collection.FindByTypeOrName(typeof (IGateway), "bar")
                .ShouldBeTheSameAs(gateway2);
        }
Example #20
0
        public void nullable_type_found_by_underlying_type()
        {
            var collection = new DependencyCollection();

            collection.Add("foo", 1);
            collection.Add("bar", 1.1m);

            collection.FindByTypeAndName(typeof(int?), "foo")
            .ShouldBe(1);

            collection.FindByTypeAndName(typeof(int?), "bar")
            .ShouldBeNull();
        }
Example #21
0
        public void existing_item_can_be_removed()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test");
            collection.Add("test2", "test");
            collection.Remove("test");

            var list = collection.ToList();

            Assert.AreEqual(1, list.Count);
            CollectionAssert.Contains(list, "test2");
        }
Example #22
0
        public void item_with_previously_added_dependency_can_be_added()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test");
            collection.Add("test2", "test");

            var list = collection.ToList();

            Assert.AreEqual(2, list.Count);
            CollectionAssert.Contains(list, "test");
            CollectionAssert.Contains(list, "test2");
        }
Example #23
0
        public void add_and_retrieve_by_name_only()
        {
            var collection = new DependencyCollection();

            collection.Add("foo", gateway1);
            collection.Add("bar", gateway2);

            collection.FindByTypeOrName(typeof(IGateway), "foo")
            .ShouldBeTheSameAs(gateway1);

            collection.FindByTypeOrName(typeof(IGateway), "bar")
            .ShouldBeTheSameAs(gateway2);
        }
Example #24
0
        public void add_and_retrieve_by_type_only()
        {
            var collection = new DependencyCollection();

            collection.Add(typeof(IService), service1);
            collection.Add(typeof(IGateway), gateway3);

            collection.FindByTypeOrName(typeof(IGateway), "foo")
            .ShouldBe(gateway3);

            collection.FindByTypeOrName(typeof(IService), "anything")
            .ShouldBe(service1);
        }
Example #25
0
        public void uses_the_top_most_dependency()
        {
            var projectDependency   = new Dependency("StructureMap");
            var projectDependencies = new DependencyCollection();

            projectDependencies.Add(projectDependency);

            var solutionDependency = new Dependency("StructureMap", "2.6.3", UpdateMode.Fixed);

            theSolutionDependencies.Add(solutionDependency);
            theSolutionDependencies.AddChild(projectDependencies);

            theSolutionDependencies.Find("StructureMap").ShouldEqual(solutionDependency);
        }
Example #26
0
        public void removing_non_existing_items_does_not_throw_exceptions()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test");
            collection.Add("test2", "test");
            collection.Remove("test3");

            var list = collection.ToList();

            Assert.AreEqual(2, list.Count);
            CollectionAssert.Contains(list, "test");
            CollectionAssert.Contains(list, "test2");
        }
        public void use_most_specific_criteria_if_possible()
        {
            var collection = new DependencyCollection();
            collection.Add("foo", typeof (IGateway), gateway1);
            collection.Add("bar", typeof (IGateway), gateway2);
            collection.Add("bar", typeof (IService), service1);

            collection.FindByTypeOrName(typeof (IGateway), "foo")
                .ShouldBeTheSameAs(gateway1);

            collection.FindByTypeOrName(typeof (IGateway), "bar")
                .ShouldBeTheSameAs(gateway2);

            collection.FindByTypeOrName(typeof (IService), "bar")
                .ShouldBeTheSameAs(service1);
        }
Example #28
0
        public void one_item_without_dependencies_can_be_added()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test");
            Assert.AreEqual(1, collection.Count());
        }
        public void use_most_specific_criteria_if_possible()
        {
            var collection = new DependencyCollection();

            collection.Add("foo", typeof(IGateway), gateway1);
            collection.Add("bar", typeof(IGateway), gateway2);
            collection.Add("bar", typeof(IService), service1);

            collection.FindByTypeOrName(typeof(IGateway), "foo")
            .ShouldBeTheSameAs(gateway1);

            collection.FindByTypeOrName(typeof(IGateway), "bar")
            .ShouldBeTheSameAs(gateway2);

            collection.FindByTypeOrName(typeof(IService), "bar")
            .ShouldBeTheSameAs(service1);
        }
Example #30
0
        internal void UpdateDependencies(NIType type)
        {
            QualifiedName oldTypeName = TypeName;
            QualifiedName typeName    = type.GetTypeDefinitionQualifiedName();

            if (oldTypeName != typeName)
            {
                TypeName = typeName;
                TransactionRecruiter.EnlistPropertyItem(this, nameof(TypeName), oldTypeName, typeName, (n, _) => TypeName = n, TransactionHints.Semantic);

                if (!oldTypeName.IsEmpty)
                {
                    _dependencies.RemoveOfType <TypeDiagramDependency>(this);
                }
                _dependencies.Add(this, new TypeDiagramDependency(this, typeName));
            }
        }
Example #31
0
        public void can_be_casted_to_IEnumerable()
        {
            var collection = new DependencyCollection <string>();

            collection.Add("test2", "test");
            collection.Add("test");

            var enumerable = (IEnumerable)collection;
            var list       = new List <object>();

            foreach (var value in enumerable)
            {
                list.Add(value);
            }
            Assert.AreEqual(2, list.Count);
            CollectionAssert.AreEqual(list, new[] { "test", "test2" });
        }
        public void sends_the_constructor_args_and_parameters_to_the_visitor()
        {
            var dependencies = new DependencyCollection();
            dependencies.Add(typeof (Rule), new ColorRule("Red"));
            dependencies.Add(typeof (IWidget), new AWidget());

            var build = ConcreteType.BuildSource(typeof (GuyWithCtorAndArgs), null, dependencies,
                Policies.Default());

            var visitor = new StubVisitor();
            build.AcceptVisitor(visitor);

            visitor.Items.ShouldHaveTheSameElementsAs(
                "Constructor: Void .ctor(StructureMap.Testing.Widget3.IGateway, StructureMap.Testing.Widget.Rule)",
                "Set IWidget Widget = Value: StructureMap.Testing.Widget.AWidget",
                "Set IService Service = *Default of IService*"
                );
        }
        public void finds_the_dependency_from_a_child_collection()
        {
            var projectDependency = new Dependency("Bottles");
            var projectDependencies = new DependencyCollection();
            projectDependencies.Add(projectDependency);

            theSolutionDependencies.AddChild(projectDependencies);

            theSolutionDependencies.Find("Bottles").ShouldEqual(projectDependency);
        }
Example #34
0
        public static DependencyProvider BuildDependencyProvider(this IServiceCollection services)
        {
            var dependencies = new DependencyCollection();

            dependencies
            .Add(new ServiceScopeDependency())
            .AddServiceCollection(services);

            return(dependencies.BuildProvider());
        }
Example #35
0
        public void sends_the_constructor_args_and_parameters_to_the_visitor()
        {
            var dependencies = new DependencyCollection();

            dependencies.Add(typeof(Rule), new ColorRule("Red"));
            dependencies.Add(typeof(IWidget), new AWidget());

            var build = ConcreteType.BuildSource(typeof(GuyWithCtorAndArgs), null, dependencies,
                                                 new Policies());

            var visitor = new StubVisitor();

            build.AcceptVisitor(visitor);

            visitor.Items.ShouldHaveTheSameElementsAs(
                "Constructor: Void .ctor(StructureMap.Testing.Widget3.IGateway, StructureMap.Testing.Widget.Rule)",
                "Set IWidget Widget = Value: StructureMap.Testing.Widget.AWidget",
                "Set IService Service = *Default of IService*"
                );
        }
        public void if_an_enumerable_type_and_there_is_no_exact_match_by_type_try_ienumerable_of_the_element_type()
        {
            var collection = new DependencyCollection();
            var instance = new EnumerableInstance(new Instance[0]);

            collection.Add(typeof (IEnumerable<IGateway>), instance);

            collection.FindByTypeOrName(typeof (IList<IGateway>), null).ShouldBeTheSameAs(instance);
            collection.FindByTypeOrName(typeof (List<IGateway>), null).ShouldBeTheSameAs(instance);
            collection.FindByTypeOrName(typeof (IGateway[]), null).ShouldBeTheSameAs(instance);
        }
Example #37
0
        public void if_an_enumerable_type_and_there_is_no_exact_match_by_type_try_ienumerable_of_the_element_type()
        {
            var collection = new DependencyCollection();
            var instance   = new EnumerableInstance(new Instance[0]);

            collection.Add(typeof(IEnumerable <IGateway>), instance);

            collection.FindByTypeOrName(typeof(IList <IGateway>), null).ShouldBeTheSameAs(instance);
            collection.FindByTypeOrName(typeof(List <IGateway>), null).ShouldBeTheSameAs(instance);
            collection.FindByTypeOrName(typeof(IGateway[]), null).ShouldBeTheSameAs(instance);
        }
Example #38
0
        public void has_missing_primitives_positive_2()
        {
            var ctor = typeof(GuyWithPrimitiveArgs).GetConstructors().Single();

            var dependencies = new DependencyCollection();

            dependencies.Add("age", 1);

            // One is still missing
            GreediestConstructorSelector.HasMissingPrimitives(ctor, dependencies).ShouldBeTrue();
        }
Example #39
0
        public void finds_the_dependency_from_a_child_collection()
        {
            var projectDependency   = new Dependency("Bottles");
            var projectDependencies = new DependencyCollection();

            projectDependencies.Add(projectDependency);

            theSolutionDependencies.AddChild(projectDependencies);

            theSolutionDependencies.Find("Bottles").ShouldEqual(projectDependency);
        }
        public void has_missing_primitives_positive_2()
        {
            var ctor = typeof(GuyWithPrimitiveArgs).GetConstructors().Single();

            var dependencies = new DependencyCollection();

            dependencies.Add("age", 1);

            // One is still missing
            GreediestConstructorSelector.HasMissingPrimitives(ctor, dependencies).ShouldBeTrue();
        }
        public void uses_the_top_most_dependency()
        {
            var projectDependency = new Dependency("StructureMap");
            var projectDependencies = new DependencyCollection();
            projectDependencies.Add(projectDependency);

            var solutionDependency = new Dependency("StructureMap", "2.6.3", UpdateMode.Fixed);
            theSolutionDependencies.Add(solutionDependency);
            theSolutionDependencies.AddChild(projectDependencies);

            theSolutionDependencies.Find("StructureMap").ShouldEqual(solutionDependency);
        }
Example #42
0
        internal void ResolveDependency(IProgressMonitor monitor, Dependency dep, AddinPackage parentPackage, PackageCollection toInstall, PackageCollection toUninstall, PackageCollection installedRequired, DependencyCollection unresolved)
        {
            AddinDependency adep = dep as AddinDependency;

            if (adep == null)
            {
                return;
            }

            string nsid = Addin.GetFullId(parentPackage.Addin.Namespace, adep.AddinId, null);

            foreach (Package p in toInstall)
            {
                AddinPackage ap = p as AddinPackage;
                if (ap != null)
                {
                    if (Addin.GetIdName(ap.Addin.Id) == nsid && ((AddinInfo)ap.Addin).SupportsVersion(adep.Version))
                    {
                        return;
                    }
                }
            }

            ArrayList addins = new ArrayList();

            addins.AddRange(service.Registry.GetAddins());
            addins.AddRange(service.Registry.GetAddinRoots());

            foreach (Addin addin in addins)
            {
                if (Addin.GetIdName(addin.Id) == nsid && addin.SupportsVersion(adep.Version))
                {
                    AddinPackage p = AddinPackage.FromInstalledAddin(addin);
                    if (!installedRequired.Contains(p))
                    {
                        installedRequired.Add(p);
                    }
                    return;
                }
            }

            AddinRepositoryEntry[] avaddins = service.Repositories.GetAvailableAddins();
            foreach (PackageRepositoryEntry avAddin in avaddins)
            {
                if (Addin.GetIdName(avAddin.Addin.Id) == nsid && ((AddinInfo)avAddin.Addin).SupportsVersion(adep.Version))
                {
                    toInstall.Add(AddinPackage.FromRepository(avAddin));
                    return;
                }
            }
            unresolved.Add(adep);
        }
Example #43
0
        public void is_valid_sad_path_with_setter_checks()
        {
            // This class needs all three of these things
            var dependencies = new DependencyCollection();
            dependencies.Add("Name", "Jeremy");
            dependencies.Add("Age", 40);
            //dependencies.Add("IsAwake", true);

            ConcreteType.BuildSource(typeof (GuyWithPrimitiveSetters), null, dependencies, Policies.Default())
                .IsValid().ShouldBeFalse();
        }
Example #44
0
        public void is_valid_happy_path_with_ctor_checks()
        {
            // This class needs all three of these things
            var dependencies = new DependencyCollection();
            dependencies.Add("name", "Jeremy");
            dependencies.Add("age", 40);
            dependencies.Add("isAwake", true);

            ConcreteType.BuildSource(typeof (GuyWithPrimitives), null, dependencies, Policies.Default())
                .IsValid().ShouldBeTrue();
        }
		/// <summary>
		/// Loads a JS-externs dependencies from virtual file system
		/// </summary>
		/// <param name="externsFilePaths">List of JS-externs file paths</param>
		/// <returns>List of JS-externs dependencies</returns>
		private DependencyCollection LoadExternsDependenciesFromVirtualFileSystem(IList<string> externsFilePaths)
		{
			var externsDependencies = new DependencyCollection();

			foreach (string externsFilePath in externsFilePaths)
			{
				if (_virtualFileSystemWrapper.FileExists(externsFilePath))
				{
					string content = _virtualFileSystemWrapper.GetFileTextContent(externsFilePath);
					externsDependencies.Add(new Dependency(externsFilePath, content, true));
				}
				else
				{
					throw new FileNotFoundException(
						string.Format(CoreStrings.Common_FileNotExist, externsFilePath));
				}
			}

			return externsDependencies;
		}
        /// <summary>
        /// "Compiles" a TypeScript-code to JS-code
        /// </summary>
        /// <param name="content">Text content written on TypeScript</param>
        /// <param name="path">Path to TypeScript-file</param>
        /// <param name="dependencies">List of dependencies</param>
        /// <param name="options">Compilation options</param>
        /// <returns>Translated TypeScript-code</returns>
        public string Compile(string content, string path, DependencyCollection dependencies,
            CompilationOptions options = null)
        {
            string newContent;
            CompilationOptions currentOptions;
            string currentOptionsString;

            if (options != null)
            {
                currentOptions = options;
                currentOptionsString = ConvertCompilationOptionsToJson(options).ToString();
            }
            else
            {
                currentOptions = _defaultOptions;
                currentOptionsString = _defaultOptionsString;
            }

            var newDependencies = new DependencyCollection();
            if (!currentOptions.NoLib)
            {
                string defaultLibFileName = (currentOptions.Target == TargetMode.EcmaScript6) ?
                    DEFAULT_LIBRARY_ES6_FILE_NAME : DEFAULT_LIBRARY_FILE_NAME;
                var defaultLibDependency = new Dependency(defaultLibFileName, _commonTypesDefinitions[defaultLibFileName]);
                newDependencies.Add(defaultLibDependency);
            }
            newDependencies.AddRange(dependencies);

            lock (_compilationSynchronizer)
            {
                Initialize();

                try
                {
                    var result = _jsEngine.Evaluate<string>(string.Format(COMPILATION_FUNCTION_CALL_TEMPLATE,
                        JsonConvert.SerializeObject(content),
                        JsonConvert.SerializeObject(path),
                        ConvertDependenciesToJson(newDependencies),
                        currentOptionsString));
                    var json = JObject.Parse(result);

                    var errors = (json["errors"] != null) ? json["errors"] as JArray : null;
                    if (errors != null && errors.Count > 0)
                    {
                        throw new TypeScriptCompilingException(FormatErrorDetails(errors[0], content, path,
                            newDependencies));
                    }

                    newContent = json.Value<string>("compiledCode");
                }
                catch (JsRuntimeException e)
                {
                    throw new TypeScriptCompilingException(
                        JsRuntimeErrorHelpers.Format(e));
                }
            }

            return newContent;
        }
        public void SetUp()
        {
            theCollection = new DependencyCollection();

            theCollection.Add(new Dependency("Bottles", "1.0.0.1"));
            theCollection.Add(new Dependency("structuremap", "2.6.3", UpdateMode.Fixed));

            theCollection.MarkRead();
        }
		/// <summary>
		/// "Compiles" a JS-code
		/// </summary>
		/// <param name="content">Text content written on JavaScript</param>
		/// <param name="path">Path to JS-file</param>
		/// <param name="externsDependencies">List of JS-externs dependencies</param>
		/// <param name="options">Compilation options</param>
		/// <returns>Compiled JS-code</returns>
		public string Compile(string content, string path, DependencyCollection externsDependencies,
			RemoteJsCompilationOptions options = null)
		{
			string newContent;
			DependencyCollection allExternsDependencies = new DependencyCollection();
			RemoteJsCompilationOptions currentOptions;
			IList<FormItem> currentOptionsFormItems;

			if (options != null)
			{
				currentOptions = options;
				currentOptionsFormItems = ConvertCompilationOptionsToFormItems(currentOptions);
			}
			else
			{
				currentOptions = _defaultOptions;
				currentOptionsFormItems = _defaultOptionsFormItems;
			}

			var formItems = new List<FormItem>();
			formItems.Add(new FormItem("js_code", content));
			if (currentOptions.CompilationLevel == CompilationLevel.Advanced
				&& (_commonExternsDependencies.Count > 0 || externsDependencies.Count > 0))
			{
				allExternsDependencies.AddRange(_commonExternsDependencies);

				foreach (Dependency externsDependency in externsDependencies)
				{
					if (!_commonExternsDependencies.ContainsUrl(externsDependency.Url))
					{
						allExternsDependencies.Add(externsDependency);
					}
				}

				foreach (Dependency externsDependency in allExternsDependencies)
				{
					formItems.Add(new FormItem("js_externs", externsDependency.Content));
				}
			}
			formItems.AddRange(currentOptionsFormItems);

			HttpContent httpContent = new CustomFormUrlEncodedContent(formItems);

			using (var client = new HttpClient())
			{
				HttpResponseMessage response;
				try
				{
					response = client
						.PostAsync(new Uri(_closureCompilerServiceUrl), httpContent)
						.Result
						;
				}
				catch (AggregateException e)
				{
					Exception innerException = e.InnerException;
					if (innerException != null)
					{
						if (innerException is HttpRequestException)
						{
							throw new Exception(
								string.Format(Strings.Minifiers_ClosureRemoteMinificationHttpRequestError,
									_closureCompilerServiceUrl),
								innerException);
						}

						throw innerException;
					}

					throw;
				}

				if (response.IsSuccessStatusCode)
				{
					var result = response.Content.ReadAsStringAsync().Result;
					var json = JObject.Parse(result);

					var serverErrors = json["serverErrors"] != null ? json["serverErrors"] as JArray : null;
					if (serverErrors != null && serverErrors.Count > 0)
					{
						throw new ClosureCompilingException(
							FormatErrorDetails(serverErrors[0], ErrorType.ServerError, path, allExternsDependencies)
						);
					}

					var errors = json["errors"] != null ? json["errors"] as JArray : null;
					if (errors != null && errors.Count > 0)
					{
						throw new ClosureCompilingException(
							FormatErrorDetails(errors[0], ErrorType.Error, path, allExternsDependencies)
						);
					}

					if (currentOptions.Severity > 0)
					{
						var warnings = json["warnings"] != null ? json["warnings"] as JArray : null;
						if (warnings != null && warnings.Count > 0)
						{
							throw new ClosureCompilingException(
								FormatErrorDetails(warnings[0], ErrorType.Warning, path, allExternsDependencies)
							);
						}
					}

					newContent = json.Value<string>("compiledCode");
				}
				else
				{
					throw new AssetMinificationException(
						string.Format(Strings.Minifiers_ClosureRemoteMinificationInvalidHttpStatus,
							response.StatusCode));
				}
			}

			return newContent;
		}
		/// <summary>
		/// "Compiles" a JS-code
		/// </summary>
		/// <param name="content">Text content written on JavaScript</param>
		/// <param name="path">Path to JS-file</param>
		/// <param name="externsDependencies">List of JS-externs dependencies</param>
		/// <param name="options">Compilation options</param>
		/// <returns>Compiled JS-code</returns>
		public string Compile(string content, string path, DependencyCollection externsDependencies,
			LocalJsCompilationOptions options = null)
		{
			string newContent;
			int commonExternsDependencyCount = _commonExternsDependencies.Count;
			string assetExternsTempDirectoryPath = Path.Combine(_tempDirectoryPath, Guid.NewGuid().ToString());
			bool assetExternsTempDirectoryCreated = false;
			LocalJsCompilationOptions currentOptions;
			string currentOptionsString;

			if (options != null)
			{
				currentOptions = options;
				currentOptionsString = ConvertCompilationOptionsToArgs(options);
			}
			else
			{
				currentOptions = _defaultOptions;
				currentOptionsString = _defaultOptionsString;
			}

			var args = new StringBuilder();
			args.AppendFormat(@"-jar ""{0}"" ", _closureCompilerAppPath);
			if (currentOptions.CompilationLevel == CompilationLevel.Advanced
				&& (commonExternsDependencyCount > 0 || externsDependencies.Count > 0))
			{
				if (!_commonExternsTempDirectoryCreated && commonExternsDependencyCount > 0)
				{
					WriteExternsToTempDirectory(_commonExternsDependencies, out _commonExternsTempDirectoryPath,
						out _commonExternsTempFilePaths);
					_commonExternsTempDirectoryCreated = true;
				}

				DependencyCollection assetExternsDependencies = new DependencyCollection();
				if (commonExternsDependencyCount > 0)
				{
					foreach (Dependency externsDependency in externsDependencies)
					{
						if (!_commonExternsDependencies.ContainsUrl(externsDependency.Url))
						{
							assetExternsDependencies.Add(externsDependency);
						}
					}
				}
				else
				{
					assetExternsDependencies.AddRange(externsDependencies);
				}

				IList<string> assetExternsTempFilePaths = new List<string>();

				if (assetExternsDependencies.Count > 0)
				{
					WriteExternsToTempDirectory(assetExternsDependencies, out assetExternsTempDirectoryPath,
						out assetExternsTempFilePaths);
					assetExternsTempDirectoryCreated = true;
				}

				var allExternsTempFilePaths = new List<string>();
				allExternsTempFilePaths.AddRange(_commonExternsTempFilePaths);
				allExternsTempFilePaths.AddRange(assetExternsTempFilePaths);

				foreach (string externsTempFilePath in allExternsTempFilePaths)
				{
					args.AppendFormat(@"--externs ""{0}"" ", externsTempFilePath);
				}
			}
			args.Append(currentOptionsString);

			var processInfo = new ProcessStartInfo
			{
				FileName = _javaVmPath,
				Arguments = args.ToString(),
				CreateNoWindow = true,
				WindowStyle = ProcessWindowStyle.Hidden,
				UseShellExecute = false,
				RedirectStandardInput = true,
				RedirectStandardOutput = true,
				RedirectStandardError = true,
			};

			var stdOutputBuilder = new StdContentBuilder();
			var stdErrorBuilder = new StdContentBuilder();
			Process process = null;

			try
			{
				process = new Process
				{
					StartInfo = processInfo
				};
				process.OutputDataReceived += stdOutputBuilder.OnDataReceived;
				process.ErrorDataReceived += stdErrorBuilder.OnDataReceived;

				process.Start();

				using (StreamWriter inputWriter = process.StandardInput)
				{
					inputWriter.Write(content);
					inputWriter.Flush();
				}

				process.BeginErrorReadLine();
				process.BeginOutputReadLine();

				process.WaitForExit();

				process.OutputDataReceived -= stdOutputBuilder.OnDataReceived;
				process.ErrorDataReceived -= stdErrorBuilder.OnDataReceived;

				string errorString = stdErrorBuilder.Content;
				if (!string.IsNullOrWhiteSpace(errorString))
				{
					IList<string> errors;
					IList<string> warnings;

					ParseErrorDetails(errorString, path, out errors, out warnings);

					if (errors.Count > 0 || warnings.Count > 0)
					{
						if (errors.Count > 0)
						{
							throw new ClosureCompilingException(errors[0]);
						}

						if (currentOptions.Severity > 0 && warnings.Count > 0)
						{
							throw new ClosureCompilingException(warnings[0]);
						}
					}
				}

				newContent = stdOutputBuilder.Content;
			}
			finally
			{
				if (process != null)
				{
					process.Dispose();
				}

				if (assetExternsTempDirectoryCreated && Directory.Exists(assetExternsTempDirectoryPath))
				{
					Directory.Delete(assetExternsTempDirectoryPath, true);
				}
			}

			return newContent;
		}
		/// <summary>
		/// Fills the list of LESS-files, that were added to a LESS-asset
		/// by using the LESS <code>@import</code> rules
		/// </summary>
		/// <param name="rootAssetUrl">URL of root LESS-asset file</param>
		/// <param name="parentStylesheet">Parent LESS-stylesheet</param>
		/// <param name="dependencies">List of LESS-files, that were added to a
		/// LESS-asset by using the LESS <code>@import</code> rules</param>
		public void FillDependencies(string rootAssetUrl, LessStylesheet parentStylesheet, DependencyCollection dependencies)
		{
			foreach (string dataUriFunctionImageUrl in parentStylesheet.DataUriFunctionAssetUrls)
			{
				var dependency = new Dependency(dataUriFunctionImageUrl, string.Empty);
				dependencies.Add(dependency);
			}

			foreach (LessImport import in parentStylesheet.Imports)
			{
				string dependencyUrl = import.Url;
				LessImportOptions dependencyOptions = import.ImportOptions;

				if (UrlHelpers.StartsWithProtocol(dependencyUrl))
				{
					if (!dependencies.ContainsUrl(dependencyUrl))
					{
						var dependency = new Dependency(dependencyUrl, string.Empty, false);
						dependencies.Add(dependency);
					}

					continue;
				}

				if (string.Equals(dependencyUrl, rootAssetUrl, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}

				var duplicateDependency = dependencies.GetByUrl(dependencyUrl);
				bool isDuplicateDependency = (duplicateDependency != null);
				bool isEmptyDependency = isDuplicateDependency && (duplicateDependency.Content.Length == 0);
				bool isNonExistentOptionalDependency = false;

				if (!isDuplicateDependency || isEmptyDependency)
				{
					if (!LessStylesheetExists(dependencyUrl))
					{
						if (dependencyOptions.Optional)
						{
							isNonExistentOptionalDependency = true;
						}
						else
						{
							throw new FileNotFoundException(
								string.Format(CoreStrings.Common_FileNotExist, dependencyUrl));
						}
					}

					var stylesheet = new LessStylesheet(dependencyUrl, string.Empty);
					string dependencyContent = null;

					if (dependencyOptions.Less || dependencyOptions.Inline)
					{
						if (!isNonExistentOptionalDependency)
						{
							stylesheet = GetLessStylesheet(dependencyUrl, dependencyOptions);
							dependencyContent = stylesheet.Content;
						}

						if (isEmptyDependency && stylesheet.Content.Length > 0)
						{
							duplicateDependency.Content = dependencyContent;
							duplicateDependency.IsObservable = true;
						}
						else
						{
							var dependency = new Dependency(dependencyUrl, dependencyContent);
							dependencies.Add(dependency);
						}
					}
					else
					{
						if (!isNonExistentOptionalDependency)
						{
							dependencyContent = string.Empty;
						}

						if (!isDuplicateDependency)
						{
							var dependency = new Dependency(dependencyUrl, dependencyContent, false);
							dependencies.Add(dependency);
						}
					}

					FillDependencies(rootAssetUrl, stylesheet, dependencies);
				}
			}
		}
        /// <summary>
        /// Fills the list of TypeScript-files, references to which have been added to a TypeScript-asset
        /// by using the "reference" comments
        /// </summary>
        /// <param name="rootAssetUrl">URL of root TypeScript-asset file</param>
        /// <param name="parentScript">Parent TypeScript-script</param>
        /// <param name="dependencies">List of TypeScript-files, references to which have been
        /// added to a TypeScript-asset by using the "reference" comments</param>
        public void FillDependencies(string rootAssetUrl, TsScript parentScript,
            DependencyCollection dependencies)
        {
            foreach (string referenceUrl in parentScript.References)
            {
                string dependencyUrl = referenceUrl;

                if (string.Equals(dependencyUrl, rootAssetUrl, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (!dependencies.ContainsUrl(dependencyUrl))
                {
                    string dependencyExtension = Path.GetExtension(dependencyUrl);
                    if (TypeScriptFileExtensionHelpers.IsTypeScript(dependencyExtension)
                        || CoreFileExtensionHelpers.IsJavaScript(dependencyExtension))
                    {
                        if (TsScriptExists(dependencyUrl))
                        {
                            TsScript script = GetTsScript(dependencyUrl);

                            var dependency = new Dependency(dependencyUrl, script.Content);
                            dependencies.Add(dependency);

                            FillDependencies(rootAssetUrl, script, dependencies);
                        }
                        else
                        {
                            throw new FileNotFoundException(
                                string.Format(CoreStrings.Common_FileNotExist, dependencyUrl));
                        }
                    }
                }
            }
        }