private FieldSourceCatalog() { List <IFieldSource> fieldSources = new List <IFieldSource>(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { Type[] types = assembly.GetTypes(); foreach (Type t in types) { Type[] interfaces = t.GetInterfaces(); if (interfaces.Contains(typeof(IFieldSource)) && !t.IsAbstract && t != typeof(NothignFieldSource)) { try { IFieldSource o = (IFieldSource)Activator.CreateInstance(t); if (o != null) { fieldSources.Add(o); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } } fieldSources = fieldSources.OrderBy(o => o.Category, StringComparer.OrdinalIgnoreCase) .ThenBy(o => o.Name, StringComparer.OrdinalIgnoreCase).ToList(); fieldSources.Insert(0, new NothignFieldSource()); m_FieldSources = fieldSources.ToArray(); }
public Field(String name, FieldOptions fieldOptions, IFieldSource source) { Name = name; FieldOptions = fieldOptions; Source = source; Boost = 1.0f; }
public bool Read(out object value) { IFieldSource changedSource = this.GetSources().FirstOrDefault(f => f.HasChanged); if (changedSource != null) { value = changedSource.Value; return(true); } value = null; return(false); }