public XamlIlAstClrProperty(IXamlIlLineInfo lineInfo, IXamlIlProperty property, XamlIlTransformerConfiguration cfg) : base(lineInfo) { Name = property.Name; Getter = property.Getter; if (property.Setter != null) { Setters.Add(new XamlIlDirectCallPropertySetter(property.Setter)); } CustomAttributes = property.CustomAttributes.ToList(); DeclaringType = (property.Getter ?? property.Setter)?.DeclaringType; var typeConverterAttributes = cfg.GetCustomAttribute(property, cfg.TypeMappings.TypeConverterAttributes); if (typeConverterAttributes != null) { foreach (var attr in typeConverterAttributes) { var typeConverter = XamlIlTransformHelpers.TryGetTypeConverterFromCustomAttribute(cfg, attr); if (typeConverter != null) { TypeConverters[property.PropertyType] = typeConverter; break; } } } }
public XamlIlMarkupExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlMethod provideValue, IXamlIlAstValueNode value) : base(lineInfo) { ProvideValue = provideValue; Value = value; Type = new XamlIlAstClrTypeReference(this, ProvideValue.ReturnType, false); }
public XamlIlPropertyAssignmentNode(IXamlIlLineInfo lineInfo, IXamlIlProperty property, IXamlIlAstValueNode value) : base(lineInfo) { Property = property; Value = value; }
public XamlIlSelectorNode(XamlIlSelectorNode previous, IXamlIlLineInfo info = null, IXamlIlType selectorType = null) : base(info ?? previous) { Previous = previous; Type = selectorType == null ? previous.Type : new XamlIlAstClrTypeReference(this, selectorType, false); }
public XamlIlAvaloniaPropertyNode(IXamlIlLineInfo lineInfo, IXamlIlType type, XamlIlAstClrProperty property) : base(lineInfo) { Type = new XamlIlAstClrTypeReference(this, type, false); Property = property; AvaloniaPropertyType = Property.Getter?.ReturnType ?? Property.Setters.First().Parameters[0]; }
public XamlIlObjectInitializationNode(IXamlIlLineInfo lineInfo, IXamlIlAstManipulationNode manipulation, IXamlIlType type) : base(lineInfo) { Manipulation = manipulation; Type = type; }
public XamlIlTypeExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlAstTypeReference value, IXamlIlType systemType) : base(lineInfo) { _systemType = systemType; Type = new XamlIlAstClrTypeReference(this, systemType); Value = value; }
public XamlIlPropertyValueManipulationNode(IXamlIlLineInfo lineInfo, IXamlIlProperty property, IXamlIlAstManipulationNode manipulation) : base(lineInfo) { Property = property; Manipulation = manipulation; }
public XamlIlMethodCallBaseNode(IXamlIlLineInfo lineInfo, IXamlIlWrappedMethod method, IEnumerable <IXamlIlAstValueNode> args) : base(lineInfo) { Method = method; Arguments = args?.ToList() ?? new List <IXamlIlAstValueNode>(); }
public XamlIlAstNamePropertyReference(IXamlIlLineInfo lineInfo, IXamlIlAstTypeReference declaringType, string name, IXamlIlAstTypeReference targetType) : base(lineInfo) { DeclaringType = declaringType; Name = name; TargetType = targetType; }
public XamlIlLoadMethodDelegateNode(IXamlIlLineInfo lineInfo, IXamlIlAstValueNode value, IXamlIlType delegateType, IXamlIlMethod method) : base(lineInfo, value) { DelegateType = delegateType; Method = method; Type = new XamlIlAstClrTypeReference(value, DelegateType); }
public static XamlIlAstClrTypeReference ResolveType(XamlIlAstTransformationContext context, string xmlns, string name, bool isMarkupExtension, List <XamlIlAstXmlTypeReference> typeArguments, IXamlIlLineInfo lineInfo, bool strict) { if (typeArguments == null || typeArguments.Count == 0) { var cache = context.GetOrCreateItem <TypeResolverCache>(); var cacheKey = (xmlns, name, isMarkupExtension); if (cache.CacheDictionary.TryGetValue(cacheKey, out var type)) { if (type == null) { return(null); } return(new XamlIlAstClrTypeReference(lineInfo, type, isMarkupExtension)); } var res = ResolveTypeCore(context, xmlns, name, isMarkupExtension, typeArguments, lineInfo, strict); cache.CacheDictionary[cacheKey] = res?.Type; return(res); } else { return(ResolveTypeCore(context, xmlns, name, isMarkupExtension, typeArguments, lineInfo, strict)); } }
public XamlIlAstXmlDirective(IXamlIlLineInfo lineInfo, string ns, string name, IEnumerable <IXamlIlAstValueNode> values) : base(lineInfo) { Namespace = ns; Name = name; Values = values.ToList(); }
public XamlIlAstLocalInitializationNodeEmitter(IXamlIlLineInfo lineInfo, IXamlIlAstValueNode value, XamlIlAstCompilerLocalNode local) : base(lineInfo, value) { Value = value; Local = local; }
public XamlIlAstNewClrObjectNode(IXamlIlLineInfo lineInfo, IXamlIlAstTypeReference type, List <IXamlIlAstValueNode> arguments) : base(lineInfo) { Type = type; Arguments = arguments; }
public XamlIlAstXmlTypeReference(IXamlIlLineInfo lineInfo, string xmlNamespace, string name, IEnumerable <XamlIlAstXmlTypeReference> genericArguments = null) : base(lineInfo) { XmlNamespace = xmlNamespace; Name = name; GenericArguments = genericArguments?.ToList() ?? GenericArguments; }
public XamlIlValueWithManipulationNode(IXamlIlLineInfo lineInfo, IXamlIlAstValueNode value, IXamlIlAstManipulationNode manipulation) : base(lineInfo, value) { Value = value; Manipulation = manipulation; }
public XamlIlAstXamlPropertyValueNode(IXamlIlLineInfo lineInfo, IXamlIlAstPropertyReference property, IXamlIlAstValueNode value) : base(lineInfo) { Property = property; Values = new List <IXamlIlAstValueNode> { value }; }
public XamlIlMarkupExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlProperty property, IXamlIlMethod provideValue, IXamlIlAstValueNode value, IXamlIlWrappedMethod manipulation) : base(lineInfo) { Property = property; ProvideValue = provideValue; Value = value; Manipulation = manipulation; }
public XamlIlAstNewClrObjectNode(IXamlIlLineInfo lineInfo, IXamlIlType type, IXamlIlConstructor ctor, List <IXamlIlAstValueNode> arguments) : base(lineInfo) { Type = new XamlIlAstClrTypeReference(lineInfo, type); Constructor = ctor; Arguments = arguments; }
public XamlIlConstantNode(IXamlIlLineInfo lineInfo, IXamlIlType type, object constant) : base(lineInfo) { if (!constant.GetType().IsPrimitive) { throw new ArgumentException($"Don't know how to emit {constant.GetType()} constant"); } Constant = constant; Type = new XamlIlAstClrTypeReference(lineInfo, type); }
public XamlIlPropertyAssignmentNode(IXamlIlLineInfo lineInfo, XamlIlAstClrProperty property, IEnumerable <IXamlIlPropertySetter> setters, IEnumerable <IXamlIlAstValueNode> values) : base(lineInfo) { Property = property; PossibleSetters = setters.ToList(); Values = values.ToList(); }
public XamlIlManipulationGroupNode(IXamlIlLineInfo lineInfo, IEnumerable <IXamlIlAstManipulationNode> children = null) : base(lineInfo) { if (children != null) { Children.AddRange(children); } }
public static bool TryGetEnumValueNode(IXamlIlType enumType, string value, IXamlIlLineInfo lineInfo, out XamlIlConstantNode rv) { if (TryGetEnumValue(enumType, value, out var constant)) { rv = new XamlIlConstantNode(lineInfo, enumType, constant); return(true); } rv = null; return(false); }
public SetterValueProperty(IXamlIlLineInfo line, IXamlIlType setterType, IXamlIlType targetType, AvaloniaXamlIlWellKnownTypes types) : base(line, "Value", setterType, null) { Getter = setterType.Methods.First(m => m.Name == "get_Value"); var method = setterType.Methods.First(m => m.Name == "set_Value"); Setters.Add(new XamlIlDirectCallPropertySetter(method, types.IBinding)); Setters.Add(new XamlIlDirectCallPropertySetter(method, types.UnsetValueType)); Setters.Add(new XamlIlDirectCallPropertySetter(method, targetType)); }
public XamlIlAstClrProperty(IXamlIlLineInfo lineInfo, IXamlIlProperty property) : base(lineInfo) { Name = property.Name; Getter = property.Getter; if (property.Setter != null) { Setters.Add(new XamlIlDirectCallPropertySetter(property.Setter)); } CustomAttributes = property.CustomAttributes.ToList(); DeclaringType = (property.Getter ?? property.Setter)?.DeclaringType; }
public XamlIlAstClrProperty(IXamlIlLineInfo lineInfo, string name, IXamlIlType declaringType, IXamlIlMethod getter, IEnumerable <IXamlIlPropertySetter> setters) : base(lineInfo) { Name = name; DeclaringType = declaringType; Getter = getter; if (setters != null) { Setters.AddRange(setters); } }
public XamlIlAstTextNode(IXamlIlLineInfo lineInfo, string text, IXamlIlType type = null) : base(lineInfo) { Text = text; if (type != null) { Type = new XamlIlAstClrTypeReference(lineInfo, type); } else { Type = new XamlIlAstXmlTypeReference(lineInfo, XamlNamespaces.Xaml2006, "String"); } }
public static IXamlIlType ResolveType(XamlIlAstTransformationContext context, string xmlName, IXamlIlLineInfo lineInfo, bool strict) { var pair = xmlName.Split(new[] { ':' }, 2); var(shortNs, name) = pair.Length == 1 ? ("", pair[0]) : (pair[0], pair[1]); if (!context.NamespaceAliases.TryGetValue(shortNs, out var xmlns)) { if (strict) { throw new XamlIlParseException( $"Unable to resolve type namespace alias {shortNs}", lineInfo); } return(null); } return(ResolveType(context, xmlns, name, new List <XamlIlAstXmlTypeReference>(), lineInfo, strict)); }
static XamlIlAstXmlTypeReference ParseTypeName(IXamlIlLineInfo info, string typeName, Func <string, string> prefixResolver) { var pair = typeName.Trim().Split(new[] { ':' }, 2); string xmlns, name; if (pair.Length == 1) { xmlns = prefixResolver(""); name = pair[0]; } else { xmlns = prefixResolver(pair[0]); if (xmlns == null) { throw new XamlIlParseException($"Namespace '{pair[0]}' is not recognized", info); } name = pair[1]; } return(new XamlIlAstXmlTypeReference(info, xmlns, name)); }