コード例 #1
0
        /// <summary>
        /// Helper method used to create an instance of <c>IConfiguration</c>c>. It is a sample configuration
        /// for creating FinancialSecurityManager by <c>FinancialSecurityManagerBuilder</c>.
        /// </summary>
        /// <returns>Sample configuration for creating FinancialSecurityManager instance using IConfiguration</returns>
        internal static IConfiguration GetConfigObject()
        {
            //Prepare the config.
            IConfiguration config = new DefaultConfiguration("accTest");

            //Add the config parameters
            config.SetSimpleAttribute("objectfactory_key", "object_key");
            config.SetSimpleAttribute("security_id_parser_key", "object_idParser");
            config.SetAttribute("security_id_types", new string[] { SecurityIdType.CUSIP, SecurityIdType.ISIN });
            config.SetAttribute("security_lookup_service_keys",
                                new string[] { "object_lookupService", "object_lookupService" });
            config.SetSimpleAttribute("recursive_lookup", "false");
            config.SetSimpleAttribute("reference_lookup", "true");
            config.SetSimpleAttribute("security_data_cache_key", "object_cache");
            config.SetSimpleAttribute("security_data_combiner_key", "object_combiner");

            IConfiguration ofConfig = new DefaultConfiguration("object_key");

            ofConfig.AddChild(GetIdParserConfigObject());

            ofConfig.AddChild(GetLookupServiceConfigObject());

            ofConfig.AddChild(GetCacheConfigObject());

            ofConfig.AddChild(GetCombinerConfigObject());

            config.AddChild(ofConfig);

            return(config);
        }
コード例 #2
0
        /// <summary>
        /// <para>
        /// Creates a configuration object used in stress tests.
        /// </para>
        /// </summary>
        ///
        /// <returns>
        /// the created <see cref="IConfiguration"/> object.
        /// </returns>
        internal static IConfiguration CreateConfig()
        {
            // the 'root'
            IConfiguration config = new DefaultConfiguration("root");

            // attributes
            config.SetSimpleAttribute("default_font_size", "1.0");
            config.SetSimpleAttribute("font_units", "1.0");
            config.SetSimpleAttribute("character_units", "1.0");

            config.SetSimpleAttribute("minimum_port_width", "1");
            config.SetSimpleAttribute("minimum_port_height", "1");
            config.SetSimpleAttribute("minimum_link_space", "1");
            config.SetSimpleAttribute("minimum_unlinked_port_space", "1");
            config.SetSimpleAttribute("minimum_node_width", "1");
            config.SetSimpleAttribute("minimum_node_height", "1");
            config.SetSimpleAttribute("minimum_synthetic_node_width", "1");
            config.SetSimpleAttribute("minimum_synthetic_node_height", "1");

            config.SetSimpleAttribute("graph_layouter_token", "MockLayouter");
            config.SetSimpleAttribute("logger_name", LogManager.DEFAULT_NAMESPACE);

            // define the layouter
            IConfiguration objConfig = new DefaultConfiguration("object_MockLayouter");

            objConfig.SetSimpleAttribute("name", "MockLayouter");
            IConfiguration typeNameConfig = new DefaultConfiguration("type_name");

            typeNameConfig.SetSimpleAttribute("value", typeof(MockGraphLayouter).AssemblyQualifiedName);
            objConfig.AddChild(typeNameConfig);

            config.AddChild(objConfig);

            return(config);
        }
コード例 #3
0
ファイル: UnitTestHelper.cs プロジェクト: kurtrips/tc
 /// <summary>
 /// Create configuration for the mediator.
 /// </summary>
 /// <returns>The configuration.</returns>
 internal static IConfiguration CreateMediatorConfig()
 {
     IConfiguration ret = new DefaultConfiguration("root");
     IConfiguration objectDef = new DefaultConfiguration("object_MediatorConfig");
     objectDef.SetSimpleAttribute("name", "AuthorizationMappingProvider");
     IConfiguration typeNameConfig = new DefaultConfiguration("type_name");
     typeNameConfig.SetSimpleAttribute("value", typeof(MockAuthorizationMappingProvider).AssemblyQualifiedName);
     objectDef.AddChild(typeNameConfig);
     ret.AddChild(objectDef);
     return ret;
 }
コード例 #4
0
        /// <summary>
        /// Helper method used to create an instance of <c>IConfiguration</c>c>. It is a sample configuration
        /// for creating an instance of <c>ICache</c> by ObjectFactory.
        /// </summary>
        /// <returns>an instance of IConfiguration used to create an <c>ICache</c></returns>
        internal static IConfiguration GetCacheConfigObject()
        {
            IConfiguration cacheConfig = new DefaultConfiguration("object_cache");

            cacheConfig.SetSimpleAttribute("name", "object_cache");
            IConfiguration cacheTypeName = new DefaultConfiguration("type_name");

            cacheTypeName.SetSimpleAttribute("value", "TopCoder.Cache.SimpleCache, TopCoder.Cache");
            cacheConfig.AddChild(cacheTypeName);

            return(cacheConfig);
        }
コード例 #5
0
        /// <summary>
        /// Helper method used to create an instance of <c>IConfiguration</c>c>. It is a sample configuration
        /// for creating an instance of <c>ISecurityDataCombiner</c> by ObjectFactory.
        /// </summary>
        ///
        /// <returns>an instance of IConfiguration used to create an <c>ISecurityDataCombiner</c></returns>
        internal static IConfiguration GetCombinerConfigObject()
        {
            IConfiguration comiberConfig = new DefaultConfiguration("object_combiner");

            comiberConfig.SetSimpleAttribute("name", "object_combiner");
            IConfiguration comiberConfigTypeName = new DefaultConfiguration("type_name");

            comiberConfigTypeName.SetSimpleAttribute("value",
                                                     "TopCoder.FinancialService.Utility.SecurityDataCombiners.DefaultSecurityDataCombiner, " +
                                                     "TopCoder.FinancialService.Utility.Test");
            comiberConfig.AddChild(comiberConfigTypeName);
            return(comiberConfig);
        }
コード例 #6
0
        /// <summary>
        /// Helper method used to create an instance of <c>IConfiguration</c>c>. It is a sample configuration
        /// for creating an instance of <c>ISecurityLookupService</c> by ObjectFactory.
        /// </summary>
        /// <returns>an instance of IConfiguration used to create an <c>ISecurityLookupService</c></returns>
        internal static IConfiguration GetLookupServiceConfigObject()
        {
            IConfiguration lookupServiceConfig = new DefaultConfiguration("object_lookupService");

            lookupServiceConfig.SetSimpleAttribute("name", "object_lookupService");
            IConfiguration lookupServiceConfigTypeName = new DefaultConfiguration("type_name");

            lookupServiceConfigTypeName.SetSimpleAttribute("value",
                                                           "TopCoder.FinancialService.Utility.AccuracyTests.SimpleSecurityLookupService, " +
                                                           "TopCoder.FinancialService.Utility.Test");
            lookupServiceConfig.AddChild(lookupServiceConfigTypeName);

            return(lookupServiceConfig);
        }
コード例 #7
0
        /// <summary>
        /// <para>Creates a valid <see cref="IConfiguration"/> child for the
        /// configuration object to be used with the
        /// <see cref="LayoutEngine"/> ctor. The returned child
        /// contains the object definition for the LayoutEngine's graphLayouter
        /// member.</para>
        /// </summary>
        /// <returns></returns>
        private static IConfiguration GetObjectFactoryConfiguration()
        {
            IConfiguration config = new DefaultConfiguration(
                "TestOFNamespace");
            IConfiguration object1 = new DefaultConfiguration("object1");

            object1.SetSimpleAttribute("name", "GraphLayouter");
            IConfiguration typeNameConfig = new DefaultConfiguration("type_name");

            typeNameConfig.SetSimpleAttribute("value",
                                              typeof(IGraphLayouter).AssemblyQualifiedName);
            object1.AddChild(typeNameConfig);

            config.AddChild(object1);
            return(config);
        }
コード例 #8
0
        /// <summary>
        /// Gets the configuration for creating the CommandLineProcessor
        /// </summary>
        /// <returns>The IConfiguration object.</returns>
        public static IConfiguration GetConfig()
        {
            //CSharpAPIProcessor configuration
            IConfiguration config = new DefaultConfiguration("processor");

            config.SetSimpleAttribute("processor_factory",
                                      "TopCoder.CodeDoc.CSharp.CSharpAPIProcessorFactory, " +
                                      "TopCoder.CodeDoc.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
            config.SetSimpleAttribute("log", "MyLoggerNamespace");

            //CSharpAPIProcessorFactory configuration
            IConfiguration processorFactoryConfig = new DefaultConfiguration("processor_factory_config");

            processorFactoryConfig.SetAttribute("reference_paths", new string[] { REFPATH });
            processorFactoryConfig.SetSimpleAttribute("logger_namespace", "MyLoggerNamespace");

            config.AddChild(processorFactoryConfig);
            return(config);
        }
コード例 #9
0
        /// <summary>
        /// Gets the IConfiguration instance to use for the tests.
        /// </summary>
        /// <returns>The IConfiguration instance to use for the tests.</returns>
        internal static IConfiguration CreateConfiguration()
        {
            IConfiguration config = new DefaultConfiguration("TestConfig");

            config.SetSimpleAttribute("default_font_size", "1.414");
            config.SetSimpleAttribute("font_units", "2.456");
            config.SetSimpleAttribute("character_units", "3.321");
            config.SetSimpleAttribute("minimum_port_width", "4");
            config.SetSimpleAttribute("minimum_port_height", "5");
            config.SetSimpleAttribute("minimum_link_space", "6");
            config.SetSimpleAttribute("minimum_unlinked_port_space", "7");
            config.SetSimpleAttribute("minimum_node_width", "8");
            config.SetSimpleAttribute("minimum_node_height", "9");
            config.SetSimpleAttribute("minimum_synthetic_node_width", "10");
            config.SetSimpleAttribute("minimum_synthetic_node_height", "11");
            config.SetSimpleAttribute("graph_layouter_token", "TestGraphLayouterToken");
            config.SetSimpleAttribute("object_factory_ns", "TestOFNamespace");
            config.SetSimpleAttribute("logger_name", "TestLoggerNamespace");

            config.AddChild(GetObjectFactoryConfiguration());

            return(config);
        }
コード例 #10
0
        /// <summary>
        /// <para>
        /// Adds a new flat configuration node with given name attribute and values
        /// </para>
        /// </summary>
        ///
        /// <param name="parent">
        /// The parent configuration of the new node.
        /// </param>
        /// <param name="name">
        /// The name of the new configuration.
        /// </param>
        /// <param name="values">
        /// The values of the new configuration.
        /// </param>
        /// <param name="propertyIndex">
        /// The index of the new node.
        /// </param>
        ///
        /// <returns>
        /// The configuration created.
        /// </returns>
        private static void AddNewFlatConfig(IConfiguration parent,
            int propertyIndex, string name, params object[] values)
        {
            if (values[0] == null)
            {
                return;
            }

            // The property node
            IConfiguration child = new DefaultConfiguration(ConfigProperty + "_" + propertyIndex);
            child.SetSimpleAttribute(ConfigName, name);

            // The value nodes
            int index = 0;
            foreach (object value in values)
            {
                if (value != null)
                {
                    IConfiguration valueNode = new DefaultConfiguration(ConfigValue + "_" + (++index));
                    valueNode.SetSimpleAttribute(ConfigNodeValue, value.ToString());

                    child.AddChild(AbstractConfiguration.Synchronized(valueNode));
                }
            }

            // Add the new property node
            parent.AddChild(AbstractConfiguration.Synchronized(child));
        }
コード例 #11
0
        /// <summary>
        /// <para>
        /// Converts the parameters configuration in FLAT structure into NESTED structure.
        /// </para>
        /// </summary>
        ///
        /// <param name="key">
        /// The key of the parameters definition.
        /// </param>
        ///
        /// <returns>
        /// The parameters configuration in NESTED structure.
        /// </returns>
        ///
        /// <exception cref="ConfigurationAPISourceException">
        /// If exceptions occur while retrieving the definition info, but may also indicate
        /// incomplete definition info (missing type name), parsing errors if the source
        /// uses string representations or some other errors.
        /// </exception>
        private IConfiguration ConvertParametersConfig(string key)
        {
            IConfiguration parametersConfig = GetChildByName(
                configuration, ConfigNamespace, key + "." + ConfigParameters, false);

            // No parameters configured
            if (parametersConfig == null)
            {
                return null;
            }

            // The new NESTED configuration
            IConfiguration nestedConfig = new DefaultConfiguration(ConfigParameters);

            IConfiguration[] parameters = parametersConfig.Children;

            // Sort the child nodes by name, since the parameters are ordered
            Array.Sort(parameters, new ConfigurationComparer());

            for (int i = 0; i < parameters.Length; ++i)
            {
                if (IsNodeMatch(parameters[i].Name, ConfigProperty))
                {
                    // The new config for the parameter
                    IConfiguration parameter = new DefaultConfiguration(ConfigParameter + "_" + (i + 1));

                    // Type name of the parameter
                    string typeWithDesc = GetSimpleAttribute(parameters[i], ConfigName, true);
                    string type = typeWithDesc.Substring(typeWithDesc.IndexOf(":") + 1).Trim();

                    // Add the type into the new config
                    parameter.SetSimpleAttribute(ConfigType, type);

                    IConfiguration[] valueConfigs = parameters[i].Children;

                    // Sort the child nodes by name, since the array values are ordered
                    Array.Sort(valueConfigs, new ConfigurationComparer());

                    // Convert parameter values
                    object[] values = new object[valueConfigs.Length];
                    for (int j = 0; j < values.Length; ++j)
                    {
                        if (IsNodeMatch(valueConfigs[j].Name, ConfigValue))
                        {
                            values[j] = GetSimpleAttribute(valueConfigs[j], ConfigNodeValue, true);
                        }
                    }

                    parameter.SetAttribute(ConfigValue, values);

                    nestedConfig.AddChild(parameter);
                }
            }

            return nestedConfig;
        }
コード例 #12
0
        /// <summary>
        /// <para>
        /// Converts the object configuration in FLAT structure into NESTED structure.
        /// </para>
        /// </summary>
        ///
        /// <param name="key">
        /// The key of the object definition.
        /// </param>
        ///
        /// <returns>
        /// The object configuration in NESTED structure.
        /// </returns>
        ///
        /// <exception cref="ConfigurationAPISourceException">
        /// If exceptions occur while retrieving the definition info, but may also indicate
        /// incomplete definition info (missing type name), parsing errors if the source
        /// uses string representations or some other errors.
        /// </exception>
        private IConfiguration ConvertObjectDefinition(string key)
        {
            IConfiguration objectConfig = GetChildByName(configuration, ConfigNamespace, key, true);

            // The nested config
            IConfiguration nestedConfig = new DefaultConfiguration(ConfigObject);
            nestedConfig.SetSimpleAttribute(ConfigName, key);

            foreach (IConfiguration child in objectConfig.Children)
            {
                string name = GetSimpleAttribute(child, ConfigName, false);

                if (name != null && Array.IndexOf(ObjectAttributes, name) != -1)
                {
                    // Simple object attributes
                    nestedConfig.AddChild(ConvertConfigNode(child, name));
                }
                else if (name == ConfigMethods)
                {
                    // Method list of the object definition
                    nestedConfig.AddChild(ConvertMethodsConfig(key, child));
                }
            }

            // Convert parameter definitions
            IConfiguration paramsConfig = ConvertParametersConfig(key);
            if (paramsConfig != null)
            {
                nestedConfig.AddChild(paramsConfig);
            }

            return nestedConfig;
        }
コード例 #13
0
        /// <summary>
        /// <para>
        /// Converts the method configuration in FLAT structure into NESTED structure.
        /// </para>
        /// </summary>
        ///
        /// <param name="objectKey">
        /// The key of the object definition.
        /// </param>
        /// <param name="methodsConfig">
        /// The method configuration in FLAT structure.
        /// </param>
        ///
        /// <returns>
        /// The method configuration in NESTED structure.
        /// </returns>
        ///
        /// <exception cref="ConfigurationAPISourceException">
        /// If exceptions occur while retrieving the definition info, but may also indicate
        /// incomplete definition info (missing type name), parsing errors if the source
        /// uses string representations or some other errors.
        /// </exception>
        private IConfiguration ConvertMethodsConfig(string objectKey, IConfiguration methodsConfig)
        {
            IConfiguration nestedConfig = new DefaultConfiguration(ConfigMethods);

            // All method keys
            object[] methodKeys = GetChildrenValues(methodsConfig);

            int index = 0;
            foreach (object methodKeyObj in methodKeys)
            {
                string methodKey = methodKeyObj as string;

                // The NESTED config of the method
                IConfiguration newMethodConfig = new DefaultConfiguration(ConfigMethod + "_" + (++index));

                // Get the FLAT config of the method
                string fullKey = objectKey + "." + methodKey;
                IConfiguration methodConfig =
                    GetChildByName(configuration, ConfigNamespace, fullKey, true);

                // Convert the method attributes
                foreach (IConfiguration methodAttr in methodConfig.Children)
                {
                    string attrName = GetSimpleAttribute(methodAttr, ConfigName, false);
                    if (attrName != null && Array.IndexOf(MethodAttributes, attrName) != -1)
                    {
                        newMethodConfig.AddChild(ConvertConfigNode(methodAttr, attrName));
                    }
                }

                // Convert the parameters attributes
                IConfiguration paramsConfig = ConvertParametersConfig(fullKey);
                if (paramsConfig != null)
                {
                    newMethodConfig.AddChild(paramsConfig);
                }

                nestedConfig.AddChild(newMethodConfig);
            }
            return nestedConfig;
        }
コード例 #14
0
        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGNAME);
            config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());
            config.SetSimpleAttribute("config_file", CONFIG_FILE);

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
            msgConfig.SetSimpleAttribute("text", MESSAGE);
            msgConfig.SetSimpleAttribute("default_level", Level.DEBUG);
            msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            logger = new Log4NETImpl(config);
        }
コード例 #15
0
        protected void SetUp()
        {
            IList<string> param = new List<string>();
            param.Add("param1");
            param.Add("param2");

            namedMsg = new NamedMessage("text1", NAME1, param, Level.ERROR);

            msgs = new Dictionary<string, NamedMessage>();
            msgs.Add(NAME1, namedMsg);
            msgs.Add(NAME2, new NamedMessage("text2", NAME2, new List<string>(), Level.WARN));

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGNAME);
            config.SetSimpleAttribute("default_level", LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAME1);
            msgConfig.SetSimpleAttribute("text", "text1");
            msgConfig.SetSimpleAttribute("default_level", Level.ERROR);
            msgConfig.SetAttribute("parameters", new object[] {"param1", "param2"});
            msgsConfig.AddChild(msgConfig);

            msgConfig = new DefaultConfiguration(NAME2);
            msgConfig.SetSimpleAttribute("text", "text2");
            msgConfig.SetSimpleAttribute("default_level", Level.WARN);
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            logger = new SimpleLogger(LOGNAME, LEVEL, msgs);
        }
コード例 #16
0
        /// <summary>
        /// Gets a sample configuration for creating FinancialSecurityManager instance using IConfiguration.
        /// </summary>
        /// <returns>
        /// Sample configuration for creating FinancialSecurityManager instance using IConfiguration.
        /// </returns>
        private static IConfiguration GetConfigObject()
        {
            // Prepare the config.
            IConfiguration config = new DefaultConfiguration("Root");

            // Add the config parameters
            config.SetSimpleAttribute("objectfactory_key", "object_of1");
            config.SetSimpleAttribute("security_id_parser_key", "object_parser1");
            config.SetAttribute("security_id_types", new string[] { SecurityIdType.CUSIP, SecurityIdType.SEDOL });
            config.SetAttribute("security_lookup_service_keys",
                                new string[] { "object_customLookupService1", "object_customLookupService1" });
            config.SetSimpleAttribute("recursive_lookup", "True");
            config.SetSimpleAttribute("reference_lookup", "False");
            config.SetSimpleAttribute("security_data_cache_key", "object_SimpleCache1");
            config.SetSimpleAttribute("security_data_combiner_key", "object_defaultCombiner1");

            // IConfiguration to be passed to the ConfigurationAPIObjectFactory constructor
            IConfiguration ofConfig = new DefaultConfiguration("object_of1");

            // Definition for the DefaultSecurityIdParser
            IConfiguration parserConfig = new DefaultConfiguration("object_parser1");

            parserConfig.SetSimpleAttribute("name", "object_parser1");
            IConfiguration parserConfigTypeName = new DefaultConfiguration("type_name");

            parserConfigTypeName.SetSimpleAttribute("value",
                                                    "TopCoder.FinancialService.Utility.SecurityIdParsers.DefaultSecurityIdParser, " +
                                                    "TopCoder.FinancialService.Utility.Test");
            parserConfig.AddChild(parserConfigTypeName);
            ofConfig.AddChild(parserConfig);

            // Definition for the SecurityLookupServiceMock
            IConfiguration lookupConfig = new DefaultConfiguration("object_customLookupService1");

            lookupConfig.SetSimpleAttribute("name", "object_customLookupService1");
            IConfiguration lookupConfigTypeName = new DefaultConfiguration("type_name");

            lookupConfigTypeName.SetSimpleAttribute("value",
                                                    "TopCoder.FinancialService.Utility.FailureTests.SecurityLookupServiceMock, " +
                                                    "TopCoder.FinancialService.Utility.Test");
            lookupConfig.AddChild(lookupConfigTypeName);
            ofConfig.AddChild(lookupConfig);

            //Definition for the SimpleCache
            IConfiguration simpleCacheConfig = new DefaultConfiguration("object_SimpleCache1");

            simpleCacheConfig.SetSimpleAttribute("name", "object_SimpleCache1");
            IConfiguration simpleCacheTypeName = new DefaultConfiguration("type_name");

            simpleCacheTypeName.SetSimpleAttribute("value", "TopCoder.Cache.SimpleCache, TopCoder.Cache");
            simpleCacheConfig.AddChild(simpleCacheTypeName);
            ofConfig.AddChild(simpleCacheConfig);

            // Definition for the DefaultSecurityDataCombiner
            IConfiguration comiberConfig = new DefaultConfiguration("object_defaultCombiner1");

            comiberConfig.SetSimpleAttribute("name", "object_defaultCombiner1");
            IConfiguration comiberConfigTypeName = new DefaultConfiguration("type_name");

            comiberConfigTypeName.SetSimpleAttribute("value",
                                                     "TopCoder.FinancialService.Utility.SecurityDataCombiners.DefaultSecurityDataCombiner, " +
                                                     "TopCoder.FinancialService.Utility.Test");
            comiberConfig.AddChild(comiberConfigTypeName);
            ofConfig.AddChild(comiberConfig);

            config.AddChild(ofConfig);

            return(config);
        }
コード例 #17
0
        /// <summary>
        /// <para>
        /// Builds an <see cref="IConfiguration"/> instance for test.
        /// </para>
        /// </summary>
        /// <returns>An IConfiguration instance containing configuration for test.</returns>
        public static IConfiguration BuildConfiguration()
        {
            // the root node
            IConfiguration config = new DefaultConfiguration("Root");

            //Add the attributes
            config.SetSimpleAttribute("objectfactory_key", "of_config");
            config.SetSimpleAttribute("security_id_parser_key", "parser1");
            config.SetAttribute("security_id_types", new string[]
            {
                SecurityIdType.CUSIP, SecurityIdType.SEDOL,
                SecurityIdType.ISIN, SecurityIdType.SymbolTicker
            });
            config.SetAttribute("security_lookup_service_keys",
                                new string[] { "LookupService1", "LookupService1", "LookupService1", "LookupService1" });
            config.SetSimpleAttribute("recursive_lookup", "True");
            config.SetSimpleAttribute("reference_lookup", "False");
            config.SetSimpleAttribute("security_data_cache_key", "SimpleCache1");
            config.SetSimpleAttribute("security_data_combiner_key", "defaultCombiner1");

            //IConfiguration used to create ConfigurationAPIObjectFactory
            IConfiguration ofConfig = new DefaultConfiguration("of_config");

            //Definition for the DefaultSecurityIdParser
            IConfiguration parserConfig = new DefaultConfiguration("object");

            parserConfig.SetSimpleAttribute("name", "parser1");
            IConfiguration parserConfigTypeName = new DefaultConfiguration("type_name");

            parserConfigTypeName.SetSimpleAttribute("value",
                                                    "TopCoder.FinancialService.Utility.SecurityIdParsers.DefaultSecurityIdParser");
            parserConfig.AddChild(parserConfigTypeName);

            IConfiguration parserConfigAssembly = new DefaultConfiguration("assembly");

            parserConfigAssembly.SetSimpleAttribute("value", "TopCoder.FinancialService.Utility.Test.dll");
            parserConfig.AddChild(parserConfigAssembly);
            ofConfig.AddChild(parserConfig);

            //Definition for the CustomSecurityLookupService
            IConfiguration lookupConfig = new DefaultConfiguration("object1");

            lookupConfig.SetSimpleAttribute("name", "LookupService1");
            IConfiguration lookupConfigTypeName = new DefaultConfiguration("type_name");

            lookupConfigTypeName.SetSimpleAttribute("value",
                                                    "TopCoder.FinancialService.Utility.StressTests.CustomSecurityLookupService");
            lookupConfig.AddChild(lookupConfigTypeName);

            IConfiguration lookupConfigAssembly = new DefaultConfiguration("assembly");

            lookupConfigAssembly.SetSimpleAttribute("value", "TopCoder.FinancialService.Utility.Test.dll");
            lookupConfig.AddChild(lookupConfigAssembly);

            ofConfig.AddChild(lookupConfig);

            //Definition for the SimpleCache
            IConfiguration simpleCacheConfig = new DefaultConfiguration("object2");

            simpleCacheConfig.SetSimpleAttribute("name", "SimpleCache1");
            IConfiguration simpleCacheTypeName = new DefaultConfiguration("type_name");

            simpleCacheTypeName.SetSimpleAttribute("value", "TopCoder.Cache.SimpleCache");
            simpleCacheConfig.AddChild(simpleCacheTypeName);

            IConfiguration simpleCacheConfigAssembly = new DefaultConfiguration("assembly");

            simpleCacheConfigAssembly.SetSimpleAttribute("value", "TopCoder.Cache.dll");
            simpleCacheConfig.AddChild(simpleCacheConfigAssembly);

            ofConfig.AddChild(simpleCacheConfig);

            //Definition for the DefaultSecurityDataCombiner
            IConfiguration comiberConfig = new DefaultConfiguration("object3");

            comiberConfig.SetSimpleAttribute("name", "defaultCombiner1");
            IConfiguration comiberConfigTypeName = new DefaultConfiguration("type_name");

            comiberConfigTypeName.SetSimpleAttribute("value",
                                                     "TopCoder.FinancialService.Utility.SecurityDataCombiners.DefaultSecurityDataCombiner");
            comiberConfig.AddChild(comiberConfigTypeName);

            IConfiguration comiberConfigAssembly = new DefaultConfiguration("assembly");

            comiberConfigAssembly.SetSimpleAttribute("value", "TopCoder.FinancialService.Utility.Test.dll");
            comiberConfig.AddChild(comiberConfigAssembly);

            ofConfig.AddChild(comiberConfig);

            config.AddChild(ofConfig);

            return(config);
        }
コード例 #18
0
        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGGER_NAME);
            config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
            msgConfig.SetSimpleAttribute("text", MESSAGE);
            msgConfig.SetSimpleAttribute("default_level", Level.DEBUG.ToString());
            msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            simpleLogger = new SimpleLogger(config);

            anotherLogger = new AnotherSimpleLogger(EXCEPTION_LOGGER_NAME);

            logger = new ExceptionSafeLogger(simpleLogger, anotherLogger);
        }