static XNamespace ()
		{
			nstable = new Dictionary<string, XNamespace> ();
			blank = Get (String.Empty);
			xml = Get ("http://www.w3.org/XML/1998/namespace");
			xmlns = Get ("http://www.w3.org/2000/xmlns/");
		}
 public void FixSize(XNamespace ab, XElement role, string name, string size)
 {
     foreach (var local in role.Elements(ab + "LocalResources"))
         foreach (var storage in local.Elements(ab + "LocalStorage"))
             if (storage.Attribute("name").Value == name)
                 storage.SetAttributeValue("sizeInMB", size);
 }
        public EpubSummaryParser(Stream source)
        {
            _zip = ZipContainer.Unzip(source);
            XDocument xmlDocument = _zip.GetFileStream("META-INF/container.xml").GetXmlDocument();
            XElement root = xmlDocument.Root;
            if (root == null)
                throw new DataException(InvalidEpubMetaInfo);

            XAttribute attribute = root.Attribute("xmlns");
            XNamespace xmlns = (attribute != null) ? XNamespace.Get(attribute.Value) : XNamespace.None;
            XAttribute fullPath = xmlDocument.Descendants(xmlns + "rootfile").First().Attribute("full-path");
            if (fullPath == null)
                throw new DataException(InvalidEpubMetaInfo);

            string path = fullPath.Value;
            _opfPath = path;
            _opf = _zip.GetFileStream(path).GetXmlDocument();
            _opfRoot = _opf.Root;
            if (_opfRoot == null)
                throw new DataException(InvalidEpubMetaInfo);

            _oebps = GetPath(path);
            _opfns = XNamespace.Get("http://www.idpf.org/2007/opf");
            _opfdc = XNamespace.Get("http://purl.org/dc/elements/1.1/");

            _coverHelper = new EpubCoverHelper(_zip, _opfns, _opfRoot, _oebps);
        }
 public ColladaDynamicMeshExporter(IRepository repository, DynamicMeshFile dynamicMeshFile, ExportDDSToPngFileDelegate exportDDSToPngFile = null)
 {
     Repository = repository;
     DynamicMeshFile = dynamicMeshFile;
     ExportDDSToPngFile = exportDDSToPngFile ?? DefaultExportDDSToPngFileDelegate;
     TNS = TemplateNameSpace;
 }
 public VS2012FixtureResult(string testName, string trxFileContents, string consoleOutput)
 {
     _testName = testName;
     _consoleOutput = consoleOutput;
     _trxXDocument = XDocument.Parse(trxFileContents);
     _namespace = _trxXDocument.Root.GetDefaultNamespace();
 }
 public objXmlEdmx(String strFilename)
     : base(strFilename)
 {
     this.strEdmxNs = XNamespace.Get(ConfigurationManager.AppSettings["EdmxNs"]);
     this.strSchemaNs = XNamespace.Get(ConfigurationManager.AppSettings["EdmxSchemaNs"]);
     InitRuntime();
 }
Beispiel #7
0
 public static string GetOfferListingId(this XElement xElement, XNamespace ns)
 {
     return xElement.Element(ns + "Offers") == null? string.Empty : xElement.Element(ns + "Offers").Elements(ns + "Offer") == null ? string.Empty :
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing") == null ? string.Empty :
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing").Descendants(ns + "OfferListingId") == null ? string.Empty : 
             xElement.Element(ns + "Offers").Elements(ns + "Offer").Elements(ns + "OfferListing").Descendants(ns + "OfferListingId").Select(f => f == null ? string.Empty : f.Value).First().ToString();
 }
        public Fb2SummaryParser(Stream source)
        {
            try
            {
                XDocument xmlDocument = source.GetXmlDocument();
                _root = xmlDocument.Root;
            }
            catch
            {
                source.Position = 0;
                var zip = ZipContainer.Unzip(source);
                source = zip.Files.First().Stream;

                source.Position = 0;
                XDocument xmlDocument = source.GetXmlDocument();
                _root = xmlDocument.Root; 
            }
                
            if (_root == null)
            {
                throw new DataException("Can't load book.");
            }
            XAttribute attribute = _root.Attribute("xmlns");
            if (attribute == null)
            {
                throw new DataException("Can't load book.");
            }
            _ns = attribute.Value;
        }
Beispiel #9
0
    static void Main(string[] args)
    {
        if (args.Length > 0 && args[0] == "-refsonly")
            onlyRefs = true;

        var nsStr = "http://schemas.microsoft.com/developer/msbuild/2003";
        nsManager = new XmlNamespaceManager(new NameTable());
        nsManager.AddNamespace("p", nsStr);
        ns = nsStr;

        //FeatureSamples.Core
        var coreCsproj = @"Samples/FeatureSamples/Core/Urho.Samples.csproj";
        var coreDoc = XDocument.Load(coreCsproj);
        RemovePackagesConfig(coreDoc);
        ReplaceRef(coreDoc, "Urho", "{641886db-2c6c-4d33-88da-97bec0ec5f86}", @"..\..\..\Bindings\Urho.csproj");
        coreDoc.Save(coreCsproj);

        //FeatureSamples.Droid
        var droidCsproj = @"Samples/FeatureSamples/Android/Urho.Samples.Droid.csproj";
        var droidDoc = XDocument.Load(droidCsproj);
        RemovePackagesConfig(droidDoc);
        ReplaceRef(droidDoc, "Urho", "{f0c1189b-75f7-4bd8-b394-a23d5b03eff6}", @"..\..\..\Bindings\Urho.Droid.csproj");
        droidDoc.Save(droidCsproj);

        //FeatureSamples.iOS
        var iosCsproj = @"Samples/FeatureSamples/iOS/Urho.Samples.iOS.csproj";
        var iosDoc = XDocument.Load(iosCsproj);
        RemovePackagesConfig(iosDoc);
        ReplaceRef(iosDoc, "Urho", "{9ae80bd9-e1e2-41da-bb6f-712b35028bd9}", @"..\..\..\Bindings\Urho.iOS.csproj");
        iosDoc.Save(iosCsproj);

        //FeatureSamples.Mac
        var desktopCsproj = @"Samples/FeatureSamples/Mac/Urho.Samples.Mac.csproj";
        var desktopDoc = XDocument.Load(desktopCsproj);
        RemovePackagesConfig(desktopDoc);
        ReplaceRef(desktopDoc, "Urho", "{F0359D5E-D6D4-47D3-A9F0-5A97C31DC476}", @"..\..\..\Bindings\Urho.Desktop.csproj");
        RemoveTargets(desktopDoc);
        desktopDoc.Save(desktopCsproj);

        //FormsSample.Core
        var formsCoreCsproj = @"Samples/FormsSample/FormsSample/FormsSample.csproj";
        var formsCoreDoc = XDocument.Load(formsCoreCsproj);
        RemovePackagesConfig(formsCoreDoc);
        ReplaceRef(formsCoreDoc, "Urho.Forms", "{D599C47F-B9E0-4A58-82E8-6286E0442E8F}", @"..\..\..\Bindings\Urho.Forms.csproj");
        formsCoreDoc.Save(formsCoreCsproj);

        //FormsSample.Droid
        var formsDroidCsproj = @"Samples/FormsSample/FormsSample.Droid/FormsSample.Droid.csproj";
        var formsDroidDoc = XDocument.Load(formsDroidCsproj);
        RemovePackagesConfig(formsDroidDoc);
        ReplaceRef(formsDroidDoc, "Urho.Forms", "{8BAE491B-46F0-4A51-A456-D7A3B332BDC4}", @"..\..\..\Bindings\Urho.Forms.Droid.csproj");
        formsDroidDoc.Save(formsDroidCsproj);

        //FormsSample.iOS
        var formsIosCsproj = @"Samples/FormsSample/FormsSample.iOS/FormsSample.iOS.csproj";
        var formsIosDoc = XDocument.Load(formsIosCsproj);
        RemovePackagesConfig(formsIosDoc);
        ReplaceRef(formsIosDoc, "Urho.Forms", "{8F3352BA-BF6A-49F8-81D6-58D54B3EA72B}", @"..\..\..\Bindings\Urho.Forms.iOS.csproj");
        formsIosDoc.Save(formsIosCsproj);
    }
        private static void AddColour(XElement liElement, XNamespace defaultNamespace, XNamespace xNamespace, XDocument doc, string swatchName="")
        {
            var name = liElement.Elements("span").First().Value;
            var hex = liElement.Elements("span").Last().Value;

            var prefix = "Primary";
            if (name.StartsWith("A"))
            {
                prefix = "Accent";
                name = name.Skip(1).Aggregate("", (current, next) => current + next);
            }

            var backgroundColourElement = new XElement(defaultNamespace + "Color", hex);
            // new XAttribute()
            backgroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}", swatchName, prefix, name)));
            doc.Root.Add(backgroundColourElement);

            var liClass = liElement.Attribute("class").Value;
            Color foregroundColour;
            if (!ClassNameToForegroundIndex.TryGetValue(liClass, out foregroundColour))
                throw new Exception("Unable to map foreground color from class " + liClass);

            var foreGroundColorHex = string.Format("#{0}{1}{2}{3}",
                ByteToHex(foregroundColour.A),
                ByteToHex(foregroundColour.R),
                ByteToHex(foregroundColour.G),
                ByteToHex(foregroundColour.B));

            var foregroundColourElement = new XElement(defaultNamespace + "Color", foreGroundColorHex);
            foregroundColourElement.Add(new XAttribute(xNamespace + "Key", string.Format("{0}{1}{2}Foreground", swatchName, prefix, name)));
            doc.Root.Add(foregroundColourElement);
        }
 public HtmlImageResultFormatter(Configuration configuration, ITestResults results, HtmlResourceSet htmlResourceSet)
 {
     this.configuration = configuration;
     this.results = results;
     this.htmlResourceSet = htmlResourceSet;
     this.xmlns = HtmlNamespace.Xhtml;
 }
Beispiel #12
0
        private static void CreateNodes(XNamespace ns, XElement nodes, DgmlNode dgmlNode)
        {
            XElement node;
            if (dgmlNode.Category == "SyntaxToken")
            {
                node = new XElement(ns + "Node",
                    new XAttribute("Id", dgmlNode.Id),
                    new XAttribute("Category", dgmlNode.Category),
                    new XAttribute("Label", dgmlNode.Label));
            }
            else
            {
                node = new XElement(ns + "Node",
                    new XAttribute("Id", dgmlNode.Id),
                    new XAttribute("Category", dgmlNode.Category),
                    new XAttribute("Label", dgmlNode.Kind));
            }

            nodes.Add(node);

            foreach (var childNode in dgmlNode.Childs)
            {
                CreateNodes(ns, nodes, childNode);
            }
        }
        //TODO Use PackageProperties.
        internal OpenXmlSdkDocumentProperties(OpenXmlSdkTextDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            _document = document;

            _xCorePropertiesNamespace = CorePropertiesSchema;
            _xDublinCoreNamespace = DublinCoreSchema;
            _xDCTermsNamespace = DublinCoreTermsSchema;

            _xCreatedElementName = _xDCTermsNamespace + "created";
            _xCreatorElementName = _xDublinCoreNamespace + "creator";
            _xDescriptionElementName = _xDublinCoreNamespace + "description";
            _xKeywordsElementName = _xCorePropertiesNamespace + "keywords";
            _xLanguageElementName = _xDublinCoreNamespace + "language";
            _xLastModifiedByElementName = _xCorePropertiesNamespace + "lastModifiedBy";
            _xLastPrintedElementName = _xCorePropertiesNamespace + "lastPrinted";
            _xModifiedElementName = _xDCTermsNamespace + "modified";
            _xRevisionElementName = _xCorePropertiesNamespace + "revision";
            _xSubjectElementName = _xDublinCoreNamespace + "subject";
            _xTitleElementName = _xDublinCoreNamespace + "title";

            using (Stream stream = document.InnerObject.CoreFilePropertiesPart.GetStream())
            {
                _xDocument = XDocument.Load(stream);
            }
        }
		public static void MyClassInitialize(TestContext testContext)
		{
			if (!Directory.Exists(Utility.RootFolder))
			{
				Directory.CreateDirectory(Utility.RootFolder);
			}
			if (!Directory.Exists(Utility.TempFolder))
			{
				Directory.CreateDirectory(Utility.TempFolder);
			}
			_mXmlNs = Utility.NS;
			_mOnGenerator = new OneNoteGenerator(Utility.RootFolder);
			//Get Id of the test notebook so we chould retrieve generated content
			//KindercareFormatConverter will create notebookName as Kindercare
			_mNotebookId = _mOnGenerator.CreateNotebook(NotebookName);

			var word = new Application();
			var doc = word.Application.Documents.Add();

			//add pages to doc
			for (int i = 1; i < DocPageTitles.Count; i++)
			{
				doc.Content.Text += DocPageTitles[i];
				doc.Words.Last.InsertBreak(WdBreakType.wdPageBreak);
			}

			var filePath = TestDocPath as object;
            doc.SaveAs(ref filePath);
            ((_WordDocument)doc).Close();
            ((_WordApplication)word).Quit();
		}
Beispiel #15
0
        /// <summary>
        /// Gets the prefix associated with a namespace for this <see cref="XDocument"/>.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="ns"></param>
        /// <returns></returns>
        public static string GetPrefixOfNamespace(this XDocument self, XNamespace ns)
        {
            Contract.Requires<ArgumentNullException>(self != null);
            Contract.Requires<ArgumentNullException>(ns != null);

            return self.Root.GetPrefixOfNamespace(ns);
        }
        private Route CreateGpx_1_1_Route(XDocument routeDocument, XNamespace ns)
        {
            XElement track = routeDocument.Root.Element(ns + "trk");
            string name = track.Element(ns + "name").Value;

            Route newRoute = new Route {Name = name, DateCreated = DateTime.Now};
            List<RoutePoint> routePoints = new List<RoutePoint>();
            var trackPoints = track.Descendants(ns + "trkpt");
            foreach (XElement trackPoint in trackPoints)
            {
                RoutePoint routePoint = new RoutePoint();
                routePoint.Latitude = double.Parse(trackPoint.Attribute("lat").Value);
                routePoint.Longitude = double.Parse(trackPoint.Attribute("lon").Value);
                routePoint.Elevation = double.Parse(trackPoint.Element(ns + "ele").Value);
                routePoint.TimeRecorded = DateTime.Parse(trackPoint.Element(ns + "time").Value);
                routePoints.Add(routePoint);
            }
            routePoints = routePoints.OrderBy(rp => rp.TimeRecorded).ToList();
            int index = 0;
            foreach (RoutePoint routePoint in routePoints)
            {
                routePoint.SequenceIndex = index;
                index++;
            }
            newRoute.RoutePoints = routePoints;
            newRoute.Distance = CalculateDistance(newRoute.RoutePoints);
            Tuple<double, double> ascentDescent = CalculateAscentDescent(newRoute.RoutePoints);
            newRoute.TotalAscent += ascentDescent.Item1;
            newRoute.TotalDescent += ascentDescent.Item2;
            return newRoute;
        }
 internal static void UpdateXElement(this XElement element, SettingsInfo settings, XNamespace ns)
 {
     element.Attribute("ID").Value = settings.Id.ToString();
     element.Attribute("processorRef").Value = settings.Processor.Id.ToString();
     element.Element(ns + "name").Value = settings.Name;
     element.Element(ns + "serialPortSettings").UpdateXElement(settings.SerialPortSettings, ns);
 }
Beispiel #18
0
 internal SchemaInfo(IFormChannelIdentifier channelIdentifier, XNamespace namespaceObj, XDocument schema)
 {
     this.ChannelIdentifier = channelIdentifier;
     this.Namespace = namespaceObj;
     this.Schema = schema;
     this.SchemaType = FormSchemaType.Uicontrols;
 }
Beispiel #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="xmlns"></param>
 /// <returns></returns>
 public override XElement CreateElement(XNamespace xmlns)
 {
     return new XElement(xmlns + "channel")
         .AddElement(xmlns + "title", Title)
         .AddElement(xmlns + "link", Link)
         .AddElement(xmlns + "description", Description);
 }
Beispiel #20
0
 //private String Method;
 //private String ApiTimeStamp;
 public ActiveForm(XNamespace ns, String ApiKey, String SecretApiKey)
 {
     this.NameSpace = ns;
       this.ApiKey = ApiKey;
       this.SecretApiKey = SecretApiKey;
       BaseUrl = "https://api.activeforms.com/4.0/";
 }
Beispiel #21
0
 public UPnPService(UPnPDevice parent, XNamespace ns, XElement service)
 {
     ParentDevice = parent;
       ServiceType = service.Elements().First(e => e.Name.LocalName == "serviceType").Value;
       ServiceID = service.Elements().First(e => e.Name.LocalName == "serviceId").Value;
       ControlUrl = service.Elements().First(e => e.Name.LocalName == "controlURL").Value;
 }
Beispiel #22
0
 private static void GenerateAllGanttTasks(IEnumerable<XElement> tasks, XNamespace xnamespace)
 {
     foreach (var t in tasks)
     {
         var ganttTask = new GanttTask();
         if (t.Element(xnamespace + "Name") != null)
         {
             ganttTask.Title = t.Element(xnamespace + "Name").Value;
         }
         ganttTask.UniqueId = t.Element(xnamespace + "UID").Value;
         ganttTask.Start = DateTime.Parse(t.Element(xnamespace + "Start").Value);
         ganttTask.End = DateTime.Parse(t.Element(xnamespace + "Finish").Value);
         ganttTask.IsMilestone = t.Element(xnamespace + "Milestone").Value == "1";
         ganttTask.Progress = Double.Parse(t.Element(xnamespace + "PercentComplete").Value);
         string outlineNumber = null;
         if (t.Element(xnamespace + "OutlineNumber") != null)
         {
             outlineNumber = t.Element(xnamespace + "OutlineNumber").Value;
         }
         var relations = t.Elements(xnamespace + "PredecessorLink");
         IList<string> relatonTaskIDs = new List<string>();
         foreach (var relation in relations)
         {
             var relationTask = relation.Element(xnamespace + "PredecessorUID").Value;
             relatonTaskIDs.Add(relationTask);
         }
         if (outlineNumber != null)
         {
             SetAllChildren(outlineNumber, ganttTask.UniqueId);
         }
         taskIdToGanttTask[ganttTask.UniqueId] = new Tuple<GanttTask, string>(ganttTask, outlineNumber);
     }
 }
 public static void SetDefaultXmlNamespace(this XElement xelem, XNamespace xmlns)
 {
     if (xelem.Name.NamespaceName == string.Empty)
         xelem.Name = xmlns + xelem.Name.LocalName;
     foreach (var e in xelem.Elements())
         e.SetDefaultXmlNamespace(xmlns);
 }
Beispiel #24
0
        public static ObservableCollection<GanttTask> GetMsTasks(XDocument xDocument, XNamespace xnamespace)
        {
            var allTasks = new ObservableCollection<GanttTask>();
            var task = xDocument.Root.Elements(xnamespace + "Tasks");
            var tasks = task.Elements(xnamespace + "Task");
            tasks.FirstOrDefault().Remove();
            PrepareXMLTasksForConvertingToGanttTasks(xnamespace, tasks);
            GenerateAllGanttTasks(tasks, xnamespace);

            foreach (var t in taskIdToGanttTask)
            {
                var gtask = t.Value.Item1;

                SetUpRelationsToGanttTask(t.Key, t.Value, gtask);

                var oNumber = t.Value.Item2;
                if (oNumber != null)
                {
                    SetUpChildrenToGanttTask(t.Value, gtask);

                }
                if (IsRootTask(oNumber))
                {
                    allTasks.Add(gtask);
                }
            }
            return allTasks;
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            doc = XDocument.Load("http://events.feed.comportal.be/agenda.aspx?event=TechDays&year=2013&speakerlist=c|Experts");

            jsonns = "http://james.newtonking.com/projects/json";
            doc.Root.SetAttributeValue(XNamespace.Xmlns + "json", jsonns);

            CleanSection("bio");
            CleanSection("description");

            ToJsonArray("timeslot");
            ToJsonArray("session");
            ToJsonArray("tag");
            ToJsonArray("speaker");

            var wrdoc = File.CreateText("sessions.xml");
            wrdoc.Write(doc);
            wrdoc.Close();

            var jsonstring = JsonConvert.SerializeXNode(doc);

            var wr = File.CreateText("sessions.json");
            wr.Write(jsonstring);
            wr.Close();

            var rdr = File.OpenText("sessions.json");
            var json = rdr.ReadToEnd();
            rdr.Close();

            var theevent = JsonConvert.DeserializeObject<TopXml>(json);

            //Console.WriteLine("done");
            //Console.ReadLine();
        }
		public static XElement XElementFromElastic(ElasticObject elastic, XNamespace nameSpace = null)
		{
			// we default to empty namespace
			nameSpace = nameSpace ?? string.Empty;
			var exp = new XElement(nameSpace + elastic.InternalName);

			foreach (var a in elastic.Attributes.Where(a => a.Value.InternalValue != null))
			{
				// if we have xmlns attribute add it like XNamespace instead of regular attribute
				if (a.Key.Equals("xmlns", StringComparison.InvariantCultureIgnoreCase))
				{
					nameSpace = a.Value.InternalValue.ToString();
					exp.Name = nameSpace.GetName(exp.Name.LocalName);
				}
				else
				{
					exp.Add(new XAttribute(a.Key, a.Value.InternalValue));
				}
			}

			if (elastic.InternalContent is string)
			{
				exp.Add(new XText(elastic.InternalContent as string));
			}

			foreach (var child in elastic.Elements.Select(c => XElementFromElastic(c, nameSpace)))
			{
				exp.Add(child);
			}

			return exp;
		}
Beispiel #27
0
 public static string GetAvailability(this XElement xElement, XNamespace ns)
 {
     return xElement.Element(ns + "Offers") == null ? string.Empty :
         xElement.Element(ns + "Offers").Element(ns + "Offer") == null ? string.Empty :
         xElement.Element(ns + "Offers").Element(ns + "Offer").Element(ns + "OfferListing") == null ? string.Empty :
         xElement.Element(ns + "Offers").Element(ns + "Offer").Element(ns + "OfferListing").ElementValue("Availability", ns);
 }
Beispiel #28
0
 /// <summary>
 /// Moves <paramref name="element"/> into namespace <paramref name="newNamespace"/>.
 /// </summary>
 /// <param name="element">The element that will be moved into a new namespace.</param>
 /// <param name="newNamespace">The new namespace for the element.</param>
 public static void MoveToNamespace(this XElement element, XNamespace newNamespace)
 {
     foreach (XElement el in element.DescendantsAndSelf())
     {
         el.Name = newNamespace.GetName(el.Name.LocalName);
     }
 }
 private CorrelationKey(string keyString, XNamespace provider) : base(GenerateKey(keyString), dictionary)
 {
     Dictionary<XName, InstanceValue> dictionary = new Dictionary<XName, InstanceValue>(2);
     dictionary.Add(provider.GetName("KeyString"), new InstanceValue(keyString, InstanceValueOptions.Optional));
     dictionary.Add(WorkflowNamespace.KeyProvider, new InstanceValue(provider.NamespaceName, InstanceValueOptions.Optional));
     this.KeyString = keyString;
 }
 static WatermarkAccessor()
 {
     ns = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
     officens = "urn:schemas-microsoft-com:office:office";
     vmlns = "urn:schemas-microsoft-com:vml";
     relationshipsns = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
 }
Beispiel #31
0
 /// <summary>Gets the XML element for a category element in the specified <paramref name="scheme"/>.</summary>
 /// <param name="term">Category term.</param>
 /// <param name="scheme">Category scheme.</param>
 /// <returns>The XML element for the category element.</returns>
 public static System.Xml.Linq.XElement GetCategoryXElement(string term, string scheme)
 {
     System.Xml.Linq.XNamespace ns = AtomXmlNamespace;
     return(new System.Xml.Linq.XElement(
                ns + "category",
                new System.Xml.Linq.XAttribute("term", term),
                new System.Xml.Linq.XAttribute("scheme", scheme)));
 }
Beispiel #32
0
 private float readGlobalScale(string relativeResourcePath)
 {
     try
     {
         System.Xml.Linq.XNamespace xmlns = "http://www.collada.org/2005/11/COLLADASchema";
         TextAsset fileContent            = Resources.Load(relativeResourcePath) as TextAsset;
         XDocument xdoc = XDocument.Parse(fileContent.text);
         string    str  = xdoc.Element(xmlns + "COLLADA").Element(xmlns + "asset").Element(xmlns + "unit").Attribute("meter").Value;
         return(float.Parse(str, CultureInfo.InvariantCulture.NumberFormat));
     }
     catch
     {
         return(1.0f);
     }
 }
Beispiel #33
0
 private string readColladaOrientation(string relativeResourcePath)
 {
     try
     {
         System.Xml.Linq.XNamespace xmlns = "http://www.collada.org/2005/11/COLLADASchema";
         relativeResourcePath = relativeResourcePath.Replace('/', '\\');
         var fileContent = Resources.Load <TextAsset>(relativeResourcePath);
         Output.Log(relativeResourcePath);
         Output.Log((fileContent != null).ToString());
         XDocument xdoc = XDocument.Parse(fileContent.text);
         var       v    = xdoc.Element(xmlns + "COLLADA").Element(xmlns + "asset").Element(xmlns + "up_axis").Value;
         Output.Log(v);
         return(v);
     }
     catch
     {
         Output.Log("failed");
         return("undefined");
     }
 }
Beispiel #34
0
    public override DataRecord Parse(DataRecord record, string Contents)
    {
        var n = System.Xml.Linq.XDocument.Parse(Contents);

        System.Xml.Linq.XNamespace gml = "http://www.opengis.net/gml";
        System.Xml.Linq.XNamespace ms  = "http://mapserver.gis.umn.edu/mapserver";
        var query = n.Root.Descendants(gml + "featureMember");


        record.Lines = new List <List <SerialVector2> >();
        foreach (var c in query)
        {
            //var d = c.Elements();

            foreach (var e in c.Descendants(ms + "msGeometry").Elements())
            {
                record.Lines.Add(SerialVector2.ToVector2Array(getPoints(e.Value).ToArray()).ToList());
            }
        }
        return(record);
    }
Beispiel #35
0
 /// <summary>
 /// Attempts to load track details from spotify uri
 /// </summary>
 /// <param name="track"></param>
 public static bool LookupTrackInfo(Track track)
 {
     try
     {
         // search for track using Spotify metadata API and get spotify URI
         System.Xml.Linq.XNamespace ns = "http://www.spotify.com/ns/music/1";
         XElement data = XElement.Load("http://ws.spotify.com/lookup/1/?uri=" + System.Web.HttpUtility.UrlEncode(track.SpotifyUri));
         track.TrackName = (string)data.Element(ns + "name");
         track.Artist    = (string)data.Element(ns + "artist").Element(ns + "name");
         if (data.Element(ns + "album") != null)
         {
             track.Album = (string)data.Element(ns + "album").Element(ns + "name");
         }
         track.Length = (int?)data.Element(ns + "length");
         return(true);
     }
     catch
     {
         // prolly rate limited
         return(false);
     }
 }
Beispiel #36
0
 private void PushAncestors(XElement?e)
 {
     while (true)
     {
         e = e !.parent as XElement;
         if (e == null)
         {
             break;
         }
         XAttribute?a = e.lastAttr;
         if (a != null)
         {
             do
             {
                 a = a.next !;
                 if (a.IsNamespaceDeclaration)
                 {
                     _resolver.AddFirst(a.Name.NamespaceName.Length == 0 ? string.Empty : a.Name.LocalName, XNamespace.Get(a.Value));
                 }
             } while (a != e.lastAttr);
         }
     }
 }
Beispiel #37
0
 private void PushElement()
 {
     _resolver.PushScope();
     foreach (XAttribute a in _attributes)
     {
         if (a.IsNamespaceDeclaration)
         {
             _resolver.Add(a.Name.NamespaceName.Length == 0 ? string.Empty : a.Name.LocalName, XNamespace.Get(a.Value));
         }
     }
 }
Beispiel #38
0
 public override void WriteStartElement(string prefix, string localName, string namespaceName)
 {
     AddNode(new XElement(XNamespace.Get(namespaceName).GetName(localName)));
 }
Beispiel #39
0
        public void exportXML()
        {
            //output to the xml file
            string path = this.xmlPath;

            linq.XNamespace ns = "http://www.edi.com.au/EnterpriseService/";

            linq.XDocument doc = linq.XDocument.Load(path);

            linq.XElement rateEntries = new linq.XElement(ns + "RateEntries");
            foreach (RateEntry r in reList)
            {
                linq.XElement entry = new linq.XElement(ns + "RateEntry");
                if (r.category != "")
                {
                    entry.Add(new linq.XElement(ns + "Category", r.category));
                }
                entry.Add(new linq.XElement(ns + "Mode", "SEA"));
                if (r.startDate != "")
                {
                    entry.Add(new linq.XElement(ns + "StartDate", r.startDate));
                }
                if (r.endDate != "")
                {
                    entry.Add(new linq.XElement(ns + "EndDate", r.endDate));
                }
                if (r.ContainerCode != "")
                {
                    linq.XElement ct = new linq.XElement(ns + "ContainerType");
                    ct.Add(new linq.XElement(ns + "ContainerCode", r.ContainerCode));
                    entry.Add(ct);
                }
                if (r.contractNum != "")
                {
                    entry.Add(new linq.XElement(ns + "ContractNumber", r.contractNum));
                }
                if (r.origin != "")
                {
                    entry.Add(new linq.XElement(ns + "Origin", r.origin));
                }
                if (r.destination != "")
                {
                    entry.Add(new linq.XElement(ns + "Destination", r.destination));
                }
                if (r.commodityCode != "")
                {
                    entry.Add(new linq.XElement(ns + "CommodityCode", r.commodityCode));
                }
                linq.XElement rls = new linq.XElement(ns + "RateLines");
                foreach (RateLine rl in r.rl)
                {
                    linq.XElement rateline = new linq.XElement(ns + "RateLine");
                    rateline.Add(new linq.XElement(ns + "Description", "Ocean Freight"));
                    rateline.Add(new linq.XElement(ns + "Currency", "USD"));
                    rateline.Add(new linq.XElement(ns + "ChargeCode", "FRT"));
                    linq.XElement rc  = new linq.XElement(ns + "RateCalculator");
                    linq.XElement unt = new linq.XElement(ns + "UNTCalculator");
                    unt.Add(new linq.XElement(ns + "PerUnitPrice", rl.price));
                    linq.XElement notes = new linq.XElement(ns + "Notes");
                    linq.XElement note  = new linq.XElement(ns + "Note");
                    note.Add(new linq.XElement(ns + "NoteType", "TradeLaneChargeInformation"));
                    note.Add(new linq.XElement(ns + "NoteData", rl.note));
                    rc.Add(unt);
                    notes.Add(note);
                    rateline.Add(rc);
                    rateline.Add(notes);
                    rls.Add(rateline);
                }
                entry.Add(rls);
                rateEntries.Add(entry);
            }
            var ele = doc.Descendants(ns + "Rate").FirstOrDefault();

            if (doc.Descendants(ns + "RateEntries").Any())
            {
                doc.Descendants(ns + "RateEntries").FirstOrDefault().Remove();
            }
            ele.Add(rateEntries);
            doc.Save(path);
        }
Beispiel #40
0
        private IDictionary <string, string> CalculateSettingsForDirectory(string directoryPath, IDictionary <string, string> initialSettings, string configFile)
        {
            foreach (var file in Directory.GetFiles(directoryPath, "*" + configFile, SearchOption.TopDirectoryOnly))
            {
                // Process the file
                // /root/Settings/key
                try
                {
                    // var xdoc = new System.Xml.XPath.XPathDocument(file).CreateNavigator();
                    var xdoc = System.Xml.Linq.XDocument.Load(file);
                    System.Xml.Linq.XNamespace c = "urn:ChirpyConfig";
                    var xRoot = xdoc.Element(c + "root");
                    if (xRoot == null)
                    {
                        xRoot = xdoc.Element("root");
                    }

                    var settings = xRoot.Element(c + "Settings");
                    if (settings == null)
                    {
                        settings = xRoot.Element("Settings");
                    }

                    if (settings != null)
                    {
                        List <XElement> listSetting = new List <XElement>();
                        listSetting.AddRange(settings.Elements(c + "Setting"));
                        listSetting.AddRange(settings.Elements("Setting"));

                        foreach (var setting in listSetting)
                        {
                            var keyElement = setting.Attribute("key");
                            if (keyElement != null && !initialSettings.ContainsKey(keyElement.Value))
                            {
                                var valueElement = setting.Attribute("value");
                                if (valueElement != null)
                                {
                                    initialSettings.Add(keyElement.Value,
                                                        valueElement.Value);
                                }
                            }
                        }
                    }
                }
                catch (System.Xml.XmlException eError)
                {
                    if (!eError.Message.Contains("Root element not found") && !eError.Message.Contains("Root element is missing"))
                    {
                        throw eError;
                    }
                }
                catch (System.IO.IOException)
                {
                    // Ignore locked files, etc.
                }
            }

            var parent = System.IO.Directory.GetParent(directoryPath);

            if (parent != null)
            {
                this.CalculateSettingsForDirectory(parent.FullName, initialSettings, configFile);
            }

            return(initialSettings);
        }
Beispiel #41
0
        private void PushElement(XElement e)
        {
            _resolver.PushScope();
            XAttribute?a = e.lastAttr;

            if (a != null)
            {
                do
                {
                    a = a.next !;
                    if (a.IsNamespaceDeclaration)
                    {
                        _resolver.Add(a.Name.NamespaceName.Length == 0 ? string.Empty : a.Name.LocalName, XNamespace.Get(a.Value));
                    }
                } while (a != e.lastAttr);
            }
        }