Exemplo n.º 1
0
 public void SaveResult(IResultSaveAdapter resultSaveAdapter)
 {
     resultSaveAdapter.Save(this.Name + DateTime.UtcNow.ToString("yyyy_MM_dd HH_mm_ss"), result);
 }
Exemplo n.º 2
0
 public void SaveResult( IResultSaveAdapter resultSaveAdapter)
 {
     //nothing
 }
Exemplo n.º 3
0
 public void SaveResult(IResultSaveAdapter resultSaveAdapter)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
        public TraceWrapperBase(List<IResultHandler> handlers = null)
        {
            #region Handlers
            Handlers = new List<IResultHandler>();
            if (handlers != null)
            {
                foreach (IResultHandler handler in handlers)
                {
                    if (Handlers.Count<IResultHandler>((h) => h.GetType() == handler.GetType()) == 0)
                    {
                        Handlers.Add(handler);
                    }
                }
            }
            else
            {
                string prefix = "IResultHandler";
                foreach (string handlername in ConfigurationManager.AppSettings.AllKeys
                         .Where(key => key.StartsWith(prefix))
                         .ToArray())
                {

                    IResultHandler handler = ReflectionUtil.CreateInstance<IResultHandler>(ConfigurationManager.AppSettings[handlername]); //CreateHandler(handlerSetting);
                    if (handler != null) handler.Name = handlername.Substring(prefix.Length, handlername.Length - prefix.Length);
                    if (handler != null && Handlers.Count<IResultHandler>((h) => h.Name == handler.Name) == 0)
                    {
                        Handlers.Add(handler);
                    }
                }

                if (Handlers.Count == 0) Handlers.Add(new DefaultEventHandler());
            }
            #endregion
            #region TraceDefinitionFile
            TraceDefinitionFile = new TraceDefinitionFile();
            foreach (IResultHandler handler in Handlers)
            {
                TraceDefinitionFile.Merge(handler.TraceDefinition);
            }
            #endregion
            #region IResultSaveAdapter
            string resultSaveAdapterSetting = ConfigurationManager.AppSettings["IResultSaveAdapter"];
            if (!string.IsNullOrEmpty(resultSaveAdapterSetting))
            {
                resultSaveAdapter = ReflectionUtil.CreateInstance<IResultSaveAdapter>(resultSaveAdapterSetting);
                if (resultSaveAdapter == null) resultSaveAdapter = new FileResultSaveAdapter();
            }
            #endregion
        }