예제 #1
0
        internal static HxlTemplate LoadMaster(
            IHxlTemplateFactory templateFactory,
            bool ignoreErrors,
            string layoutName)
        {
            if (templateFactory == HxlTemplateFactory.Null)
            {
                if (ignoreErrors)
                {
                    return(null);
                }
                throw HxlFailure.CannotLoadAnyMasterTemplates();
            }
            var master = templateFactory.CreateTemplate(layoutName, "layout", null);

            if (master == null)
            {
                if (ignoreErrors)
                {
                    return(null);
                }
                throw HxlFailure.CannotLoadMasterTemplate(layoutName);
            }

            return(master);
        }
예제 #2
0
        private void VerifyPrefix(string prefix, string argumentName)
        {
            if (prefix == null)
            {
                throw new ArgumentNullException(argumentName);
            }
            if (string.IsNullOrEmpty(prefix))
            {
                throw Failure.EmptyString(argumentName);
            }

            if (this.map.ContainsKey(prefix))
            {
                throw HxlFailure.PrefixAlreadyDefined("prefix", prefix);
            }

            switch (prefix)
            {
            case "hxl":
            case "c":
            case "xml":
            case "xmlns":
                throw HxlFailure.CannotUseBuiltinPrefixes(argumentName);
            }
        }
예제 #3
0
 public override Type GetElementNodeType(HxlQualifiedName name)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     throw HxlFailure.NoMatchingServerElement(name.FullName);
 }
예제 #4
0
 public override DomAttribute CreateAttribute(HxlQualifiedName name)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     throw HxlFailure.NoMatchingServerAttribute(name.FullName);
 }
예제 #5
0
        protected override Uri LookupNamespace(string prefix)
        {
            var result = base.LookupNamespace(prefix);

            if (result == null)
            {
                throw HxlFailure.PrefixDoesNotMapToNamespace(prefix);
            }
            return(result);
        }
예제 #6
0
        public static HxlTemplate FromName(Assembly assembly, string name, string type)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

#if NET
            if (assembly.ReflectionOnly)
            {
                throw HxlFailure.AssemblyIsReflectionOnly("assembly");
            }
#endif
            var f = HxlTemplateFactory.FromAssembly(assembly);
            return(f.CreateTemplate(name, null, null));
        }
            public void Render(DomElement element, HxlWriter output)
            {
                var eti      = new HxlElementTemplateInfo(element.Name, element.Attribute("class"));
                var services = ServiceProvider.Compose(
                    ServiceProvider.Current,
                    ServiceProvider.FromValue(eti));

                var template = output.TemplateContext.TemplateFactory.CreateTemplate(_name, _type, services);

                if (template == null)
                {
                    // TODO Missing line number
                    throw HxlFailure.CannotFindMatchingTemplate(_type, _name, -1, -1);
                }

                var context = output.TemplateContext.CreateChildContext(template);

                context.Data.Add("element", element);

                template.Transform(output.BaseWriter, context);
            }
예제 #8
0
 private void InvalidWrite()
 {
     throw HxlFailure.InvalidToWriteTextOutput();
 }