コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
 public XamlIlMarkupExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlMethod provideValue,
                                  IXamlIlAstValueNode value) : base(lineInfo)
 {
     ProvideValue = provideValue;
     Value        = value;
     Type         = new XamlIlAstClrTypeReference(this, ProvideValue.ReturnType, false);
 }
コード例 #3
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlPropertyAssignmentNode(IXamlIlLineInfo lineInfo,
                                     IXamlIlProperty property, IXamlIlAstValueNode value)
     : base(lineInfo)
 {
     Property = property;
     Value    = value;
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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];
 }
コード例 #6
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlObjectInitializationNode(IXamlIlLineInfo lineInfo,
                                       IXamlIlAstManipulationNode manipulation, IXamlIlType type)
     : base(lineInfo)
 {
     Manipulation = manipulation;
     Type         = type;
 }
コード例 #7
0
 public XamlIlTypeExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlAstTypeReference value,
                                IXamlIlType systemType) : base(lineInfo)
 {
     _systemType = systemType;
     Type        = new XamlIlAstClrTypeReference(this, systemType);
     Value       = value;
 }
コード例 #8
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlPropertyValueManipulationNode(IXamlIlLineInfo lineInfo,
                                            IXamlIlProperty property, IXamlIlAstManipulationNode manipulation)
     : base(lineInfo)
 {
     Property     = property;
     Manipulation = manipulation;
 }
コード例 #9
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlMethodCallBaseNode(IXamlIlLineInfo lineInfo,
                                 IXamlIlWrappedMethod method, IEnumerable <IXamlIlAstValueNode> args)
     : base(lineInfo)
 {
     Method    = method;
     Arguments = args?.ToList() ?? new List <IXamlIlAstValueNode>();
 }
コード例 #10
0
ファイル: Xaml.cs プロジェクト: danwalmsley/XamlIl
 public XamlIlAstNamePropertyReference(IXamlIlLineInfo lineInfo,
                                       IXamlIlAstTypeReference declaringType, string name, IXamlIlAstTypeReference targetType) : base(lineInfo)
 {
     DeclaringType = declaringType;
     Name          = name;
     TargetType    = targetType;
 }
コード例 #11
0
 public XamlIlLoadMethodDelegateNode(IXamlIlLineInfo lineInfo, IXamlIlAstValueNode value,
                                     IXamlIlType delegateType, IXamlIlMethod method) : base(lineInfo, value)
 {
     DelegateType = delegateType;
     Method       = method;
     Type         = new XamlIlAstClrTypeReference(value, DelegateType);
 }
コード例 #12
0
        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));
            }
        }
コード例 #13
0
ファイル: Xaml.cs プロジェクト: danwalmsley/XamlIl
 public XamlIlAstXmlDirective(IXamlIlLineInfo lineInfo,
                              string ns, string name, IEnumerable <IXamlIlAstValueNode> values) : base(lineInfo)
 {
     Namespace = ns;
     Name      = name;
     Values    = values.ToList();
 }
コード例 #14
0
ファイル: CompilerHelpers.cs プロジェクト: OmniUI/XamlIl2
 public XamlIlAstLocalInitializationNodeEmitter(IXamlIlLineInfo lineInfo,
                                                IXamlIlAstValueNode value,
                                                XamlIlAstCompilerLocalNode local) : base(lineInfo, value)
 {
     Value = value;
     Local = local;
 }
コード例 #15
0
ファイル: Clr.cs プロジェクト: danwalmsley/XamlIl
 public XamlIlAstNewClrObjectNode(IXamlIlLineInfo lineInfo,
                                  IXamlIlAstTypeReference type,
                                  List <IXamlIlAstValueNode> arguments) : base(lineInfo)
 {
     Type      = type;
     Arguments = arguments;
 }
コード例 #16
0
 public XamlIlAstXmlTypeReference(IXamlIlLineInfo lineInfo, string xmlNamespace, string name,
                                  IEnumerable <XamlIlAstXmlTypeReference> genericArguments = null) : base(lineInfo)
 {
     XmlNamespace     = xmlNamespace;
     Name             = name;
     GenericArguments = genericArguments?.ToList() ?? GenericArguments;
 }
コード例 #17
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlValueWithManipulationNode(IXamlIlLineInfo lineInfo,
                                        IXamlIlAstValueNode value,
                                        IXamlIlAstManipulationNode manipulation) : base(lineInfo, value)
 {
     Value        = value;
     Manipulation = manipulation;
 }
コード例 #18
0
ファイル: Xaml.cs プロジェクト: danwalmsley/XamlIl
 public XamlIlAstXamlPropertyValueNode(IXamlIlLineInfo lineInfo,
                                       IXamlIlAstPropertyReference property, IXamlIlAstValueNode value) : base(lineInfo)
 {
     Property = property;
     Values   = new List <IXamlIlAstValueNode> {
         value
     };
 }
コード例 #19
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlMarkupExtensionNode(IXamlIlLineInfo lineInfo, IXamlIlProperty property, IXamlIlMethod provideValue,
                                  IXamlIlAstValueNode value, IXamlIlWrappedMethod manipulation) : base(lineInfo)
 {
     Property     = property;
     ProvideValue = provideValue;
     Value        = value;
     Manipulation = manipulation;
 }
コード例 #20
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlAstNewClrObjectNode(IXamlIlLineInfo lineInfo,
                                  IXamlIlType type, IXamlIlConstructor ctor,
                                  List <IXamlIlAstValueNode> arguments) : base(lineInfo)
 {
     Type        = new XamlIlAstClrTypeReference(lineInfo, type);
     Constructor = ctor;
     Arguments   = arguments;
 }
コード例 #21
0
 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);
 }
コード例 #22
0
 public XamlIlPropertyAssignmentNode(IXamlIlLineInfo lineInfo,
                                     XamlIlAstClrProperty property,
                                     IEnumerable <IXamlIlPropertySetter> setters, IEnumerable <IXamlIlAstValueNode> values)
     : base(lineInfo)
 {
     Property        = property;
     PossibleSetters = setters.ToList();
     Values          = values.ToList();
 }
コード例 #23
0
ファイル: Clr.cs プロジェクト: cm4ker/XamlIl
 public XamlIlManipulationGroupNode(IXamlIlLineInfo lineInfo,
                                    IEnumerable <IXamlIlAstManipulationNode> children = null)
     : base(lineInfo)
 {
     if (children != null)
     {
         Children.AddRange(children);
     }
 }
コード例 #24
0
        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);
        }
コード例 #25
0
            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));
            }
コード例 #26
0
 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;
 }
コード例 #27
0
 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);
     }
 }
コード例 #28
0
ファイル: Xaml.cs プロジェクト: cm4ker/XamlIl
 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");
     }
 }
コード例 #29
0
        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));
        }
コード例 #30
0
            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));
            }