Exemplo n.º 1
0
            public void MergeInto (AssemblyConfiguration result) {
                result.Ignored.AddRange(Ignored);
                result.Stubbed.AddRange(Stubbed);
                result.Proxies.AddRange(Proxies);

                foreach (var kvp in Redirects)
                    result.Redirects[kvp.Key] = kvp.Value;
            }
Exemplo n.º 2
0
        private static void InitializeType(Type type, bool isSandboxAssembly)
        {
#if !STANDALONE
            TypeConfiguration typeConfiguration = null;
#endif

            foreach (var field in type.GetRuntimeFields())
            {
                var attr = field.GetCustomAttribute <ConfigurationAttribute>();
                if (attr != null)
                {
#if SHAMAN
                    if (isSandboxAssembly && type.FullName.EndsWith("Sandbox") && type.Name.AsValueString().Substring(0, type.Name.Length - "Sandbox".Length) != ConfigurationManagerConfig.AlternateEntrypointName)
                    {
                        attr.CommandLineAlias = null;
                    }
#endif

                    object value;
                    if (TryGetValue(field, attr, out value))
                    {
                        field.SetValue(null, value);
#if !STANDALONE
                        if (typeConfiguration == null)
                        {
                            if (configuration == null)
                            {
                                configuration = new List <AssemblyConfiguration>();
                            }
                            var asmname = type.Assembly().GetName().Name;
                            var asm     = configuration.FirstOrDefault(x => x.AssemblyName == asmname);
                            if (asm == null)
                            {
                                asm = new AssemblyConfiguration()
                                {
                                    AssemblyName = asmname, Types = new List <TypeConfiguration>()
                                };
                                configuration.Add(asm);
                            }
                            typeConfiguration = asm.Types.FirstOrDefault(x => x.FullName == type.FullName);
                            if (typeConfiguration == null)
                            {
                                typeConfiguration = new TypeConfiguration()
                                {
                                    FullName = type.FullName, Fields = new List <FieldConfiguration>()
                                };
                                asm.Types.Add(typeConfiguration);
                            }
                            typeConfiguration.Fields.Add(new FieldConfiguration()
                            {
                                FieldName = field.Name, Value = value
                            });
                        }
#endif
                    }
                }
            }
        }
Exemplo n.º 3
0
            public void MergeInto(AssemblyConfiguration result)
            {
                result.Ignored.AddRange(Ignored);
                result.Stubbed.AddRange(Stubbed);
                result.Proxies.AddRange(Proxies);

                foreach (var kvp in Redirects)
                {
                    result.Redirects[kvp.Key] = kvp.Value;
                }
            }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the configuration, given an assembly.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 /// <returns></returns>
 private static AssemblyConfiguration GetConfiguration(Assembly assembly)
 {
     lock (ConfigurationByAssembly)
     {
         var assemblyName = assembly.GetName();
         if (!ConfigurationByAssembly.TryGetValue(assemblyName, out var configuration))
         {
             var configurationAttribute = assembly.GetCustomAttributes(typeof(PersistentConfigurationAttribute), false)
                                          .OfType <PersistentConfigurationAttribute>().SingleOrDefault();
             var persistentDataType       = configurationAttribute?.PersistentDataType ?? typeof(PersistentData);
             var persistentSerializerType = configurationAttribute?.PersistentSerializerType ?? typeof(RegistryPersistentSerializer);
             configuration = new AssemblyConfiguration
             {
                 Data       = (IPersistentData)GetInstance(persistentDataType, assembly),
                 Serializer = (IPersistentSerializer)GetInstance(persistentSerializerType, assembly)
             };
             ConfigurationByAssembly[assemblyName] = configuration;
         }
         return(configuration);
     }
 }
Exemplo n.º 5
0
 public void MergeInto(AssemblyConfiguration result)
 {
     result.Ignored.AddRange(Ignored);
     result.Stubbed.AddRange(Stubbed);
     result.Proxies.AddRange(Proxies);
 }
Exemplo n.º 6
0
 public void MergeInto(AssemblyConfiguration result)
 {
     result.Ignored.AddRange(Ignored);
     result.Stubbed.AddRange(Stubbed);
     result.Proxies.AddRange(Proxies);
 }
Exemplo n.º 7
0
 public void RunTests(AssemblyConfiguration assemblyConfiguration)
 {
     RunTests(assemblyConfiguration.Path);
 }