Exemplo n.º 1
0
        protected override void Parse(System.Xml.XmlDocument doc)
        {
            GenerationContext.NamespaceManager = XmlUtils.BuildNamespaceManager(doc, "http://www.workshare.com/docxmapping");
            XmlElement rootNode = doc.SelectSingleNode("/x:DocxMappingDefinition", GenerationContext.NamespaceManager) as XmlElement;
            GenerationContext.DocObjectsSourceLocation = XmlUtils.GetOptionalAttribute(rootNode, "DocObjectsSourceLocation");
            GenerationContext.TargetSourceProject = XmlUtils.GetOptionalAttribute(rootNode, "TargetSourceProject");
            GenerationContext.TargetNamespace = XmlUtils.GetOptionalAttribute(rootNode, "TargetNamespace");
            GenerationContext.LoadSchema(rootNode.Attributes["SchemaPath"].Value);

            ParseNamespacePrefixes(rootNode);

            projUpdater = new CSProjUpdater(GenerationContext.TargetSourceProject);

            foreach (XmlNode xn in doc.SelectNodes("/x:DocxMappingDefinition/x:NodeToSimpleContentTypeMapping", GenerationContext.NamespaceManager))
            {
                NodeHandlerDefinition newnh = new NodeHandlerDefinition(xn as XmlElement);
                m_nodeHandlers.Add(newnh);
                projUpdater.AddFile(newnh.GetOutputFileName());
            }

            foreach (XmlNode xn in doc.SelectNodes("/x:DocxMappingDefinition/x:NodeToTypeMapping", GenerationContext.NamespaceManager))
            {
                NodeHandlerDefinition newnh = new NodeHandlerDefinition(xn as XmlElement);
                m_nodeHandlers.Add(newnh);
                projUpdater.AddFile(newnh.GetOutputFileName());
            }

        }
Exemplo n.º 2
0
        public void SetSection(System.Xml.XmlNode nodSection)
        {
            System.Xml.XmlNodeList lstHTML;
            System.Xml.XmlNodeList lstTitle;
            bool bolShowTitle;

            if (nodSection.Attributes["hastitle"] == null)
            {
                bolShowTitle = true;

            }
            else
            {
                bolShowTitle = Convert.ToBoolean(nodSection.Attributes["hastitle"].Value);
            }

            if (bolShowTitle)
            {
                lstTitle = nodSection.SelectNodes("title");

                lblTitle.Text = lstTitle[0].InnerText;
            }
            else
            {
                trTitleRow.Visible = false;
                trSep.Visible = false;
            }

            lstHTML = nodSection.SelectNodes("html");

            spnContent.InnerHtml = lstHTML[0].InnerText.Replace("src=\"", "src=\"" + System.Configuration.ConfigurationManager.AppSettings["MarketPlaceImagePrefix"]);
        }
Exemplo n.º 3
0
        internal static FolderDatasetList Parse(Server oServer, string strKey, int iTimestamp, System.Xml.XmlDocument oCatalog, out string strEdition)
        {
            strEdition = string.Empty;
             ArrayList oList = new ArrayList();

             // --- get the catalog edition ---

             System.Xml.XmlNodeList oNodeList = oCatalog.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.CONFIGURATION_TAG);
             if (oNodeList != null && oNodeList.Count != 0)
             {
            System.Xml.XmlNode oAttr = oNodeList[0].Attributes.GetNamedItem(Geosoft.Dap.Xml.Common.Constant.Attribute.VERSION_ATTR);
            if (oAttr != null)
               strEdition = oAttr.Value;
             }

             oNodeList = oCatalog.SelectNodes("//" + Geosoft.Dap.Xml.Common.Constant.Tag.ITEM_TAG);
             if (oNodeList != null)
             {
            foreach (System.Xml.XmlElement oDatasetNode in oNodeList)
            {
               Geosoft.Dap.Common.DataSet oDataSet;
               oServer.Command.Parser.DataSet(oDatasetNode, out oDataSet);
               oList.Add(oDataSet);
            }
             }
             return new FolderDatasetList(strKey, iTimestamp, oList);
        }
        public void Upgrade(string projectPath, string userSettingsPath, ref System.Xml.XmlDocument projectDocument, ref System.Xml.XmlDocument userSettingsDocument, ref System.Xml.XmlNamespaceManager nsm)
        {
            //Add DataTypeReferencedTableMappingSchemaName to each Parameter.
            foreach (XmlAttribute node in projectDocument.SelectNodes("//*/@DataTypeReferencedTableMappingName", nsm))
            {
                XmlAttribute tableSchemaName = (XmlAttribute)node.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm);
                XmlAttribute dataTypeReferencedTableMappingSchemaName = projectDocument.CreateAttribute("DataTypeReferencedTableMappingSchemaName");

                dataTypeReferencedTableMappingSchemaName.Value = tableSchemaName.Value;

                node.OwnerElement.Attributes.Append(dataTypeReferencedTableMappingSchemaName);
            }

            //Add ParentTableMappingSchemaName and ReferencedTableMappingSchemaName to each Foreign Key Mapping.
            foreach (XmlElement node in projectDocument.SelectNodes("//P:ForeignKeyMapping", nsm))
            {
                XmlAttribute parentTableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ParentTableMappingName")), nsm);
                XmlAttribute referencedTableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.GetAttribute("ReferencedTableMappingName")), nsm);
                XmlAttribute parentTableMappingSchemaName = projectDocument.CreateAttribute("ParentTableMappingSchemaName");
                XmlAttribute referencedTableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName");

                parentTableMappingSchemaName.Value = parentTableSchemaName.Value;
                referencedTableMappingSchemaName.Value = referencedTableSchemaName.Value;

                node.Attributes.Append(parentTableMappingSchemaName);
                node.Attributes.Append(referencedTableMappingSchemaName);
            }

            //Add ReferencedTableMappingSchemaName to each Enumeration Mapping.
            //Rename ReferencedTableName to ReferencedTableMappingName for each Enumeration Mapping
            foreach (XmlAttribute node in projectDocument.SelectNodes("//P:EnumerationMapping/@ReferencedTableName", nsm))
            {
                XmlAttribute tableSchemaName = (XmlAttribute)projectDocument.SelectSingleNode("//P:TableMapping[@TableName='{0}']/@SchemaName".FormatString(node.Value), nsm);
                XmlAttribute tableMappingSchemaName = projectDocument.CreateAttribute("ReferencedTableMappingSchemaName");
                XmlAttribute tableMappingName = projectDocument.CreateAttribute("ReferencedTableMappingName");

                tableMappingSchemaName.Value = tableSchemaName.Value;
                tableMappingName.Value = node.Value;

                node.OwnerElement.Attributes.Append(tableMappingSchemaName);
                node.OwnerElement.Attributes.Append(tableMappingName);
                node.OwnerElement.Attributes.Remove(node);
            }

            //Remove Template.Name attribute.
            foreach (XmlAttribute node in projectDocument.SelectNodes("//P:Template/@Name", nsm))
                node.OwnerElement.Attributes.Remove(node);
        }
        /// <summary>
        /// 实现IConfigurationSectionHandler接口Create方法
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="configContext"></param>
        /// <param name="section"></param>
        /// <returns></returns>
        public object Create(Object parent, Object configContext, System.Xml.XmlNode section)
        {
            Permission P_Mission = new Permission();
            XmlNode AppNode = section.SelectSingleNode("ApplicationID");
            P_Mission.ApplicationID = Convert.ToInt32(AppNode.InnerText);
            P_Mission.ApplicationName = AppNode.Attributes["name"].Value;
            AppNode = section.SelectSingleNode("PageCode");
            P_Mission.PageCode = AppNode.InnerText;
            P_Mission.PageCodeName = AppNode.Attributes["name"].Value;

            List<string> Files = Common.GetDirFileList("aspx");
            XmlNodeList ItemNodes = section.SelectNodes("Item");
            foreach (XmlNode Node in ItemNodes)
            {
                PermissionItem Item = new PermissionItem();
                Item.Item_Name = Node.Attributes["name"].Value;
                Item.Item_Value = Convert.ToInt32(Node.Attributes["value"].Value);
                Item.Item_FileList = Node.InnerText.ToLower();               
                P_Mission.ItemList.Add(Item);
                if (Item.Item_FileList.Trim() != "")
                {
                    RemoveFile(Files, Item.Item_FileList.Trim());
                }                
            }
            UpdatePermissionConfig(P_Mission, Files);
            
            return P_Mission;
        }
Exemplo n.º 6
0
 public static MapInfoDocument Parse(System.Xml.XmlDocument xmldoc, System.Xml.XmlNamespaceManager NameSpaceManager)
 {
     MapInfoDocument doc = new MapInfoDocument();
     doc.map = new CT_MapInfo();
     doc.map.Map = new System.Collections.Generic.List<CT_Map>();
     foreach (XmlElement mapNode in xmldoc.SelectNodes("d:MapInfo/d:Map", NameSpaceManager))
     { 
         CT_Map ctMap=new CT_Map();
         ctMap.ID = XmlHelper.ReadUInt(mapNode.GetAttributeNode("ID"));
         ctMap.Name = XmlHelper.ReadString(mapNode.GetAttributeNode("Name"));
         ctMap.RootElement = XmlHelper.ReadString(mapNode.GetAttributeNode("RootElement"));
         ctMap.SchemaID = XmlHelper.ReadString(mapNode.GetAttributeNode("SchemaID"));
         ctMap.ShowImportExportValidationErrors = XmlHelper.ReadBool(mapNode.GetAttributeNode("ShowImportExportValidationErrors"));
         ctMap.PreserveFormat = XmlHelper.ReadBool(mapNode.GetAttributeNode("PreserveFormat"));
         ctMap.PreserveSortAFLayout = XmlHelper.ReadBool(mapNode.GetAttributeNode("PreserveSortAFLayout"));
         ctMap.Append = XmlHelper.ReadBool(mapNode.GetAttributeNode("Append"));
         ctMap.AutoFit = XmlHelper.ReadBool(mapNode.GetAttributeNode("AutoFit"));
         doc.map.Map.Add(ctMap);
     }
     doc.map.Schema = new System.Collections.Generic.List<CT_Schema>();
     foreach (XmlNode schemaNode in xmldoc.SelectNodes("d:MapInfo/d:Schema", NameSpaceManager))
     {
         CT_Schema ctSchema = new CT_Schema();
         ctSchema.ID = schemaNode.Attributes["ID"].Value;
         if (schemaNode.Attributes["Namespace"] != null)
             ctSchema.Namespace = schemaNode.Attributes["Namespace"].Value;
         if (schemaNode.Attributes["SchemaRef"] != null)
             ctSchema.SchemaRef = schemaNode.Attributes["SchemaRef"].Value;
         ctSchema.InnerXml = schemaNode.InnerXml;
         doc.map.Schema.Add(ctSchema);
     }
     return doc;
 }
Exemplo n.º 7
0
        public void Load(System.Xml.XmlNode element)
        {
            this.Name = element.Attributes["Name"].Value;

            XmlNodeList nodes = element.SelectNodes("Columns");
            if (nodes.Count == 1)
            {
                foreach(XmlNode node in nodes[0].ChildNodes)
                {
                    if (node.Name == "Column")
                    {
                        Column tmpCol = new Column(node.Attributes["Name"].Value, node.Attributes["Type"].Value);
                        tmpCol.Load(node);
                        Columns.Add(tmpCol);
                    }
                }
            }

            /*while (txR.Read())
            {
                switch (txR.Name)
                {
                    case "Columns":
                        {
                            // Load columns
                            XmlTextReader columnReader = txR.ReadSubtree();
                            while(columnReader.Read())
                            {
                                if (columnReader.Name == "Column")
                                {
                                    Column tmpCol = new Column(columnReader.GetAttribute("Name"), columnReader.GetAttribute("Type"));
                                    tmpCol.Load(columnReader.ReadSubtree());
                                    Columns.Add(tmpCol);
                                }
                            }
                            break;
                        }
                }
            }*/

               /*Name = txR.GetAttribute(0);
            while (txR.Name != "Columns")
            {
                txR.Read();
            }
            txR.Read();

            while(txR.Name != "Columns")
            {
                if(txR.Name == "Column")
                {
                    Column tmpCol = new Column();
                    tmpCol.Load(txR);
                    Columns.Add(tmpCol);
                }
                txR.Read();
            }
            txR.Read();
            txR.Read();*/
        }
        /// <summary>
        /// Parses the XML of the configuration section.
        /// </summary>
        /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
        /// <param name="configContext">An HttpConfigurationContext when Create is called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
        /// <param name="section">The XmlNode that contains the configuration information from the configuration file. Provides direct access to the XML contents of the configuration section.</param>
        /// <returns>A configuration object.</returns>
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            if (section == null)
            {
                throw new ConfigurationErrorsException("The sourceForge/objectFactory section has not been defined.");
            }

            objectDefinitions = new SynchronizedDictionary<string, ObjectDefinition>();

            if (section.HasChildNodes)
            {
                // Register each object's configuration, without the constructor or property information
                foreach (XmlElement element in section.SelectNodes("object"))
                {
                    // In the event of a reference property or constructor argument already being processed, don't process the definition again
                    if (objectDefinitions.ContainsKey(element.GetAttribute("id")) == false)
                    {
                        ObjectDefinition objectDefinition = GetObjectDefinition(section as XmlElement, element, element.GetAttribute("id"));
                        objectDefinitions.Add(objectDefinition.Id, objectDefinition);
                    }
                }
            }

            return this;
        }
		public object Create(object parent, object configContext, System.Xml.XmlNode section)
		{
			var objectTypes = new Dictionary<string, ObjectConfigurationType>();
			XmlNodeList nodeObjects = section.SelectNodes(ObjectElement);
			foreach (XmlNode nodeObject in nodeObjects)
			{
				var objectType = new ObjectConfigurationType((XmlElement)nodeObject);
				objectTypes[objectType.Name] = objectType;
			}
			return objectTypes;
		}
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            CssServerConfiguration returnValue = new CssServerConfiguration();

            foreach (XmlNode node in section.SelectNodes("userTokens/userToken"))
            {
                returnValue.UserTokens.Add(node.Attributes["name"].Value, node.Attributes["value"].Value);
            }

            return returnValue;
        }
        private void RemoveExceptionAttributeFromActions(System.Xml.XmlDocument catalogueXml)
        {
            string searchKey = "/PolicySetCatalogue/Actions/Action";
            XmlNodeList actionNodes = catalogueXml.SelectNodes(searchKey);
            if (null == actionNodes)
                return;

            foreach (XmlNode node in actionNodes)
            {
                node.Attributes.Remove(node.Attributes.GetNamedItem("ExceptionHandler") as XmlAttribute);
            }
        }
		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(System.Xml.XmlNode testConfig, Context context)
		{
			XmlNodeList nodelist = testConfig.SelectNodes("VerifyId");

			foreach(XmlNode node in nodelist)
			{
				string valueToVerify = node.InnerText ;
				string appinstance = node.Attributes.GetNamedItem("appInstance").Value;
				string entity = node.Attributes.GetNamedItem("idXRef").Value;

				string commonId = CrossReferencing.GetCommonID(entity,appinstance,valueToVerify);

				if(commonId == null ||commonId == string.Empty)
				{
					throw new ApplicationException("AppId " + valueToVerify + " not found" );
				}

				context.LogInfo("IdXRef = " + entity  + ". AppInstance = " + appinstance + ". AppId = " + valueToVerify + ". CommonId = " + commonId);
			}

			XmlNodeList valueNodelist = testConfig.SelectNodes("VerifyValue");

			foreach(XmlNode node in valueNodelist)
			{
				string valueToVerify = node.InnerText ;
				string appType = node.Attributes.GetNamedItem("appType").Value;
				string entity = node.Attributes.GetNamedItem("valueXRef").Value;

				string commonValue = CrossReferencing.GetCommonValue(entity,appType,valueToVerify);

				if(commonValue == null ||commonValue == string.Empty)
				{
					throw new ApplicationException("AppValue " + valueToVerify + " not found" );
				}

				context.LogInfo("IdXRef = " + entity  + ". AppType = " + appType + ". AppValue = " + valueToVerify + ". CommonValue = " + commonValue);
			}

			context.LogInfo("Cross Reference Id and Value verification is complete");
		}
Exemplo n.º 13
0
 public static List<ResolverBase> GetResolverChain(System.Xml.XmlNode packageResolverChainNode)
 {
     var resolvers = new List<ResolverBase>();
     foreach (var resolverNode in packageResolverChainNode.SelectNodes("child::resolver").OfType<System.Xml.XmlNode>())
     {
         if (resolverNode.Attributes["type"] == null)
             throw new InvalidOperationException("Resolver misses a type attribute.");
         var resolver = GetResolverByName(resolverNode.Attributes["type"].Value);
         resolver.resolverNode = resolverNode;
         resolvers.Add(resolver);
     }
     return resolvers;
 }
Exemplo n.º 14
0
 private IList<DataBean> BuildDataBeanEntity(System.Xml.XmlNode xmlNode)
 {
     IList<DataBean> lsit = new List<DataBean>();
     XmlNodeList xmlNodes = xmlNode.SelectNodes("xsjl");
     for (int i = 0; i < xmlNodes.Count; i++)
     {
         DataBean data = new DataBean();
         data.guid = System.Guid.NewGuid();
         data.ShcBh = xmlNodes[i].SelectSingleNode("ShcBh").InnerText;
         data.ShcDj = xmlNodes[i].SelectSingleNode("ShcDj").InnerText;
         data.XSSL = xmlNodes[i].SelectSingleNode("XSSL").InnerText;
         data.XSTime = Convert.ToDateTime(xmlNodes[i].SelectSingleNode("XSTime").InnerText);
         data.ZydBh = xmlNodes[i].SelectSingleNode("ZydBh").InnerText;
         lsit.Add(data);
     }
     return lsit;
 }
        /// <summary>
        /// Log configuration from XmlDocument
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static List<NetworkConfiguration> FromXmlDocument(System.Xml.XmlDocument doc)
        {
            List<NetworkConfiguration> configurations = new List<NetworkConfiguration>();

            log.Debug("Loading configurations");

            // Chargement des règles
            foreach (System.Xml.XmlNode networkNode in doc.SelectNodes("/Networks/Network"))
            {
                NetworkRulesSet networkRulesSet = new NetworkRulesSet();
                ProxySettings proxySettings = null;

                networkRulesSet = ReadRules(networkNode.SelectNodes("Rules/*"));

                // Chargement des paramètres du configuration
                System.Xml.XmlNode proxyNode = networkNode.SelectSingleNode("Proxy");

                switch (proxyNode.Attributes["type"].Value)
                {
                    case "PacFile":
                        proxySettings = new ProxyPACSettings(proxyNode.Attributes["url"].Value);
                        break;

                    case "Standard":
                        bool? bypassLocal = proxyNode.Attributes["bypasslocal"] != null ? (bool?)bool.Parse(proxyNode.Attributes["bypasslocal"].Value) : null;
                        string exceptions = proxyNode.Attributes["exceptions"] != null ? proxyNode.Attributes["exceptions"].Value : null;
                        proxySettings = new StandardProxySettings(proxyNode.Attributes["url"].Value, exceptions, bypassLocal);
                        break;

                    case "None":
                        proxySettings = new NoProxySettings();
                        break;

                    default:
                        throw new Exception("Unknown Proxy type " + proxyNode.Attributes["type"].Value);
                }

                // Ajouter la configuration
                configurations.Add(new NetworkConfiguration(networkNode.Attributes["name"].Value, networkRulesSet, proxySettings));
            }

            log.DebugFormat("Configurations loaded: {0}", configurations.Count);

            return configurations;
        }
Exemplo n.º 16
0
        public override void LoadValues(System.Xml.XmlElement elem)
        {
            base.LoadValues(elem);
            var mappingelements = elem.SelectNodes("mapping");
            Source = (UAVStructure)((UAVBase)this.Parent).uavData.GetFromPath(elem.GetAttribute("source"));
            Source.ValueChanged += new ValueChangedHandler(Source_ValueChanged);

            lock (Syncobj)
            {
                var mapping = Mapping;
                if (mappingelements.Count > 0)
                {
                    mapping.Clear();
                    foreach (XmlElement item in mappingelements)
                    {
                        mapping.Add(item.GetAttribute("key"), item.GetAttribute("value"));
                    }
                    Mapping = mapping;
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Get the number of entities in this response
        /// </summary>
        /// <param name="hDocument">The GeosoftXML response</param>
        public bool AuthenticateUser(System.Xml.XmlDocument hDocument)
        {
            bool bAuthenticate = false;
            System.Xml.XmlNodeList hReturnList;

            // --- find all the item elements located anywhere in the document ---

            hReturnList = hDocument.SelectNodes("//" + Constant.Tag.AUTHENTICATE_TAG);

            if (hReturnList != null && hReturnList.Count > 0)
            {
                System.Xml.XmlNode oAttr;
                oAttr = hReturnList[0].Attributes.GetNamedItem(Constant.Tag.VALUE_TAG);
                try
                {
                    bAuthenticate = Convert.ToBoolean(oAttr.Value);
                }
                catch { }
            }
            return bAuthenticate;
        }
Exemplo n.º 18
0
        protected override void Install(System.Xml.XmlDocument data, StringBuilder log)
        {
            var templateElements = data.SelectNodes("snapshot/templates/template").Cast<XmlElement>().ToArray();
            var existingDocumentTypes = DocumentType.GetAllAsList().ToDictionary(d => d.Alias);
            var documentTypeLookup = new Dictionary<string, DocumentType>();
            foreach (var element in templateElements)
            {
                var alias = element.GetAttribute("alias");
                if (existingDocumentTypes.ContainsKey(alias))
                    new TemplateUpdater(existingDocumentTypes[alias], _connectionString, element).UpdateTemplate(log, documentTypeLookup);
                else
                {
                    new TemplateCreator(_connectionString, element).Process(log, documentTypeLookup);
                    ContentType.RemoveFromDataTypeCache(alias);
                    new TemplateUpdater(DocumentType.GetByAlias(alias), _connectionString, element).UpdateTemplate(log, documentTypeLookup);
                }
                ContentType.RemoveFromDataTypeCache(alias);
                var documentType = DocumentType.GetByAlias(alias);
                documentTypeLookup.Add(DataHelper.GetPath(documentType), documentType);
                existingDocumentTypes.Remove(alias);
            }

            foreach (var element in templateElements)
            {
                var alias = element.GetAttribute("alias");
                ContentType.RemoveFromDataTypeCache(alias);
                var updater = new TemplateUpdater(DocumentType.GetByAlias(alias), _connectionString, element);
                updater.UpdateChildStrucure(log, documentTypeLookup);
                updater.UpdateTabs(log, documentTypeLookup);

            }
            foreach (var element in templateElements)
            {
                var alias = element.GetAttribute("alias");
                ContentType.RemoveFromDataTypeCache(alias);
                var updater = new TemplateUpdater(DocumentType.GetByAlias(alias), _connectionString, element);
                updater.UpdateProperties(log, documentTypeLookup);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Automatically create the table of contents for the specified document.
        /// Insert an ID in the document if the heading doesn't have it.
        /// Returns the XHTML for the TOC
        /// </summary>
        public static string GenerateTOC(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNodeList headings = doc.SelectNodes("//*");

              Heading root = new Heading("ROOT", null, 0);
              int index = 0;
              GenerateHeadings(headings, root, ref index);

              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
              {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.WriteStartElement("div");
            root.WriteChildrenToXml(writer);
            writer.WriteEndElement();
            writer.Flush();

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);

            return reader.ReadToEnd();
              }
        }
Exemplo n.º 20
0
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            List<SimulatedDevice> devices = null;
            string[] mapping;

            if (section == null) { return devices; }

            devices = new List<SimulatedDevice>();

            XmlNodeList xmldevices = section.SelectNodes("//Device");

            foreach (XmlElement elem in xmldevices)
            {
                try
                {
                    SimulatedDevice device = new SimulatedDevice();
                    device.deviceId = elem.GetAttribute("name");
                    device.szNCFilename = elem.GetAttribute("CsvFile");
                    device.filter = elem.GetAttribute("filter");

                    mapping = elem.GetAttribute("mapping").Split(',');
                    for (int i = 0; i < mapping.Count(); i++)
                    {
                       string[] dict = mapping[i].Split('=');
                       if (dict.Count() < 2)
                           continue;
                       device.mappings[dict[0].Trim()] = dict[1].Trim();
                    }

                    devices.Add(device);
                }
                catch (Exception e)
                {
                    Logger.LogMessage("Device Configuration Error " + e.Message, 2);
                }
            }

            return devices;
        }
		/// <summary>
		/// Creates an object from the XmlNode passed to this ProviderConfigurationSectionHandler by the Configuration Runtime.
		/// This method is not intended for external use. It is only public due to the interface limitations implied by the C# 
		/// language specifications. We'll use interface hiding to hide it unless explicitly cast to the IConfigurationSectionHandler interface.
		/// </summary>
		/// <returns></returns>
		object IConfigurationSectionHandler.Create(object parent, object configContext, System.Xml.XmlNode section)
		{
			// create a collection for the providers defined in this config section
			ProviderCollection providers = this.GetProviderCollection();
						
			// grab all of the providers defined 
			XmlNodeList nodes = section.SelectNodes("Provider");
			
			foreach (XmlNode node in nodes)
			{
				// grab the required 'Type' attribute
				XmlAttribute typeAttribute = XmlUtilities.GetAttribute(node, "Type", true);
				
				// load the type from the attribute's value
				Type type = TypeUtilities.GetTypeFromFullyQualifiedName(typeAttribute.Value, true, true);

				// create the provider from the type and any additional info stored in the node
				providers.Add(this.CreateProvider(node, type));
			}
			
			// return the collection of providers
			return providers;
		}
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            ArrayList addInDirectories = new ArrayList();
            XmlNode attr = section.Attributes.GetNamedItem("ignoreDefaultPath");
            if (attr != null) {
                try {
                    addInDirectories.Add(Convert.ToBoolean( attr.Value ));
                } catch {
                    addInDirectories.Add(false);
                }
            } else {
                addInDirectories.Add(false);
            }

            XmlNodeList addInDirList = section.SelectNodes("AddInDirectory");
            foreach (XmlNode addInDir in addInDirList) {
                XmlNode path = addInDir.Attributes.GetNamedItem("path");
                if (path != null) {
                    addInDirectories.Add(path.Value);
                }
            }
            return addInDirectories;
        }
Exemplo n.º 23
0
        public static StupidTM2Image4bpp ConstructFromXml(System.Xml.XmlNode node)
        {
            ImageInfo info = GetImageInfo(node);
            var palPos = GetPalettePositionFromImageNode(info.Sector, node);

            var posNodes = node.SelectNodes("Position");
            PatcherLib.Iso.KnownPosition firstPosition = ParsePositionNode(info.Sector, posNodes[0]);
            PatcherLib.Iso.KnownPosition[] positions = new PatcherLib.Iso.KnownPosition[posNodes.Count - 1];
            for (int i = 1; i < posNodes.Count; i++)
            {
                positions[i - 1] = ParsePositionNode(info.Sector, posNodes[i]);
            }

            StupidTM2Image4bpp image = new StupidTM2Image4bpp(info.Name, info.Width, info.Height, palPos, firstPosition, positions);
            image.PaletteCount = info.PaletteCount;
            image.DefaultPalette = info.DefaultPalette;
            image.CurrentPalette = info.CurrentPalette;
            image.OriginalFilename = info.OriginalFilename;
            image.Filesize = info.Filesize;
            image.Sector = info.Sector;

            return image;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList xmlNodeList;
            Transform newTransform;
            IEnumerator enumerator;
            XmlElement iterationXmlElement;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

            this.transformCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("ds:Transform", xmlNamespaceManager);
            enumerator = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newTransform = new Transform();
                        newTransform.LoadXml(iterationXmlElement);
                        this.transformCollection.Add(newTransform);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("DigestAlgAndValue missing");
            }
            this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
            this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:CRLIdentifier", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                this.crlIdentifier = null;
            }
            else
            {
                this.crlIdentifier = new CRLIdentifier();
                this.crlIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
Exemplo n.º 26
0
        protected override void InitializeTask(System.Xml.XmlNode taskNode)
        {
            base.InitializeTask (taskNode);

            // grab the script block
            XmlNodeList scriptList = taskNode.SelectNodes(SCRIPT_NODE_NAME, NamespaceManager);
            if (0 == scriptList.Count) {
                _script = EMPTY_STRING;
            } else {
                if (1 == scriptList.Count) {
                    _script = scriptList.Item(0).InnerText;
                } else {
                    throw new BuildException("Only one <ftpscript> block allowed.", Location);
                } // if
            } // if
            scriptList = null;

            // grab the put and get filestatements
            XmlNodeList transferList = taskNode.SelectNodes(TRANSFER_NODE_XPATH, NamespaceManager);
            TransferFileSet aSet = null;
            this.Log(Level.Debug, "transferList.Count: {0}", transferList.Count);
            foreach (XmlNode node in transferList) {
                this.Log(Level.Debug, "- found a {0} set", node.Name);
                aSet = (TransferFileSet)TypeFactory.CreateDataType(node,this.Project);
                aSet.Parent = this;
                aSet.NamespaceManager = NamespaceManager;
                aSet.Initialize(node);
                if (aSet.IfDefined && !aSet.UnlessDefined) {
                    this._transferList.Add(aSet);
                    this.Log(Level.Debug, "  and added it to our _transferList (count now at {0})", _transferList.Count);
                }
            }

            return;
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyId", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.signaturePolicyId = new SignaturePolicyId();
                this.signaturePolicyId.LoadXml((XmlElement)xmlNodeList.Item(0));
                this.signaturePolicyImplied = false;
            }
            else
            {
                xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyImplied", xmlNamespaceManager);
                if (xmlNodeList.Count != 0)
                {
                    this.signaturePolicyImplied = true;
                    this.signaturePolicyId = null;
                }
                else
                {
                    throw new CryptographicException("SignaturePolicyId or SignaturePolicyImplied missing");
                }
            }
        }
Exemplo n.º 28
0
		/// <summary>
		/// Load state from an XML element
		/// </summary>
		/// <param name="xmlElement">XML element containing new state</param>
		public void LoadXml(System.Xml.XmlElement xmlElement)
		{
			XmlNamespaceManager xmlNamespaceManager;
			XmlNodeList xmlNodeList;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException("xmlElement");
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

			xmlNodeList = xmlElement.SelectNodes("ds:DigestMethod", xmlNamespaceManager);
			if (xmlNodeList.Count == 0)
			{
				throw new CryptographicException("DigestMethod missing");
			}
			this.digestMethod = new DigestMethod();
			this.digestMethod.LoadXml((XmlElement)xmlNodeList.Item(0));

			xmlNodeList = xmlElement.SelectNodes("ds:DigestValue", xmlNamespaceManager);
			if (xmlNodeList.Count == 0)
			{
				throw new CryptographicException("DigestValue missing");
			}
			this.digestValue = Convert.FromBase64String(xmlNodeList.Item(0).InnerText);
		}
Exemplo n.º 29
0
        internal void Init(System.Xml.XmlNode XMLNode)
        {
            if (XMLNode.SelectSingleNode("Root") != null) {
                _root = XMLNode.SelectSingleNode("Root").InnerText;
            }

            if (XMLNode.SelectSingleNode("Port") != null) {
                _port = XMLNode.SelectSingleNode("Port").InnerText;
            }

            if (XMLNode.SelectSingleNode("Compatible") != null) {
                _compatible = Convert.ToBoolean(XMLNode.SelectSingleNode("Compatible").InnerText);
            }

            if (XMLNode.SelectSingleNode("Theme") != null) {
                _theme = XMLNode.SelectSingleNode("Theme").InnerText;
                _themePath = _theme + '\\';
            }

            if (XMLNode.SelectSingleNode("SessionOutTime") != null) {
                _sessionOutTime = Convert.ToInt32(XMLNode.SelectSingleNode("SessionOutTime").InnerText);
            }

            if (XMLNode.SelectSingleNode("EncryptKey") != null) {
                _encryptKey = XMLNode.SelectSingleNode("EncryptKey").InnerText;
            }

            if (XMLNode.SelectSingleNode("EncryptIV") != null) {
                _encryptIV = XMLNode.SelectSingleNode("EncryptIV").InnerText;
            }

            if (XMLNode.SelectSingleNode("XySessionId") != null) {
                _userKeyCookieName = XMLNode.SelectSingleNode("XySessionId").InnerText;
            } else {
                _userKeyCookieName = "XyFrameSessionId";
            }

            if (XMLNode.SelectSingleNode("DebugMode") != null) {
                _debugMode = string.Compare(XMLNode.SelectSingleNode("DebugMode").InnerText, "true", true) == 0;
            }

            if (XMLNode.SelectSingleNode("Encoding") != null) {
                switch (XMLNode.SelectSingleNode("Encoding").InnerText.ToLower()) {
                    case "defalut":
                        _encoding = System.Text.Encoding.Default;
                        break;
                    case "gb2312":
                        _encoding = System.Text.Encoding.GetEncoding("GB2312");
                        break;
                    case "ascii":
                        _encoding = System.Text.Encoding.ASCII;
                        break;
                    case "unicode":
                        _encoding = System.Text.Encoding.Unicode;
                        break;
                    case "utf8":
                    case "utf-8":
                    default:
                        _encoding = new System.Text.UTF8Encoding(true);
                        break;
                }
            }

            foreach (System.Xml.XmlNode _xn in XMLNode.SelectNodes("Config/Item")) {
                if (_xn.Attributes["Name"] != null) {
                    _config[_xn.Attributes["Name"].Value] = _xn.InnerText;
                }
            }

            foreach (System.Xml.XmlNode _xn in XMLNode.SelectNodes("Translate/Item")) {
                if (_xn.Attributes["Name"] != null) {
                    _translate[_xn.Attributes["Name"].Value] = _xn.InnerText;
                }
            }

            _xsltDir = Xy.AppSetting.ThemeDir + _themePath + Xy.AppSetting.XSLT_PATH;
            _pageDir = Xy.AppSetting.ThemeDir + _themePath + Xy.AppSetting.PAGE_PATH;
            _includeDir = Xy.AppSetting.ThemeDir + _themePath + Xy.AppSetting.INCLUDE_PATH;
            _cacheDir = Xy.AppSetting.CacheDir + _themePath;

            if (!string.IsNullOrEmpty(_config["ScriptPath"])) {
                _scriptPath = _config["ScriptPath"];
            } else {
                _scriptPath = "/Xy_Theme/" + (_themePath + Xy.AppSetting.SCRIPT_PATH).Replace('\\', '/'); ;
            }

            if (!string.IsNullOrEmpty(_config["CssPath"])) {
                _cssPath = _config["CssPath"];
            } else {
                _cssPath = "/Xy_Theme/" + (_themePath + Xy.AppSetting.CSS_PATH).Replace('\\', '/'); ;
            }

            if (!string.IsNullOrEmpty(_config["ScriptDir"])) {
                _scriptDir = _config["ScriptDir"];
            } else {
                _scriptDir = Xy.AppSetting.ThemeDir + _themePath + Xy.AppSetting.SCRIPT_PATH;
            }

            if (!string.IsNullOrEmpty(_config["CssDir"])) {
                _cssDir = _config["CssDir"];
            } else {
                _cssDir = Xy.AppSetting.ThemeDir + _themePath + Xy.AppSetting.CSS_PATH;
            }

            CreateFolders();
        }
Exemplo n.º 30
0
		/// <summary>
		/// Load state from an XML element
		/// </summary>
		/// <param name="xmlElement">XML element containing new state</param>
		public void LoadXml(System.Xml.XmlElement xmlElement)
		{
			XmlNamespaceManager xmlNamespaceManager;
			XmlNodeList xmlNodeList;
			
			if (xmlElement == null)
			{
				throw new ArgumentNullException("xmlElement");
			}

			if (xmlElement.HasAttribute("ObjectReference"))
			{
				this.objectReferenceAttribute = xmlElement.GetAttribute("ObjectReference");
			}
			else
			{
				this.objectReferenceAttribute = "";
				throw new CryptographicException("ObjectReference attribute missing");
			}

			xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

			xmlNodeList = xmlElement.SelectNodes("xsd:Description", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.description = xmlNodeList.Item(0).InnerText;
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:ObjectIdentifier", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.objectIdentifier = new ObjectIdentifier("ObjectIdentifier");
				this.objectIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:MimeType", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.mimeType = xmlNodeList.Item(0).InnerText;
			}

			xmlNodeList = xmlElement.SelectNodes("xsd:Encoding", xmlNamespaceManager);
			if (xmlNodeList.Count != 0)
			{
				this.encoding = xmlNodeList.Item(0).InnerText;
			}
		}