static void Main(string[] args) { DirectOutput.General.TypeList Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.Cab.Toys.IToy).IsAssignableFrom(p) && !p.IsAbstract)); Types.Sort((T1, T2) => T1.FullName.CompareTo(T2.FullName)); string S = "Built in Toys {#toy_builtin}\n"; S += "==========\n"; foreach (Type T in Types.OrderBy(T => T.Name)) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\64_Toys_BuiltIn.md"); Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.FX.IEffect).IsAssignableFrom(p) && !p.IsAbstract)); Types.Sort((T1, T2) => T1.FullName.CompareTo(T2.FullName)); S = "Built in Effects {#fx_builtin}\n"; S += "==========\n"; foreach (Type T in Types.OrderBy(T => T.Name)) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\61_FX_BuiltIn.md"); Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.Cab.Out.IOutputController).IsAssignableFrom(p) && !p.IsAbstract)); S = "Built in Output controllers {#outputcontrollers_builtin}\n"; S += "==========\n"; foreach (Type T in Types.OrderBy(T => T.Name)) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\66_OutputControllers_BuiltIn.md"); }
private object GetSampleReferenceType(Type RefType) { Type T = RefType; if (T.IsInterface) { DirectOutput.General.TypeList Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => T.IsAssignableFrom(p) && !p.IsAbstract)); if (Types.Count > 0) { T = Types[0]; } else { return(null); } } Object O = Activator.CreateInstance(T); foreach (PropertyInfo PI in O.GetType().GetXMLSerializableProperties()) { if (PI.PropertyType == typeof(string)) { string V = (string)PI.GetValue(O, null); if (V.IsNullOrWhiteSpace()) { if (PI.Name.ToUpper() == "NAME") { PI.SetValue(O, "Name of {0}".Build(O.GetType().Name), null); } else if (PI.Name.ToUpper().EndsWith("NAME")) { PI.SetValue(O, "Name of {0}".Build(PI.Name.Substring(0, PI.Name.Length - 4)), null); } else { PI.SetValue(O, "{0} string".Build(PI.Name), null); } } } else if (PI.PropertyType.IsArray) { object A = PI.GetValue(O, null); if (A == null) { object[] SampleArray = GetSampleArray(PI.PropertyType); PI.SetValue(O, SampleArray, null); } } else if (PI.PropertyType.IsGenericList()) { IList EN = GetSampleGenericList(PI.PropertyType); PI.SetValue(O, EN, null); } else if (typeof(IDictionary).IsAssignableFrom(PI.PropertyType) && PI.PropertyType.IsGenericType) { IDictionary EN = GetSampleGenericDictionary(PI.PropertyType); PI.SetValue(O, EN, null); } else if (PI.PropertyType.IsValueType) { if (PI.PropertyType == typeof(char)) { PI.SetValue(O, GetSampleValueType(PI.PropertyType), null); } } else if (PI.PropertyType == typeof(DateTime)) { PI.SetValue(O, DateTime.Now, null); } else if (PI.PropertyType == typeof(TimeSpan)) { PI.SetValue(O, TimeSpan.Zero, null); } else if (!PI.PropertyType.IsValueType) { PI.SetValue(O, GetSampleReferenceType(PI.PropertyType), null); } else { throw new Exception("Unknow type {0}".Build(PI.PropertyType.Name)); } } return(O); }
private object GetSampleReferenceType(Type RefType) { Type T=RefType; if (T.IsInterface) { DirectOutput.General.TypeList Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => T.IsAssignableFrom(p) && !p.IsAbstract)); if (Types.Count > 0) { T = Types[0]; } else { return null; } } Object O = Activator.CreateInstance(T); foreach (PropertyInfo PI in O.GetType().GetXMLSerializableProperties()) { if (PI.PropertyType == typeof(string)) { string V = (string)PI.GetValue(O, null); if (V.IsNullOrWhiteSpace()) { if (PI.Name.ToUpper() == "NAME") { PI.SetValue(O, "Name of {0}".Build(O.GetType().Name), null); } else if (PI.Name.ToUpper().EndsWith("NAME")) { PI.SetValue(O, "Name of {0}".Build(PI.Name.Substring(0, PI.Name.Length - 4)), null); } else { PI.SetValue(O, "{0} string".Build(PI.Name), null); } } } else if (PI.PropertyType.IsArray) { object A = PI.GetValue(O,null); if (A == null) { object[] SampleArray = GetSampleArray(PI.PropertyType); PI.SetValue(O, SampleArray, null); } } else if (PI.PropertyType.IsGenericList()) { IList EN = GetSampleGenericList(PI.PropertyType); PI.SetValue(O, EN, null); } else if (typeof(IDictionary).IsAssignableFrom(PI.PropertyType) && PI.PropertyType.IsGenericType) { IDictionary EN = GetSampleGenericDictionary(PI.PropertyType); PI.SetValue(O, EN, null); } else if (PI.PropertyType.IsValueType) { if (PI.PropertyType == typeof(char)) { PI.SetValue(O, GetSampleValueType(PI.PropertyType), null); } } else if (PI.PropertyType == typeof(DateTime)) { PI.SetValue(O, DateTime.Now, null); } else if (PI.PropertyType == typeof(TimeSpan)) { PI.SetValue(O, TimeSpan.Zero, null); } else if (!PI.PropertyType.IsValueType) { PI.SetValue(O, GetSampleReferenceType(PI.PropertyType), null); } else { throw new Exception("Unknow type {0}".Build(PI.PropertyType.Name)); } } return O; }
static void Main(string[] args) { DirectOutput.General.TypeList Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.Cab.Toys.IToy).IsAssignableFrom(p) && !p.IsAbstract)); Types.Sort((T1, T2) => T1.FullName.CompareTo(T2.FullName)); string S = "Built in Toys {#toy_builtin}\n"; S += "==========\n"; foreach (Type T in Types) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\64_Toys_BuiltIn.md"); Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.FX.IEffect).IsAssignableFrom(p) && !p.IsAbstract)); Types.Sort((T1, T2) => T1.FullName.CompareTo(T2.FullName)); S = "Built in Effects {#fx_builtin}\n"; S += "==========\n"; foreach (Type T in Types) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\61_FX_BuiltIn.md"); Types = new DirectOutput.General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(DirectOutput.Cab.Out.IOutputController).IsAssignableFrom(p) && !p.IsAbstract)); S = "Built in Output controllers {#outputcontrollers_builtin}\n"; S += "==========\n"; foreach (Type T in Types) { TypeDocuData I = new TypeDocuData(); I.Type = T; S += I.GetDocu(); } S.WriteToFile(@"..\..\..\Documentation\66_OutputControllers_BuiltIn.md"); }