public System.Xml.Linq.XElement ToPhysical(System.Xml.Linq.XElement udsService)
        {
            string name = udsService.Attribute("Name").Value;
            XElement x = new XElement("Service", new XAttribute("Name", name));
            XElement prop = new XElement("Property", new XAttribute("Name", "Definition"));
            x.Add(prop);

            XElement serv = new XElement("Service");
            prop.Add(serv);

            XElement sd = new XElement("ServiceDescription");
            serv.Add(sd);

            XElement handler = new XElement("Handler", new XAttribute("ExecType", "RemoteComponent"));
            sd.Add(handler);
            
            XElement udsDefinition = udsService.Element("Definition");
            foreach (XElement e in udsDefinition.Elements())
                sd.Add(e);

            XElement usage = new XElement("Usage");
            sd.Add(usage);

            XElement sh = new XElement("ServiceHelp");
            sh.Add(new XElement("Description"));
            sh.Add(new XElement("RequestSDDL"));
            sh.Add(new XElement("ResponseSDDL"));
            sh.Add(new XElement("Errors"));
            sh.Add(new XElement("RelatedDocumentServices"));
            sh.Add(new XElement("Samples"));
            serv.Add(sh);
            return x;
        }
 public void From_XML(System.Xml.Linq.XElement xml)
 {
     var element = xml.Element("name");
     if (element == null)
     {
         if (xml.Name == "name") element = xml;
         else element = null;
     }
     if (element != null)
     {
         name = element.Value;
     }
     element = xml.Element("title");
     if (element != null)
     {
         title = element.Value;
     }
     element = xml.Element("description");
     if (element != null)
     {
         description = element.Value;
     }
     element = xml.Element("uuid");
     if (element != null)
     {
         uuid = element.Value;
     }
 }
 public void ParseFromXElement(System.Xml.Linq.XElement source)
 {
     if (source.Name != XElementName)
         throw new Exception("Can not parse " + source.Name + " from " + XElementName);
     CompanyName = source.Element("CompanyName").Value;
     CompanyID = source.Element("CompanyID").Value;
 }
 /// <summary>
 /// AudioItem: represents an audio
 /// </summary>
 /// <param name="element">Element of XML</param>
 public AudioItem(System.Xml.Linq.XElement element)
 {
     itemType = MediaType.Audio;
     FillMediaItem(element);
     MediaUrl = GetUri(element.Element("media"), "href");
     PictureUrl = GetString(element.Element("picture"), "href");
 }
 public void From_XML(System.Xml.Linq.XElement xml)
 {
     Reset();
     var element = xml.Element("vcpu");
     if (element == null)
     {
         if (xml.Name == "vcpu") element = xml;
         else element = null;
     }
     if (element != null)
     {
         var i = 0;
         Int32.TryParse(element.Value, out i);
         if (i == 0) i = 1;
         vCpu_Count = i;
     }
     element = xml.Element("cpu");
     if (element != null)
     {
         element = element.Element("model");
         if (element != null)
         {
             var b = CPU_Models.qemu64;
             Enum.TryParse(element.Value, true, out b);
             Cpu_Model = b;
         }
         else Cpu_Model = CPU_Models.Hypervisor_Default;
     }
 }
        public void Parsing(System.Xml.Linq.XElement xml)
        {
            if (xml.Element("SmallBoxType") != null)
                SmallBoxType = (ESmallBoxType)Enum.Parse(typeof(ESmallBoxType), xml.Element("SmallBoxType").Value);

            if (xml.Element("BoxTransferServoPositions") != null)
                BoxTransferServoPositions.Parsing(xml.Element("BoxTransferServoPositions"));
        }
        public void Parsing(System.Xml.Linq.XElement xml)
        {
            if (xml.Element("FrontServoPositions") != null)
                FrontServoPositions.Parsing(xml.Element("FrontServoPositions"));

            if (xml.Element("RearServoPositions") != null)
                RearServoPositions.Parsing(xml.Element("RearServoPositions"));
        }
        public void Parsing(System.Xml.Linq.XElement xml)
        {
            if (xml.Element("Servo1Positions") != null)
                Servo1Positions.Parsing(xml.Element("Servo1Positions"));

            if (xml.Element("Servo2Positions") != null)
                Servo2Positions.Parsing(xml.Element("Servo2Positions"));
        }
Esempio n. 9
0
 public Episode(System.Xml.Linq.XElement element, Podcast podcast)
 {
     XNamespace itunes = "http://www.itunes.com/dtds/podcast-1.0.dtd";
     Name = element.Element("title").Value;
     WebPath = element.Element("enclosure").Attribute("url").Value;
     Author = element.Element(itunes + "author").Value;
     Published = ToDateTime(element.Element("pubDate").Value);
     ImageUrl = element.Element(itunes + "image") != null ? element.Element(itunes + "image").Attribute("href").Value : podcast.ImageUrl;
     Summary = element.Element(itunes + "summary") != null ? element.Element(itunes + "summary").Value : null;
     Description = element.Element("description") != null ? element.Element("description").Value : null;
     Podcast = podcast;
 }
Esempio n. 10
0
 public void Deserialize(System.Xml.Linq.XElement source)
 {
     try
     {
         TagID = new Guid(source.Element("tagid").Value);
         AssessmentID = new Guid(source.Element("assessmentid").Value);
     }
     catch (Exception)
     {
         throw new Exception("Failed to deserialize AssessmentTag entity.");
     }
 }
Esempio n. 11
0
        protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap)
        {
            Debug.Assert(xml.Name == "object");
            Debug.Assert(xml.Element("polyline") != null);

            var points = from pt in xml.Element("polyline").Attribute("points").Value.Split(' ')
                         let x = float.Parse(pt.Split(',')[0])
                         let y = float.Parse(pt.Split(',')[1])
                         select new PointF(x, y);

            this.Points = points.ToList();
        }
        public void ParseFromXElement(System.Xml.Linq.XElement source)
        {
            if (source.Name != XElementName)
                throw new Exception("Expected " + XElementName + " but got " + source.Name);

            ID = source.Element(IDFieldName).Value;

            dynamic doc = new Document.PreviewDocument(source.Element("Document").Attribute("DocumentType").Value);
            doc.LocalizedDocumentType = source.Element("Document").Attribute("LocalizedDocumentType").Value;
            Document = doc;

            Export = new DummyExport() { Name = source.Element("Export").Attribute("Name").Value, GuID = source.Element("Export").Attribute("ID").Value };
        }
Esempio n. 13
0
 public void Deserialize(System.Xml.Linq.XElement source)
 {
     try
     {
         MembershipID = new Guid(source.Element("membershipid").Value);
         Password = source.Element("password").Value;
         Username = source.Element("username").Value;
         Email = source.Element("email").Value;
     }
     catch (Exception)
     {
         throw new Exception("Failed to deserialize MembershipInfo entity.");
     }
 }
Esempio n. 14
0
 public void Deserialize(System.Xml.Linq.XElement source)
 {
     try
     {
         CourseTermMemberID = new Guid(source.Element("coursetermmemberid").Value);
         CourseTermID = new Guid(source.Element("coursetermid").Value);
         MembershipID = new Guid(source.Element("membershipid").Value);
         AccessLevel = byte.Parse(source.Element("accesslevel").Value);
     }
     catch (Exception)
     {
         throw new Exception("Failed to deserialize CourseTermMember entity.");
     }
 }
Esempio n. 15
0
 public void Deserialize(System.Xml.Linq.XElement source)
 {
     try
     {
         AnswerKeyID = new Guid(source.Element("answerkeyid").Value);
         AnswerID = new Guid(source.Element("answerid").Value);
         Weight = double.Parse(source.Element("weight").Value);
         Value = HttpContext.Current.Server.HtmlDecode(source.Element("value").Value);
     }
     catch (Exception)
     {
         throw new Exception("Failed to deserialize AnswerKey entity.");
     }
 }
        public void From_XML(System.Xml.Linq.XElement xml)
        {
            if (xml == null) return;

            var element = xml.Element("volume");
            if (element == null)
            {
                if (xml.Name == "volume") element = xml;
                else return;
            }

            var ele = xml.Element("name");
            if (ele != null)
                name = ele.Value;

            ele = xml.Element("allocation");
            if (ele != null)
            {
                allocation = UInt64.Parse(ele.Value);
                var attr = ele.Attribute("unit");
                if (attr != null)
                {
                    Memory_Units = (Memory_Allocation.UnitTypes)Enum.Parse(typeof(Memory_Allocation.UnitTypes), attr.Value);
                }
            }
            ele = xml.Element("capacity");
            if (ele != null)
            {
                capacity = UInt64.Parse(ele.Value);
                var attr = ele.Attribute("unit");
                if (attr != null)
                {
                    Memory_Units = (Memory_Allocation.UnitTypes)Enum.Parse(typeof(Memory_Allocation.UnitTypes), attr.Value);
                }
            }
            ele = xml.Element("target");
            if (ele != null)
            {
                ele = ele.Element("format");
                if (ele != null)
                {
                    var attr = ele.Attribute("type");
                    if (attr != null)
                    {
                        Volume_Type = (Volume_Types)Enum.Parse(typeof(Volume_Types), attr.Value);
                    }
                }
            }
        }
        public void Parsing(System.Xml.Linq.XElement xml)
        {
            try
            {
                if (xml.Element("FoamPadProgramNo") != null)
                    FoamPadProgramNo = byte.Parse(xml.Element("FoamPadProgramNo").Value);

                if (xml.Element("SmallBoxProgramNo") != null)
                    SmallBoxProgramNo = byte.Parse(xml.Element("SmallBoxProgramNo").Value);
            }
            catch (Exception e)
            {
                Manager.LogManager.Instance.WriteSystemLog(e.ToString());
            }
        }
Esempio n. 18
0
 public void Deserialize(System.Xml.Linq.XElement source)
 {
     try
     {
         ResponseID = new Guid(source.Element("responseid").Value);
         SubmissionRecordID = new Guid(source.Element("submissionrecordid").Value);
         AnswerID = new Guid(source.Element("answerid").Value);
         ResponseText = HttpContext.Current.Server.HtmlDecode(source.Element("responsetext").Value);
         Score = double.Parse(source.Element("score").Value);
     }
     catch (Exception)
     {
         throw new Exception("Failed to deserialize Response entity.");
     }
 }
Esempio n. 19
0
        /// <summary>
        /// Get Artist object from XElement node
        /// </summary>
        /// <param name="node"></param>
        /// <remarks>
        /// Takes an XElement node of eventItem and extracts the data for that events 
        /// Artist element. Checks to see if that Artist already exists, if yes than return, 
        /// if no then create a new Artist from data in node.
        /// </remarks>
        /// <returns></returns>
        public static Artist GetArtistFromNode(System.Xml.Linq.XElement node)
        {
            if (node == null || node.Element(Constants.Artist.artistIDElement) == null)
                return null;

            int artistId = 0;
            var artistElement = node.GetXElement(Constants.Artist.artistIDElement);
            int.TryParse(artistElement, out artistId);

            Artist artist = Artist.GetArtistByID(artistId);
            if (!artist.IsNew)
                return artist;

            int artistStatusId, artistStatus;
            string artistFirstName = (string)node.GetXElement(Constants.Artist.artistFirstNameElement);
            string artistLastName = (string)node.GetXElement(Constants.Artist.artistLastNameElement);
            string artistName4 = (string)node.GetXElement(Constants.Artist.artistName4Element);
            string artistName5 = (string)node.GetXElement(Constants.Artist.artistName5Element);
            string artistNote = (string)node.GetXElement(Constants.Artist.artistNoteElement);

            int.TryParse((string)node.GetXElement(Constants.Artist.artistStatusElement), out artistStatus);
            int.TryParse((string)node.GetXElement(Constants.Artist.artistStatusIDElement), out artistStatusId);

            artist = SetArtistData(artist, artistId, artistFirstName, artistLastName, artistName4, artistName5, artistNote, artistStatus, artistStatusId);

            return artist;
        }
 public void From_XML(System.Xml.Linq.XElement xml)
 {
     var element = xml.Element("pool");
     if (element == null)
     {
         if (xml.Name == "pool") element = xml;
         else element = null;
     }
     if (element == null) return;
     IStorage_Pool_Item.Pool_Types type = IStorage_Pool_Item.Pool_Types.dir;
     if (element != null)
     {
         var attr = element.Attribute("type");
         if (attr != null)
         {
             type = (IStorage_Pool_Item.Pool_Types)Enum.Parse(typeof(IStorage_Pool_Item.Pool_Types), attr.Value);
         }
     }
     if (type == IStorage_Pool_Item.Pool_Types.dir) Storage_Pool_Item = new Storage_Pool_Dir();
     else if (type == IStorage_Pool_Item.Pool_Types.iscsi) Storage_Pool_Item = new Storage_Pool_Iscsi();
     else if (type == IStorage_Pool_Item.Pool_Types.netfs) Storage_Pool_Item = new Storage_Pool_Netfs();
     else if (type == IStorage_Pool_Item.Pool_Types.disk) Storage_Pool_Item = new Storage_Pool_Disk();
     else
     {
         throw new NotImplementedException("Other Storage Types are not implemented yet");
     }
     Storage_Pool_Item.From_XML(element);
 }
Esempio n. 21
0
        protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap)
        {
            var points = from pt in xml.Element("polygon").Attribute("points").Value.Split(' ')
                         let x = float.Parse(pt.Split(',')[0])
                         let y = float.Parse(pt.Split(',')[1])
                         select new PointF(x, y);

            this.Points = points.ToList();

            // Test if polygons are counter clocksise
            // From: http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
            float sum = 0.0f;
            for (int i = 1; i < this.Points.Count(); i++)
            {
                var p1 = this.Points[i - 1];
                var p2 = this.Points[i];

                float v = (p2.X - p1.X) * -(p2.Y + p1.Y);
                sum += v;
            }

            if (sum < 0)
            {
                // Winding of polygons is counter-clockwise. Reverse the list.
                this.Points.Reverse();
            }
        }
Esempio n. 22
0
        public new void From_XML(System.Xml.Linq.XElement xml)
        {
            Reset();
            base.From_XML(xml);
            var element = xml.Element("capability");
            if (element == null)
            {
                if (xml.Name == "capability") element = xml;
                else element = null;
            }
            if (element == null) return;

            var ele = element.Element("block");
            if (ele != null) block = ele.Value;
            ele = element.Element("bus");
            if (ele != null) bus = ele.Value;

            ele = element.Element("drive_type");
            if (ele != null) drive_type = ele.Value;

            ele = element.Element("model");
            if (ele != null) model = ele.Value;

            ele = element.Element("vendor");
            if (ele != null) vendor = ele.Value;

            ele = element.Element("serial");
            if (ele != null) serial = ele.Value;
            ele = element.Element("size");
            if (ele != null) size = ele.Value;
            ele = element.Element("logical_block_size");
            if (ele != null) logical_block_size = ele.Value;
            ele = element.Element("num_blocks");
            if (ele != null) num_blocks = ele.Value;
        }
 public override void From_XML(System.Xml.Linq.XElement xml)
 {
     var element = xml.Element("source");
     if (element == null)
     {
         if (xml.Name == "source") element = xml;
         else element = null;
     }
     if (element == null) return;
     element = element.Element("device");
     if (element != null)
     {
         var attr = element.Attribute("path");
         if (attr != null)
         {
             device_path = attr.Value;
         }
     }
     element = element.Element("format");
     if (element != null)
     {
         var attr = element.Attribute("type");
         if (attr != null)
         {
             Pool_Format_Type = (Pool_Format_Types)Enum.Parse(typeof(Pool_Format_Types), attr.Value);
         }
     }
 }
Esempio n. 24
0
        /// <summary>
        /// Get a Work object from XElement node
        /// </summary>
        /// <remarks>
        /// Gets the workItem data from the XElement and checks if the 
        /// Work object already exists. If yes then return that work item. 
        /// Otherwise create a new Work object and assign its values the 
        /// data extracted from the XElement node.
        /// </remarks>
        /// <param name="node"></param>
        /// <returns></returns>
        public static Work GetWorkFromNode(System.Xml.Linq.XElement node)
        {
            if(node == null || node.Element(Constants.Work.workIDElement) == null)
                return null;

            int workID = 0;
            int.TryParse(node.GetXElement(Constants.Work.workIDElement), out workID);

            Work work = GetWorkByID(workID);

            if (!work.IsNew)
            {
                work.WorkPremiere = (string)node.GetXElement(Constants.Work.workPremiereElement);

                return work;
            }

            work.WorkID = workID;

            work = SetWorkTitles(node, work);

            work = GetComposers(node, work);

            work = SetWorkData(node, workID, work);

            work = GetWorkInstruments(node, work);

            work = GetWorkArtists(node, work);

            BsoArchiveEntities.Current.Save();

            return work;
        }
Esempio n. 25
0
        /// <summary>
        /// Get Venue object from XmlNode
        /// </summary>
        /// <param name="venueItemNode"></param>
        /// <remarks>
        /// Takes a eventVenue child element from an eventItem and 
        /// gets its child elements to create a Venue object, then returns
        /// that object.
        /// </remarks>
        /// <returns></returns>
        public static Venue GetVenueFromNode(System.Xml.Linq.XElement venueItemNode)
        {
            System.Xml.Linq.XElement venueElement = venueItemNode.Element(Constants.Venue.venueElement);
            if (venueElement == null || string.IsNullOrEmpty((string)venueElement.GetXElement(Constants.Venue.venueIDElement)))
                return null;

            int venueID;
            int.TryParse(venueElement.GetXElement(Constants.Venue.venueIDElement), out venueID);

            if (venueID == 0)
                return null;

            Venue venue = Venue.GetVenueByID(venueID);
            if (!venue.IsNew)
                return venue;

            string venueName = (string)venueElement.GetXElement(Constants.Venue.venueNameElement);
            string venueCode = (string)venueElement.GetXElement(Constants.Venue.venueCodeElement);
            string venueCountry = (string)venueElement.GetXElement(Constants.Venue.venueCountryElement);
            string venueCity = (string)venueElement.GetXElement(Constants.Venue.venueCityElement);
            string venueZipCode = (string)venueElement.GetXElement(Constants.Venue.venueZipCodeElement);
            string venueState = (string)venueElement.GetXElement(Constants.Venue.venueStateElement);
            string venueStreet = (string)venueElement.GetXElement(Constants.Venue.venueStreetElement);

            SetVenueData(venue, venueID, venueName, venueCode, venueCountry, venueCity, venueZipCode, venueState, venueStreet);

            return venue;
        }
        public void SetProperty(umbraco.cms.businesslogic.property.Property prop, System.Xml.Linq.XElement root)
        {
            var s = new Settings(prop);

            var elm = root.Element(prop.PropertyType.Alias);
            var paths = elm.Elements("item").Select(x => x.Value);

            IEnumerable<CMSNode> nodes = null;
            if (s.Source == Settings.DataSource.Content)
            {
                nodes = paths.Select(x => ContentSyncer.Find(x));
            }
            else
            {
                nodes = paths.Select(x => MediaSyncer.Find(x));
            }

            var ids = nodes.Select(x => x.Id);
            if (s.Format == Settings.DataFormat.Csv)
            {
                prop.Value = string.Join(",", ids);
            }
            else {

                var xml = new XElement("MultiNodePicker",
                        new XAttribute("type", s.Source.ToString().ToLower())
                    );
                foreach (var id in ids) {
                    xml.Add(new XElement("nodeId", id));
                }

                prop.Value = xml.ToString();
            }
        }
        public void From_XML(System.Xml.Linq.XElement xml)
        {
            Reset();
            var element = xml.Element("memory");
            if (element == null)
            {
                if (xml.Name == "memory") element = xml;
                else element = null;
            }
            if (element != null)
            {
                Int64 i = 0;
                Int64.TryParse(element.Value, out i);
                if (i < 128) i = 128;
                var attr = element.Attribute("unit");
                if (attr != null)
                {
                    var b = UnitTypes.MiB;
                    Enum.TryParse(attr.Value, true, out b);
                    memory_unit = b;
                }
                else memory_unit = UnitTypes.KiB;//default
                memory = i;
            }
            element = xml.Element("currentMemory");
            if (element != null)
            {
                Int64 i = 0;
                Int64.TryParse(element.Value, out i);
                if (i < 128) i = 128;
                var attr = element.Attribute("unit");
                if (attr != null)
                {
                    var b = UnitTypes.MiB;
                    Enum.TryParse(attr.Value, true, out b);
                    currentMemory_unit = b;
                }
                else memory_unit = UnitTypes.KiB;//default
                currentMemory = i;

            }
            else
            {// if not present, uses same as memory
                currentMemory = memory;
                currentMemory_unit = memory_unit;
            }
        }
        public void SetProperty(umbraco.cms.businesslogic.property.Property prop, System.Xml.Linq.XElement root)
        {
            var elm = root.Element(prop.PropertyType.Alias);

            if (elm != null)
            {
                prop.Value = elm.Value;
            }
        }
        public void Parsing(System.Xml.Linq.XElement xml)
        {
            if (xml.Element("SSDBoxesPuttingServoPositions") != null)
                SSDBoxesPuttingServoPositions.Parsing(xml.Element("SSDBoxesPuttingServoPositions"));

            if (xml.Element("SSDBoxesFoamPadGuideServoPositions") != null)
                SSDBoxesFoamPadGuideServoPositions.Parsing(xml.Element("SSDBoxesFoamPadGuideServoPositions"));

            if (xml.Element("SSDBoxInsertingUnitTransferServoPositions") != null)
                SSDBoxInsertingUnitTransferServoPositions.Parsing(xml.Element("SSDBoxInsertingUnitTransferServoPositions"));
        }
Esempio n. 30
0
        protected override void InternalFromXml(System.Xml.Linq.XElement xml, TmxMap tmxMap)
        {
            Debug.Assert(xml.Name == "object");
            Debug.Assert(xml.Element("polyline") != null);

            var points = from pt in xml.Element("polyline").Attribute("points").Value.Split(' ')
                         let x = float.Parse(pt.Split(',')[0])
                         let y = float.Parse(pt.Split(',')[1])
                         select new PointF(x, y);

            this.Points = points.ToList();
            float grid = 4;
            for (int i = 0; i < Points.Count; i++)
            {
                PointF pt = Points[i];
                int x = (int)(Math.Round(pt.X / grid) * grid);
                int y = (int)(Math.Round(pt.Y / grid) * grid);
                Points[i] = new PointF(x, y);
            }
        }