Пример #1
0
        public ObjectLog(ObjectLogSchema schema, ObjectLogConfiguration configuration)
        {
            this.configuration = configuration;
            this.schemaEntries = ObjectLog <T> .GetSchemaEntries(schema);

            this.logSchema = ObjectLog <T> .GetLogSchema(schema, this.schemaEntries);

            this.log = new Log(configuration.FilenamePrefix, new LogHeaderFormatter(this.logSchema, LogHeaderCsvOption.CsvStrict), configuration.LogComponentName, true);
            this.log.Configure(configuration.LoggingFolder, configuration.MaxLogAge, configuration.MaxLogDirSize, configuration.MaxLogFileSize, configuration.BufferLength, configuration.StreamFlushInterval, configuration.Note, configuration.FlushToDisk);
        }
Пример #2
0
        private static LogSchema GetLogSchema(ObjectLogSchema schema, List <IObjectLogPropertyDefinition <T> > schemaEntries)
        {
            List <string> list = new List <string>();

            list.Add("Time");
            foreach (IObjectLogPropertyDefinition <T> objectLogPropertyDefinition in schemaEntries)
            {
                list.Add(objectLogPropertyDefinition.FieldName);
            }
            return(new LogSchema(schema.Software, schema.Version, schema.LogType, list.ToArray()));
        }
Пример #3
0
        public static List <IObjectLogPropertyDefinition <T> > GetSchemaEntries(ObjectLogSchema schema)
        {
            List <IObjectLogPropertyDefinition <T> > list = new List <IObjectLogPropertyDefinition <T> >();

            FieldInfo[] fields = schema.GetType().GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            foreach (FieldInfo fieldInfo in fields)
            {
                object          value           = fieldInfo.GetValue(null);
                ObjectLogSchema objectLogSchema = value as ObjectLogSchema;
                if (objectLogSchema != null)
                {
                    list.AddRange(ObjectLog <T> .GetSchemaEntries(objectLogSchema));
                }
                else
                {
                    IObjectLogPropertyDefinition <T> objectLogPropertyDefinition = value as IObjectLogPropertyDefinition <T>;
                    if (objectLogPropertyDefinition != null)
                    {
                        if (schema.ExcludedProperties == null || !schema.ExcludedProperties.Contains(objectLogPropertyDefinition.FieldName))
                        {
                            list.Add(objectLogPropertyDefinition);
                        }
                    }
                    else
                    {
                        IEnumerable <IObjectLogPropertyDefinition <T> > enumerable = value as IEnumerable <IObjectLogPropertyDefinition <T> >;
                        if (enumerable != null)
                        {
                            foreach (IObjectLogPropertyDefinition <T> objectLogPropertyDefinition2 in enumerable)
                            {
                                if (schema.ExcludedProperties == null || !schema.ExcludedProperties.Contains(objectLogPropertyDefinition2.FieldName))
                                {
                                    list.Add(objectLogPropertyDefinition2);
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Пример #4
0
 public DisposableObjectLog(ObjectLogSchema schema, ObjectLogConfiguration configuration) : base(schema, configuration)
 {
 }
Пример #5
0
        public static LogSchema GetLogSchema(ObjectLogSchema schema)
        {
            List <IObjectLogPropertyDefinition <T> > list = ObjectLog <T> .GetSchemaEntries(schema);

            return(ObjectLog <T> .GetLogSchema(schema, list));
        }