/// <summary> /// Constructs a new instance of the settings object /// </summary> /// <param name="type">An optional override type for the renderer</param> /// <param name="property">The IMetaProperty that references the object being resolved</param> /// <param name="fileProvider">A file provider used for checking for the existence of views</param> public DynamicRendererSettings(IMetaType type, IMetaProperty property, IFileProvider fileProvider) { this.Type = type ?? throw new ArgumentNullException(nameof(type)); this.TypeFullName = this.Type.FullName; this.Property = property; this.FileProvider = fileProvider; }
/// <summary> /// Constructs a new instance of the settings object /// </summary> /// <param name="type">An optional override type for the renderer</param> /// <param name="property">The IMetaProperty that references the object being resolved</param> /// <param name="fileProvider">A file provider used for checking for the existence of views</param> public DynamicRendererSettings(IMetaType type, IMetaProperty property, IFileProvider fileProvider) { Contract.Requires(type != null); this.Type = type; this.TypeFullName = this.Type.FullName; this.Property = property; this.FileProvider = fileProvider; }
public MetaOperation(Oid oid, string localName, IMetaType result, string nameSpace = "") : base(oid, localName, nameSpace) { if (result == null) { Result = null; } Parameters = new ConcurrentDictionary <string, IMetaType>(); }
private void EvaluateType(SqlNode node, IMetaType metaType) { var sessionFactory = SessionFactoryHelper.Factory; var className = sessionFactory.GetImportedClassName(node.OriginalText); var discriminatorValue = metaType.GetMetaValue( TypeNameParser.Parse(className).Type, sessionFactory.Dialect); node.Text = discriminatorValue; }
/// <summary> /// Compares two metatypes based on AssemblyQualifiedName /// </summary> /// <param name="other">The MetaType to compare against</param> /// <returns>Whether or not they share an Assembly Qualified Name</returns> public bool Equals(IMetaType other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(this.AssemblyQualifiedName == other.AssemblyQualifiedName); }
public static string GetUnproxifiedName(this IMetaType t) { if (t is null) { throw new ArgumentNullException(nameof(t)); } if (t.Namespace == DYNAMIC_PROXIES_NS) { return(t.BaseType.FullName); } else { return(t.FullName); } }
/// <summary> /// Tests for type equality between an object implementing ITypeInfo and a Type, by full name /// </summary> /// <param name="o">The object to test</param> /// <param name="StringValue">The ToString value of the type</param> /// <returns>Whether or not the types are equal</returns> public static bool Is(this ITypeInfo o, string StringValue) { if (o is null) { return(false); } IMetaType toCheck = o.TypeOf(); do { if (toCheck.ToString() == StringValue) { return(true); } } while ((toCheck = toCheck.BaseType) != null); return(false); }
public static string?GetKeyForType(IMetaType t, bool throwError = true) { if (t is null) { throw new ArgumentNullException(nameof(t)); } if (t.Is(typeof(KeyedObject))) { return(nameof(KeyedObject._Id)); } else if (t.Properties.Any(p => string.Equals(p.Name, "id", StringComparison.OrdinalIgnoreCase))) { return(t.Properties.First(p => string.Equals(p.Name, "id", StringComparison.OrdinalIgnoreCase)).Name); } else if (throwError) { throw new Exception(KEY_NOT_FOUND_MESSAGE); } else { return(null); } }
/// <summary> /// Constructs a new instance of this renderer /// </summary> /// <param name="settings">A collection of settings for the dynamic renderer</param> public DynamicRenderer(DynamicRendererSettings settings) { if (settings is null) { throw new System.ArgumentNullException(nameof(settings)); } List <string> renderingOrder = null; if (settings.Type is null) { renderingOrder = new List <string> { settings.TypeFullName }; } else { renderingOrder = new List <string>(); IMetaType CascadeType = settings.Type.CoreType == CoreType.Collection ? settings.Type.CollectionType : settings.Type; string Prepend = string.Empty; if (settings.Type.CoreType == CoreType.Collection) { if (settings.Type.IsArray) { Prepend = "Array."; } else { Prepend = $"{settings.Type.Namespace}.{settings.Type.Name.To("`")}."; } } do { string TypeName = CascadeType.FullName; if (settings.Type.CoreType == CoreType.Collection && settings.Type.IsArray) { TypeName = CascadeType.FullName.To("["); } if (settings.Property != null && settings.Property.Attributes.AnyNotNull()) { //search based on attribute foreach (IMetaAttribute a in settings.Property.Attributes.Where(a => !a.IsInherited)) { renderingOrder.Add($"{Prepend}@{a.Instance.Value}"); } } renderingOrder.Add($"{Prepend}{TypeName}"); if (CascadeType.Attributes.AnyNotNull()) { //search based on attribute foreach (IMetaAttribute a in CascadeType.Attributes.Where(a => !a.IsInherited)) { renderingOrder.Add($"{Prepend}@{a.Instance.Value}"); } } CascadeType = CascadeType.BaseType; }while (!settings.ExactOnly && CascadeType != null); //for all objects in namespace renderingOrder.Add($"{settings.Type.Namespace}.{Prepend}$Object"); if (settings.StartAtBottom) { renderingOrder.Reverse(); } } this.Results = new List <ViewValidationResult>(); foreach (string thisType in renderingOrder) { string @namespace = thisType.Remove(Constants.RootNamespace + ".").Replace(".", "/"); ViewPathValidation pathValidation = new ViewPathValidation(settings.BasePath + @namespace, settings.FileProvider); foreach (ViewValidationResult result in pathValidation.ValidationResults) { this.Results.Add(result); } } if (!this.HasMatch) { this.IsDynamic = true; ViewPathValidation pathValidation = new ViewPathValidation(settings.BasePath + settings.DynamicViewName, settings.FileProvider); foreach (ViewValidationResult result in pathValidation.ValidationResults) { this.Results.Add(result); } } }
/// <summary> /// Constructs a new instance of this renderer /// </summary> /// <param name="type">An optional override type</param> /// <param name="property">The IMetaProperty leading to this serialized object</param> /// <param name="fileProvider">A file provider used for checking for the existence of views</param> public DynamicRenderer(IMetaType type, IMetaProperty property, IFileProvider fileProvider) : this(new DynamicRendererSettings(type, property, fileProvider)) { }
public void AddParameter(ref IMetaType parameterMetaType, string parameterName) { throw new NotImplementedException(); }
public bool UpdateMetaTypeMetaData(ref IMetaType metaType) { throw new NotImplementedException(); }
public bool AddMetaType(ref IMetaType metaType) { throw new NotImplementedException(); }