public override ICustomWriter GetCustomWriter(System.Type type) { const Ref::BindingFlags BF = Ref::BindingFlags.Public | Ref::BindingFlags.NonPublic | Ref::BindingFlags.Instance; const string MISSING_CTOR = @"[BindCustomWriterAttribute({0})] 指定した ICustomWriter 実装型{0}には、System.Type 一つを引数に持つコンストラクタ亦は、既定のコンストラクタが定義されていません。 .ctor(System.Type) / .ctor() の何れかが実装されている必要があります。詳細に関しては BindCustomWriterAttribute の説明で確認して下さい。"; //------------------------------------------------------- if (writer != null) { return(writer); } Ref::ConstructorInfo ctor; ctor = writer_type.GetConstructor(BF, null, new System.Type[] { typeof(System.Type) }, null); if (ctor != null) { return(this.writer = (ICustomWriter)ctor.Invoke(new object[] { type })); } ctor = writer_type.GetConstructor(BF, null, new System.Type[0], null); if (ctor != null) { return(this.writer = (ICustomWriter)ctor.Invoke(new object[0])); } throw new System.MissingMethodException(string.Format(MISSING_CTOR, writer_type)); }
/// <summary> /// ICustomWriter を登録します。 /// 登録すると ICustomWriter で対応している型 T を StreamAccessor の Write() で書き込む事が出来る様になります。 /// </summary> /// <param name="writer">登録する ICustomWriter を指定します。</param> public static void RegisterCustomWriter(ICustomWriter writer) { if (cwriters.ContainsKey(writer.Type) && cwriters[writer.Type] != null) { throw new System.ApplicationException("追加定義書込は既に定義されています。複数定義されていると不整合の原因になります。"); } cwriters[writer.Type] = writer; }
public static ICustomWriter createWriter(string type = "console") { ICustomWriter writer = null; type = type.ToLower(); if (type.Equals("console") | type.Equals("")) { writer = new ConsoleWriter(); } else if (type.Equals("database")) { writer = new DatabaseWriter(); } else if (type.Equals("file")) { writer = new FileWriter(); } return(writer); }
private static CustomWriterConfiguration CreateLoggerConfigurationInstance(ICustomWriter config) { CustomAppConfigWriterConfiguration src = new CustomAppConfigWriterConfiguration(ConvertLogLevel(config.LogLevel), config.Type, config.Parameters); return(CustomAppConfigWriterConfigurationConverter.Convert(src)); }