Esempio n. 1
0
        private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager)
        {
            Dictionary <string, string> attributeNameValues = ReadAttributeElements(reader, manager);

            string elementPrefix = MiscellaneousUtils.GetPrefix(propertyName);

            IXmlElement element = CreateElement(propertyName, document, elementPrefix, manager);

            currentNode.AppendChild(element);

            // add attributes to newly created element
            foreach (KeyValuePair <string, string> nameValue in attributeNameValues)
            {
                string attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key);

                IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix))
                               ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix), nameValue.Value)
                               : document.CreateAttribute(nameValue.Key, nameValue.Value);

                element.SetAttributeNode(attribute);
            }

            if (reader.TokenType == JsonToken.String)
            {
                element.AppendChild(document.CreateTextNode(reader.Value.ToString()));
            }
            else if (reader.TokenType == JsonToken.Integer)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((long)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Float)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((double)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Boolean)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((bool)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Date)
            {
                DateTime d = (DateTime)reader.Value;
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind))));
            }
            else if (reader.TokenType == JsonToken.Null)
            {
                // empty element. do nothing
            }
            else
            {
                // finished element will have no children to deserialize
                if (reader.TokenType != JsonToken.EndObject)
                {
                    manager.PushScope();

                    DeserializeNode(reader, document, manager, element);

                    manager.PopScope();
                }
            }
        }
Esempio n. 2
0
        private void AnalyzePropertiesAndItems(BoundSourceFileBuilder binder, IXmlElement parent)
        {
            foreach (var group in parent.Elements("PropertyGroup"))
            {
                binder.AddReferences(group.Attribute("Condition").GetAttributeValueExpressionSpans());
                foreach (var element in group.Elements)
                {
                    binder.AddElementNameReferences(element,
                                                    CreatePropertyReference(element.Name));

                    ExpressionProcessor propertyValueProcessor = null;
                    if (element.Name.EndsWith("DependsOn"))
                    {
                        propertyValueProcessor = ProcessSemicolonSeparatedTargetList;
                    }

                    binder.AddReferences(element.Attribute("Condition").GetAttributeValueExpressionSpans());
                    binder.AddReferences(element.GetElementValueExpressionSpans(propertyValueProcessor));
                }
            }

            foreach (var group in parent.Elements("ItemGroup"))
            {
                AnalyzeItemGroup(binder, group);
            }

            foreach (var group in parent.Elements("ItemDefinitionGroup"))
            {
                AnalyzeItemGroup(binder, group, isDefinition: true);
            }
        }
        /// <summary>
        /// Writes <paramref name="element"/> to <paramref name="fileName"/>.
        /// </summary>
        /// <param name="element">The element to serializer</param>
        /// <param name="fileName">The file name to write <paramref name="element"/> to</param>
        public static void WriteElement(IXmlElement element, string fileName)
        {
            var extension          = Path.GetExtension(fileName);
            var compressionEnabled = extension.Equals(DEFAULT_COMPRESSED_EXTENSION, StringComparison.OrdinalIgnoreCase);

            WriteElement(element, fileName, compressionEnabled);
        }
Esempio n. 4
0
        /// <summary>
        /// Loads desktop from xml file. Creates define windows as well.
        /// </summary>
        /// <param name="reader">xml document to load from.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if ((null != root) && (root.Name == "desktop"))
            {
                this.desktopSize.Width  = UIUtils.FromString(root.GetAttributeValue("Width", ""), this.desktopSize.Width);
                this.desktopSize.Height = UIUtils.FromString(root.GetAttributeValue("Height", ""), this.desktopSize.Height);
                this.Wallpaper          = root.GetAttributeValue("wallpaper", this.Wallpaper);

                foreach (IXmlElement element in root.Elements)
                {
                    if (element.Name == "window")
                    {
                        String type = element.GetAttributeValue("type", "");

                        if (type.Length > 0)
                        {
                            NewRegisteredWindow(type);
                        }
                        else
                        {
                            NewWindow(CreationFlag.NeedLoading, element.GetAttributeValue("name", ""));
                        }

                        if (null != this.Resized)
                        {
                            this.Resized(this, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public override IDesignModel GenerateDesignModel(IXmlElement xmlElement, DesignModelParseContext context)
        {
            var projectConfiguration = new ProjectConfiguration(
                CoreConstants.DesignModelType_ProjectConfiguration,
                context.Namespace,
                xmlElement,
                _projectCollection
                );
            var configFileDir   = Path.GetFullPath(Path.GetDirectoryName(xmlElement.ParseLocation.File.GetSourcePath()));
            var solutionElement = xmlElement.FindChildElement("Solution");
            var solutionPath    = solutionElement.GetAttribute("path").Value;

            solutionPath = Path.GetFullPath(Path.Combine(configFileDir, solutionPath));

            foreach (var projectElement in solutionElement.Children.Where(x => x.Definition.Name.LocalName == "Project"))
            {
                var project = new Project(
                    projectElement.GetAttribute("name").Value,
                    projectElement.GetAttribute("type").Value,
                    Path.Combine(solutionPath, projectElement.GetAttribute("path").Value)
                    );

                project.SetDesignModelsFolder("DesignModels,Plugins/*/DesignModels");

                projectConfiguration.Projects.AddProject(project);
            }

            return(projectConfiguration);
        }
Esempio n. 6
0
        /// <summary>
        /// Configure the CacheFactory.
        /// </summary>
        /// <param name="xmlCache">
        /// An optional <see cref="IXmlElement"/> that conforms to
        /// <c>cache-config.xsd</c>.
        /// </param>
        /// <param name="xmlCoherence">
        /// An optional <see cref="IXmlElement"/> that conforms to
        /// <c>coherence.xsd</c>.
        /// </param>
        /// <since>Coherence 3.7</since>
        public static void Configure(IXmlElement xmlCache, IXmlElement xmlCoherence)
        {
            // create an IOperationalContext
            var ctx = new DefaultOperationalContext(xmlCoherence);

            // create a IConfigurableCacheFactory
            var xmlFactory = ctx.Config.GetSafeElement("configurable-cache-factory-config");
            var typeName   = xmlFactory.GetSafeElement("class-name").GetString(null);
            IConfigurableCacheFactory factory;

            if (typeName == null)
            {
                factory = new DefaultConfigurableCacheFactory(xmlCache);
            }
            else
            {
                var type  = TypeResolver.Resolve(typeName);
                var param = XmlHelper.ParseInitParams(
                    xmlFactory.GetSafeElement("init-params"));

                factory = (IConfigurableCacheFactory)
                          ObjectUtils.CreateInstance(type, param);
            }
            if (factory is DefaultConfigurableCacheFactory)
            {
                ((DefaultConfigurableCacheFactory)factory).OperationalContext = ctx;
            }

            Configure(factory, ctx);
        }
Esempio n. 7
0
        public void TestNamedDefaultPofSerializer()
        {
            IXmlElement xmlConfig = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-extend-named-pof-default-serializer-cache-config.xml");

            CacheFactory.Configure(xmlConfig, null);
            INamedCache cache = CacheFactory.GetCache("dist-default");

            cache.Clear();

            // create a key, and value
            String sKey   = "hello";
            String sValue = "grid";

            // insert the pair into the cache
            cache.Add(sKey, sValue);

            // get the key and value back
            IDictionary entries = cache.GetAll(cache.Keys);

            Assert.AreEqual(1, entries.Count);
            Assert.IsInstanceOf(typeof(IDictionary), entries);
            Assert.AreEqual(sValue, ((String)((IDictionary)entries)[sKey]));

            CacheFactory.ReleaseCache(cache);
        }
        public void TestTransformInitParams()
        {
            IXmlDocument root       = new SimpleDocument("root");
            IXmlDocument initParams = new SimpleDocument("init-params");

            for (int i = 1; i < 4; i++)
            {
                IXmlElement paramEl = initParams.AddElement("init-param");
                paramEl.AddElement("param-name").SetString("name" + i);
                paramEl.AddElement("param-value").SetInt(i);
            }
            Assert.AreEqual(initParams.ElementList.Count, 3);
            Assert.AreEqual(root.ElementList.Count, 0);
            XmlHelper.TransformInitParams(root, initParams);
            Assert.AreEqual(root.ElementList.Count, 3);
            for (int i = 1; i < 4; i++)
            {
                Assert.IsNotNull(root.GetElement("name" + i));
                Assert.AreEqual(root.GetElement("name" + i).GetInt(), i);
            }

            IXmlDocument xml = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-util-transformparams.xml");

            IXmlElement el = xml.FindElement("configurable-cache-factory-config/init-params");

            root = new SimpleDocument("root");
            XmlHelper.TransformInitParams(root, el);
            Assert.IsNotNull(root.GetElement("long"));
            Assert.IsNotNull(root.GetElement("date"));
            Assert.IsNotNull(root.GetElement("float"));
        }
Esempio n. 9
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads control settings from xml file.
        /// </summary>
        /// <param name="element">xml file to load from.</param>
        private void LoadControl(IXmlElement element)
        {
            String controlName = element.GetAttributeValue("control", "");

            if (controlName.Length <= 0)
            {
                return;
            }

            ControlSettings controlSettings = new ControlSettings();

            controlSettings.Name              = controlName;
            controlSettings.ColorBack         = this.Colors.GetColor(element.GetAttributeValue("backColor", ""), Colors.Control);
            controlSettings.ColorBorderLight1 = this.Colors.GetColor(element.GetAttributeValue("borderLight1", ""), Colors.ControlLight);
            controlSettings.ColorBorderLight2 = this.Colors.GetColor(element.GetAttributeValue("borderLight2", ""), Colors.Control);
            controlSettings.ColorBorderDark1  = this.Colors.GetColor(element.GetAttributeValue("borderDark1", ""), Colors.ControlDark);
            controlSettings.ColorBorderDark2  = this.Colors.GetColor(element.GetAttributeValue("borderDark2", ""), Colors.ControlDarkDark);
            controlSettings.BordersFilePrefix = element.GetAttributeValue("imagesPrefix", "images/control_");
            controlSettings.Skinned           = UIUtils.FromString(element.GetAttributeValue("skinned", ""), this.skinned);
            controlSettings.BorderWidth       = UIUtils.FromString(element.GetAttributeValue("borderWidth", null), 2);
            controlSettings.BackImage         = element.GetAttributeValue("backImage", "");
            controlSettings.ControlSize       = UIUtils.FromString(element.GetAttributeValue("controlSize", null), controlSettings.ControlSize);

            this.controlsSettings[controlName] = controlSettings;
        }
        private void CreateElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string elementName, XmlNamespaceManager manager, string elementPrefix, Dictionary <string, string> attributeNameValues)
        {
            IXmlElement xmlElement = this.CreateElement(elementName, document, elementPrefix, manager);

            currentNode.AppendChild(xmlElement);
            foreach (KeyValuePair <string, string> attributeNameValue in attributeNameValues)
            {
                string str    = XmlConvert.EncodeName(attributeNameValue.Key);
                string prefix = MiscellaneousUtils.GetPrefix(attributeNameValue.Key);
                xmlElement.SetAttributeNode((!string.IsNullOrEmpty(prefix) ? document.CreateAttribute(str, manager.LookupNamespace(prefix) ?? string.Empty, attributeNameValue.Value) : document.CreateAttribute(str, attributeNameValue.Value)));
            }
            if (reader.TokenType == JsonToken.String || reader.TokenType == JsonToken.Integer || reader.TokenType == JsonToken.Float || reader.TokenType == JsonToken.Boolean || reader.TokenType == JsonToken.Date)
            {
                string xmlValue = this.ConvertTokenToXmlValue(reader);
                if (xmlValue != null)
                {
                    xmlElement.AppendChild(document.CreateTextNode(xmlValue));
                    return;
                }
            }
            else if (reader.TokenType != JsonToken.Null)
            {
                if (reader.TokenType != JsonToken.EndObject)
                {
                    manager.PushScope();
                    this.DeserializeNode(reader, document, manager, xmlElement);
                    manager.PopScope();
                }
                manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
            }
        }
Esempio n. 11
0
        public void TestCheckNotInit()
        {
            ConfigurablePofContext ctx    = new ConfigurablePofContext("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-config.xml");
            IXmlElement            config = ctx.Config;

            ctx.Config = config;
        }
        private void ReadArrayElements(JsonReader reader, IXmlDocument document, string propertyName, IXmlNode currentNode, XmlNamespaceManager manager)
        {
            string elementPrefix = MiscellaneousUtils.GetPrefix(propertyName);

            IXmlElement nestedArrayElement = CreateElement(propertyName, document, elementPrefix, manager);

            currentNode.AppendChild(nestedArrayElement);

            int count = 0;

            while (reader.Read() && reader.TokenType != JsonToken.EndArray)
            {
                DeserializeValue(reader, document, manager, propertyName, nestedArrayElement);
                count++;
            }

            if (WriteArrayAttribute)
            {
                AddJsonArrayAttribute(nestedArrayElement, document);
            }

            if (count == 1 && WriteArrayAttribute)
            {
                IXmlElement arrayElement = nestedArrayElement.ChildNodes.CastValid <IXmlElement>().Single(n => n.LocalName == propertyName);
                AddJsonArrayAttribute(arrayElement, document);
            }
        }
        /*
         * common method for tests of this suite
         */
        private void runTest(IXmlDocument config, string cacheName, string serializerName)
        {
            IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;
            IXmlElement originalConfig    = ccf.Config;

            ccf.Config = config;

            INamedCache cache = ccf.EnsureCache(cacheName);

            cache.Clear();

            // create a key, and value
            String sKey   = "hello";
            String sValue = "grid";

            // insert the pair into the cache
            cache.Insert(sKey, sValue);

            // read back the value, custom serializer should have converted
            Assert.AreEqual(cache.Count, 1);
            Assert.AreEqual(cache[sKey], serializerName);

            ccf.DestroyCache(cache);
            ccf.Config = originalConfig;
        }
Esempio n. 14
0
        private void ReadArrayElements(JsonReader reader, IXmlDocument document, string propertyName, IXmlNode currentNode, XmlNamespaceManager manager)
        {
            string      prefix   = MiscellaneousUtils.GetPrefix(propertyName);
            IXmlElement newChild = this.CreateElement(propertyName, document, prefix, manager);

            currentNode.AppendChild(newChild);
            int num = 0;

            while (reader.Read() && (reader.TokenType != JsonToken.EndArray))
            {
                this.DeserializeValue(reader, document, manager, propertyName, newChild);
                num++;
            }
            if (this.WriteArrayAttribute)
            {
                this.AddJsonArrayAttribute(newChild, document);
            }
            if ((num == 1) && this.WriteArrayAttribute)
            {
                foreach (IXmlElement element2 in newChild.ChildNodes)
                {
                    if ((element2 != null) && (element2.LocalName == propertyName))
                    {
                        this.AddJsonArrayAttribute(element2, document);
                        break;
                    }
                }
            }
        }
Esempio n. 15
0
        private String GetFontName(String fileName, UIEngine engine)
        {
            using (IXmlReader reader = this.engine.OpenXmlFile(fileName))
            {
                if (null != reader)
                {
                    IXmlElement root     = reader.RootElement;
                    String      fontName = "";

                    if ("font" == root.Name)
                    {
                        fontName = root.GetAttributeValue("name", "");
                    }

                    if ("" == fontName)
                    {
                        return(null);
                    }
                    else
                    {
                        return(fontName);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="xml">字符串参数</param>
        /// <param name="isXmlFile">是否是xml文件</param>
        public DataSourceControl(IXmlElement parent, XElement xElem)
            : base(parent, xElem)
        {
            if (xElem.Attribute("dataSource") != null)
            {
                //Domain.DataSource ds = new DataSourceService().GetDomain(xElem.Attribute("dataSource").Value);

                //if (ds != null)
                //{
                //    DBSource db = new DBSourceService().GetDomain(ds.DBSourceID) ?? new DBSource()
                //    {
                //        DBType = (short)(DatabaseManager.Instance.GetDatabase().NHConfiguration.Properties["connection.driver_class"].Contains("Oracle") ? DatabaseType.Oracle : DatabaseType.Mssql2005)
                //    };

                //    DataSource = new DataSource()
                //    {
                //        CmdText = ds.CmdText,
                //        DatabaseType = db.DBType.Cast<DatabaseType>(DatabaseType.Mssql2005),
                //        ConnectionString = db.ConnectionString ?? DatabaseManager.Instance.GetDatabase().NHConfiguration.Properties["connection.connection_string"],
                //        Name = ds.Name,
                //        Id = ds.ID
                //    };
                //}
            }
        }
        public void TestConnectionTimeout()
        {
            var initiator = new TcpInitiator
            {
                OperationalContext = new DefaultOperationalContext()
            };
            Stream       stream    = GetType().Assembly.GetManifestResourceStream("Tangosol.Resources.s4hc-timeout-cache-config.xml");
            IXmlDocument xmlConfig = XmlHelper.LoadXml(stream);

            IXmlElement initConfig = xmlConfig.FindElement("caching-schemes/remote-cache-scheme/initiator-config");

            initiator.Configure(initConfig);
            initiator.RegisterProtocol(CacheServiceProtocol.Instance);
            initiator.RegisterProtocol(NamedCacheProtocol.Instance);
            initiator.Start();
            Assert.AreEqual(initiator.IsRunning, true);

            IConnection conn            = null;
            bool        exceptionCaught = false;

            try {
                conn = initiator.EnsureConnection();
            }
            catch (Tangosol.Net.Messaging.ConnectionException)
            {
                // good, should time out
                exceptionCaught = true;
            }
            Assert.IsNull(conn);
            Assert.IsTrue(exceptionCaught);
            initiator.Stop();
        }
        private void ReadArrayElements(JsonReader reader, IXmlDocument document, string propertyName, IXmlNode currentNode, XmlNamespaceManager manager)
        {
            string      prefix     = MiscellaneousUtils.GetPrefix(propertyName);
            IXmlElement xmlElement = this.CreateElement(propertyName, document, prefix, manager);

            currentNode.AppendChild(xmlElement);
            int num = 0;

            while (reader.Read() && reader.TokenType != JsonToken.EndArray)
            {
                this.DeserializeValue(reader, document, manager, propertyName, xmlElement);
                num++;
            }
            if (this.WriteArrayAttribute)
            {
                this.AddJsonArrayAttribute(xmlElement, document);
            }
            if (num == 1 && this.WriteArrayAttribute)
            {
                foreach (IXmlNode childNode in xmlElement.ChildNodes)
                {
                    IXmlElement xmlElement1 = childNode as IXmlElement;
                    if (xmlElement1 == null || !(xmlElement1.LocalName == propertyName))
                    {
                        continue;
                    }
                    this.AddJsonArrayAttribute(xmlElement1, document);
                    return;
                }
            }
        }
        private void ReadArrayElements(
            JsonReader reader,
            IXmlDocument document,
            string propertyName,
            IXmlNode currentNode,
            XmlNamespaceManager manager)
        {
            string      prefix   = MiscellaneousUtils.GetPrefix(propertyName);
            IXmlElement element1 = this.CreateElement(propertyName, document, prefix, manager);

            currentNode.AppendChild((IXmlNode)element1);
            int num = 0;

            while (reader.Read() && reader.TokenType != JsonToken.EndArray)
            {
                this.DeserializeValue(reader, document, manager, propertyName, (IXmlNode)element1);
                ++num;
            }
            if (this.WriteArrayAttribute)
            {
                this.AddJsonArrayAttribute(element1, document);
            }
            if (num != 1 || !this.WriteArrayAttribute)
            {
                return;
            }
            foreach (IXmlNode childNode in element1.ChildNodes)
            {
                if (childNode is IXmlElement element2 && element2.LocalName == propertyName)
                {
                    this.AddJsonArrayAttribute(element2, document);
                    break;
                }
            }
        }
Esempio n. 20
0
        private void CreateElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string elementName, XmlNamespaceManager manager, string elementPrefix, Dictionary <string, string> attributeNameValues)
        {
            IXmlElement newChild = this.CreateElement(elementName, document, elementPrefix, manager);

            currentNode.AppendChild(newChild);
            foreach (KeyValuePair <string, string> pair in attributeNameValues)
            {
                string qualifiedName = XmlConvert.EncodeName(pair.Key);
                string prefix        = MiscellaneousUtils.GetPrefix(pair.Key);
                string text1         = manager.LookupNamespace(prefix);
                if (text1 == null)
                {
                }
                IXmlNode attribute = !string.IsNullOrEmpty(prefix) ? document.CreateAttribute(qualifiedName, string.Empty, pair.Value) : document.CreateAttribute(qualifiedName, pair.Value);
                newChild.SetAttributeNode(attribute);
            }
            if (((reader.TokenType == JsonToken.String) || (reader.TokenType == JsonToken.Integer)) || (((reader.TokenType == JsonToken.Float) || (reader.TokenType == JsonToken.Boolean)) || (reader.TokenType == JsonToken.Date)))
            {
                string text = this.ConvertTokenToXmlValue(reader);
                if (text != null)
                {
                    newChild.AppendChild(document.CreateTextNode(text));
                }
            }
            else if (reader.TokenType != JsonToken.Null)
            {
                if (reader.TokenType != JsonToken.EndObject)
                {
                    manager.PushScope();
                    this.DeserializeNode(reader, document, manager, newChild);
                    manager.PopScope();
                }
                manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
            }
        }
        private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
        {
            do
            {
                switch (reader.TokenType)
                {
                case JsonToken.PropertyName:
                    if (currentNode.NodeType == XmlNodeType.Document && document.DocumentElement != null)
                    {
                        throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.");
                    }

                    string propertyName = reader.Value.ToString();
                    reader.Read();

                    if (reader.TokenType == JsonToken.StartArray)
                    {
                        int count = 0;
                        while (reader.Read() && reader.TokenType != JsonToken.EndArray)
                        {
                            DeserializeValue(reader, document, manager, propertyName, currentNode);
                            count++;
                        }

                        if (count == 1 && WriteArrayAttribute)
                        {
                            IXmlElement arrayElement = currentNode.ChildNodes.CastValid <IXmlElement>().Single(n => n.LocalName == propertyName);
                            AddJsonArrayAttribute(arrayElement, document);
                        }
                    }
                    else
                    {
                        DeserializeValue(reader, document, manager, propertyName, currentNode);
                    }
                    break;

                case JsonToken.StartConstructor:
                    string constructorName = reader.Value.ToString();

                    while (reader.Read() && reader.TokenType != JsonToken.EndConstructor)
                    {
                        DeserializeValue(reader, document, manager, constructorName, currentNode);
                    }
                    break;

                case JsonToken.Comment:
                    currentNode.AppendChild(document.CreateComment((string)reader.Value));
                    break;

                case JsonToken.EndObject:
                case JsonToken.EndArray:
                    return;

                default:
                    throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + reader.TokenType);
                }
            } while (reader.TokenType == JsonToken.PropertyName || reader.Read());
            // don't read if current token is a property. token was already read when parsing element attributes
        }
Esempio n. 22
0
        public override IDesignModel GenerateDesignModel(IXmlElement xmlElement, DesignModelParseContext context)
        {
            var sourceDesignModelName  = xmlElement.GetStringAttributeValue("src");
            var destinationDesingModel = context.DesignModel;

            if (!(destinationDesingModel is IClassModel destinationClassDesignModel))
            {
                throw new ParseException(xmlElement.ParseLocation, $"Mapping destination model '{destinationDesingModel.FullyQualifiedName}' must be a class-like design model.");
            }

            var ns        = destinationDesingModel.Namespace;
            var classData = new ClassDerivation
            {
                Source        = _designModelCollection.CreateClassModelReference(ns, xmlElement.ParseLocation, sourceDesignModelName),
                Destination   = destinationClassDesignModel.CreateClassModelReference(xmlElement.ParseLocation),
                ParseLocation = xmlElement.ParseLocation
            };

            foreach (var attributeElement in xmlElement.GetChildElments("Attribute"))
            {
                var attributeData = new AttributeDerivation
                {
                    Source        = new ClassAttributeReference(attributeElement.GetStringAttributeValue("src"), attributeElement.ParseLocation),
                    Destination   = new ClassAttributeReference(attributeElement.GetStringAttributeValue("dest"), attributeElement.ParseLocation),
                    ParseLocation = attributeElement.ParseLocation
                };

                classData.AttributeDerivations.Add(attributeData);
            }

            foreach (var relationElement in xmlElement.GetChildElments("Relation"))
            {
                var relationData = new RelationDerivation
                {
                    Source        = new ClassRelationReference(relationElement.GetStringAttributeValue("src"), relationElement.ParseLocation),
                    Destination   = new ClassRelationReference(relationElement.GetStringAttributeValue("dest"), relationElement.ParseLocation),
                    MapAttributes = relationElement.GetBoolAttributeValue("attributes", true),
                    ParseLocation = relationElement.ParseLocation
                };

                foreach (var attributeElement in relationElement.GetChildElments("Attribute"))
                {
                    var relationAttributeData = new AttributeDerivation
                    {
                        Source        = new ClassAttributeReference(attributeElement.GetStringAttributeValue("src"), attributeElement.ParseLocation),
                        Destination   = new ClassAttributeReference(attributeElement.GetStringAttributeValue("dest"), attributeElement.ParseLocation),
                        ParseLocation = attributeElement.ParseLocation
                    };

                    relationData.AttributeDerivations.Add(relationAttributeData);
                }

                classData.RelationDerivations.Add(relationData);
            }

            destinationClassDesignModel.SetClassDerivationData(classData);

            return(null);
        }
Esempio n. 23
0
 public void Load()
 {
     if (!isLoaded)
     {
         isLoaded = true;
         this.xml = XmlElement.Parse(location);
     }
 }
        public void TestEnableReferenceConfig()
        {
            const string path   = "config/reference-pof-config.xml";
            var          ctx    = new ConfigurablePofContext(path);
            IXmlElement  config = ctx.Config;

            Assert.IsTrue(ctx.IsReferenceEnabled);
        }
 private void AddJsonArrayAttribute(IXmlElement element, IXmlDocument document)
 {
     element.SetAttributeNode(document.CreateAttribute("json:Array", "http://james.newtonking.com/projects/json", "true"));
     if (element is XElementWrapper && element.GetPrefixOfNamespace("http://james.newtonking.com/projects/json") == null)
     {
         element.SetAttributeNode(document.CreateAttribute("xmlns:json", "http://www.w3.org/2000/xmlns/", "http://james.newtonking.com/projects/json"));
     }
 }
Esempio n. 26
0
        private IXmlElement CreateElement(string elementName, IXmlDocument document, string elementPrefix, XmlNamespaceManager manager)
        {
            string ns = string.IsNullOrEmpty(elementPrefix) ? manager.DefaultNamespace : manager.LookupNamespace(elementPrefix);

            IXmlElement element = (!string.IsNullOrEmpty(ns)) ? document.CreateElement(elementName, ns) : document.CreateElement(elementName);

            return(element);
        }
Esempio n. 27
0
 /// <summary>
 /// Loads menu theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadMenu(IXmlElement element, ThemeColors colors)
 {
     this.menuHasShadow          = UIUtils.FromString(element.GetAttributeValue("hasShadow", ""), this.menuHasShadow);
     this.colorMenuPopUpBack     = colors.GetColor(element.GetAttributeValue("popUpBackColor", ""), this.colorMenuPopUpBack);
     this.menuHasPopUpBackImage  = UIUtils.FromString(element.GetAttributeValue("hasPopUpBackImage", ""), this.menuHasPopUpBackImage);
     this.menuHasIconPlaceHolder = UIUtils.FromString(element.GetAttributeValue("hasIconPlaceholderImage", ""), this.menuHasIconPlaceHolder);
     this.menuSimple             = UIUtils.FromString(element.GetAttributeValue("hasSimpleMenu", ""), this.menuSimple);
 }
 /// <summary>
 /// Writes <paramref name="element"/> to <paramref name="outputStream"/>
 /// </summary>
 /// <param name="element">The element to serialize</param>
 /// <param name="outputStream">The output stream</param>
 public static void WriteElement(IXmlElement element, Stream outputStream)
 {
     using (var writer = XmlWriter.Create(outputStream)) {
         writer.WriteStartDocument();
         WriteElement(writer, element);
         writer.WriteEndDocument();
     }
 }
Esempio n. 29
0
 public void Load()
 {
     if (!isLoaded)
     {
         isLoaded = true;
         this.xml = XmlElement.Parse(location);
     }
 }
 /// <summary>
 /// Configure the controllable service.
 /// </summary>
 /// <remarks>
 /// <p/>
 /// This method can only be called before the controllable service
 /// is started.
 /// </remarks>
 /// <param name="xml">
 /// An <see cref="IXmlElement"/> carrying configuration information
 /// specific to the IControllable object.
 /// </param>
 /// <exception cref="InvalidOperationException">
 /// Thrown if the service is already running.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown if the configuration information is invalid.
 /// </exception>
 public virtual void Configure(IXmlElement xml)
 {
     lock (this)
     {
         Debug.Assert(!IsRunning);
         DoConfigure(xml);
     }
 }
Esempio n. 31
0
        static IXmlNode CreateInlineImageNode(IXmlDocument content, string imagePath)
        {
            IXmlNode    bindingNode     = GetNode(content, "binding");
            IXmlElement imageElement    = CreateElement(content, "image");
            IXmlNode    inlineImageNode = AppendNode(bindingNode, (IXmlNode)imageElement);

            SetAttribute(inlineImageNode, "src", imagePath);
            return(inlineImageNode);
        }
Esempio n. 32
0
        public static void AddElementNameReferences(
            this BoundSourceFileBuilder binder,
            IXmlElement element,
            params ReferenceSymbol[] references)
        {
            var nameNode = element.NameNode();

            binder.AnnotateReferences(nameNode.Start, nameNode.FullWidth - nameNode.GetTrailingTriviaWidth(), references);
        }
Esempio n. 33
0
        private static void MakeDocumentAssertions(IXmlElement xhtml)
        {
            const string paragraphContent = "How stable will the West Antarctic Ice sheet be as";

            Assert.IsNotNull(xhtml);
            Assert.AreEqual(2, xhtml.Children.OfType<IComment>().Count());

            var declaration = xhtml.Children.OfType<IDeclaration>().FirstOrDefault();
            Assert.IsNotNull(declaration);
            Assert.AreEqual("UTF-8", declaration.Encoding);
            Assert.AreEqual("1.0", declaration.Version);

            var root = xhtml.Children.OfType<IElement>().FirstOrDefault();
            Assert.IsNotNull(root);
            Assert.AreEqual("html", root.Name.ToString());
            Assert.AreEqual(8, xhtml.Where<IElement>(x => x.Name.ToString() == "link").Count());
            Assert.AreEqual(277, xhtml.Where<IElement>(x => x.Name.ToString() == "div").Count());
            var p = xhtml.Where<IElement>(x => x.Name.ToString() == "p" && x.ToString().Contains(paragraphContent)).FirstOrDefault();
            Assert.IsNotNull(p);
        }
Esempio n. 34
0
        public static FieldControl CreateControl(IXmlElement parent, XElement xElem)
        {
            if (xElem == null)
            {
                log.Debug("xElem is null! parent=" + parent.ToXml());
                return null;
            }

            string typeName = xElem.Attribute("type").Value;
            if (!typeName.StartsWith("AgileEAP.EForm"))
                typeName = string.Format("AgileEAP.EForm.{0}", typeName);

            FieldControl control = null;
            try
            {
                control = Activator.CreateInstance(Type.GetType(typeName), new object[] { parent, xElem }) as FieldControl;
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }

            return control;
        }
Esempio n. 35
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="nodeName"></param>
 public XmlElement(IXmlElement parent, string nodeName)
     : this(parent, nodeName, string.Empty)
 {
 }
Esempio n. 36
0
 private void AddJsonArrayAttribute(IXmlElement element, IXmlDocument document)
 {
   element.SetAttributeNode(document.CreateAttribute("json:Array", JsonNamespaceUri, "true"));
 }
Esempio n. 37
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="nodeName"></param>
 /// <param name="xElem"></param>
 public XmlElement(IXmlElement parent, string nodeName, XElement xElem)
     : this(parent, nodeName, string.Empty, xElem)
 {
 }
Esempio n. 38
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="nodeName"></param>
 /// <param name="nodeValue"></param>
 public XmlElement(IXmlElement parent, string nodeName, string nodeValue)
     : this(parent, nodeName, nodeValue, null)
 {
 }
Esempio n. 39
0
        private void MakeArsXmlAssertions(IXmlElement xml)
        {
            #region Constants

            const int attribCount = 6;
            const int linksCount = 30;
            const int rssLinksCount = 26;
            const int rootRssLinkCount = 1;
            const int atomLinksCount = 2;
            const int commentsCount = 3;
            const int mediaCreditCount = 22;
            const int escapedCount = 365;
            const int rootNamespaceCount = 3;
            const int namespaceCount = 4;
            const string xmlBaseUri = "http://arstechnica.com/";
            const string xmlLang = "en-US";
            const int channelChildCount = 48;
            const string mediaRssNamespace = "http://search.yahoo.com/mrss/";
            const int mediaRssContentCount = 20;
            const string feedBurnerInfoUri = "arstechnica/index";
            const string dcTitleContent = "Ars Technica";

            #endregion

            Assert.IsNotNull(xml);

            foreach (var child in xml.Root.Children)
                Assert.IsNotNull(child.Parent);

            Assert.AreEqual(linksCount, xml.Root.Where<IElement>(elem => elem.Name.LocalPart == "link").Count());
            Assert.AreEqual(atomLinksCount, xml.Root.Where<IElement>(elem => elem.Name.Prefix == "atom10" && elem.Name.LocalPart == "link").Count());
            Assert.AreEqual(commentsCount, xml.Root.Where<IComment>(comment => comment != null).Count());
            Assert.AreEqual(mediaCreditCount, xml.Root.Where<IElement>(elem => elem.Name.ToString() == "media:credit").Count());
            Assert.AreEqual(escapedCount, xml.Root.Where<IEscapedSection>(esc => esc != null).Count());
            Assert.AreEqual(rootNamespaceCount, xml.Root.Namespaces.Count());
            Assert.AreEqual(namespaceCount, xml.Root.Where<INamespaceDeclaration>(ns => ns != null).DistinctBy(ns => ns.Name.ToString()).Count());
            Assert.AreEqual(attribCount, xml.Root.Attributes.Count());
            Assert.IsTrue(xml.Root.Attributes.All(attrib => attrib != null && attrib.Parent == xml.Root));
            Assert.IsNotNull(xml.Root.Attributes.Where(x => x.Name.ToString() == "xml:base").FirstOrDefault() as BaseAttribute);
            Assert.IsNotNull(xml.Root.Attributes.Where(x => x.Name.Prefix == "xmlns").FirstOrDefault() as INamespaceDeclaration);

            var xmlBaseAttrib = xml.Root.Where<IAttribute>(attrib => attrib != null && attrib.Name.ToString() == "xml:base").FirstOrDefault() as IBaseAttribute;
            Assert.IsNotNull(xmlBaseAttrib);
            Assert.IsNotNull(xmlBaseAttrib.Value);
            Assert.AreEqual(xmlBaseUri, xmlBaseAttrib.Value.ToString());

            var xmlLangAttrib = xml.Root.Where<IAttribute>(attrib => attrib != null && attrib.Name.ToString() == "xml:lang").FirstOrDefault() as ILangAttribute;
            Assert.IsNotNull(xmlLangAttrib);
            Assert.IsNotNull(xmlLangAttrib.Value);
            Assert.AreEqual(xmlLang, xmlLangAttrib.Value.ToString());

            var channelElem = xml.Root.Where<IElement>(elem => elem.Name.ToString() == "channel").FirstOrDefault();
            Assert.IsNotNull(channelElem);
            Assert.AreEqual(channelChildCount, channelElem.ChildElements.Count());
            var link = channelElem.Where<IElement>(elem => elem.Name.ToString() == "link").FirstOrDefault();
            Assert.IsNotNull(link);
            Assert.IsNotNull(link.Children.FirstOrDefault());

            var rss = xml.Root as IRssFeed;
            Assert.IsNotNull(rss);

            var channel = rss.Children.FirstOrDefault() as IRssChannel;
            Assert.IsNotNull(channel);
            Assert.IsNull(channel.CurrentNamespace);

            var links = rss.Where<IRssLink>(x => x != null);
            Assert.AreEqual(rssLinksCount, links.Count());

            var rootLinks = rss.Where<IRssLink>(x => x != null && x.Parent is IRssChannel);
            Assert.AreEqual(rootRssLinkCount, rootLinks.Count());

            var atomLinks = rss.Where<IAtomLink>(x => x != null);
            Assert.AreEqual(atomLinksCount, atomLinks.Count());

            var allLinks = rss.Where<IElement>(x => x != null && x.Name.LocalPart == "link");
            Assert.AreEqual(linksCount, allLinks.Count());

            var mediaRssContents = rss.Where<IMediaContent>(x => x != null && x.Name.LocalPart == "content");
            Assert.AreEqual(mediaRssContentCount, mediaRssContents.Count());
            Assert.IsNotNull(mediaRssContents.FirstOrDefault());
            Assert.AreEqual("image/jpeg", mediaRssContents.FirstOrDefault().MediaType);
            var firstContents = mediaRssContents.FirstOrDefault();
            Assert.IsNotNull(firstContents.CurrentNamespace);
            Assert.AreEqual(mediaRssNamespace, firstContents.CurrentNamespace.Identifier.ToString());

            var feedBurnerInfo = rss.Where<IFeedBurnerInfo>(x => x != null).FirstOrDefault();
            Assert.IsNotNull(feedBurnerInfo);
            Assert.AreEqual(feedBurnerInfoUri, feedBurnerInfo.Uri.ToString());

            var dcTitle = rss.Where<IDcTitle>(x => x != null).FirstOrDefault();
            Assert.IsNotNull(dcTitle);
            Assert.AreEqual(dcTitleContent, dcTitle.Content);
        }
Esempio n. 40
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public DatePicker(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.DatePicker;
 }
Esempio n. 41
0
File: Theme.cs Progetto: drme/thw-ui
 /// <summary>
 /// Loads settings for all controls.
 /// </summary>
 /// <param name="elements">xml file to load settings from.</param>
 private void LoadBorders(IXmlElement elements)
 {
     foreach (IXmlElement element in elements.Elements)
     {
         if ((element.Name == "border") || (element.Name == "control"))
         {
             LoadControl(element);
         }
     }
 }
Esempio n. 42
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public ChooseTree(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.ChooseTree;
 }
Esempio n. 43
0
 // Token: 0x060006E7 RID: 1767
 // RVA: 0x00009E6B File Offset: 0x0000806B
 private void AddJsonArrayAttribute(IXmlElement element, IXmlDocument document)
 {
     element.SetAttributeNode(document.CreateAttribute("json:Array", "http://james.newtonking.com/projects/json", "true"));
 }
Esempio n. 44
0
 /// <summary>
 /// Loads window theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadWindow(IXmlElement element)
 {
     this.windowHasTitleImage = UIUtils.FromString(element.GetAttributeValue("hasTitleImage", "false"), this.windowHasTitleImage);
     this.windowBorderSize = UIUtils.FromString(element.GetAttributeValue("windowBorderSize"), this.windowBorderSize);
     this.windowBorderOffset = UIUtils.FromString(element.GetAttributeValue("windowBorderOffset"), this.windowBorderOffset);
     this.windowSplitImagePosition = UIUtils.FromString(element.GetAttributeValue("windowSplitImagePosition"), this.windowSplitImagePosition);
     this.windowSplitWidth = UIUtils.FromString(element.GetAttributeValue("windowSplitWidth"), this.windowSplitWidth);
     this.windowTitleHeight = UIUtils.FromString(element.GetAttributeValue("windowTitleHeight"), this.windowTitleHeight);
     this.windowSplitPosition = UIUtils.FromString(element.GetAttributeValue("windowSplitPosition"), this.windowSplitPosition);
     this.windowShadowSize = UIUtils.FromString(element.GetAttributeValue("windowShadowSize"), this.windowShadowSize);
 }
Esempio n. 45
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public SingleCombox(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.SingleCombox;
 }
Esempio n. 46
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public MonthPicker(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.MonthPicker;
 }
Esempio n. 47
0
        private void MakeRssFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string version = "2.0";
            const string title = "Ars Technica";
            const string link = "http://arstechnica.com/index.php";
            const string description = "The Art of Technology";
            var language = LanguageTag.Parse("en");
            var lastBuildDate = new DateTime(2011, 6, 29, 18, 45, 05); //Wed, 29 Jun 2011 18:45:05 +0000
            const string generator = "http://www.sixapart.com/movabletype/";
            const string docs = "http://www.rssboard.org/rss-specification";
            const string copyright = "Copyright 2011 Conde Nast Digital. The contents of this feed are available for non-commercial use only.";
            var pubDate = new DateTime(2011, 6, 4, 9, 14, 58); //Sat, 4 Jun 2011 09:14:58 +0000
            const string managingEditor = "[email protected] (Ken Fisher)";
            const string webMaster = "[email protected] (Clint Ecker)";

            const string categoryDomain = "http://www.sixapart.com/ns/types#category";
            const string categoryName = "News";

            const string cloudDomain = "radio.xmlstoragesystem.com";
            const int cloudPort = 80;
            const string cloudPath = "/RPC2";
            const string cloudProc = "xmlStorageSystem.rssPleaseNotify";
            var cloudProcotol = RssCloudProtocol.xml_rpc;

            const int ttl = 45;

            const string imageUrl = "http://static.arstechnica.net//public/v6/styles/light/images/masthead/logo.png?1309476728";
            const string imageTitle = "Ars Technica";
            const string imageLink = "http://arstechnica.com/index.php";
            const int imageHeight = 169;
            const int imageWidth = 300;
            const string imageDescription = "The Art of Technology";

            const string ratingExcerpt = "'http://www.gcf.org/v2.5' labels";

            const string textInputTitle = "Contact Us";
            const string textInputDescription = "Email us with feedback";
            const string textInputName = "Submit";
            const string textInputLink = "http://arstechnica.com/contact-us.php";

            var skipHours = new List<Hour> { Hour.Zero, Hour.One, Hour.Two, Hour.Twelve, Hour.Thirteen, Hour.Nineteen, Hour.TwentyThree };
            var skipDays = new List<Day> { Day.Sunday, Day.Thursday, Day.Saturday };

            //const string ext1Prefix = "dc";
            //const string ext1Name = "title";
            //const string ext1Namespace = "http://purl.org/dc/elements/1.1/";

            const string item1Title = "Impressions from Uncharted 3: Drake's Deception's open beta ";
            const string item1Author = "[email protected] (Josh McIllwain)";
            //const string item1MediaContentUrl = "http://static.arstechnica.net/assets/2011/06/uncharted-3-thumb-300x169-23017-f.jpg";
            const string item1Guid = "http://arstechnica.com/gaming/news/2011/06/impressions-from-uncharted-3-drakes-deceptions-open-beta.ars?utm_source=rss&utm_medium=rss&utm_campaign=rss";
            var item1PubDate = new DateTime(2011, 6, 29, 16, 47, 00); //Wed, 29 Jun 2011 11:47:00 -0500

            #endregion

            var feed = document.Root as IRssFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Channel);
            Assert.AreEqual(version, feed.Version);
            Assert.AreEqual(2, document.Where<IStyleSheet>(x => x != null).Count());
            Assert.AreEqual(3, feed.Namespaces.Count());

            Assert.AreEqual(title, feed.Channel.Title);
            Assert.AreEqual(link, feed.Channel.Link.ToString());
            Assert.AreEqual(description, feed.Channel.Description);
            Assert.AreEqual(language.PrimaryLanguage, feed.Channel.Language.PrimaryLanguage);
            Assert.AreEqual(lastBuildDate, feed.Channel.LastBuildDate);
            Assert.AreEqual(generator, feed.Channel.Generator);
            Assert.AreEqual(docs, feed.Channel.Docs.ToString());
            Assert.AreEqual(copyright, feed.Channel.Copyright);
            Assert.AreEqual(pubDate, feed.Channel.PubDate);
            Assert.AreEqual(managingEditor, feed.Channel.ManagingEditor);
            Assert.AreEqual(webMaster, feed.Channel.WebMaster);
            Assert.IsNotNull(feed.Channel.Cloud);
            Assert.AreEqual(cloudDomain, feed.Channel.Cloud.Domain);
            Assert.AreEqual(cloudPort, feed.Channel.Cloud.Port);
            Assert.AreEqual(cloudPath, feed.Channel.Cloud.Path);
            Assert.AreEqual(cloudProc, feed.Channel.Cloud.RegisterProcedure);
            Assert.AreEqual(cloudProcotol, feed.Channel.Cloud.Protocol);
            Assert.AreEqual(ttl, feed.Channel.Ttl.TotalMinutes);
            Assert.IsNotNull(feed.Channel.Image);
            Assert.AreEqual(imageUrl, feed.Channel.Image.Url.ToString());
            Assert.AreEqual(imageTitle, feed.Channel.Image.Title);
            Assert.AreEqual(imageLink, feed.Channel.Image.Link.ToString());
            Assert.AreEqual(imageHeight, feed.Channel.Image.Height);
            Assert.AreEqual(imageWidth, feed.Channel.Image.Width);
            Assert.AreEqual(imageDescription, feed.Channel.Image.Description);
            Assert.IsNotNull(feed.Channel.Rating);
            Assert.IsTrue(feed.Channel.Rating.Contains(ratingExcerpt));
            Assert.IsNotNull(feed.Channel.TextInput);
            Assert.AreEqual(textInputTitle, feed.Channel.TextInput.Title);
            Assert.AreEqual(textInputDescription, feed.Channel.TextInput.Description);
            Assert.AreEqual(textInputName, feed.Channel.TextInput.InputName);
            Assert.AreEqual(textInputLink, feed.Channel.TextInput.Link.ToString());
            Assert.IsTrue(skipHours.SequenceEqual(feed.Channel.SkipHours.Hours.Select(x => x.Value)));
            Assert.IsTrue(skipDays.SequenceEqual(feed.Channel.SkipDays.Days.Select(x => x.Value)));
            Assert.AreEqual(1, feed.Channel.Categories.Count());
            Assert.AreEqual(categoryDomain, feed.Channel.Categories.First().Domain.ToString());
            Assert.AreEqual(categoryName, feed.Channel.Categories.First().CategoryName);
            //Assert.AreEqual(4, feed.Channel.Extensions.Count());
            //Assert.AreEqual(ext1Name, feed.Channel.Extensions.First().Name);
            //Assert.AreEqual(ext1Prefix, feed.Channel.Extensions.First().Prefix);
            //Assert.IsNotNull(feed.Channel.Extensions.First().PrimaryNamespace);
            Assert.AreEqual(25, feed.Channel.Items.Count());
            var firstItem = feed.Channel.Items.First();
            Assert.IsNotNull(firstItem);
            Assert.AreEqual(item1Title, firstItem.Title);
            Assert.AreEqual(item1Author, firstItem.Author);
            Assert.IsNotNull(firstItem.Guid);
            Assert.AreEqual(item1Guid, firstItem.Guid.Value);
            Assert.IsFalse(firstItem.Guid.IsPermaLink);
            Assert.AreEqual(item1PubDate, firstItem.PubDate);
            Assert.AreEqual(5, firstItem.Categories.Count());
            //var firstMediaContentExt = firstItem.Extensions.Where(x => x.Prefix == "media" && x.Name == "content").FirstOrDefault();
            //Assert.IsNotNull(firstMediaContentExt);
            //Assert.IsTrue(firstMediaContentExt.ToString().Contains(item1MediaContentUrl));
            var lastItem = feed.Channel.Items.Last();
            Assert.IsNotNull(lastItem);
        }
        private string ProcessXmlElementName(ClassifiedRange range, string text, bool isRootProject, IXmlElement element)
        {
            if (element.Name == "UsingTask")
            {
                var taskName = element.Attributes.FirstOrDefault(a => a.Key == "TaskName").Value;
                if (taskName != null)
                {
                    int lastDot = taskName.LastIndexOf(".");
                    if (lastDot > -1)
                    {
                        taskName = taskName.Substring(lastDot + 1);
                    }

                    return ProcessTaskName(
                        range.LineText,
                        range.LineNumber + 1,
                        range.Column,
                        text,
                        taskName,
                        isRootProject,
                        isUsage: false);
                }
            }

            var parentElement = element.Parent;
            if (parentElement != null)
            {
                if (parentElement.Name == "PropertyGroup")
                {
                    return ProcessPropertyName(
                        range.LineText,
                        range.LineNumber + 1,
                        range.Column,
                        text,
                        isRootProject,
                        isUsage: false);
                }
                else if (parentElement.Name == "ItemGroup" && !ExcludeItem(element.Name))
                {
                    return ProcessItemName(
                        range.LineText,
                        range.LineNumber + 1,
                        range.Column,
                        text,
                        isRootProject,
                        isUsage: false);
                }
                else if (parentElement.Name == "Target" && element.Name != "ItemGroup" && element.Name != "PropertyGroup")
                {
                    return ProcessTaskName(
                        range.LineText,
                        range.LineNumber + 1,
                        range.Column,
                        text,
                        text.Trim(),
                        isRootProject,
                        isUsage: true);
                }
            }

            return text;
        }
Esempio n. 49
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="nodeName"></param>
        /// <param name="nodeValue"></param>
        /// <param name="xElem"></param>
        public XmlElement(IXmlElement parent, string nodeName, string nodeValue, XElement xElem)
        {
            Parent = parent;
            ElementName = nodeName;
            ElementValue = nodeValue;

            Attibutes = new Dictionary<string, object>();

            if (xElem == null)
            {
                log.Warn("field xElem is null");
                return;
            }

            Current = (xElem.Name.LocalName == nodeName) ? xElem : xElem.Element(nodeName) ?? xElem.Descendants(nodeName).FirstOrDefault();
            Initilize(Current);
        }
Esempio n. 50
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads control settings from xml file.
        /// </summary>
        /// <param name="element">xml file to load from.</param>
        private void LoadControl(IXmlElement element)
        {
            String controlName = element.GetAttributeValue("control", "");

            if (controlName.Length <= 0)
            {
                return;
            }

            ControlSettings controlSettings = new ControlSettings();

            controlSettings.Name = controlName;
            controlSettings.ColorBack = this.Colors.GetColor(element.GetAttributeValue("backColor", ""), Colors.Control);
            controlSettings.ColorBorderLight1 = this.Colors.GetColor(element.GetAttributeValue("borderLight1", ""), Colors.ControlLight);
            controlSettings.ColorBorderLight2 = this.Colors.GetColor(element.GetAttributeValue("borderLight2", ""), Colors.Control);
            controlSettings.ColorBorderDark1 = this.Colors.GetColor(element.GetAttributeValue("borderDark1", ""), Colors.ControlDark);
            controlSettings.ColorBorderDark2 = this.Colors.GetColor(element.GetAttributeValue("borderDark2", ""), Colors.ControlDarkDark);
            controlSettings.BordersFilePrefix = element.GetAttributeValue("imagesPrefix", "images/control_");
            controlSettings.Skinned = UIUtils.FromString(element.GetAttributeValue("skinned", ""), this.skinned);
            controlSettings.BorderWidth = UIUtils.FromString(element.GetAttributeValue("borderWidth", null), 2);
            controlSettings.BackImage = element.GetAttributeValue("backImage", "");
            controlSettings.ControlSize = UIUtils.FromString(element.GetAttributeValue("controlSize", null), controlSettings.ControlSize);

            this.controlsSettings[controlName] = controlSettings;
        }
Esempio n. 51
0
 /// <summary>
 /// Loads menu theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadMenu(IXmlElement element, ThemeColors colors)
 {
     this.menuHasShadow = UIUtils.FromString(element.GetAttributeValue("hasShadow", ""), this.menuHasShadow);
     this.colorMenuPopUpBack = colors.GetColor(element.GetAttributeValue("popUpBackColor", ""), this.colorMenuPopUpBack);
     this.menuHasPopUpBackImage = UIUtils.FromString(element.GetAttributeValue("hasPopUpBackImage", ""), this.menuHasPopUpBackImage);
     this.menuHasIconPlaceHolder = UIUtils.FromString(element.GetAttributeValue("hasIconPlaceholderImage", ""), this.menuHasIconPlaceHolder);
     this.menuSimple = UIUtils.FromString(element.GetAttributeValue("hasSimpleMenu", ""), this.menuSimple);
 }
Esempio n. 52
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public MultiCombox(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.MultiCombox;
 }
Esempio n. 53
0
 /// <summary>
 /// Loads theme colro values from theme xml file.
 /// </summary>
 /// <param name="element">colors xml element.</param>
 internal void LoadColors(IXmlElement element)
 {
     this.ControlLight.UpdateColor(element.GetAttributeValue("ControlLight", ""), this);
     this.ControlDark.UpdateColor(element.GetAttributeValue("ControlDark", ""), this);
     this.ControlDarkDark.UpdateColor(element.GetAttributeValue("ControlDarkDark", ""), this);
     this.Control.UpdateColor(element.GetAttributeValue("Control", ""), this);
     this.Highlight.UpdateColor(element.GetAttributeValue("Highlight", ""), this);
     this.HighlightBorder.UpdateColor(element.GetAttributeValue("HighlightBorder", ""), this);
     this.TextDark.UpdateColor(element.GetAttributeValue("TextDark", ""), this);
     this.TextLight.UpdateColor(element.GetAttributeValue("TextLight", ""), this);
     this.BackLight.UpdateColor(element.GetAttributeValue("BackLight", ""), this);
     this.BackBorder.UpdateColor(element.GetAttributeValue("BackBorder", ""), this);
     this.BackLightLight.UpdateColor(element.GetAttributeValue("BackLightLight", ""), this);
     this.BorderDark.UpdateColor(element.GetAttributeValue("BorderDark", ""), this);
     this.WindowTitleStart.UpdateColor(element.GetAttributeValue("WindowTitleStart", ""), this);
     this.WindowTitleEnd.UpdateColor(element.GetAttributeValue("WindowTitleEnd", ""), this);
     this.Window.UpdateColor(element.GetAttributeValue("Window", ""), this);
 }
Esempio n. 54
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="xml">字符串参数</param>
 /// <param name="isXmlFile">是否是xml文件</param>
 public TextBox(IXmlElement parent, XElement xElem)
     : base(parent, xElem)
 {
     ControlType = ControlType.TextBox;
 }
Esempio n. 55
0
        private void MakeAtomFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string authorName = "David";
            const string authorUri = "http://www.blogger.com/profile/06751101786776663258";
            const string authorEmail = "*****@*****.**";
            const string cat1Term = "Blogs/News";
            const string cat1Scheme = "http://example.com/schemes/categories";
            const string cat1Label = "<Blogs & News>";
            const string contribName = "Bob Lawbla";
            const string contribUri = "http://www.blogger.com/profile/06751101786776661148";
            const string contribEmail = "*****@*****.**";
            const string genUri = "http://www.blogger.com/";
            const string genName = "Blogger";
            const string iconUri = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_1.png";
            const string id = "tag:blogger.com,1999:blog-8677504";
            const string link1Rel = "http://schemas.google.com/g/2005#feed";
            var link1Type = "application/atom+xml";
            const string logoUri = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_2.png";
            var feedLang = LanguageTag.Parse("en-GB");
            const string rightsBaseId = "http://example.co.uk/license";
            var rightsLang = LanguageTag.Parse("en-GB");
            var rightsType = AtomTextType.xhtml;
            //var rightsText = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";
            //var rightsTextEscaped = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";
            
            //"<xhtml:div>Oy Guv'na, no rights! <xhtml:em> &lt; </xhtml:em></xhtml:div>";
            //"Oy, Guv'nor you ain't got NO right'a be readin' 'is!";
            const string subtitle = "Qué barbaridad!";
            var subtitleLang = LanguageTag.Parse("es-MX");
            const string title = "A Bear Librarians's Cave";
            var titleType = AtomTextType.text;
            var updated = new DateTime(2011, 6, 21, 9, 21, 56, 27); //2011-06-21T02:21:56.027-07:00
            //const string lastExtPrefix = "openSearch";
            //const string lastExtName = "itemsPerPage";
            //const string lastExtContent = ">25</";

            const string entryAuthorEmail = "*****@*****.**";
            //const string entryAuthorExtPrefix = "gd";
            //const string entryAuthorExtName = "extendedProperty";
            //const string entryAuthorExtContent = "<gd:extendedProperty xmlns:gd=\"http://schemas.google.com/g/2005\" name=\"OpenSocialUserId\" value=\"12777363245656199557\" />";
            const string entryCategoryTerm = "Comedy";
            const string entryContentText = "Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I&apos;m typing this entry as one of my classes is taking a test.  I&apos;m working full-time as a librarian and teaching three classes in the evening.  It&apos;s still fun to teach, but it&apos;s also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!&lt;br /&gt;&lt;br /&gt;Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don&apos;t necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I&apos;ve started.  However, if I keep getting crappy emails from people at work, I&apos;m going to have to get going!  It rarely happens, and honestly this is really the first time I&apos;ve ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn&apos;t hear about it for 6 months.  Now I&apos;ve got someone complaining that I didn&apos;t get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it&apos;s not like I&apos;m one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I&apos;m trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don&apos;t even have an OPAC!  I&apos;m just trying to make things better and all I get is, sorry, but your little library project isn&apos;t worthwhile, now go back and shelve some books.  I think that&apos;s the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don&apos;t get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.&lt;br /&gt;&lt;br /&gt;That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can&apos;t help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.&lt;br /&gt;&lt;br /&gt;Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don&apos;t want to come to class, it&apos;s bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I&apos;m not a bloody kindergarden teacher.  Maybe I&apos;ll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .&lt;br /&gt;&lt;br /&gt;Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I&apos;m that negative.  I really am just a positive person having a bad day!!!!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&apos;1&apos; height=&apos;1&apos; src=&apos;https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com&apos; alt=&apos;&apos; /&gt;&lt;/div&gt;";
            //"Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I'm typing this entry as one of my classes is taking a test.  I'm working full-time as a librarian and teaching three classes in the evening.  It's still fun to teach, but it's also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!<br /><br />Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don't necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I've started.  However, if I keep getting crappy emails from people at work, I'm going to have to get going!  It rarely happens, and honestly this is really the first time I've ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn't hear about it for 6 months.  Now I've got someone complaining that I didn't get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it's not like I'm one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I'm trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don't even have an OPAC!  I'm just trying to make things better and all I get is, sorry, but your little library project isn't worthwhile, now go back and shelve some books.  I think that's the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don't get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.<br /><br />That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can't help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.<br /><br />Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don't want to come to class, it's bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I'm not a bloody kindergarden teacher.  Maybe I'll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .<br /><br />Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I'm that negative.  I really am just a positive person having a bad day!!!!<div class=\"blogger-post-footer\"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com' alt='' /></div>";
            var entryContentType = AtomTextType.html;
            const string entryContrib3Name = "Curly";
            const string entryId = "tag:blogger.com,1999:blog-8677504.post-112778942212704032";
            const string entryLink5Rel = "alternate";
            const string entryLink5Href = "http://bearbrarian.blogspot.com/2005/09/ways-down-road.html";
            var entryLink5MediaType = "text/html";
            const string entryLink5Title = "A ways down the road...";
            var entryLink5HrefLang = LanguageTag.Parse("en-US");
            var entryPublished = new DateTime(2005, 9, 27, 2, 31, 0); //2005-09-26T19:31:00.000-07:00
            const string entryRights = "You have the right to remain silent.";

            const string entrySourceTitleText = "\r\n        <b xmlns=\"http://www.w3.org/2005/Atom\">The original article</b>";
            var entrySourceTitleType = AtomTextType.html;
            const string entrySummary = "road, what road?";
            const string entryTitle = "A ways down the road";
            var entryUpdated = new DateTime(2005, 9, 27, 2, 50, 22, 140); //2005-09-26T19:50:22.140-07:00
            //var entryExtension1Prefix = "thr";
            //var entryExtension1Name = "total";

            #endregion

            var feed = document.Root as IAtomFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Lang);

            Assert.AreEqual(feedLang.PrimaryLanguage, feed.Lang.PrimaryLanguage);
            Assert.AreEqual(feedLang.Country, feed.Lang.Country);
            Assert.AreEqual(4, feed.Namespaces.Count());
            Assert.IsNotNull(feed.Namespaces.Last());
            Assert.AreEqual(1, document.Where<IStyleSheet>(x => x != null).Count());
            Assert.IsNotNull(document.Where<IStyleSheet>(x => x != null).FirstOrDefault());

            Assert.AreEqual(1, feed.Authors.Count());
            Assert.AreEqual(authorName, feed.Authors.First().PersonName);
            Assert.AreEqual(authorUri, feed.Authors.First().Uri.ToString());
            Assert.AreEqual(authorEmail, feed.Authors.First().Email);

            Assert.AreEqual(2, feed.Categories.Count());
            Assert.IsNotNull(feed.Categories.First());
            Assert.AreEqual(cat1Term, feed.Categories.First().Term);
            Assert.AreEqual(cat1Scheme, feed.Categories.First().Scheme.ToString());
            Assert.AreEqual(cat1Label, feed.Categories.First().Label);

            Assert.AreEqual(2, feed.Contributors.Count());
            Assert.AreEqual(contribName, feed.Contributors.First().PersonName);
            Assert.AreEqual(contribUri, feed.Contributors.First().Uri.ToString());
            Assert.AreEqual(contribEmail, feed.Contributors.First().Email);

            Assert.IsNotNull(feed.Generator);
            Assert.AreEqual(genUri, feed.Generator.Uri.ToString());
            Assert.AreEqual(genName, feed.Generator.GeneratorName);

            Assert.IsNotNull(feed.Icon);
            Assert.AreEqual(iconUri, feed.Icon.Uri.ToString());

            Assert.IsNotNull(feed.Id);
            Assert.AreEqual(id, feed.Id.Content.ToString());

            Assert.AreEqual(4, feed.Links.Count());
            Assert.AreEqual(link1Rel, feed.Links.First().Rel);
            Assert.AreEqual(link1Type, feed.Links.First().MediaType);

            Assert.IsNotNull(feed.Logo);
            Assert.AreEqual(logoUri, feed.Logo.Uri.ToString());

            Assert.IsNotNull(feed.Rights);
            Assert.AreEqual(rightsBaseId, feed.Rights.BaseId.ToString());
            Assert.AreEqual(rightsLang, feed.Rights.Lang);
            Assert.AreEqual(rightsType, feed.Rights.Type);
            //Assert.AreEqual(rightsText, feed.Rights.Text);            

            Assert.IsNotNull(feed.Subtitle);
            Assert.AreEqual(subtitle, feed.Subtitle.Text);
            Assert.AreEqual(subtitleLang, feed.Subtitle.Lang);

            Assert.IsNotNull(feed.Title);
            Assert.AreEqual(title, feed.Title.Text);
            Assert.AreEqual(titleType, feed.Title.Type);

            Assert.IsNotNull(feed.Updated);
            Assert.AreEqual(updated, feed.Updated.Date);

            //Assert.AreEqual(3, feed.Extensions.Count());
            //Assert.AreEqual(lastExtPrefix, feed.Extensions.Last().Prefix);
            //Assert.AreEqual(lastExtName, feed.Extensions.Last().Name);
            //Assert.IsTrue(feed.Extensions.Last().ToString().Contains(lastExtContent));

            Assert.AreEqual(6, feed.Entries.Count());
            Assert.IsNotNull(feed.Entries.First());

            Assert.AreEqual(1, feed.Entries.First().Authors.Count());
            Assert.AreEqual(entryAuthorEmail, feed.Entries.First().Authors.First().Email);
            //Assert.AreEqual(1, feed.Entries.First().Authors.First().Extensions.Count());
            //Assert.AreEqual(entryAuthorExtPrefix, feed.Entries.First().Authors.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryAuthorExtName, feed.Entries.First().Authors.First().Extensions.First().Name);
            //Assert.AreEqual(entryAuthorExtContent, feed.Entries.First().Authors.First().Extensions.First().ToString());

            Assert.AreEqual(1, feed.Entries.First().Categories.Count());
            Assert.AreEqual(entryCategoryTerm, feed.Entries.First().Categories.First().Term);

            Assert.IsNotNull(feed.Entries.First().Content);
            Assert.AreEqual(entryContentText, feed.Entries.First().Content.Text);
            Assert.AreEqual(entryContentType, feed.Entries.First().Content.Type);

            Assert.AreEqual(3, feed.Entries.First().Contributors.Count());
            Assert.AreEqual(entryContrib3Name, feed.Entries.First().Contributors.Last().PersonName);

            Assert.IsNotNull(feed.Entries.First().Id);
            Assert.AreEqual(entryId, feed.Entries.First().Id.Content.ToString());

            Assert.AreEqual(5, feed.Entries.First().Links.Count());
            Assert.AreEqual(entryLink5Href, feed.Entries.First().Links.Last().Href.ToString());
            Assert.AreEqual(entryLink5HrefLang, feed.Entries.First().Links.Last().HrefLang);
            Assert.AreEqual(entryLink5MediaType, feed.Entries.First().Links.Last().MediaType);
            Assert.AreEqual(entryLink5Title, feed.Entries.First().Links.Last().Title);
            Assert.AreEqual(entryLink5Rel, feed.Entries.First().Links.Last().Rel);

            Assert.IsNotNull(feed.Entries.First().Published);
            Assert.AreEqual(entryPublished, feed.Entries.First().Published.Date);

            Assert.IsNotNull(feed.Entries.First().Rights);
            Assert.AreEqual(entryRights, feed.Entries.First().Rights.Text);

            Assert.IsNotNull(feed.Entries.First().Source);
            Assert.IsNotNull(feed.Entries.First().Source.Title);
            Assert.AreEqual(entrySourceTitleText, feed.Entries.First().Source.Title.Text);
            Assert.AreEqual(entrySourceTitleType, feed.Entries.First().Source.Title.Type);

            Assert.IsNotNull(feed.Entries.First().Summary);
            Assert.AreEqual(entrySummary, feed.Entries.First().Summary.Text);

            Assert.IsNotNull(feed.Entries.First().Title);
            Assert.AreEqual(entryTitle, feed.Entries.First().Title.Text);

            Assert.IsNotNull(feed.Entries.First().Updated);
            Assert.AreEqual(entryUpdated, feed.Entries.First().Updated.Date);

            //Assert.AreEqual(1, feed.Entries.First().Extensions.Count());
            //Assert.AreEqual(entryExtension1Prefix, feed.Entries.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryExtension1Name, feed.Entries.First().Extensions.First().Name);
        }
Esempio n. 56
0
    private void AddJsonArrayAttribute(IXmlElement element, IXmlDocument document)
    {
      element.SetAttributeNode(document.CreateAttribute("json:Array", JsonNamespaceUri, "true"));

#if !NET20
      // linq to xml doesn't automatically include prefixes via the namespace manager
      if (element is XElementWrapper)
      {
        if (element.GetPrefixOfNamespace(JsonNamespaceUri) == null)
        {
          element.SetAttributeNode(document.CreateAttribute("xmlns:json", "http://www.w3.org/2000/xmlns/", JsonNamespaceUri));
        }
      }
#endif
    }
Esempio n. 57
0
        private void MakeAtomXmlAssertions(IXmlElement xml)
        {
            const string atomNamespace = "http://www.w3.org/2005/Atom";
            const string openSearchNamespace = "http://a9.com/-/spec/opensearchrss/1.0/";

            Assert.IsNotNull(xml);
            var feed = xml.Where<IElement>(x => x.Name.LocalPart == "feed").FirstOrDefault();
            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.CurrentNamespace);
            Assert.AreEqual(atomNamespace, feed.CurrentNamespace.Identifier.ToString());
            var totalResults = feed.Where<IOpenSearchTotalResults>(x => true);
            Assert.AreEqual(2, totalResults.Count());
            Assert.IsTrue(totalResults.All(x => x.CurrentNamespace != null && x.CurrentNamespace.Identifier.ToString() == openSearchNamespace && x.Content > 0));
        }