/// <summary>Initializes a new instance of the <see cref="T:System.Object"></see> class.</summary> public TypeMeta(Type typeRef, Hijack h) { _hijack = h; TypeRef = typeRef; _isAnonymous = typeRef.IsAnonymousType(); if (!_isAnonymous) { try { DefaultInstance = Activator.CreateInstance(typeRef); } catch (Exception) { DefaultInstance = typeRef.InstanceNonpublic(); } } var properties = GetProperties(); InlineProperties = properties.Where(x => x.PropertyType.IsInlineable()).ToArray(); CollectionProperties = properties.Where(x => (!x.PropertyType.IsDictionary() && x.PropertyType.IsEnumerable()) || (x.PropertyType.IsTuple() && !x.PropertyType.IsInlineable())).ToArray(); DictionaryProperties = properties.Where(x => x.PropertyType.IsDictionary()).ToArray(); NestedProperties = properties.Where(x => !InlineProperties.Contains(x) && !CollectionProperties.Contains(x) && !DictionaryProperties.Contains(x)).ToArray(); }
public override bool Execute() { Logger.LogAction = (msg, level) => { if (level == LogLevel.Error) { Log.LogError(msg); } if (level == LogLevel.Warning) { Log.LogWarning(msg); } if (level == LogLevel.Debug) { Log.LogMessage(MessageImportance.High, msg); } }; var config = GeneratorConfiguration.FromFile(ConfigFile); config.ApplyProperties(InlineProperties.Parse(Properties)); var globalConfig = GeneratorConfiguration.FromFile(Path.Combine(config.SetsPath, "configbuddy.configurations.xml")); globalConfig.OutputDir = config.OutputDir; globalConfig.ConfigDir = Path.Combine(config.SetsPath, globalConfig.ConfigDir); ConfigGenerator.ForOneSet(globalConfig.TemplateDir, globalConfig.OutputDir, globalConfig.ConfigDir, config.SetsPath, globalConfig.TemplateExtension, globalConfig.ConfigExtension, globalConfig.Debug, null); return(true); }
public override bool Execute() { Logger.LogAction = (msg, level) => { if (level == LogLevel.Error) { Log.LogError(msg); } if (level == LogLevel.Warning) { Log.LogWarning(msg); } if (level == LogLevel.Debug) { Log.LogMessage(MessageImportance.High, msg); } }; var config = GeneratorConfiguration.FromFile(ConfigFile); config.ApplyProperties(InlineProperties.Parse(Properties)); ConfigGenerator.ForAllSets(config); return(true); }
public void Should_parse_properties_from_one_line_text() { var properties = InlineProperties.Parse("TargetDir=$(TargetDir);ProjectName=$(ProjectName)").ToList(); Assert.AreEqual(2, properties.Count); Assert.AreEqual("TargetDir", properties[0].Key); Assert.AreEqual("$(TargetDir)", properties[0].Value); Assert.AreEqual("ProjectName", properties[1].Key); Assert.AreEqual("$(ProjectName)", properties[1].Value); }