internal virtual void AddAssemblyDirective(ILocation location, TagAttributes attrs)
        {
            IDictionary tbl  = attrs.GetDictionary(null);
            string      name = GetAndRemove(tbl, "Name");
            string      src  = GetAndRemove(tbl, "Src");

            if (name == null && src == null)
            {
                throw new ParseException(location, "You gotta specify Src or Name");
            }

            if (name != null && src != null)
            {
                throw new ParseException(location, "Src and Name cannot be used together");
            }

            if (name != null)
            {
                AddAssemblyByName(name, location);
            }
            else
            {
                GetAssemblyFromSource(src, location);
            }

            if (tbl.Count > 0)
            {
                throw new ParseException(location, "Unrecognized attribute in Assembly directive");
            }
        }
Exemple #2
0
        private void TagParsed(ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
        {
            switch (tagtype)
            {
            case TagType.Directive:
                ProcessDirective(tagid, attributes);
                break;

            case TagType.ServerComment:
                break;

            case TagType.CodeRender:
            {
                DumpContent();
                _codeBuilder.Append(tagid);
                _contentBuilder.Length = 0;
            }
            break;

            case TagType.CodeRenderExpression:
            {
                DumpContent();
                string str = string.Format("System.Console.Write({0});\n", tagid);
                _codeBuilder.Append(str);
                _contentBuilder.Length = 0;
            }
            break;
            }
        }
Exemple #3
0
        protected void ProcessTemplate(string relativePath, string templateFile, string outFileName, ITemplateGeneratorHost host)
        {
            string result = InternalProcessTemplate(relativePath, templateFile, outFileName, host);

            OutputType    outputType             = OutputType.Normal;
            TagAttributes codeTemplateAttributes = _currentTemplateContext.Directives["CodeTemplate"] as TagAttributes;

            if (codeTemplateAttributes != null)
            {
                string tmp = codeTemplateAttributes["OutputType"] as string;
                if (tmp != null)
                {
                    try
                    {
                        outputType = (OutputType)Enum.Parse(typeof(OutputType), tmp, true);
                    }
                    catch (ArgumentException) { }
                }
            }

            if (outputType == OutputType.Normal)
            {
                host.AddFile(relativePath, outFileName, result);
            }
        }
Exemple #4
0
 public PSTagAttribute(TagAttributes attribute)
 {
     Registry  = attribute?.Registry;
     ImageName = attribute?.ImageName;
     if (attribute != null)
     {
         Attributes = new PSTagAttributeBase(attribute.Attributes);
     }
 }
Exemple #5
0
        void OnTagParsed(TagType tagtype, string id, TagAttributes attributes)
        {
            TagParsedHandler eh = events [tagParsedEvent] as TagParsedHandler;

            if (eh != null)
            {
                eh(this, tagtype, id, attributes);
            }
        }
        // Summary:
        //     Gets the value of the specified attribute for this element.
        //
        // Parameters:
        //   attributeName:
        //     The name of the attribute.
        //
        // Returns:
        //     The attribute's current value. Returns a null if the value is not set.
        //
        // Exceptions:
        //   OpenQA.Selenium.StaleElementReferenceException:
        //     Thrown when the target element is no longer valid in the document DOM.
        //
        // Remarks:
        //     The OpenQA.Selenium.IWebElement.GetAttribute(System.String) method will return
        //     the current value of the attribute, even if the value has been modified after
        //     the page has been loaded. Note that the value of the following attributes
        //     will be returned even if there is no explicit attribute on the element: Attribute
        //     nameValue returned if not explicitly specifiedValid element typescheckedcheckedCheck
        //     BoxselectedselectedOptions in Select elementsdisableddisabledInput and other
        //     UI elements
        public string GetAttribute(TagAttributes tagAttribute)
        {
            driver.WaitReadyState(); /// Something wrong with the method
                                     ///
            WaitHelper.Wait(1000);   /// Waiting for attributes have been changed successfully

            string attributeName = tagAttribute.GetEnumDescription();

            return(FindSingle().GetAttribute(attributeName));
        }
        public override PSTagAttribute SendRequest()
        {
            TagAttributes tag = _client
                                .GetClient()
                                .Tag
                                .GetAttributesAsync(_repositoryName, _tag)
                                .GetAwaiter()
                                .GetResult();

            return(new PSTagAttribute(tag));
        }
Exemple #8
0
        void GetServerTag(out TagType tagtype, out string id, out TagAttributes attributes)
        {
            string inside_tags;
            bool   old = tokenizer.ExpectAttrValue;

            tokenizer.ExpectAttrValue = false;
            if (Eat('@'))
            {
                tokenizer.ExpectAttrValue = old;
                tagtype = TagType.Directive;
                id      = "";
                if (Eat(Token.DIRECTIVE))
                {
                    id = tokenizer.Value;
                }

                attributes = GetAttributes();
                if (!Eat('%') || !Eat('>'))
                {
                    OnError("expecting '%>'");
                }

                return;
            }

            if (Eat(Token.DOUBLEDASH))
            {
                tokenizer.ExpectAttrValue = old;
                tokenizer.Verbatim        = true;
                inside_tags        = GetVerbatim(tokenizer.get_token(), "--%>");
                tokenizer.Verbatim = false;
                id         = null;
                attributes = null;
                tagtype    = TagType.ServerComment;
                return;
            }

            tokenizer.ExpectAttrValue = old;
            bool varname;
            bool databinding;

            varname     = Eat('=');
            databinding = !varname && Eat('#');

            tokenizer.Verbatim = true;
            inside_tags        = GetVerbatim(tokenizer.get_token(), "%>");
            tokenizer.Verbatim = false;
            id         = inside_tags;
            attributes = null;
            tagtype    = (databinding ? TagType.DataBinding :
                          (varname ? TagType.CodeRenderExpression : TagType.CodeRender));
        }
Exemple #9
0
 /**
  * Walks through the hierarchy (bottom-up) looking for
  * a property key. Returns true as soon as a match is
  * found or false if the key can't be found.
  * @param	key	the key of the property
  * @return	true if the key is found
  */
 virtual public bool HasProperty(String key)
 {
     for (int k = chain.Count - 1; k >= 0; --k)
     {
         TagAttributes p = chain[k];
         IDictionary <String, String> attrs = p.attrs;
         if (attrs.ContainsKey(key))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #10
0
 /**
  * Walks through the hierarchy (bottom-up) looking for
  * a property key. Returns a value as soon as a match
  * is found or null if the key can't be found.
  * @param	key	the key of the property
  * @return	the value of the property
  */
 public String this[String key] {
     get {
         for (int k = chain.Count - 1; k >= 0; --k)
         {
             TagAttributes p = chain[k];
             IDictionary <String, String> attrs = p.attrs;
             if (attrs.ContainsKey(key))
             {
                 return(attrs[key]);
             }
         }
         return(null);
     }
 }
Exemple #11
0
 void ProcessDirective(string tagid, TagAttributes attributes)
 {
     if (tagid == "Import")
     {
         _currentTemplateContext.Imports[attributes["Namespace"]] = attributes;
         return;
     }
     if (tagid == "Assembly")
     {
         _currentTemplateContext.Assemblies[attributes["Name"]] = attributes;
         return;
     }
     _currentTemplateContext.Directives[tagid] = attributes;
 }
Exemple #12
0
        internal virtual void AddDefaultDirective(ILocation location, TagAttributes attrs)
        {
#if NET_2_0
            CompilationSection compConfig;
#else
            CompilationConfiguration compConfig;
#endif
            compConfig = CompilationConfig;

            if (gotDefault)
            {
                throw new ParseException(location, "duplicate " + DefaultDirectiveName + " directive");
            }

            gotDefault = true;
            Hashtable attributes = attrs.GetDictionary(null);
            className = GetAndRemove(attributes, "class");
            if (className == null)
            {
                throw new ParseException(null, "No Class attribute found.");
            }

            string d = GetAndRemove(attributes, "debug");
            if (d != null)
            {
                debug = (String.Compare(d, "true", true, Helpers.InvariantCulture) == 0);
                if (debug == false && String.Compare(d, "false", true, Helpers.InvariantCulture) != 0)
                {
                    throw new ParseException(null, "Invalid value for Debug attribute");
                }
            }
            else
            {
                debug = compConfig.Debug;
            }

            language = GetAndRemove(attributes, "language");
            if (language == null)
            {
                language = compConfig.DefaultLanguage;
            }

            GetAndRemove(attributes, "codebehind");
            if (attributes.Count > 0)
            {
                throw new ParseException(location, "Unrecognized attribute in " +
                                         DefaultDirectiveName + " directive");
            }
        }
Exemple #13
0
    IExternalNode GetExternalNode(TagAttributes tag)
    {
        IExternalNode node;
        var           id = tag.getValue("id");

        if (Nodes.TryGetValue(id, out node))
        {
            return(node);
        }

        var child = Object.Instantiate(prefab);

        Tools.AddChild(label.gameObject, child);
        child.name = "external:" + id;

        node = new RectTransformNode(child.transform as RectTransform);
        Nodes.Add(id, node);
        return(node);
    }
        //[Test]
        public void Generate()
        {
            SortedList <string, TagAttributes> tags = new SortedList <string, TagAttributes>();

            AddTags(tags, _rcDataTags, TagAttributes.RCData);
            AddTags(tags, _selfClosing, TagAttributes.SelfClosing);
            AddTags(tags, _headTag, TagAttributes.IsHeadTag);
            AddTags(tags, _topLevelTag, TagAttributes.TopLevel);

            foreach (string tag in tags.Keys)
            {
                Console.Write("{\"" + tag + "\", ");
                TagAttributes attrMask       = tags[tag];
                string        attrMaskString = "";
                foreach (TagAttributes attrValue in Enum.GetValues(typeof(TagAttributes)))
                {
                    if ((attrMask & attrValue) > 0)
                    {
                        attrMaskString += ((attrMaskString.Length > 0) ? " | " : "") + "TagAttributes." + attrValue.ToString();
                    }
                }
                Console.WriteLine(attrMaskString + "},");
            }
        }
Exemple #15
0
        TagAttributes GetAttributes()
        {
            int           token;
            TagAttributes attributes;
            string        id;
            bool          wellFormedForServer = true;

            attributes = new TagAttributes();
            while ((token = tokenizer.get_token()) != Token.EOF)
            {
                if (token == '<' && Eat('%'))
                {
                    tokenizer.Verbatim = true;
                    attributes.Add("", "<%" +
                                   GetVerbatim(tokenizer.get_token(), "%>") + "%>");
                    tokenizer.Verbatim = false;
                    tokenizer.InTag    = true;
                    continue;
                }

                if (token != Token.IDENTIFIER)
                {
                    break;
                }

                id = tokenizer.Value;
                if (Eat('='))
                {
                    if (Eat(Token.ATTVALUE))
                    {
                        attributes.Add(id, tokenizer.Value);
                        wellFormedForServer &= tokenizer.AlternatingQuotes;
                    }
                    else if (Eat('<') && Eat('%'))
                    {
                        tokenizer.Verbatim = true;
                        attributes.Add(id, "<%" +
                                       GetVerbatim(tokenizer.get_token(), "%>") + "%>");
                        tokenizer.Verbatim = false;
                        tokenizer.InTag    = true;
                    }
                    else
                    {
                        OnError("expected ATTVALUE");
                        return(null);
                    }
                }
                else
                {
                    attributes.Add(id, null);
                }
            }

            tokenizer.put_back();

            if (attributes.IsRunAtServer() && !wellFormedForServer)
            {
                OnError("The server tag is not well formed.");
                return(null);
            }

            return(attributes);
        }
Exemple #16
0
        void GetTag(out TagType tagtype, out string id, out TagAttributes attributes)
        {
            int token = tokenizer.get_token();

            tagtype    = TagType.ServerComment;
            id         = null;
            attributes = null;
            switch (token)
            {
            case '%':
                GetServerTag(out tagtype, out id, out attributes);
                break;

            case '/':
                if (!Eat(Token.IDENTIFIER))
                {
                    OnError("expecting TAGNAME");
                }

                id = tokenizer.Value;
                if (!Eat('>'))
                {
                    OnError("expecting '>'. Got '" + id + "'");
                }

                tagtype = TagType.Close;
                break;

            case '!':
                bool double_dash = Eat(Token.DOUBLEDASH);
                if (double_dash)
                {
                    tokenizer.put_back();
                }

                tokenizer.Verbatim = true;
                string end     = double_dash ? "-->" : ">";
                string comment = GetVerbatim(tokenizer.get_token(), end);
                tokenizer.Verbatim = false;
                if (comment == null)
                {
                    OnError("Unfinished HTML comment/DTD");
                }

                string pathType, filename;
                if (double_dash && GetInclude(comment, out pathType, out filename))
                {
                    tagtype    = TagType.Include;
                    attributes = new TagAttributes();
                    attributes.Add(pathType, filename);
                }
                else
                {
                    tagtype = TagType.Text;
                    id      = "<!" + comment + end;
                }
                break;

            case Token.IDENTIFIER:
                if (this.filename == "@@inner_string@@")
                {
                    // Actually not tag but "xxx < yyy" stuff in inner_string!
                    tagtype         = TagType.Text;
                    tokenizer.InTag = false;
                    id = "<" + tokenizer.Odds + tokenizer.Value;
                }
                else
                {
                    id = tokenizer.Value;
                    try
                    {
                        attributes = GetAttributes();
                    }
                    catch (Exception e)
                    {
                        OnError(e.Message);
                        break;
                    }

                    tagtype = TagType.Tag;
                    if (Eat('/') && Eat('>'))
                    {
                        tagtype = TagType.SelfClosing;
                    }
                    else if (!Eat('>'))
                    {
                        if (attributes.IsRunAtServer())
                        {
                            OnError("The server tag is not well formed.");
                            break;
                        }
                        tokenizer.Verbatim = true;
                        attributes.Add("", GetVerbatim(tokenizer.get_token(), ">") + ">");
                        tokenizer.Verbatim = false;
                    }
                }

                break;

            default:
                tagtype         = TagType.Text;
                tokenizer.InTag = false;
                id = "<" + tokenizer.Value;
                break;
            }
        }
Exemple #17
0
		/// <summary>
		/// Creates a ParsingObject as a child of this one, and returns it.
		/// </summary>
		public virtual ParsingObject CreateChildParsingObject (ILocation location, string tagid, TagAttributes attributes)
		{
			string[] str = tagid.Split(':');

			//html tags
			//TODO: check for valid tags?
			if (str.Length == 1)
			{
				if (attributes.IsRunAtServer () && (0 == string.Compare ("form", tagid)))
					return new ServerFormParsingObject (location.PlainText, tagid, this);
				return new HtmlParsingObject (location.PlainText, tagid, this);
			}

			//fall through to server tags
			if (str.Length != 2)
				throw new ParseException (location, "Server tag name is not of form prefix:name");

			Type tagType = WebFormReferenceManager.GetObjectType(str[0], str[1]);
			if (tagType == null)
				throw new ParseException(location, "The tag " + tagid + "has not been registered");

			return new ServerObjectParsingObject (tagType, attributes.GetDictionary(null), tagid, this);
		}
		/*TODO: if only we could get the controlbuilder to build the control like in .NET 2's builder.BuildObject ()
		ControlBuilder builder = ControlBuilder.CreateBuilderFromType (null, b, tagType, str[1], (string) attributes["ID"], attributes.GetDictionary (null), currentLocation.BeginLine, currentLocation.Filename);

		if (builder == null)
			throw new ParseException (currentLocation, "Could not create builder for type " + tagType);
		builder.SetServiceProvider (host);
		Control c = builder.BuildObject ();
		*/
		
		void ProcessDirective (string tagid, TagAttributes attributes)
		{
			string placeholder = document.AddDirective (tagid, attributes.GetDictionary (null));
			openObject.AddText (placeholder);
		}
Exemple #19
0
 public static string GetAttribute(this IWebElement element, TagAttributes tagAttribute)
 {
     return(element.GetAttribute(ObjectUtil.GetEnumDescription(tagAttribute)));
 }
        void TagParsed(ILocation location, System.Web.Compilation.TagType tagtype, string tagid, TagAttributes attributes)
        {
            if (tagtype != System.Web.Compilation.TagType.Directive)
            {
                throw new ParseException(location, "Unexpected tag");
            }

            if (tagid == null || tagid.Length == 0 || String.Compare(tagid, DefaultDirectiveName, true, Helpers.InvariantCulture) == 0)
            {
                AddDefaultDirective(location, attributes);
            }
            else if (String.Compare(tagid, "Assembly", true, Helpers.InvariantCulture) == 0)
            {
                AddAssemblyDirective(location, attributes);
            }
            else
            {
                throw new ParseException(location, "Unexpected directive: " + tagid);
            }
        }
Exemple #21
0
 /// <summary>
 /// Quickly add an attribute
 /// it always returns the tag itself again, allowing chaining of multiple add-calls
 /// </summary>
 /// <param name="nameWithValue">Object which can be ToString()ed</param>
 /// <returns></returns>
 public T Attr(object nameWithValue)
 {
     TagAttributes.AddObject(nameWithValue);
     return((T)this);
 }
Exemple #22
0
        private string Execute(ITemplateGeneratorHost host, string relativePath, string templateFile, string outFileName)
        {
            Type compiledType = null;

            if (!_compiledAssemblies.Contains(templateFile))
            {
                string guid = Guid.NewGuid().ToString("N");
                string generatorClassName = "Template" + guid;
                string import             = @"using System;
using System.Collections;
";

                foreach (DictionaryEntry entry in _currentTemplateContext.Imports)
                {
                    TagAttributes tagAttributes = entry.Value as TagAttributes;
                    import += "using " + tagAttributes["Namespace"].ToString() + ";\r\n";
                }

                string prefix = @"
namespace FluorineFx.CodeGenerator
{
	public class "     + generatorClassName + @" : Template
	{
		public "         + generatorClassName + @"(TemplateEngine templateEngine, ITemplateGeneratorHost host, TemplateContext templateContext) : base(templateEngine, host, templateContext)
		{
		}

		public void RunTemplate()
		{"        ;

                string suffix = @"
		}
	}
}";

                string code = import + prefix + _codeBuilder.ToString() + suffix;

                if (_templateEngineSettings.Trace)
                {
                    host.AddFile(relativePath, outFileName + ".trace.cs", code);
                }

                CodeDomProvider provider = null;
                //Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
                //Microsoft.VisualBasic.VBCodeProvider provider = new Microsoft.VisualBasic.VBCodeProvider();
                provider = new Microsoft.CSharp.CSharpCodeProvider();
#if (NET_1_1)
                ICodeCompiler compiler = provider.CreateCompiler();
#endif
                CompilerParameters options = new CompilerParameters();
                options.GenerateInMemory   = true;
                options.GenerateExecutable = false;
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    //options.ReferencedAssemblies.Add(Path.GetFileName(assembly.Location));
                    options.ReferencedAssemblies.Add(assembly.Location);
                }

                Uri    uri     = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                string libPath = Path.GetDirectoryName(uri.LocalPath);
                options.CompilerOptions = "/lib:\"" + libPath + "\"";
                if (AppDomain.CurrentDomain.BaseDirectory != null)
                {
                    options.CompilerOptions += " /lib:\"" + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\"";
                }
                if (AppDomain.CurrentDomain.DynamicDirectory != null)
                {
                    options.CompilerOptions += " /lib:\"" + Path.GetDirectoryName(AppDomain.CurrentDomain.DynamicDirectory) + "\"";
                }

                foreach (DictionaryEntry entry in _currentTemplateContext.Assemblies)
                {
                    TagAttributes tagAttributes = entry.Value as TagAttributes;
                    bool          referenced    = false;
                    foreach (string referencedAssembly in options.ReferencedAssemblies)
                    {
                        string assembly = Path.GetFileName(referencedAssembly);
                        if (assembly.ToLower() == tagAttributes["Name"].ToString().ToLower())
                        {
                            referenced = true;
                            break;
                        }
                    }
                    if (!referenced)
                    {
                        options.ReferencedAssemblies.Add(tagAttributes["Name"].ToString());
                    }
                }

                //log.Debug("Compiling code");
                //log.Debug(code);

                /*
                 * string output = Path.Combine(Path.GetTempPath(), generatorClassName + ".cs");
                 * using (StreamWriter sw = File.CreateText(output))
                 * {
                 *  sw.Write(code);
                 * }
                 */

#if (NET_1_1)
                CompilerResults results = compiler.CompileAssemblyFromSource(options, code);
#else
                CompilerResults results = provider.CompileAssemblyFromSource(options, code);
                //CompilerResults results = provider.CompileAssemblyFromFile(options, output);
#endif
                if (results.Errors.Count != 0)
                {
                    StringBuilder errorBuilder = new StringBuilder();
                    errorBuilder.Append("*** Compilation Errors ***\n");
                    log.Error("*** Compilation Errors ***");
                    foreach (CompilerError error in results.Errors)
                    {
                        errorBuilder.Append(error.Line + ", " + error.Column + ", " + error.ErrorNumber + ": ");
                        errorBuilder.Append(error.ErrorText);
                        errorBuilder.Append("\r\n");
                        log.Error(error.Line + ", " + error.Column + ", " + error.ErrorNumber + ": " + error.ErrorText);
                    }
                    host.AddFile(relativePath, outFileName + ".error.txt", errorBuilder.ToString());
                    return(errorBuilder.ToString());
                }

                compiledType = results.CompiledAssembly.GetType("FluorineFx.CodeGenerator." + generatorClassName);
                _compiledAssemblies[templateFile] = compiledType;
            }
            else
            {
                compiledType = _compiledAssemblies[templateFile] as Type;
            }

            TextWriter   saved  = Console.Out;
            StringWriter writer = new StringWriter();
            Console.SetOut(writer);
            try
            {
                object     generator = Activator.CreateInstance(compiledType, new object[] { this, host, _currentTemplateContext });//Assembly.CreateInstance("FluorineFx.CodeGenerator." + generatorClassName, true, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this, host, _currentTemplateContext }, null, null);
                MethodInfo mi        = generator.GetType().GetMethod("RunTemplate");
                mi.Invoke(generator, new object[] {});
                return(writer.ToString());
            }
            catch (Exception ex)
            {
                log.Error("Error calling code generator", ex);
                Console.SetOut(saved);
                //Console.WriteLine(code.ToString());
                Console.WriteLine();
                Console.WriteLine("Unable to invoke entry point: {0}", ex.Message);
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException);
                }
                return(ex.ToString());
            }
            finally
            {
                Console.SetOut(saved);
            }
        }
Exemple #23
0
 public string GetAttribute(TagAttributes tagAttribute)
 {
     log.Debug($"        ('{FirstSelector}').GetAttribute('{tagAttribute}')");
     return(FindSingle().GetAttribute(EnumHelper.GetEnumDescription(tagAttribute)));
 }
 private void AddTags(SortedList <string, TagAttributes> tagCollection, string[] tags, TagAttributes attr)
 {
     foreach (string tag in tags)
     {
         if (!tagCollection.ContainsKey(tag))
         {
             tagCollection.Add(tag, TagAttributes.None);
         }
         tagCollection[tag] = tagCollection[tag] | attr;
     }
 }
 public string GetAttribute(TagAttributes tagAttribute)
 {
     return(FindSingle().GetAttribute(EnumHelper.GetEnumDescription(tagAttribute)));
 }
 public WebElement ByAttribute(TagAttributes tagAttribute, int attributeValue, bool exactMatch = true)
 {
     return(ByAttribute(EnumHelper.GetEnumDescription(tagAttribute), attributeValue.ToString(), exactMatch));
 }
 public WebElement ByAttribute(TagAttributes tagAttribute, int attributeValue, bool exactMatch = true)
 {
     return ByAttribute(EnumHelper.GetEnumDescription(tagAttribute), attributeValue.ToString(), exactMatch);
 }
		public override ParsingObject CreateChildParsingObject (ILocation location, string tagid, TagAttributes attributes)
		{
			switch (mode) {
				case ParseChildrenMode.DefaultProperty:
					//oops, we didn't need to tokenise this.
					innerText += location.PlainText;
					//how do we get end tag?
					throw new NotImplementedException ("Inner default properties that look like tags have not been implemented yet.");
				case ParseChildrenMode.DefaultEncodedProperty:
					innerText += System.Web.HttpUtility.HtmlDecode (location.PlainText);
					//how do we get end tag?
					throw new NotImplementedException ("Inner default properties that look like tags have not been implemented yet.");
				case ParseChildrenMode.Controls:
					//html tags
					if (tagid.IndexOf(':') == -1)
						return new HtmlParsingObject (location.PlainText, tagid, this);
					goto case ParseChildrenMode.DefaultCollectionProperty;
				case ParseChildrenMode.DefaultCollectionProperty:
					string[] str = tagid.Split(':');
					if (str.Length != 2)
						throw new ParseException (location, "Server tag name is not of form prefix:name");

					Type tagType = WebFormReferenceManager.GetObjectType(str[0], str[1]);
					if (tagType == null)
						throw new ParseException(location, "The tag " + tagid + "has not been registered");

					return new ServerObjectParsingObject (tagType, attributes.GetDictionary(null), tagid, this);
				case ParseChildrenMode.Properties:
					throw new NotImplementedException ("Multiple child properties have not yet been implemented.");
			}
			throw new ParseException (location, "Unexpected state encountered: ");
		}
Exemple #29
0
 /// <summary>
 /// Quickly add an attribute
 /// it always returns the tag itself again, allowing chaining of multiple add-calls
 /// </summary>
 /// <param name="name">the attribute name, or a complete value like "name='value'"</param>
 /// <param name="value">optional value - if the attribute already exists, it will be appended</param>
 /// <param name="appendSeparator">attribute appendSeparator in case the value is appended</param>
 /// <returns></returns>
 public T Attr(string name, object value = null, string appendSeparator = null)
 {
     TagAttributes.Add(name, value, appendSeparator);
     return((T)this);
 }
 public WebElement ByAttribute(TagAttributes tagAttribute, string attributeValue, bool exactMatch = true)
 {
     return(ByAttribute(tagAttribute.GetEnumDescription(), attributeValue, exactMatch));
 }
		void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
		{
			switch (tagtype)
			{
				case TagType.Close:
					if (openObject == null)
						throw new ParseException (location, "There are more closing tags than opening tags");

					if (0 != string.Compare (openObject.TagID, tagid))
						throw new ParseException (location, "Closing tag " + tagid + " does not match opening tag " + openObject.TagID);
					openObject = openObject.CloseObject (location.PlainText);
					break;
				case TagType.CodeRender:
					throw new NotImplementedException ("Code render expressions have not yet been implemented: " + location.PlainText);
					//break;
				case TagType.CodeRenderExpression:
					throw new NotImplementedException ("Code render expressions have not yet been implemented: " + location.PlainText);
					//break;
				case TagType.DataBinding:
					throw new NotImplementedException("Data binding expressions have not yet been implemented: " + location.PlainText);
					//break;
				case TagType.Directive:
					ProcessDirective (tagid, attributes);
					break;
				case TagType.Include:
					throw new NotImplementedException ("Server-side includes have not yet been implemented: " + location.PlainText);
					//break;
				case TagType.ServerComment:
					throw new NotImplementedException ("Server comments have not yet been implemented: " + location.PlainText);
					//break;
				case TagType.Tag:
					//TODO: don't do this for XHTML
					if ((string.Compare (tagid, "br", true) == 0)
						|| (string.Compare (tagid, "hr", true) == 0))
						goto case TagType.SelfClosing;
					
					openObject = openObject.CreateChildParsingObject(location, tagid, attributes);
					break;
				case TagType.SelfClosing:
					if (openObject == null)
						throw new Exception ("Root tag cannot be self-closing");
				
					openObject = openObject.CreateChildParsingObject(location, tagid, attributes);
					openObject = openObject.CloseObject(string.Empty);
					break;
				case TagType.Text:
					throw new NotImplementedException("Text tagtypes have not yet been implemented: " + location.PlainText);
					//break;
			}
		}