コード例 #1
0
ファイル: TagName.cs プロジェクト: baks/Simple.Xml
 public TagName(string name, NamespacePrefix namespacePrefix)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     if (namespacePrefix == null)
     {
         throw new ArgumentNullException(nameof(namespacePrefix));
     }
     this.name = name;
     this.namespacePrefix = namespacePrefix;
 }
コード例 #2
0
 public Selector <Element> Universal(NamespacePrefix prefix)
 {
     return(prefix.IsSpecific
         ? (Selector <Element>)(nodes => Enumerable.Empty <Element>())
         : (Selector <Element>)(nodes => nodes));
 }
コード例 #3
0
 public Selector <SvgElement> AttributeExists(NamespacePrefix prefix, string name)
 {
     return(nodes => nodes.Where(n => n.Attributes.ContainsKey(name) || n.CustomAttributes.ContainsKey(name)));
 }
コード例 #4
0
        public Selector <SvgElement> Type(NamespacePrefix prefix, string name)
        {
            var type = SvgElementFactory.AvailableElements.SingleOrDefault(e => e.ElementName == name);

            return(nodes => nodes.Where(n => n.GetType() == type.ElementType));
        }
コード例 #5
0
 /// <summary>
 /// Generates a <a href="http://www.w3.org/TR/css3-selectors/#universal-selector">universal selector</a>,
 /// any single element in the document tree in any namespace
 /// (including those without a namespace) if no default namespace
 /// has been specified for selectors.
 /// </summary>
 public virtual Selector <HtmlNode> Universal(NamespacePrefix prefix) =>
 prefix.IsSpecific
     ? (Selector <HtmlNode>)(nodes => Enumerable.Empty <HtmlNode>())
     : (nodes => nodes.Elements());
コード例 #6
0
        public void NamespacePrefix_does_not_match_sibling_namespace_with_same_textual_prefix()
        {
            NamespacePrefix p = new NamespacePrefix("System.Web");

            Assert.IsFalse(p.Matches("System.WebServer"));
        }
コード例 #7
0
        public void NamespacePrefix_matches_child_namespaces()
        {
            NamespacePrefix p = new NamespacePrefix("System.Web.*");

            Assert.IsTrue(p.Matches("System.Web.UI.Page"));
        }
コード例 #8
0
 public void AttributeExists(NamespacePrefix prefix, string name)
 {
 }
コード例 #9
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void Type(NamespacePrefix prefix, string name)
 {
     TypePrefix = prefix;
     TypeName   = name;
 }
コード例 #10
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
            #line 1 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            // This template creates an inherited type, e.g., type MyFloat float64 in a <PackageName>_<StructName>StructOf(<GoTypeName>).cs file

            #line default
            #line hidden
            this.Write(@"//---------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool. Changes to this
//     file may cause incorrect behavior and will be lost
//     if the code is regenerated.
//
//     Generated on ");

            #line 10 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedTime));

            #line default
            #line hidden
            this.Write("\r\n// </auto-generated>\r\n//-------------------------------------------------------" +
                       "--\r\nusing System.CodeDom.Compiler;\r\nusing System.Runtime.CompilerServices;\r\n");

            #line 15 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            if (!NamespacePrefix.Equals("go"))
            {
            #line default
            #line hidden
                this.Write("using go;\r\n");

            #line 17 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n#nullable enable\r\n\r\n");

            #line 21 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(NamespaceHeader));

            #line default
            #line hidden
            this.Write("\r\n    public static partial class ");

            #line 22 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(PackageName));

            #line default
            #line hidden
            this.Write("_package\r\n    {\r\n        [");

            #line 24 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedCodeAttribute));

            #line default
            #line hidden
            this.Write("]\r\n        ");

            #line 25 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Scope));

            #line default
            #line hidden
            this.Write(" partial struct ");

            #line 25 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("\r\n        {\r\n            // Value of the ");

            #line 27 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" struct\r\n            private readonly ");

            #line 28 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(TypeName));

            #line default
            #line hidden
            this.Write(" m_value;\r\n\r\n            public ");

            #line 30 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(");

            #line 30 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(TypeName));

            #line default
            #line hidden
            this.Write(" value) => m_value = value;\r\n\r\n            // Enable implicit conversions between" +
                       " ");

            #line 32 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(TypeName));

            #line default
            #line hidden
            this.Write(" and ");

            #line 32 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" struct\r\n            [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n        " +
                       "    public static implicit operator ");

            #line 34 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(");

            #line 34 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(TypeName));

            #line default
            #line hidden
            this.Write(" value) => new ");

            #line 34 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(value);\r\n            \r\n            [MethodImpl(MethodImplOptions.AggressiveInlin" +
                       "ing)]\r\n            public static implicit operator ");

            #line 37 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(TypeName));

            #line default
            #line hidden
            this.Write("(");

            #line 37 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value) => value.m_value;\r\n            \r\n            // Enable comparisons betwee" +
                       "n nil and ");

            #line 39 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" struct\r\n            [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n        " +
                       "    public static bool operator ==(");

            #line 41 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value, NilType nil) => value.Equals(default(");

            #line 41 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("));\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n          " +
                       "  public static bool operator !=(");

            #line 44 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value, NilType nil) => !(value == nil);\r\n\r\n            [MethodImpl(MethodImplOpt" +
                       "ions.AggressiveInlining)]\r\n            public static bool operator ==(NilType ni" +
                       "l, ");

            #line 47 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value) => value == nil;\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveI" +
                       "nlining)]\r\n            public static bool operator !=(NilType nil, ");

            #line 50 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value) => value != nil;\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveI" +
                       "nlining)]\r\n            public static implicit operator ");

            #line 53 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(NilType nil) => default(");

            #line 53 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(");\r\n        }\r\n    }\r\n");

            #line 56 "D:\Projects\go2cs\src\go2cs.Templates\InheritedTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(NamespaceFooter));

            #line default
            #line hidden
            this.Write("\r\n");
            return(this.GenerationEnvironment.ToString());
        }
コード例 #11
0
 public void AttributeSubstring(NamespacePrefix prefix, string name, string value)
 {
 }
コード例 #12
0
 public void AttributeSuffixMatch(NamespacePrefix prefix, string name, string value)
 {
 }
コード例 #13
0
 public void AttributeIncludes(NamespacePrefix prefix, string name, string value)
 {
 }
コード例 #14
0
 public void AttributeExact(NamespacePrefix prefix, string name, string value)
 {
 }
コード例 #15
0
 public void Equality()
 {
     Assert.That(NamespacePrefix.None.Equals(NamespacePrefix.None), Is.True);
     Assert.That(NamespacePrefix.Any.Equals(NamespacePrefix.Any), Is.True);
     Assert.That(NamespacePrefix.Empty.Equals(NamespacePrefix.Empty), Is.True);
     var foo = new NamespacePrefix("foo");
     Assert.That(foo.Equals(foo), Is.True);
     Assert.That(foo.Equals((object) foo), Is.True);
 }
コード例 #16
0
 public void Inequality()
 {
     var foo = new NamespacePrefix("foo");
     var bar = new NamespacePrefix("bar");
     Assert.That(foo.Equals(bar), Is.False);
     Assert.That(foo.Equals((object)bar), Is.False);
 }
コード例 #17
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void Universal(NamespacePrefix prefix)
 {
     UniversalPrefix = prefix;
 }
コード例 #18
0
ファイル: StructTypeTemplate.cs プロジェクト: zjmit/go2cs
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
            #line 1 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            // This template creates a <PackageName>_<StructName>Struct.cs file

            #line default
            #line hidden
            this.Write(@"//---------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool. Changes to this
//     file may cause incorrect behavior and will be lost
//     if the code is regenerated.
//
//     Generated on ");

            #line 17 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedTime));

            #line default
            #line hidden
            this.Write("\r\n// </auto-generated>\r\n//-------------------------------------------------------" +
                       "--\r\nusing System;\r\nusing System.CodeDom.Compiler;\r\nusing System.Diagnostics;\r\nus" +
                       "ing System.Reflection;\r\nusing System.Runtime.CompilerServices;\r\n");

            #line 25 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(Environment.NewLine, UsingStatements)));

            #line default
            #line hidden
            this.Write("\r\n");

            #line 26 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            if (!NamespacePrefix.Equals("go"))
            {
            #line default
            #line hidden
                this.Write("using go;\r\n");

            #line 28 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n#nullable enable\r\n\r\n");

            #line 32 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(NamespaceHeader));

            #line default
            #line hidden
            this.Write("\r\n    public static partial class ");

            #line 33 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(PackageName));

            #line default
            #line hidden
            this.Write("_package\r\n    {\r\n        [");

            #line 35 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedCodeAttribute));

            #line default
            #line hidden
            this.Write("]");

            #line 35 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"

            foreach (string promotedStruct in PromotedStructs)
            {
                if (!string.IsNullOrEmpty(promotedStruct))
                {
            #line default
            #line hidden
                    this.Write("\r\n        [PromotedStruct(typeof(");

            #line 42 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(promotedStruct));

            #line default
            #line hidden
                    this.Write("))]");

            #line 42 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                }
            }

            #line default
            #line hidden
            this.Write("\r\n        ");

            #line 46 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Scope));

            #line default
            #line hidden
            this.Write(" partial struct ");

            #line 46 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("\r\n        {");

            #line 47 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"

            foreach (KeyValuePair <string, List <FunctionSignature> > kvp in PromotedFunctions)
            {
                foreach (var decl in kvp.Value)
                {
            #line default
            #line hidden

            #line 52 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(new StructFuncDeclTemplate
                    {
                        PromotedField      = kvp.Key,
                        FunctionName       = decl.Name,
                        Scope              = "public",
                        ParameterSignature = decl.Signature.GenerateParametersSignature(),
                        ParameterNames     = GetParameterNames(decl),
                        ParameterTypes     = GetParameterTypeNames(decl),
                        ResultType         = decl.Signature.GenerateResultSignature()
                    }
                                                                       .TransformText()));

            #line default
            #line hidden

            #line 62 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                }
            }

            foreach (KeyValuePair <string, List <FieldInfo> > kvp in PromotedFields)
            {
                FieldInfo promotedStruct = GetPromotedStruct(kvp.Key);
                bool      isPointer      = promotedStruct?.Type is PointerTypeInfo;


            #line default
            #line hidden
                this.Write("\r\n            // ");

            #line 73 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write(" structure promotion - sourced from ");

            #line 73 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(isPointer ? "pointer" : "value copy"));

            #line default
            #line hidden
                this.Write("\r\n            private readonly ptr<");

            #line 74 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write("> m_");

            #line 74 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write("Ref;\r\n\r\n            private ref ");

            #line 76 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write(" ");

            #line 76 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write("_");

            #line 76 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(isPointer ? "ptr" : "val"));

            #line default
            #line hidden
                this.Write(" => ref m_");

            #line 76 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                this.Write("Ref.Value;\r\n");

            #line 77 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"


                foreach (var decl in kvp.Value)
                {
            #line default
            #line hidden
                    this.Write("\r\n            public ref ");

            #line 83 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Type.TypeName));

            #line default
            #line hidden
                    this.Write(" ");

            #line 83 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                    this.Write(" => ref m_");

            #line 83 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Key));

            #line default
            #line hidden
                    this.Write("Ref.Value.");

            #line 83 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                    this.Write(";\r\n");

            #line 84 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                }
            }

            if (PromotedFunctions.Count > 0)
            {
            #line default
            #line hidden
                this.Write("            \r\n            [DebuggerStepperBoundary]\r\n            static ");

            #line 93 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
                this.Write("()\r\n            {\r\n                Type targetType = typeof(");

            #line 95 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
                this.Write(");\r\n                MethodInfo extensionMethod;");

            #line 96 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"


                foreach (KeyValuePair <string, List <FunctionSignature> > kvp in PromotedFunctions)
                {
                    foreach (var decl in kvp.Value)
                    {
            #line default
            #line hidden

            #line 102 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(new StructFuncInitTemplate
                        {
                            FunctionName = decl.Name
                        }
                                                                           .TransformText()));

            #line default
            #line hidden

            #line 106 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    }
                }

            #line default
            #line hidden
                this.Write("\r\n            }\r\n");

            #line 111 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n            // Constructors\r\n            public ");

            #line 116 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(NilType _)\r\n            {");

            #line 117 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"

            foreach (var decl in StructFields)
            {
                if (PromotedStructs.Contains(decl.Type.TypeName))
                {
                    // Promoted struct

            #line default
            #line hidden
                    this.Write("\r\n                this.m_");

            #line 124 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                    this.Write("Ref = new ptr<");

            #line 124 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Type.TypeName));

            #line default
            #line hidden
                    this.Write(">(new ");

            #line 124 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Type.TypeName));

            #line default
            #line hidden
                    this.Write("(nil));");

            #line 124 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                }
                else
                {
                    // Promoted interface or normal struct field

            #line default
            #line hidden
                    this.Write("\r\n                this.");

            #line 130 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                    this.Write(" = default;");

            #line 130 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                }
            }

            #line default
            #line hidden
            this.Write("\r\n            }");

            #line 134 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"


            if (StructFields.Length > 0)
            {
            #line default
            #line hidden
                this.Write("\r\n\r\n            public ");

            #line 140 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
                this.Write("(");

            #line 140 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(", ", StructFields.Select(field => $"{(field.Type is PointerTypeInfo ? "ref " : "")}{field.Type.TypeName} {field.Name} = default"))));

            #line default
            #line hidden
                this.Write(")\r\n            {");

            #line 141 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"

                foreach (var decl in StructFields)
                {
                    if (PromotedStructs.Contains(decl.Type.TypeName))
                    {
                        // Promoted struct

            #line default
            #line hidden
                        this.Write("\r\n                this.m_");

            #line 148 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                        this.Write("Ref = new ptr<");

            #line 148 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Type.TypeName));

            #line default
            #line hidden
                        this.Write(">(");

            #line 148 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Type is PointerTypeInfo ? "ref " : ""));

            #line default
            #line hidden

            #line 148 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                        this.Write(");");

            #line 148 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    }
                    else
                    {
                        // Promoted interface or normal struct field

            #line default
            #line hidden
                        this.Write("\r\n                this.");

            #line 154 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                        this.Write(" = ");

            #line 154 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(decl.Name));

            #line default
            #line hidden
                        this.Write(";");

            #line 154 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
                    }
                }

            #line default
            #line hidden
                this.Write("\r\n            }\r\n");

            #line 159 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n            // Enable comparisons between nil and ");

            #line 162 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" struct\r\n            [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n        " +
                       "    public static bool operator ==(");

            #line 164 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value, NilType nil) => value.Equals(default(");

            #line 164 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("));\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n          " +
                       "  public static bool operator !=(");

            #line 167 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value, NilType nil) => !(value == nil);\r\n\r\n            [MethodImpl(MethodImplOpt" +
                       "ions.AggressiveInlining)]\r\n            public static bool operator ==(NilType ni" +
                       "l, ");

            #line 170 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value) => value == nil;\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveI" +
                       "nlining)]\r\n            public static bool operator !=(NilType nil, ");

            #line 173 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" value) => value != nil;\r\n\r\n            [MethodImpl(MethodImplOptions.AggressiveI" +
                       "nlining)]\r\n            public static implicit operator ");

            #line 176 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(NilType nil) => default(");

            #line 176 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(");\r\n        }\r\n\r\n        [");

            #line 179 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GeneratedCodeAttribute));

            #line default
            #line hidden
            this.Write("]\r\n        ");

            #line 180 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Scope));

            #line default
            #line hidden
            this.Write(" static ");

            #line 180 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write(" ");

            #line 180 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("_cast(dynamic value)\r\n        {\r\n            return new ");

            #line 182 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(StructName));

            #line default
            #line hidden
            this.Write("(");

            #line 182 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(GetConstructorParameterNames()));

            #line default
            #line hidden
            this.Write(");\r\n        }\r\n    }\r\n");

            #line 185 "D:\Projects\go2cs\src\go2cs.Templates\StructTypeTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(NamespaceFooter));

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
コード例 #19
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void AttributeExists(NamespacePrefix prefix, string name)
 {
     AttributeExistsPrefix = prefix;
     AttributeExistsName   = name;
 }
コード例 #20
0
        public void NamespacePrefix_matches_exact_namespaces()
        {
            NamespacePrefix p = new NamespacePrefix("System.Web");

            Assert.IsTrue(p.Matches("System.Web"));
        }
コード例 #21
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void AttributeExact(NamespacePrefix prefix, string name, string value)
 {
     AttributeExactPrefix = prefix;
     AttributeExactName   = name;
     AttributeExactValue  = value;
 }
コード例 #22
0
 /// <summary>
 /// Generates a <a href="http://www.w3.org/TR/css3-selectors/#type-selectors">type selector</a>,
 /// which represents an instance of the element type in the document tree.
 /// </summary>
 public virtual Selector <HtmlNode> Type(NamespacePrefix prefix, string type) =>
 prefix.IsSpecific
     ? (Selector <HtmlNode>)(nodes => Enumerable.Empty <HtmlNode>())
     : (nodes => nodes.Elements().Where(n => n.Name == type));
コード例 #23
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void AttributeIncludes(NamespacePrefix prefix, string name, string value)
 {
     AttributeIncludesPrefix = prefix;
     AttributeIncludesName   = name;
     AttributeIncludesValue  = value;
 }
コード例 #24
0
 /// <summary>
 /// Generates an <a href="http://www.w3.org/TR/css3-selectors/#attribute-selectors">attribute selector</a>
 /// that represents an element with the given attribute <paramref name="name"/>
 /// whatever the values of the attribute.
 /// </summary>
 public virtual Selector <HtmlNode> AttributeExists(NamespacePrefix prefix, string name) =>
 prefix.IsSpecific
     ? (Selector <HtmlNode>)(nodes => Enumerable.Empty <HtmlNode>())
     : (nodes => nodes.Elements().Where(n => n.Attributes[name] != null));
コード例 #25
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void AttributeSuffixMatch(NamespacePrefix prefix, string name, string value)
 {
     AttributeSuffixMatchPrefix = prefix;
     AttributeSuffixMatchName   = name;
     AttributeSuffixMatchValue  = value;
 }
コード例 #26
0
 public Selector <SvgElement> Universal(NamespacePrefix prefix)
 {
     return(nodes => nodes);
 }
コード例 #27
0
ファイル: ParserTests.cs プロジェクト: usametov/fizzler
 public void AttributeSubstring(NamespacePrefix prefix, string name, string value)
 {
     AttributeSubstringPrefix = prefix;
     AttributeSubstringName   = name;
     AttributeSubstringValue  = value;
 }
コード例 #28
0
 public Selector <Element> Type(NamespacePrefix prefix, string name)
 {
     return(prefix.IsSpecific ?
            (Selector <Element>)(nodes => Enumerable.Empty <Element>())
         : (Selector <Element>)(nodes => nodes.Where(n => n.TagName.ToUpper() == name.ToUpper())));
 }
コード例 #29
0
ファイル: XmlNodeOps.cs プロジェクト: tuyenbuiqn/fizzler
 public virtual Selector <XmlNode> Type(NamespacePrefix prefix, string type)
 {
     // TODO Proper namespace support
     return(nodes => nodes.Where(n => n.Name == type));
 }
コード例 #30
0
 public Selector <Element> AttributeDashMatch(NamespacePrefix prefix, string name, string value)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
ファイル: XmlNodeOps.cs プロジェクト: tuyenbuiqn/fizzler
 public virtual Selector <XmlNode> Universal(NamespacePrefix prefix)
 {
     // TODO Proper namespace support
     return(nodes => nodes.Elements());
 }
コード例 #32
0
 public void HashCode()
 {
     var foo = new NamespacePrefix("foo");
     var bar = new NamespacePrefix("bar");
     Assert.That(foo.GetHashCode() == bar.GetHashCode(), Is.False);
 }
コード例 #33
0
ファイル: XmlNodeOps.cs プロジェクト: tuyenbuiqn/fizzler
 public virtual Selector <XmlNode> AttributeExists(NamespacePrefix prefix, string name)
 {
     // TODO Proper namespace support
     return(nodes => nodes.Elements().Where(n => n.Attributes[name] != null));
 }
コード例 #34
0
 public void TypeEquality()
 {
     var foo = new NamespacePrefix("foo");
     Assert.That(foo, Is.Not.EqualTo(null));
     Assert.That(foo, Is.Not.EqualTo(123));
 }
コード例 #35
0
 public void Universal(NamespacePrefix prefix)
 {
 }