public override void Load(System.Xml.Linq.XElement xElement)
        {
            base.Load(xElement);

            Request = new Dictionary<string, string>();
            Response = new Dictionary<string, string>();
            foreach (var element in xElement.Elements("request"))
            {
                Request[element.Attribute("name").Value] = element.Value;
            }

            foreach (var element in xElement.Elements("response"))
            {
                Response[element.Attribute("name").Value] = element.Value;
            }
        }
        public override void Build(YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder, System.Xml.Linq.XElement panelSetOrderElement)
        {
            Test.LLP.PanelSetOrderLeukemiaLymphoma llpPanelSetOrder = (Test.LLP.PanelSetOrderLeukemiaLymphoma)panelSetOrder;

            List<XElement> markerElements = (from item in panelSetOrderElement.Elements("FlowMarkerCollection")
                                             select item).ToList<XElement>();

            llpPanelSetOrder.FlowMarkerCollection.RemoveDeleted(markerElements.Elements("FlowMarker"));

            Flow.FlowMarkerItem flowMarker = null;
            foreach (XElement markerElement in markerElements.Elements("FlowMarker"))
            {
                string flowMarkerId = markerElement.Element("FlowMarkerId").Value;

                if (llpPanelSetOrder.FlowMarkerCollection.Exists(flowMarkerId) == true)
                {
                    flowMarker = llpPanelSetOrder.FlowMarkerCollection.Get(flowMarkerId);
                }
                else
                {
                    flowMarker = new Flow.FlowMarkerItem();
                    llpPanelSetOrder.FlowMarkerCollection.Add(flowMarker);
                }

                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(markerElement, flowMarker);
                xmlPropertyWriter.Write();
            }
        }
        public void FormatCollector(Dictionary<string, string> parameters, Dictionary<string, string> collectorDict, System.Xml.Linq.XElement collectorElement, Type collectorType, Processor processor)
        {
            CollectorHelpers.IsCollectorFormatterValid(collectorType, "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector");

            switch (collectorType.FullName)
            {
                case "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector":
                    {
                        string[] files = collectorDict["Files"].Split(',');
                        var dictRet = new Dictionary<string, Dictionary<string, string>>();

                        foreach (var file in files)
                        {
                            var xmlDoc = XDocument.Load(file);
                            foreach (var xmlRefVal in collectorElement.Elements("XmlRefToKeyValue"))
                            {
                                processor.AddDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file));

                                XElement ele = xmlDoc.XPathSelectElement(xmlRefVal.Attribute("name").Value);
                                if (ele != null)
                                    processor.GetDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file))[xmlRefVal.Attribute("domain_key").Value] = ele.Value;
                            }
                        }
                    }
                    break;
            }
        }
 public static System.Xml.Linq.XElement RemoveAllNamespaces(System.Xml.Linq.XElement rootElement)
 {
     System.Xml.Linq.XElement xElement = new System.Xml.Linq.XElement(rootElement.Name.LocalName);
     if (rootElement.HasAttributes)
     {
         foreach (System.Xml.Linq.XAttribute attribute in rootElement.Attributes())
         {
             if (!attribute.IsNamespaceDeclaration)
             {
                 if (rootElement.Name.LocalName == "Category")
                 {
                     xElement.Add(attribute);
                 }
                 else
                 {
                     if (attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type"
                         || attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}nil")
                     {
                         //  We dont want xsi: attribute
                         //  except for certain types where we will inject our own value
                         if (rootElement.Name.LocalName == "Activity"
                             && attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type"
                             && attribute.Value.EndsWith("RepairAndMaintenanceActivity"))
                         {
                             attribute.Value = "RepairAndMaintenanceActivity";
                             xElement.Add(attribute);
                         }
                         if (rootElement.Name.LocalName == "Activity"
                             && attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type"
                             && attribute.Value.EndsWith("CustomerActivity"))
                         {
                             attribute.Value = "CustomerActivity";
                             xElement.Add(attribute);
                         }
                     }
                     else
                     {
                         xElement.Add(attribute);
                     }
                 }
             }
         }
     }
     if (rootElement.HasElements)
     {
         //  Recurse the structure
         foreach (System.Xml.Linq.XElement childElement in rootElement.Elements())
         {
             xElement.Add(RemoveAllNamespaces(childElement));
         }
     }
     else
     {
         //  Take the current value across
         xElement.Value = rootElement.Value;
     }
     return xElement;
 }
Exemple #5
0
        public static XmlRpc.Value ParseXml(System.Xml.Linq.XElement value_el)
        {
            if (value_el.Name != "value")
            {
                string msg = string.Format("XML Element should have name \"value\" instead found \"{0}\"", value_el.Name);
                throw new XmlRpcException();
            }

            var input_value = value_el.Value;
            if (value_el.HasElements)
            {
                var type_el = value_el.Elements().First();

                string typename = type_el.Name.ToString();
                if (typename == Array.TypeString)
                {
                    return Array.XmlToValue(type_el);
                }
                else if (typename == Struct.TypeString)
                {
                    return Struct.XmlToValue(type_el);
                }
                else if (typename == StringValue.TypeString)
                {
                    return StringValue.XmlToValue(type_el);
                }
                else if (typename == DoubleValue.TypeString)
                {
                    return DoubleValue.XmlToValue(type_el);
                }
                else if (typename == Base64Data.TypeString)
                {
                    return Base64Data.XmlToValue(type_el);
                }
                else if (typename == DateTimeValue.TypeString)
                {
                    return DateTimeValue.XmlToValue(type_el);
                }
                else if (typename == IntegerValue.TypeString || typename == IntegerValue.AlternateTypeString)
                {
                    return IntegerValue.XmlToValue(type_el);
                }
                else if (typename == BooleanValue.TypeString )
                {
                    return BooleanValue.XmlToValue(type_el);
                }
                else
                {
                    string msg = string.Format("Unsupported type: {0}", typename);
                    throw new XmlRpcException(msg);
                }
            }
            else
            {
                // no <type> element provided. Treat the content as a string
                return new StringValue(input_value);
            }
        }
        public static YawControllerSettings FromXmlElement(System.Xml.Linq.XElement angleControllerElement)
        {
            var cwProfileElement = angleControllerElement.Elements("PidProfile").Single(x => x.Attribute("Direction").Value == DirectionProfile.CW.ToString());
            var ccwProfileElement = angleControllerElement.Elements("PidProfile").Single(x => x.Attribute("Direction").Value == DirectionProfile.CCW.ToString());

            var settings = new YawControllerSettings()
            {
                IsEnabled = angleControllerElement.Attribute("IsEnabled").ParseOptionalBoolean(),
                MotorDriver = (MotorDriver)Enum.Parse(typeof(MotorDriver), angleControllerElement.Attribute("MotorDriver").Value),
                IntegralWindupThreshold = angleControllerElement.Attribute("IntegralWindupThreshold").ParseDouble(),
                OutputRateLimit = angleControllerElement.Attribute("OutputRateLimit").ParseInt(),
                PidProfiles = new Dictionary<DirectionProfile, PidProfile>
                {
                    {DirectionProfile.CW, PidProfile.FromXmlElement(cwProfileElement) },
                    {DirectionProfile.CCW, PidProfile.FromXmlElement(ccwProfileElement) }
                },
            };

            return settings;
        }
 public override void Build(Test.PanelSetOrder panelSetOrder, System.Xml.Linq.XElement panelSetOrderElement)
 {
     List<XElement> markerElements = (from item in panelSetOrderElement.Elements("FlowMarkerCollection")
                                      select item).ToList<XElement>();
     foreach (XElement markerElement in markerElements.Elements("FlowMarker"))
     {
         Flow.FlowMarkerItem flowMarkerItem = new Flow.FlowMarkerItem();
         YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new YellowstonePathology.Business.Persistence.XmlPropertyWriter(markerElement, flowMarkerItem);
         xmlPropertyWriter.Write();
         ((Test.LLP.PanelSetOrderLeukemiaLymphoma)panelSetOrder).FlowMarkerCollection.Add(flowMarkerItem);
     }
 }
        internal static VertexShaderFieldList Parse(System.Xml.Linq.XElement xElement)
        {
            if (xElement.Name != typeof(VertexShaderFieldList).Name) { throw new Exception(); }

            var result = new VertexShaderFieldList();
            foreach (var item in xElement.Elements(typeof(ShaderField).Name))
            {
                result.Add(ShaderField.Parse(item));
            }

            return result;
        }
Exemple #9
0
        public Location(System.Xml.Linq.XElement data)
        {
            this.RealName = data.Attribute("RealName").Value;
            this.Latitude = data.Attribute("Latitude").Value;
            this.Longtitude = data.Attribute("Longtitude").Value;
            this.LocationType = (TransportType)Enum.Parse(typeof(TransportType), data.Attribute("LocationType").Value);

            foreach (var x in data.Elements("Alias"))
            {
                this.aliases.Add(x.Value);
            }
        }
        public void ParseFromXElement(System.Xml.Linq.XElement source)
        {
            if (source.Name != XElementName)
                throw new Exception("Expected " + XElementName + " but got " + source.Name);

            ID = source.Element("ID").Value;
            var docs = source.Elements("Entry");
            Documents.Clear();
            foreach (var doc in docs)
            {
                dynamic prevDoc = new Document.PreviewDocument(doc.Attribute("Type").Value) { DocumentID = doc.Attribute("ID").Value };
                prevDoc.LocalizedDocumentType = doc.Attribute("LocalizedDocumentType").Value;
                Documents.Add(prevDoc);
            }
        }
        public override void loadConfig(System.Xml.Linq.XElement config)
        {
            IEnumerable<XElement> elements =
            from el in config.Elements()
            where el.Name == "render"
            select el;
           
            XElement erender = elements.First();
            VarParser.XMLrequire(erender, "render");

            if (erender.Attribute("width") != null)
                this.cWidth = (int)erender.Attribute("width");
            if (erender.Attribute("height") != null)
                this.cHeight = (int)erender.Attribute("height");
        }
        private IEnumerable<XElement> GetCustomAndDefault(params string[] nodes)
        {
            Func<XElement, IEnumerable<XElement>> filter = x =>
            {
                IEnumerable<XElement> filtered = new [] { x };
                foreach (var node in nodes)
                    filtered = filtered.Elements<XElement>(node);

                return filtered;
            };

            var defaultElements = _document.Element("config").Element("default");
            var customElements = _document.Element("config").Element("custom");

            return filter(defaultElements).Union(filter(customElements));
        }
        public override void ConfigureFromNode(System.Xml.Linq.XElement node)
        {
            base.ConfigureFromNode(node);

            var levelValue = XmlUtilities.GetEnumValueFromAttribute(node, "logLevel", SupportedLoggingLevels.Values.None);
            LogLevel = levelValue.GetAssociatedLevel();

            foreach (var child in node.Elements())
            {
                var condition = GetInstanceFromNode<AbstractCondition>(child);
                if (condition == null)
                    continue;

                if (!condition.Initialized())
                    continue;

                Conditions.Add(condition);
            }
        }
Exemple #14
0
        /// <inheritdoc/>
        public override void Load( System.Xml.Linq.XElement elem )
        {
            base.Load( elem );

            foreach( var prop in elem.Elements() )
            {
                switch( prop.Name.ToString().ToLower() )
                {
                case "credentials":
                    this.Credentials = new NetworkCredential( 
                                            (string)prop.Attribute( "UserName" ),
                                            (string)prop.Attribute( "Password" )  );
                    break;
                case "repo":
                    this.RepoName = (string)prop;
                    break;
                default:
                    break;
                }
            }

            Validate();
        }
        internal void XLRowFromXml(System.Xml.Linq.XElement iDCSys)
        {
            //check if data already exists
            for (int i = rowStart; i < rowEnd + 1; i++)
            {
                if (rowList[i].lMRedSerNum == iDCSys.Element(colMRedSerHdr).Value.Trim())
                {

                    Excel.Range rowDataRng = xlWsheet.Range["A" + i.ToString() + ":AZ" + i.ToString()];
                    object[,] rowDataObj = new object[1, rowDataRng.Count];
                    rowDataObj = rowDataRng.Value2;
                    int j = 0;
                    for (j = 0; j < iDCSys.Elements().Count(); j++)
                    {
                        if (rowDataObj[1, j + 1] != null && rowDataObj[1, j + 1].ToString() != iDCSys.Elements().ElementAt(j).Value.Trim())
                            break;
                    }
                    if (j == iDCSys.Elements().Count())
                    {
                        rowsXMLRecsIdentical++;
                        return;
                    }
                }
            }
            string colEnd = "";
            rowEnd++;   //we are extending worksheet by one row
            if (iDCSys.Elements().Count() < 26)
                colEnd = alpha[iDCSys.Elements().Count() - 2].ToString();
            else if (iDCSys.Elements().Count() < 52)
                colEnd = "A" + alpha[iDCSys.Elements().Count() - 2].ToString();     //if more than 52 cols will throw an error
            object[,] objData = new object[1, iDCSys.Elements().Count()];
            Excel.Range rngIDC = xlWsheet.Range["A" + rowEnd.ToString() + ":" + colEnd + rowEnd.ToString()];
            for (int i = 0; i < iDCSys.Elements().Count(); i++)
            {
                objData[0, i] = iDCSys.Elements().ElementAt(i).Value.Trim();
            }
            rngIDC.Value2 = objData;
            //Next update rowList
            rowList.Add(new RowData { lAssTag = iDCSys.Element(colAssTagHdr).Value.Trim(), lMfgSerNum = iDCSys.Element(colMfgSerHdr).Value.Trim(), lMRedSerNum = iDCSys.Element(colMRedSerHdr).Value.Trim() });
            rowsXMLrecsImported++;
        }
        //public AnimationFrame ToAnimationFrame(TextureAtlas textureAtlas)
        //{
        //    AnimationFrame toReturn = ToAnimationFrame(null, false);
        //    var entry = textureAtlas.GetEntryFor(this.TextureName);

        //    if (entry != null)
        //    {

        //        float left;
        //        float right;
        //        float top;
        //        float bottom;


        //        entry.FullToReduced(toReturn.LeftCoordinate, toReturn.RightCoordinate,
        //            toReturn.TopCoordinate, toReturn.BottomCoordinate,
        //            out left, out right, out top, out bottom);

        //        toReturn.LeftCoordinate = left;
        //        toReturn.RightCoordinate = right;
        //        toReturn.TopCoordinate = top;
        //        toReturn.BottomCoordinate = bottom;

        //    }

        //    return toReturn;
        //}


        internal static AnimationFrameSave FromXElement(System.Xml.Linq.XElement element)
        {
            AnimationFrameSave toReturn = new AnimationFrameSave();

                        
            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                    case "FlipHorizontal":
                        toReturn.FlipHorizontal = SceneSave.AsBool(subElement);
                        break;
                    case "FlipVertical":
                        toReturn.FlipVertical = SceneSave.AsBool(subElement);
                        break;
                    case "TextureName":
                        toReturn.TextureName = subElement.Value;
                        break;
                    case "FrameLength":
                        toReturn.FrameLength = SceneSave.AsFloat(subElement);
                        break;
                    case "LeftCoordinate":
                        toReturn.LeftCoordinate = SceneSave.AsFloat(subElement);
                        break;
                    case "RightCoordinate":
                        toReturn.RightCoordinate = SceneSave.AsFloat(subElement);
                        break;
                    case "TopCoordinate":
                        toReturn.TopCoordinate = SceneSave.AsFloat(subElement);
                        break;
                    case "BottomCoordinate":
                        toReturn.BottomCoordinate = SceneSave.AsFloat(subElement);
                        break;
                    case "RelativeX":
                        toReturn.RelativeX = SceneSave.AsFloat(subElement);
                        break;
                    case "RelativeY":
                        toReturn.RelativeY = SceneSave.AsFloat(subElement);
                        break;
                }
            }

            return toReturn;
        }
        private static void RemoveSCCElementsAttributes(System.Xml.Linq.XElement el)
        {
            el.Elements().Where( x => x.Name.LocalName.StartsWith( "Scc" ) ).Remove();
            el.Attributes().Where( x => x.Name.LocalName.StartsWith( "Scc" ) ).Remove();

            foreach( var child in el.Elements() )
            {
                RemoveSCCElementsAttributes(child);
            }
        }
        public static AnimationChainGridSave FromXElement(System.Xml.Linq.XElement element)
        {
                        
            AnimationChainGridSave acs = new AnimationChainGridSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                    case "FirstPaintedY":
                        acs.FirstPaintedY = SceneSave.AsFloat(subElement);
                        break;
                    case "ReferenceGrid":
                        acs.ReferenceGrid = ToAnimationChainReferenceArrayArray(subElement);
                        break;
                    default:
                        throw new NotImplementedException("Node not understood: " + subElement.Name.LocalName);
                }
            }

            return acs;
        }
        static FloatRectangle[][] ToFloatRectangleArrayArray(System.Xml.Linq.XElement element)
        {
            List<List<FloatRectangle>> frReferenceListList = new List<List<FloatRectangle>>();

            foreach (var subElement in element.Elements())
            {
                List<FloatRectangle> newList = new List<FloatRectangle>();

                frReferenceListList.Add(newList);
                foreach (var subSubElement in subElement.Elements())
                {
                    FloatRectangle newRectangle = ToFloatRectangle(subSubElement);
                    newList.Add(newRectangle);
                }


            }

            FloatRectangle[][] toReturn = new FloatRectangle[frReferenceListList.Count][];

            for (int i = 0; i < frReferenceListList.Count; i++)
            {
                toReturn[i] = frReferenceListList[i].ToArray();

            }

            return toReturn;
        }
        internal static DisplayRegionGridSave FromXElement(System.Xml.Linq.XElement element)
        {
            DisplayRegionGridSave drgs = new DisplayRegionGridSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                    case "ReferenceGrid":
                        drgs.ReferenceGrid = ToFloatRectangleArrayArray(subElement);

                        break;
                    case "FirstPaintedX":
                        drgs.FirstPaintedX = SceneSave.AsFloatList(subElement);
                        break;
                    case "FirstPaintedY":
                        drgs.FirstPaintedY = SceneSave.AsFloat(subElement);
                        break;
                    default:
                        throw new NotImplementedException(subElement.Name.LocalName);
                        //break;
                }
            }

            return drgs;
        }
Exemple #21
0
        public static Effect ParseEffect(System.Xml.Linq.XElement effectNode)
        {
            Effect action = entity => { };

            foreach (XElement prop in effectNode.Elements())
            {
                switch (prop.Name.LocalName)
                {
                    case "Pause":
                        action += entity =>
                        {
                            entity.GetComponent<InputComponent>().Paused = true;
                        };
                        break;

                    case "Unpause":
                        action += entity =>
                        {
                            entity.GetComponent<InputComponent>().Paused = false;
                        };
                        break;
                }
            }

            return action;
        }
        private void LoadAxisGearedInfo(System.Xml.Linq.XElement xml)
        {
            foreach (var item in xml.Elements())
            {
                ushort masterAxis = 0;

                if (item.Element("MasterAxis") != null)
                {
                    var value = item.Element("MasterAxis").Value.Trim();
                    if (ushort.TryParse(value, out masterAxis) == false)
                        continue;
                }
                else
                    continue;

                if (item.Element("SlaveAxis") != null)
                {
                    var value = item.Element("SlaveAxis").Value.Trim();
                    var geardInfos = ParseGearedInfo(value);
                    if (geardInfos.Count == 0) continue;

                    _axisGearedInfos.Add(masterAxis, geardInfos.ToArray());
                }
                else
                    continue;
            }
        }
        public void Load(System.Xml.Linq.XElement _Data)
        {
            Sequence.Load(_Data.Element("Sequence"));
            Name = _Data.Attribute("Name").Value;
            try
            {
                IPAddress = IPAddress.Parse(_Data.Attribute("IPAddress").Value);
                Port = ushort.Parse(_Data.Attribute("Port").Value);
                Reconnect();
            }
            catch { }

            foreach (XElement element in _Data.Elements("MainStation"))
            {
                FrontEndMainStation ms = new FrontEndMainStation();
                ms.Load(element);
                mainstations.Add(ms);
            }

            foreach (XElement element in _Data.Elements("WebInterface"))
            {
                FrontEndWebInterface wi = new FrontEndWebInterface(element);
                webinterfaces.Add(wi);
            }
        }
        static FloatRectangle ToFloatRectangle(System.Xml.Linq.XElement element)
        {
            FloatRectangle toReturn = new FloatRectangle();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                    case "Bottom":
                        toReturn.Bottom = SceneSave.AsFloat(subElement);
                        break;
                    case "Left":
                        toReturn.Left = SceneSave.AsFloat(subElement);
                        break;
                    case "Right":
                        toReturn.Right = SceneSave.AsFloat(subElement);
                        break;
                    case "Top":
                        toReturn.Top = SceneSave.AsFloat(subElement);
                        break;

                    default:
                        throw new NotImplementedException(subElement.Name.LocalName);
                        //break;
                }


            }


            return toReturn;

        }
        private void Transit(System.Xml.Linq.XElement expression)
        {
            if (expression == null)
            {
                return;
            }

            if (expression.Elements().Any())
            {
                foreach (var element in expression.Elements())
                {
                    Transit(element);
                }
            }
            var attirbs = from attirb in expression.Attributes()
                          where attirb.Value == typeof(DTO).FullName
                          select attirb;
            foreach (var attrib in attirbs)
            {
                attrib.Value = typeof(Entity).FullName;
                //expression.ReplaceAttributes(new XAttribute("Name", typeof(Entity).FullName));
            }
        }
Exemple #26
0
        protected override void LoadConfig(System.Xml.Linq.XElement moduleEl)
        {
            base.LoadConfig(moduleEl);

            foreach (var userEl in moduleEl.Elements("user"))
            {
                var user = new User();
                BotModule.LoadProperties(user, userEl);
                if (_userIndex.ContainsKey(user.Name))
                {
                    throw new BotConfigException(string.Format(
                        "There are multiple users with the name {0}.", user.Name));
                }
                _users.Add(user);
                _userIndex.Add(user.Name, user);
            }
        }
        private static void RemoveSCCElementsAttributes(System.Xml.Linq.XElement el)
        {
            try
            {
                el.Elements().ToList().RemoveAll(x => x.Name.LocalName.StartsWith("Scc"));

                el.Attributes().ToList().RemoveAll(x => x.Name.LocalName.StartsWith("Scc"));

                foreach (var child in el.Elements())
                {
                    RemoveSCCElementsAttributes(child);
                }
            }
            catch (Exception ex)
            {
                Log.CaptureException(ex);
            }
        }
 public void Load(System.Xml.Linq.XElement _Data)
 {
     Sequence.Load(_Data.Element("Sequence"));
     Sequence.CenterSequence();
     foreach (XElement element in _Data.Elements("Device"))
     {
         devices.Add(new MainStationDevice(element));
     }
     foreach (MainStationDevice d in devices) d.mainstation = this;
 }
 Root(System.Xml.Linq.XElement element)
 {
     this.books = new List<Book>();
     System.Collections.Generic.IEnumerator<System.Xml.Linq.XElement> iterator = element.Elements("book").GetEnumerator();
     try {
         for (
         ; iterator.MoveNext();
         ) {
             this.books.Add(new Book(iterator.Current));
         }
     }
     finally {
         iterator.Dispose();
     }
 }