Example #1
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();
            registry.Register<CombinedFingerprintProtocol>();
            registry.Register<SourceSetFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = CreateDependencyObject();
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            CombinedFingerprint fp2;
            using (var ms = new MemoryStream(data))
            {
                fp2 = new CombinedFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Example #2
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();

            registry.Register <CombinedFingerprintProtocol>();
            registry.Register <SourceSetFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = CreateDependencyObject();
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            CombinedFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new CombinedFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Example #3
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();

            registry.Register <ObjectPropertiesProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = new ProjectPropertiesDependencies(project, "Type");
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            ObjectPropertiesFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new ObjectPropertiesFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Example #4
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();

            registry.Register <ObjectPropertiesProtocol>();

            var ser = new BinarySerializer(registry);
            var obj = new
            {
                A = "hello",
                B = 10,
                C = 12.2,
                D = new TimeSpan(2, 10, 25)
            };
            var fp1 = new ObjectPropertiesFingerprint(obj, new[] { "A", "B", "C", "D" });

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            ObjectPropertiesFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new ObjectPropertiesFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Example #5
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();

            registry.Register <FSRepositoryFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            FSRepositoryFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new FSRepositoryFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();
            registry.Register<ObjectPropertiesProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = new ProjectPropertiesDependencies(project, "Type");
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            ObjectPropertiesFingerprint fp2;
            using (var ms = new MemoryStream(data))
            {
                fp2 = new ObjectPropertiesFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();
            registry.Register<FSRepositoryFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = new FSRepositoryReferenceDependencies(kernel.Get<IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            FSRepositoryFingerprint fp2;
            using (var ms = new MemoryStream(data))
            {
                fp2 = new FSRepositoryFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();
            registry.Register<ObjectPropertiesProtocol>();

            var ser = new BinarySerializer(registry);
            var obj = new
            {
                A = "hello",
                B = 10,
                C = 12.2,
                D = new TimeSpan(2, 10, 25)
            };
            var fp1 = new ObjectPropertiesFingerprint(obj, new[] { "A", "B", "C", "D" });

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            ObjectPropertiesFingerprint fp2;
            using (var ms = new MemoryStream(data))
            {
                fp2 = new ObjectPropertiesFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Example #9
0
        /// <summary>
        /// Registers default bindings offered by the core bari module to the given ninject kernel
        /// </summary>
        /// <param name="kernel">The kernel to be used for registration</param>
        public static void RegisterCoreBindings(IKernel kernel)
        {
            Contract.Requires(kernel != null);

            kernel.Bind <IBindingRoot>().ToConstant(kernel);

            kernel.Bind <IPluginLoader>().To <DefaultPluginLoader>();

            kernel.Bind <ISuiteFactory>().To <DefaultSuiteFactory>().InSingletonScope();
            kernel.Bind <IModelLoader>().To <LocalYamlModelLoader>().InSingletonScope();
            kernel.Bind <IModelLoader>().To <InMemoryYamlModelLoader>().InSingletonScope();
            kernel.Bind <ISuiteLoader>().To <DefaultSuiteLoader>().InSingletonScope();

            kernel.Bind <IEnvironmentVariableContext>().To <DefaultEnvironmentVariableContext>().InSingletonScope();

            kernel.Bind <IYamlProjectParametersLoader>().To <YamlReferenceAliasesLoader>();
            kernel.Bind <IYamlProjectParametersLoader>().To <YamlTestsLoader>();

            kernel.Bind <ISuiteValidator>().To <DefaultSuiteValidator>();

            // Command factory and enumerator
            RegisterCommandFactory(kernel);

            // Builder enumerator
            kernel.Bind <IBuilderEnumerator>().ToConstant(new BuilderEnumerator());

            // Built-in commands
            RegisterCommand <HelpCommand, HelpCommandPrerequisites>(kernel, "help");
            RegisterCommand <InfoCommand, DefaultCommandPrerequisites>(kernel, "info");
            RegisterCommand <CleanCommand, DefaultCommandPrerequisites>(kernel, "clean");
            RegisterCommand <BuildCommand, DefaultCommandPrerequisites>(kernel, "build");
            RegisterCommand <TestCommand, DefaultCommandPrerequisites>(kernel, "test");
            RegisterCommand <RebuildCommand, DefaultCommandPrerequisites>(kernel, "rebuild");
            RegisterCommand <PackCommand, DefaultCommandPrerequisites>(kernel, "pack");
            RegisterCommand <PublishCommand, DefaultCommandPrerequisites>(kernel, "publish");
            RegisterCommand <SelfUpdateCommand, SelfUpdateCommandPrerequisites>(kernel, "selfupdate");

            // Built-in suite explorers
            kernel.Bind <ISuiteExplorer>().To <ModuleProjectDiscovery>();

            // Default serializer
            var protocolRegistry = new DependencyFingerprintProtocolRegistry();

            kernel.Bind <IDependencyFingerprintProtocolRegistry>().ToConstant(protocolRegistry).InSingletonScope();
            kernel.Bind <IProtocolSerializer>().To <BinarySerializer>();

            protocolRegistry.Register <CombinedFingerprintProtocol>();
            protocolRegistry.Register <ObjectPropertiesProtocol>();
            protocolRegistry.Register <SourceSetFingerprintProtocol>();

            protocolRegistry.RegisterEnum(i => (ProjectType)i);

            // Builder store
            kernel.Bind <IBuilderStore>().To <BuilderStore>().InSingletonScope();

            // Builder statistics
            kernel.Bind <IBuilderStatistics>().To <DefaultBuilderStatistics>();
            kernel.Bind <IMonitoredBuilderFactory>().ToFactory();

            // Default build context
            kernel.Bind <IBuildContext>().To <BuildContext>();
            kernel.Bind <IBuildContextFactory>().ToFactory();

            // Builders
            kernel.Bind <IReferenceBuilder>().To <SuiteReferenceBuilder>().Named("suite");
            kernel.Bind <IReferenceBuilder>().To <SuiteReferenceBuilder>().Named("module");
            kernel.Bind <IReferenceBuilder>().To <AliasReferenceBuilder>().Named("alias");
            kernel.Bind <IReferenceBuilder>().To <FileReferenceBuilder>().Named("file");

            // Builder factories
            kernel.Bind <ICoreBuilderFactory>().ToFactory();
            kernel.Bind <ICachedBuilderFactory>().ToFactory();
            kernel.Bind <IReferenceBuilderFactory>().ToFactory(() => new ReferenceBuilderInstanceProvider());

            kernel.Bind <ISourceSetDependencyFactory>().ToFactory();
            kernel.Bind <ISourceSetFingerprintFactory>().ToFactory();

            kernel.Bind <IProjectBuilderFactory>().To <ContentProjectBuilderFactory>();

            // Packager factory
            kernel.Bind <IProductPackagerFactory>().ToFactory(() => new PackagerFactoryInstanceProvider());

            // Default command target parser
            kernel.Bind <ICommandTargetParser>().To <CommandTargetParser>();

            // Clean helpers
            kernel.Bind <ISoftCleanPredicates>().To <SoftCleanPredicates>().InSingletonScope();
        }