/// <summary> /// Register a type as exposed to template-based extraction (such as code generation), /// storing the Type, generic-base indication and explicit members. /// </summary> internal static Tuple <Type, bool, string[], string[]> ExposeForTemplateBasedExtraction(Type DeclaringType, bool IsGenericBase = false, params string[] ExplicitMembers) { if (DeclaringType == null) { return(null); } var AllowedMembers = DeclaringType.GetProperties().Select(pi => pi.Name).ToArray(); AllowedMembers = AllowedMembers.Concat(ExplicitMembers == null ? Enumerable.Empty <string>() : ExplicitMembers.Except(AllowedMembers) // Exclusion to avoid duplicate the explicit/required members ).OrderBy(m => m).ToArray(); var Duplicates = AllowedMembers.Duplicates().ToArray(); // Force exclusion of duplicates (instance properties hiding others with the "new" C# modifier) if (Duplicates.Length > 0) { AllowedMembers = AllowedMembers.Except(Duplicates).ToArray(); } /* Alternative (problem is that the properties not declared in the class-definitor, such as Idea.Definitor, must be included manually) * var AllowedMembers = ClassDefinitor.Properties.Select(p => p.TechName) * .Concat(Members.NullDefault(Enumerable.Empty<string>())).Distinct().ToArray(); */ DotLiquid.Template.RegisterSafeType(DeclaringType, AllowedMembers); return(Tuple.Create(DeclaringType, IsGenericBase, AllowedMembers, ExplicitMembers)); }
public bool Equals(Scenario other) { var result = false; if (other != null) { if (ExplicitMembers.Equals(other.ExplicitMembers)) { result |= TypedMembers.Equals(other.TypedMembers); } } return(result); }
public override string ToString() { var members = new List <string>(); if (ExplicitMembers != null) { members.AddRange(ExplicitMembers.Select(m => m.ToString())); } if (TypedMembers != null) { members.AddRange(TypedMembers.Select(m => m.ToString())); } members.Sort(); return(string.Join(", ", members)); }
public ExplicitMember AddExplicitMember(string dimension, string value) { return(ExplicitMembers.Add(dimension, value)); }