Пример #1
0
 public Util(Core RennderCore)
 {
     R = RennderCore;
     Str = new Str(R);
     Xml = new Xml();
     Serializer = new Serializer(R);
 }
Пример #2
0
            public static Xml createMessage(string type)
            {
                Xml ret = new Xml("msg");
                ret.root.attribute("type").set(type);

                return ret;
            }
Пример #3
0
        static internal PipeLaunchOptions CreateFromXml(Xml.LaunchOptions.PipeLaunchOptions source)
        {
            var options = new PipeLaunchOptions(RequireAttribute(source.PipePath, "PipePath"), source.PipeArguments);
            options.InitializeCommonOptions(source);

            return options;
        }
Пример #4
0
        public static byte[] Build(Xml.FileGroupXml group, string spriteFile)
        {
            var bmps = group.Files.Select(x => new System.Drawing.Bitmap(x.Path));

            var maxWidth = bmps.Max(x => x.Width);
            var totalHeight = bmps.Sum(x => x.Height);

            int top = 0;
            using (var sprite = new System.Drawing.Bitmap(maxWidth, totalHeight))
            using (var mem = new System.IO.MemoryStream())
            using (var g = System.Drawing.Graphics.FromImage(sprite))
            {
                foreach (var bmp in bmps)
                {
                    using (bmp)
                    {
                        g.DrawImage(bmp, new System.Drawing.Rectangle(0, top, bmp.Width, bmp.Height), new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.GraphicsUnit.Pixel);
                        top += bmp.Height;
                    }
                }

                sprite.Save(mem, GetFormat(spriteFile) ?? System.Drawing.Imaging.ImageFormat.Png);
                return mem.ToArray();
            }
        }
Пример #5
0
        public NuGetDependency(Xml.NuGet.NuSpec.Dependency dependency)
            : this()
        {
            Dependency = dependency;

            _uiName.Text = Dependency.Id;
            _uiVersion.Text = Dependency.Version;
            _uiOriginalFramework.Text = Dependency.OriginalTargetFramework;
        }
Пример #6
0
 public IEnumerable<Xml.IQueryableNode> FollowingSiblings(Xml.IQueryableNode node)
 {
   var result = node.FollowingSibling();
   while (result != null)
   {
     yield return result;
     result = result.FollowingSibling();
   }
 }
Пример #7
0
        public static ReadOnlyCollection<LaunchCommand> CreateCollectionFromXml(Xml.LaunchOptions.Command[] source)
        {
            LaunchCommand[] commandArray = source?.Select(x => new LaunchCommand(x.Value, x.Description, x.IgnoreFailures)).ToArray();
            if (commandArray == null)
            {
                commandArray = new LaunchCommand[0];
            }

            return new ReadOnlyCollection<LaunchCommand>(commandArray);
        }
Пример #8
0
 internal void WriteSvg(Xml.SvgWriter w)
 {
     w.WriteStartElement("pressure");
     w.WriteAttributeString("midiChannel", _midiChannel.ToString());
     if(_inputControls != null)
     {
         _inputControls.WriteSvg(w);
     }
     w.WriteEndElement(); // trkOff
 }
Пример #9
0
 public void Xml_CData_AddsCDataNode()
 {
     var xml = new Xml();
     xml.Tag("tag", Xml.Fragment(() =>
     {
         xml.CData("content");
         xml.Tag("hello", "world");
     }));
     Assert.Equal("<tag><![CDATA[content]]><hello>world</hello></tag>", xml);
 }
Пример #10
0
	public Xml()
	{
		if (instance != null)
		{
			return;
		}
		else
		{
			instance = this;
		}
	}
Пример #11
0
        public void Initialize(Xml.XAccessor x)
        {
            string strHostType = x.GetStringValue(CLASS);
            if (string.IsNullOrEmpty(strHostType))
                ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), CLASS);
            Type hostType = Reflector.LoadType(strHostType);
            string memberName = x.GetStringValue(MEMBER);
            if (string.IsNullOrEmpty(memberName))
                ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), MEMBER);

            IReflector r = Reflector.Bind(hostType, ReflectorPolicy.TypePublic);
            _instance = r.GetPropertyOrFieldValue(memberName, false);
        }
Пример #12
0
 internal void WriteSvg(Xml.SvgWriter w)
 {
     w.WriteStartElement("pressures");
     if(_inputControls != null)
     {
         _inputControls.WriteSvg(w);
     }
     Debug.Assert(_pressures != null && _pressures.Count > 0);
     foreach(Pressure pressure in _pressures)
     {
         pressure.WriteSvg(w);
     }
     w.WriteEndElement(); // pressures
 }
Пример #13
0
 internal void WriteSvg(Xml.SvgWriter w)
 {
     w.WriteStartElement("trkOffs");
     if(_inputControls != null)
     {
         _inputControls.WriteSvg(w);
     }
     Debug.Assert(_trkOffs != null && _trkOffs.Count > 0);
     foreach(TrkOff trkOff in _trkOffs)
     {
         trkOff.WriteSvg(w);
     }
     w.WriteEndElement(); // trkOffs
 }
Пример #14
0
 /// <summary>
 /// This function only writes TrkRefs that refer to Trks stored in external VoiceDefs. 
 /// Note that successive Trks in the same VoiceDef may, in principle, contain common IUniqueDefs...
 /// SVG files contain voice definitions that contain MidiChordDefs and restDefs, but no Trks.
 /// </summary>
 /// <param name="w"></param>
 internal void WriteSvg(Xml.SvgWriter w)
 {
     w.WriteStartElement("seq");
     if(TrkOptions != null)
     {
         TrkOptions.WriteSvg(w, false);
     }
     Debug.Assert(TrkRefs != null && TrkRefs.Count > 0);
     foreach(TrkRef trkRef in TrkRefs)
     {
         trkRef.WriteSvg(w);
     }
     w.WriteEndElement(); // seq
 }
Пример #15
0
        /// <inheritdoc />
        public IEnumerable<IAnalysisLogDiff> DiffReturnValues(Xml.Value oldValue, Xml.Value newValue)
        {
            // If both values are not null...
            IEnumerable<IAnalysisLogDiff> list;
            if (oldValue != null && newValue != null)
            {
                if (!newValue.IsComparableTo(oldValue))
                {
                    var msg = string.Format(
                        "Items are incompatible for comparison! oldObject.Item.Type => {0}, newObject.Item.Type => {1}",
                        oldValue.UnderlyingType,
                        newValue.UnderlyingType);
                    throw new ArgumentException(msg);
                }

                if (newValue.IsPrimtive && oldValue.IsPrimtive && !newValue.AsPrimitive.Equals(oldValue.AsPrimitive))
                {
                    list = new IAnalysisLogDiff[]
                    {
                        new ReturnValueAnalysisLogDiff(oldValue.AsPrimitive.Value, newValue.AsPrimitive.Value, newValue.AsPrimitive.FullName)
                    };
                }
                else if (newValue.IsObject && oldValue.IsObject)
                {
                    list = this.DiffObjects(oldValue.AsObject, newValue.AsObject);
                }
                else
                {
                    // No diff.
                    list = Enumerable.Empty<IAnalysisLogDiff>();
                }
            }
            else if (oldValue == null && newValue == null)
            {
                // No diff.
                list = Enumerable.Empty<IAnalysisLogDiff>();
            }
            else
            {
                // Either the old or new value is null. Not sure what happened here--should be impossible.
                var msg = string.Format(
                    "The {0} return value was null! This indicates an analysis log file corruption. Terminating analysis!",
                    oldValue == null ? "old" : "current");
                throw new ArgumentException(msg);
            }

            return list;
        }
Пример #16
0
        protected ElementBase(Xml.ElementGroup node)
        {
            if (node.name.StartsWith("&#x"))
            {
                string[] val = node.name.Split(new[] {';'}, 2, StringSplitOptions.None);
                var c = (char) int.Parse(val[0].Substring(3), NumberStyles.HexNumber, null);
                this.name = c + val[1];
            }
            else
            {
                this.name = node.name;
            }

            this.repeat = node.repeat;
            this.optional = node.optional;
            this.desc = node.desc;
        }
Пример #17
0
    public IEnumerable<Xml.IQueryableNode> Parents(Xml.IQueryableNode node)
    {
      var curr = node;
      var result = node.Parent();
      while (result != null)
      {
        if (string.Compare(curr.Name.LocalName, "tr", StringComparison.OrdinalIgnoreCase) == 0 &&
          string.Compare(result.Name.LocalName, "table", StringComparison.OrdinalIgnoreCase) == 0)
        {
          yield return new TbodyNode(curr);
        }

        yield return result;
        curr = result;
        result = result.Parent();
      }

      var html = new HtmlNode();
      switch (curr.Name.LocalName.ToLowerInvariant())
      {
        case "html":
          // do nothing
          break;
        case "body":
        case "head":
          yield return html;
          break;
        case "title":
        case "base":
        case "link":
        case "style":
        case "meta":
        case "script":
        case "noscript":
        case "command":
          yield return new HeadNode(curr, null, html);
          yield return html;
          break;
        default:
          yield return new BodyNode(curr, null, html);
          yield return html;
          break;
      }
    }
        public NuGetDependencyGroup(Xml.NuGet.NuSpec.Group dependencyGroup)
            : this()
        {
            Group = dependencyGroup;

            _uiTargetFramework.Text = Group.TargetFramework;

            foreach (Xml.NuGet.NuSpec.Dependency dependency in dependencyGroup.Dependencies)
            {
                _uiDependencies.Items.Add(new NuGetDependency(dependency)
                {
                    OnRemoveFromDependencyGroup = OnDependencyRemovedFromGroup
                });
            }

            _uiItemsCount.Text = _uiDependencies.Items.Count.ToString();

            Refresh();
        }
 protected override bool HandleElement(Xml.XmlReader reader)
 {
     if (base.HandleElement(reader))
     {
         return true;
     } 
     else if (CanHandleElement(reader, XmlConstants.ValueAnnotation))
     {
         // EF does not support this EDM 3.0 element, so ignore it.
         SkipElement(reader);
         return true;
     }
     else if (CanHandleElement(reader, XmlConstants.TypeAnnotation))
     {
         // EF does not support this EDM 3.0 element, so ignore it.
         SkipElement(reader);
         return true;
     }
     return false;
 }
Пример #20
0
        public SubrecordStructure(Xml.Subrecord node)
            : base(node)
        {
            this.notininfo = node.notininfo;
            this.size = node.size;
            this.Condition = (!string.IsNullOrEmpty(node.condition))
                                 ? (CondType) Enum.Parse(typeof (CondType), node.condition, true)
                                 : CondType.None;
            this.CondID = node.condid;
            this.CondOperand = node.condvalue;
            this.UseHexEditor = node.usehexeditor;

            // if (optional && repeat)
            // {
            // throw new RecordXmlException("repeat and optional must both have the same value if they are non zero");
            // }

            this.elementTree = GetElementTree(node.Items).ToArray();
            this.elements = GetElementArray(elementTree).ToArray();
            this.ContainsConditionals = this.elements.Count(x => x.CondID != 0) > 0;
        }
        private void GuardarXml(Alumno al, bool condicion)
        {
            Xml <Alumno> inst = new Xml <Alumno>();

            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if (condicion)
            {
                path += "\\SegundoParcialUtn\\JardinUtn\\Serializaciones\\APROBADOS";

                path += $"\\{al.Apellido}_{al.Nombre}_{DateTime.Now.ToString("dd_MM_yyyy")}.xml";

                try
                {
                    inst.Guardar(path, al);
                }
                catch (GuardarLogsException)
                {
                    Texto.Guardar(pathLogs + "\\SegundoParcialUtn\\JardinUtn\\Logs.txt", $"El Archivo XML no fue encontrado. De todas maneras se creo el archivo y se guardaron los datos del Alumno {al.Nombre} {al.Apellido}");
                }
            }
            else
            {
                path += "\\SegundoParcialUtn\\JardinUtn\\Serializaciones\\DESAPROBADOS";

                path += $"\\{al.Apellido}_{al.Nombre}_{DateTime.Now.ToString("dd_MM_yyyy")}.xml";
                try
                {
                    inst.Guardar(path, al);
                }
                catch (GuardarLogsException)
                {
                    Texto.Guardar(pathLogs + "\\SegundoParcialUtn\\JardinUtn\\Logs.txt", $"El Archivo XML no fue encontrado. De todas maneras se creo el archivo y se guardaron los datos del Alumno {al.Nombre} {al.Apellido}");
                }
            }
        }
Пример #22
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            RpfFileEntry = entry;
            Name         = entry.Name;
            FilePath     = Name;


            if (entry.NameLower.EndsWith(".meta"))
            {
                string xml = TextUtil.GetUTF8Text(data);

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(xml);


                ResidentTxd = Xml.GetChildInnerText(xmldoc.SelectSingleNode("CVehicleModelInfo__InitDataList"), "residentTxd");

                LoadInitDatas(xmldoc);

                LoadTxdRelationships(xmldoc);

                Loaded = true;
            }
        }
        /// <summary>
        /// Retrieves the time of the XMPP entity with the specified JID.
        /// </summary>
        /// <param name="jid">The JID of the XMPP entity to retrieve the time
        /// for.</param>
        /// <returns>The time of the XMPP entity with the specified JID.</returns>
        /// <exception cref="ArgumentNullException">The jid parameter
        /// is null.</exception>
        /// <exception cref="NotSupportedException">The XMPP entity with
        /// the specified JID does not support the 'Entity Time' XMPP extension.</exception>
        /// <exception cref="XmppErrorException">The server returned an XMPP error code.
        /// Use the Error property of the XmppErrorException to obtain the specific
        /// error condition.</exception>
        /// <exception cref="XmppException">The server returned invalid data or another
        /// unspecified XMPP error occurred.</exception>
        public async Task <DateTime> GetTime(Jid jid)
        {
            jid.ThrowIfNull("jid");
            if (!await ecapa.Supports(jid, Extension.EntityTime))
            {
                throw new NotSupportedException("The XMPP entity does not support " +
                                                "the 'Entity Time' extension.");
            }
            Iq iq = await im.IqRequest(IqType.Get, jid, im.Jid,
                                       Xml.Element("time", "urn:xmpp:time"));

            if (iq.Type == IqType.Error)
            {
                throw Util.ExceptionFromError(iq, "The time could not be retrieved.");
            }
            var time = iq.Data["time"];

            if (time == null || time["tzo"] == null || time["utc"] == null)
            {
                throw new XmppException("Erroneous IQ response.");
            }
            string tzo = time["tzo"].InnerText;
            string utc = time["utc"].InnerText;

            // Try to parse utc into datetime, tzo into timespan.
            try
            {
                DateTime dt = DateTime.Parse(utc).ToUniversalTime();
                TimeSpan sp = TimeSpan.Parse(tzo.TrimStart('+'));
                return(dt.Add(sp));
            }
            catch (FormatException e)
            {
                throw new XmppException("Invalid tzo or utc value.", e);
            }
        }
Пример #24
0
        public static int Write <T>(T obj, FileType?outputType = FileType.CSV)
        {
            var queue = ObjectProcessing.ObjectQueue;

            queue.Enqueue(obj);
            int count = 0;

            while (queue.Count > 0)
            {
                count++;
                var(Name, Body) = ObjectProcessing.GetInformation(queue.Dequeue());
                switch (outputType)
                {
                case FileType.CSV:
                    Csv.WriteFile(Name, Body);
                    break;

                case FileType.Excel:
                    Excel.WriteFile(Name, Body);
                    break;

                case FileType.Json:
                    Json.WriteFile(Name, Body);
                    break;

                case FileType.XML:
                    Xml.WriteFile(Name, Body);
                    break;

                default:
                    break;
                }
                ;
            }
            return(count);
        }
Пример #25
0
    void InstantiateVideoObject(XElement info, TrackableBehaviour tb, out UnityEngine.Object asset)
    {
        asset = planePrefab;
        CustomTrackableEventHandler cte = tb.gameObject.GetComponent <CustomTrackableEventHandler> ();

        cte.videoPath = GetAssetsPath(Xml.Attribute(info, "videosrc"), true);
        GameObject obj    = InstantiateObject(tb, asset);
        bool       showBg = Xml.Boolean(info, "showbg", false);

        if (showBg)
        {
            GameObject           videoPlane = obj.GetChildByName("plane");
            Vector3              scale      = videoPlane.transform.localScale;
            ImageTargetBehaviour itg        = (ImageTargetBehaviour)tb;
            Vector3              size       = itg.GetSize();
            Logger.Log(size.ToString(), "blue");
            float imageTargetRatio = size.x / size.y;
            if (imageTargetRatio > 1)
            {
                obj.transform.localScale = new Vector3(1, 1, 1 / imageTargetRatio);
            }
            else
            {
                obj.transform.localScale = new Vector3(imageTargetRatio, 1, 1);
            }
            float ratio = Xml.Float(info, "ratio", 1);
            if (ratio > size.x / size.y)
            {
                videoPlane.transform.localScale = scale.SetZ(scale.z * size.x / size.y / ratio);
            }
            else
            {
                videoPlane.transform.localScale = scale.SetX(scale.x * size.y / size.x * ratio);
            }
        }
    }
Пример #26
0
        [Test] public void Xml_Values()
        {
            Xml xml = new Xml();

            Assert.AreEqual("", xml.DocumentContent, "V1");
            Assert.AreEqual(null, xml.Document, "V2");
            Assert.AreEqual("", xml.DocumentSource, "V3");

            Assert.AreEqual(null, xml.Transform, "V4");
            Assert.AreEqual(null, xml.TransformArgumentList, "V5");
            Assert.AreEqual("", xml.TransformSource, "V6");

            // Check that assignments to null, are mapped back into ""
            xml.DocumentContent = null;
            Assert.AreEqual("", xml.DocumentContent, "V7");

            xml.TransformSource = null;
            Assert.AreEqual("", xml.TransformSource, "V8");

            Assert.AreEqual(null, xml.Transform, "V9");
            Assert.AreEqual(false, xml.EnableTheming, "EnableTheming");
            Assert.AreEqual(String.Empty, xml.SkinID, "SkinID");
            Assert.AreEqual(null, xml.XPathNavigator, "XPathNavigator");
        }
Пример #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TvCardDVBS"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public TvCardDVBS(DsDevice device)
            : base(device)
        {
            _cardType = CardType.DvbS;

            try
            {
                _configFilesDir = PathManager.GetDataPath;
                _configFile     = _configFilesDir + "\\dish.xml";
                if (File.Exists(_configFile))
                {
                    Log.Log.WriteFile("TvCardDVBS: dish Config: loading {0}", _configFile);
                }
                else
                {
                    Log.Log.Debug("TvCardDVBS: dish Config: file not found, {0}", _configFile);
                }
                Xml xmlreader = new Xml(_configFile);
                {
                    _postDiSEqWait = xmlreader.GetValueAsInt("General", "WaitAfterDiSEqC", 10);
                    if (_postDiSEqWait < 10)
                    {
                        _postDiSEqWait = 10;
                    }
                    if (_postDiSEqWait > 30000)
                    {
                        _postDiSEqWait = 30000;
                    }
                }
                Log.Log.WriteFile("TvCardDVBS: WaitAfterDiSEqC setting {0} ms", _postDiSEqWait);
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
            }
        }
Пример #28
0
        private void _vista_UsuarioDeseaObtenerIndicesDeBodega(object sender, Argumentos.InventarioInactivoArgumento e)
        {
            try
            {
                var arg = new InventarioInactivoArgumento
                {
                    Login = InteraccionConUsuarioServicio.ObtenerUsuario()
                    ,
                    WarehouseXml = Xml.ConvertListToXml(_vista.Bodegas.Where(b => b.IS_SELECTED).ToList())
                    ,
                    ZoneXml = Xml.ConvertListToXml(new List <Zona>())
                    ,
                    MaterialXml = Xml.ConvertListToXml(_vista.Materiales.Where(m => m.IS_SELECTED).ToList())
                    ,
                    DateWarehouseIndices = e.DateWarehouseIndices
                };

                _vista.IndicesDeBodegas = IndiceBodegaServicio.ObtenerIndicesBodegas(arg);
            }
            catch (Exception ex)
            {
                InteraccionConUsuarioServicio.Mensaje(ex.Message);
            }
        }
Пример #29
0
        public void Test_Embedded4()
        {
            var resource          = Xml.Embedded("hasResourceIncludes.xml");
            var interpreter       = new XmlInterpreter(resource);
            var kernel            = new DefaultKernel();
            var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
            var processor         = new XmlProcessor(null, resourceSubSystem);
            var assemRes          = resource as AssemblyResource;

            Assert.IsNotNull(assemRes);
            var doc = new XmlDocument();

            using (var stream = resource.GetStreamReader())
            {
                doc.Load(stream);
            }
            var engine = new DefaultXmlProcessorEngine(null, resourceSubSystem);

            engine.PushResource(resource);
            Assert.AreEqual(doc.DocumentElement.InnerText, "");
            var element = processor.Process(doc.DocumentElement);

            engine.PopResource();
        }
Пример #30
0
        /// <summary>
        /// Returns an enumerable collection of blocked contacts.
        /// </summary>
        /// <returns>An enumerable collection of JIDs which are on the client's
        /// blocklist.</returns>
        /// <exception cref="NotSupportedException">The XMPP entity with
        /// the specified JID does not support the 'Blocking Command' XMPP
        /// extension.</exception>
        /// <exception cref="XmppErrorException">The server returned an XMPP error code.
        /// Use the Error property of the XmppErrorException to obtain the specific
        /// error condition.</exception>
        /// <exception cref="XmppException">The server returned invalid data or another
        /// unspecified XMPP error occurred.</exception>
        public IEnumerable <Jid> GetBlocklist()
        {
            // Probe for server support.
            if (!ecapa.Supports(im.Jid.Domain, Extension.BlockingCommand))
            {
                throw new NotSupportedException("The server does not support " +
                                                "the 'Blocking Command' extension.");
            }
            Iq iq = im.IqRequest(IqType.Get, null, im.Jid,
                                 Xml.Element("blocklist", "urn:xmpp:blocking"));

            if (iq.Type == IqType.Error)
            {
                throw Util.ExceptionFromError(iq, "The blocklist could not be retrieved.");
            }
            ISet <Jid> set  = new HashSet <Jid>();
            var        list = iq.Data["blocklist"];

            if (list == null || list.NamespaceURI != "urn:xmpp:blocking")
            {
                throw new XmppException("Erroneous server response.");
            }
            foreach (XmlElement item in list.GetElementsByTagName("item"))
            {
                try
                {
                    string jid = item.GetAttribute("jid");
                    set.Add(jid);
                }
                catch (FormatException e)
                {
                    throw new XmppException("Encountered an invalid JID.", e);
                }
            }
            return(set);
        }
Пример #31
0
        public Task LeaveRoom(Jid mucService, string roomName, string status = "")
        {
            mucService.ThrowIfNull("mucService");
            roomName.ThrowIfNullOrEmpty("roomName");

            const string ns = "http://jabber.org/protocol/muc";

            var tcs = new TaskCompletionSource <bool>();

            var roomJid = new Jid(mucService.Domain, roomName, im.Jid.Node);

            m_pendingRoomLeaves[roomJid.ToString().ToLower()] = tcs;

            XmlElement payload = null;

            if (!string.IsNullOrEmpty(status))
            {
                payload = Xml.Element("status", ns).Text(status);
            }

            im.SendPresence(new Presence(roomJid, im.Jid, PresenceType.Unavailable, null, null, payload));

            return(tcs.Task);
        }
Пример #32
0
    IEnumerator OnItemClickHandler(SelectionItem item)
    {
        string name = item.name;

        Logger.Log(name + " clicked");
        okCancelPanel.Reset();
        Enabled      = false;
        configLoader = new ConfigLoader();
        //configLoader.loadedHandler = FileLoaded;
        configLoader.progressHandler = FileProgressing;
        configLoader.okCancelPanel   = okCancelPanel;
        yield return(configLoader.LoadConfig(name + "/config.xml"));

        progressPanel.Hide();
        Enabled = true;
        if (!configLoader.forceBreak && !okCancelPanel.isCancel)
        {
            Hashtable arg = new Hashtable();
            arg.Add("type", item.type);
            arg.Add("name", name);
            arg.Add("data", Xml.GetChildByAttribute(layout.Element("items"), "title", name));
            SceneManagerExtension.LoadScene("Scan", arg);
        }
    }
Пример #33
0
        /*
         * private void UpdateCount()
         * {
         *  Regex re = new Regex("\\[\\d*\\]");
         #if DEBUG
         *  Console.WriteLine(count);
         #endif
         *  Recall_Text.Text = re.Replace(Recall_Text.Text, "["+Convert.ToString(Math.Ceiling(count / 8))+"]");
         * }
         *
         * public void ModifyRecallCount()
         * {
         *  Recall_Text.Dispatcher.Invoke(
         *      System.Windows.Threading.DispatcherPriority.Normal,
         *      new TextChanger(UpdateCount));
         * }*/


        public MainWindow()
        {
            InitializeComponent();
            //ShortCut.init_shortcut("MoRecall");
            Xml.init_xml();
            CheckUpdate.init_checkUpdate();
            init_minimize();
            if (Xml.CheckXml())
            {
                Xml.antiRElement["PortText"]      = Xml.QueryXml("PortText");
                Xml.antiRElement["PortText_Copy"] = Xml.QueryXml("PortText_Copy");
                Xml.antiRElement["QQPath"]        = Xml.QueryXml("QQPath");
                Xml.antiRElement["TIMPath"]       = Xml.QueryXml("TIMPath");
                //Xml.antiRElement["NewUser"] = Xml.QueryXml("NewUser");
                Xml.antiRElement["Mode"] = Xml.QueryXml("Mode");
                PortText.Text            = Xml.antiRElement["PortText"];
                PortText_Copy.Text       = Xml.antiRElement["PortText_Copy"];
            }
            else
            {
                Xml.CreateXml(Xml.antiRElement);
            }
            Loaded            += MainWindow_Loaded;
            this.jc.Foreground = System.Windows.Media.Brushes.Black;
            this.jc.IsEnabled  = true;
            //if (Xml.antiRElement["NewUser"] == "new")
            //{
            this.Descript_text.Content = "一个不修改文件的防撤回工具";
            // }
            //else
            //{
            //    this.Descript_text.Content = "你好新用户";
            //}

            ModeCheck();
        }
Пример #34
0
        /// <summary>
        /// Queries the XMPP entity with the JID in the specified RoomInfo for item information.
        /// </summary>
        /// <param name="room">Holds the JID of the XMPP entity to query.</param>
        /// <returns>A more detailed description of the specified room.</returns>
        private RoomInfoExtended QueryRoom(Jid room)
        {
            room.ThrowIfNull("roomInfo");
            Iq iq = im.IqRequest(IqType.Get, room, im.Jid,
                                 Xml.Element("query", MucNs.NsRequestInfo));

            if (iq.Type != IqType.Result)
            {
                throw new NotSupportedException("Could not query features: " + iq);
            }
            // Parse the result.
            var query = iq.Data["query"];

            if (query == null || query.NamespaceURI != MucNs.NsRequestInfo)
            {
                throw new NotSupportedException("Erroneous response: " + iq);
            }

            Identity id = ParseIdentity(query);
            IEnumerable <DataField> features = ParseFields(query, "feature");
            IEnumerable <DataField> fields   = ParseFields(query, "field");

            return(new RoomInfoExtended(room, id.Name, features, fields));
        }
Пример #35
0
        private string[] GetStringArray(XmlNode node, string childName, char delimiter)
        {
            var ldastr = Xml.GetChildInnerText(node, childName);
            var ldarr  = ldastr?.Split(delimiter);

            if (ldarr == null)
            {
                return(null);
            }
            getStringArrayList.Clear();
            foreach (var ldstr in ldarr)
            {
                var ldt = ldstr?.Trim();
                if (!string.IsNullOrEmpty(ldt))
                {
                    getStringArrayList.Add(ldt);
                }
            }
            if (getStringArrayList.Count == 0)
            {
                return(null);
            }
            return(getStringArrayList.ToArray());
        }
Пример #36
0
        public void ParseNode(XmlNode n)
        {
            if (n == null)
            {
                return;
            }

            if (n.Attributes.GetNamedItem("ID") != null)
            {
                Id = n.Attributes.GetNamedItem("ID").InnerText;
            }
            Prohibitions = Xml.ParseInnerText(n, "Prohibitions");
            Restrictions = Xml.ParseInnerText(n, "Restrictions");
            Observations = Xml.ParseInnerText(n, "Observations");
            CustomsForms = Xml.ParseInnerText(n, "CustomsForms");
            ExpressMail  = Xml.ParseInnerText(n, "ExpressMail");
            AreasServed  = Xml.ParseInnerText(n, "AreasServed");
            Postages.Clear();
            foreach (XmlNode n2 in n.SelectNodes("Service"))
            {
                var p = new InternationalPostage(n2);
                Postages.Add(p);
            }
        }
Пример #37
0
        /// <summary>
        /// Parse the XML nodes
        /// </summary>
        /// <param name="xmlNode">The <Condition></Condition> nodes</param>
        public void fromXml(XmlNode xmlNode)
        {
            String value;

            Xml.getAttribute(xmlNode, XmlAttributes.ID, true, out value);
            ConditionType conditionType;

            if (Enumeration.TryParse <ConditionType>(value, out conditionType))
            {
                setConditionType(conditionType);
            }
            else
            {
                throw (new Exception("Unable to convert '" + value + "' into a ConditionType" + "\n\n" + xmlNode.InnerXml));
            }
            Xml.getValue(xmlNode, true, out value);
            setValue(value);
            if (Xml.getAttribute(xmlNode, XmlAttributes.FLAGS, false, out value))
            {
                setFlag(value);
            }

            addValidations();
        }
Пример #38
0
        public override int Run(string[] remainingArguments)
        {
            var data = Common.ParseArasFeatureManifest(AmlSyncFile);

            Console.WriteLine("Extracting AML into local files...\n");

            foreach (var aml in data.AmlFragments)
            {
                Console.WriteLine($"  Loading {aml.AmlFile}...");

                // ReSharper disable once AssignNullToNotNullAttribute
                var amlFile = Path.Combine(data.LocalDirectory, aml.AmlFile);

                var doc = new XmlDocument();
                doc.Load(amlFile);

                foreach (var node in aml.Nodes)
                {
                    Xml.ExtractInnerTextToFile(doc, node.File, node.XPath);
                }
            }

            return(0);
        }
Пример #39
0
        public void Publish(string title = null, string artist = null, string track = null, int length = 0, int rating = 0, string source = null, string uri = null)
        {
            length.ThrowIfOutOfRange(0, 0x7fff);
            rating.ThrowIfOutOfRange(0, 10);
            XmlElement e = Xml.Element("tune", "http://jabber.org/protocol/tune");

            if (!string.IsNullOrEmpty(title))
            {
                e.Child(Xml.Element("title", null).Text(title));
            }
            if (!string.IsNullOrEmpty(artist))
            {
                e.Child(Xml.Element("artist", null).Text(artist));
            }
            if (!string.IsNullOrEmpty(track))
            {
                e.Child(Xml.Element("track", null).Text(track));
            }
            if (length > 0)
            {
                e.Child(Xml.Element("length", null).Text(length.ToString()));
            }
            if (rating > 0)
            {
                e.Child(Xml.Element("rating", null).Text(rating.ToString()));
            }
            if (!string.IsNullOrEmpty(source))
            {
                e.Child(Xml.Element("source", null).Text(source));
            }
            if (!string.IsNullOrEmpty(uri))
            {
                e.Child(Xml.Element("uri", null).Text(uri));
            }
            this.pep.Publish("http://jabber.org/protocol/tune", null, new XmlElement[] { e });
        }
Пример #40
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     Xml.SetValue(this.m_setupNode, "name", "COM" + ((int)this.nudPort.Value).ToString());
     Xml.SetValue(this.m_setupNode, "threshold", ((int)this.nudThreshold.Value).ToString());
     for (int i = 0; i < 8; i++)
     {
         if (this.m_typeCombos[i].SelectedItem != null)
         {
             Xml.SetValue(this.m_setupNode, "Type" + i.ToString(), this.m_typeCombos[i].SelectedItem.ToString());
         }
         else
         {
             Xml.SetValue(this.m_setupNode, "Type" + i.ToString(), string.Empty);
         }
         if (this.m_addrCombos[i].SelectedItem != null)
         {
             Xml.SetValue(this.m_setupNode, "Addr" + i.ToString(), this.m_addrCombos[i].SelectedItem.ToString());
         }
         else
         {
             Xml.SetValue(this.m_setupNode, "Addr" + i.ToString(), string.Empty);
         }
     }
 }
Пример #41
0
        private IEnumerable <S22.Xmpp.Extensions.Item> QueryItems(Jid jid)
        {
            jid.ThrowIfNull <Jid>("jid");
            Iq iq = base.im.IqRequest(IqType.Get, jid, base.im.Jid, Xml.Element("query", "http://jabber.org/protocol/disco#items"), null, -1, "");

            if (iq.Type != IqType.Result)
            {
                throw new NotSupportedException("Could not query items: " + iq);
            }
            XmlElement element = iq.Data["query"];

            if ((element == null) || (element.NamespaceURI != "http://jabber.org/protocol/disco#items"))
            {
                throw new NotSupportedException("Erroneous response: " + iq);
            }
            ISet <S22.Xmpp.Extensions.Item> set = new HashSet <S22.Xmpp.Extensions.Item>();

            foreach (XmlElement element2 in element.GetElementsByTagName("item"))
            {
                string attribute = element2.GetAttribute("jid");
                string str2      = element2.GetAttribute("node");
                string str3      = element2.GetAttribute("name");
                if (!string.IsNullOrEmpty(attribute))
                {
                    try
                    {
                        Jid jid2 = new Jid(attribute);
                        set.Add(new S22.Xmpp.Extensions.Item(jid2, string.IsNullOrEmpty(str2) ? null : str2, string.IsNullOrEmpty(str3) ? null : str3));
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }
            return(set);
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string identifica = cmbSeIdentifica.SelectedItem.ToString();
            int    edad       = Convert.ToInt32(cmbEdad.SelectedItem.ToString());

            try
            {
                Encuesta nuevaEncuesta = new Encuesta(cmbSeIdentifica.SelectedItem.ToString(),
                                                      Convert.ToInt32(cmbEdad.SelectedItem.ToString()),
                                                      cmbProvincia.SelectedItem.ToString(),
                                                      Convert.ToInt32(cmbAniosExperiencia.SelectedItem.ToString()),
                                                      Convert.ToInt32(cmbPersonalACargo.SelectedItem.ToString()),
                                                      cmbNivelEstudios.SelectedItem.ToString(),
                                                      "Completado",
                                                      cmbPuesto.SelectedItem.ToString(),
                                                      cmbJornada.SelectedItem.ToString(),
                                                      Convert.ToDouble(cmbSalarioNeto.SelectedItem.ToString()),
                                                      cmbRubro.SelectedItem.ToString(),
                                                      Convert.ToInt32(cmbRecomiendaEmpresa.SelectedItem.ToString()));

                CalculoEstadistica.listaDatosPedidos.Add(nuevaEncuesta);
                Xml auxXml = new Xml();
                auxXml.GuardarDatos(CalculoEstadistica.listaDatosPedidos);
            }
            catch (DatoInvalido ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (ValorFueraDeRangoException ex)
            {
                MessageBox.Show(ex.Message);
            }


            MessageBox.Show("Se registró la encuesta correctamente!");
        }
Пример #43
0
        public ListDefinitionLevel CreateLevel(int level, int start, NumberFormat numberFormat, ListNumberAlignment numberAlignment, int indentLeftTw, int hangingTw,
                                               string levelText, bool tentative = true, string?tplc = null)
        {
            var xml = new XElement(Namespaces.w + "lvl",
                                   new XAttribute(Namespaces.w + "ilvl", level),
                                   new XAttribute(Namespaces.w + "tentative", tentative ? 1 : 0),
                                   new XElement(Namespaces.w + "start", new XAttribute(Namespaces.w + "val", start)),
                                   new XElement(Namespaces.w + "numFmt", new XAttribute(Namespaces.w + "val", numberFormat.ToCamelCase())),
                                   new XElement(Namespaces.w + "lvlText", new XAttribute(Namespaces.w + "val", levelText)),
                                   new XElement(Namespaces.w + "lvlJc", new XAttribute(Namespaces.w + "val", numberAlignment.ToCamelCase())),
                                   new XElement(Namespaces.w + "pPr",
                                                new XElement(Namespaces.w + "ind",
                                                             new XAttribute(Namespaces.w + "left", indentLeftTw),
                                                             new XAttribute(Namespaces.w + "hanging", hangingTw)))
                                   );

            if (tplc != null)
            {
                xml.SetAttributeValue(Namespaces.w + "tplc", tplc);
            }

            Xml.Add(xml);
            return(new ListDefinitionLevel(xml));
        }
Пример #44
0
        }             // buildMapOfFrequencyBands

        /// <summary>
        /// Output configuration
        /// </summary>
        /// <param name="xmlData"></param>
        internal void SaveToXml(ref XmlNode xmlData)
        {
            Xml.SetValue(xmlData, m_xmlName_id, m_id);
            Xml.SetValue(xmlData, m_xmlName_name, Name);
            Xml.SetValue(xmlData, m_xmlName_usePeakLevels, m_usePeakLevels.ToString());
            Xml.SetValue(xmlData, m_xmlName_minBinVariableRange, m_minBinVariableRange.ToString());
            Xml.SetValue(xmlData, m_xmlName_maxBinVariableRange, m_maxBinVariableRange.ToString());
            Xml.SetValue(xmlData, m_xmlName_clearChannelsOnWrite, m_clearChannelsOnWrite.ToString());

            // output frequency settings
            XmlNode xmlFrequencyData = Xml.GetEmptyNodeAlways(xmlData, m_xmlName_mapOfFrequencyBands);

            foreach (var frequencyBand in m_mapOfFrequencyBands)
            {
                // is this frequency a member of this band?
                if (true == frequencyBand.Value.Member)
                {
                    Xml.SetNewValue(xmlFrequencyData, "Frequency", frequencyBand.Value.Name);
                }
            }             // end process frequency info

            // output channels that are part of this band
            // start a new section for the channels
            XmlNode xmlChannelData = Xml.GetEmptyNodeAlways(xmlData, m_xmlName_mapOfChannels);

            // save the data for each color organ band
            foreach (var channel in m_mapOfChannels)
            {
                // is the channel part of this band?
                if (true == channel.Value.Member)
                {
                    // save the channel ID
                    Xml.SetNewValue(xmlChannelData, "Channel", channel.Value.Id);
                } // end channel is a member of this band
            }     // end build color organ band list
        }         // SaveToXml
 public void BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, Xml.Schema.XmlSchemaSet xmlSchemas, ICollection<Xml.XmlElement> policy)
 {
     foreach (WsdlNS.ServiceDescription wsdl in wsdlDocuments)
     {
         if (wsdl != null)
         {
             foreach (WsdlNS.Binding wsdlBinding in wsdl.Bindings)
             {
                 if (wsdlBinding != null && wsdlBinding.Extensions != null)
                 {
                     WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)wsdlBinding.Extensions.Find(typeof(WsdlNS.SoapBinding));
                     if (soapBinding != null)
                     {
                         string transportUri = soapBinding.Transport;
                         if (!string.IsNullOrEmpty(transportUri) && transportUri.Equals(UdpConstants.WsdlSoapUdpTransportUri, StringComparison.Ordinal))
                         {
                             WsdlImporter.SoapInPolicyWorkaroundHelper.InsertAdHocPolicy(wsdlBinding, soapBinding.Transport, this.udpTransportUriKey);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #46
0
        public Task <JoinRoomResult> JoinRoom(Jid mucService, string roomName, string password = "")
        {
            mucService.ThrowIfNull("mucService");
            roomName.ThrowIfNull("roomName");

            const string ns = "http://jabber.org/protocol/muc";

            var tcs = new TaskCompletionSource <JoinRoomResult>();

            var roomJid = new Jid(mucService.Domain, roomName, im.Jid.Node);

            m_pendingRoomJoins[roomJid.ToString().ToLower()] = tcs;

            var payload = Xml.Element("x", ns);

            if (!string.IsNullOrEmpty(password))
            {
                payload.Child(Xml.Element("password", ns).Text(password));
            }

            im.SendPresence(new Presence(roomJid, im.Jid, PresenceType.Available, null, null, payload));

            return(tcs.Task);
        }
Пример #47
0
        private void btnLeerXML_Click(object sender, EventArgs e)
        {
            try
            {
                Xml <string> texto = new Xml <string>();
                //string nombres = "";
                if (texto.Leer(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + ".\\Ensamblados.xml", out string nombres))
                {
                    rtbArchivos.Text = nombres;
                }

                //Binario<string> binary = new Binario<string>();
                ////string nombres = "";
                //if (binary.Leer(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + ".\\Ensamblados.bin", out string nombres))
                //{
                //    rtbArchivos.Text = nombres;
                //}
            }

            catch (ArchivoException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #48
0
        /// <summary>
        /// Queries the XMPP entity with the specified JID for information.
        /// </summary>
        /// <param name="jid">The JID of the XMPP entity to query.</param>
        /// <returns>An enumerable collection of values from the Extension enumeration
        /// denoting the XMPP extensions the entity supports.</returns>
        /// <exception cref="ArgumentNullException">The jid parameter
        /// is null.</exception>
        /// <exception cref="NotSupportedException">The query could not be
        /// performed or the response was invalid.</exception>
        IEnumerable <Extension> QueryFeatures(Jid jid)
        {
            jid.ThrowIfNull("jid");
            Iq iq = im.IqRequest(IqType.Get, jid, im.Jid,
                                 Xml.Element("query", "http://jabber.org/protocol/disco#info"));

            if (iq.Type != IqType.Result)
            {
                throw new NotSupportedException("Could not query features: " + iq);
            }
            // Parse the result.
            var query = iq.Data["query"];

            if (query == null || query.NamespaceURI != "http://jabber.org/protocol/disco#info")
            {
                throw new NotSupportedException("Erroneous response: " + iq);
            }
            ISet <string> ns = new HashSet <string>();

            foreach (XmlElement e in query.GetElementsByTagName("feature"))
            {
                ns.Add(e.GetAttribute("var"));
            }
            // Go through each extension we support and see if the entity supports
            // all of the extension's namespaces.
            ISet <Extension> feats = new HashSet <Extension>();

            foreach (XmppExtension ext in im.Extensions)
            {
                if (ns.IsSupersetOf(ext.Namespaces))
                {
                    feats.Add(ext.Xep);
                }
            }
            return(feats);
        }
Пример #49
0
 public string setXml(string json)
 {
     //if (!Program.registrado) { return "falha"; }
     try
     {
         Mapa novo = new Mapa();
         novo         = JsonConvert.DeserializeObject <Mapa>(json);
         Program.mapa = novo;
         novo.salvaArquivo(novo);
         Xml xml = new Xml(novo);
         if (xml.salvaArquivo())
         {
             return("ok");
         }
         else
         {
             return("falha");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #50
0
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            Delete(dataGridView1.RowCount - 2);
            Xml xmlDeSerializer = new Xml();

            HumanTreat = xmlDeSerializer.DeSerializer(openFileDialog1.FileName, HumanTreat);
            for (int i = 0; i < HumanTreat.Count; i++)
            {
                dataGridView1.Rows.Add();
                dataGridView1[0, i].Value = HumanTreat.ElementAt(i).Firstname;//[0,i].Value.ToString();
                dataGridView1[1, i].Value = HumanTreat.ElementAt(i).Secondname;
                dataGridView1[2, i].Value = HumanTreat.ElementAt(i).Delivery;
                dataGridView1[3, i].Value = HumanTreat.ElementAt(i).Sname;
                dataGridView1[4, i].Value = HumanTreat.ElementAt(i).Product;
                dataGridView1[5, i].Value = HumanTreat.ElementAt(i).Count;
                dataGridView1[6, i].Value = HumanTreat.ElementAt(i).Comments;
                dataGridView1[7, i].Value = HumanTreat.ElementAt(i).Adres;
                dataGridView1[8, i].Value = HumanTreat.ElementAt(i).Car;
            }
        }
Пример #51
0
        /// <summary>
        /// Runs the search (hoTools SQL file, EA search or LINQ Search). It handles the exceptions.
        /// It converts wild cards of the &lt;Search Term>.
        /// - First search for SQL-File
        /// - Search the LINQ Search if LINQ is supported
        /// - If no SQL file found run EA Search
        /// </summary>
        /// <param name="searchName">EA Search name or SQL file name (uses path to find absolute path)</param>
        /// <param name="searchTerm"></param>
        /// <param name="exportToExcel"></param>
        public string SearchRun(string searchName, string searchTerm, bool exportToExcel = false)
        {
            searchName = searchName.Trim();
            if (searchName == "")
            {
                return("");
            }


            // SQL file?
            string sqlFile = _globalCfg.GetSqlFileName(searchName);

            if (sqlFile != "")

            {
                // ---------------------SQL Search----------------------------
                string sqlString = _globalCfg.ReadSqlFile(searchName);

                // run sql search
                searchTerm = UtilSql.ReplaceSqlWildCards(Repository, searchTerm, RepositoryType);
                return(SqlRun(searchName, sqlString, searchTerm, exportToExcel));
            }
            // LINQPad
            string linqPadFile = _globalCfg.GetLinqPadQueryFileName(searchName);

            if (linqPadFile != "")
            {
                LinqPad linqPad = new LinqPad(Repository, _globalCfg.LprunPath, _globalCfg.TempFolder, @"html",
                                              _globalCfg.UseLinqPadConnection)
                {
                    UseLinqPadConnections = _globalCfg.UseLinqPadConnection,
                    LinqPadConnections    = _globalCfg.LinqPadConnectionPath
                };

                Boolean result = linqPad.Run(linqPadFile, @"html", linqPad.GetArg(Repository, searchTerm));
                if (!result)
                {
                    return("");
                }

                // output target to browser
                if (_globalCfg.LinqPadOutputHtml)
                {
                    Process.Start(linqPad.TargetFile);
                }
                // HTML to DataTable
                System.Data.DataTable dtHtml = linqPad.ReadHtml();

                if (exportToExcel)
                {
                    // DataTable to Excel
                    string excelFile = Path.Combine(_globalCfg.TempFolder,
                                                    $"{Path.GetFileNameWithoutExtension(linqPadFile)}");
                    Excel.SaveTableToExcel(ref excelFile, dtHtml);
                }

                // Make EA xml
                string xml = Xml.MakeXmlFromDataTable(dtHtml);
                // Output to EA
                Repository.RunModelSearch("", "", "", xml);
                return("");
            }
            else
            {
                // EA Search
                try
                {
                    // run SQL search and display in Search Window
                    Repository.RunModelSearch(searchName, searchTerm, "", "");
                    return("");
                }
                catch (Exception e)
                {
                    MessageBox.Show($@"Can't find search!{Environment.NewLine}{Environment.NewLine}- MDG hoTools.. enabled?{Environment.NewLine}- SQL path in Settings correct?{Environment.NewLine}- LINQPad support enabled (Settings General)? :{Environment.NewLine}'{searchName}' '{searchTerm}'{Environment.NewLine}- *.sql in path '{_globalCfg.GetSqlPaths()}'{Environment.NewLine}- *.linq in path '{_globalCfg.GetLinqPaths()}'{Environment.NewLine}- EA Search{Environment.NewLine}{Environment.NewLine}Note:{Environment.NewLine}- Define path in File, Settings{Environment.NewLine}- LINQPad needs a license and has to be installed!{Environment.NewLine}{Environment.NewLine}{e}",
                                    $@"Error start search.");
                    return("");
                }
            }
        }
Пример #52
0
        protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions source)
        {
            if (this.ExePath == null)
            {
                string exePath = source.ExePath;
                if (!string.IsNullOrWhiteSpace(exePath))
                {
                    this.ExePath = exePath;
                }
            }

            if (this.TargetArchitecture == TargetArchitecture.Unknown && source.TargetArchitectureSpecified)
            {
                this.TargetArchitecture = ConvertTargetArchitectureAttribute(source.TargetArchitecture);
            }

            this.DebuggerMIMode = ConvertMIModeAttribute(source.MIMode);

            if (string.IsNullOrEmpty(this.ExeArguments))
                this.ExeArguments = source.ExeArguments;

            if (string.IsNullOrEmpty(this.WorkingDirectory))
                this.WorkingDirectory = source.WorkingDirectory;

            if (string.IsNullOrEmpty(this.VisualizerFile))
                this.VisualizerFile = source.VisualizerFile;

            this.ShowDisplayString = source.ShowDisplayString;
            this.WaitDynamicLibLoad = source.WaitDynamicLibLoad;

            this.SetupCommands = LaunchCommand.CreateCollectionFromXml(source.SetupCommands);

            if (source.CustomLaunchSetupCommands != null)
            {
                this.CustomLaunchSetupCommands = LaunchCommand.CreateCollectionFromXml(source.CustomLaunchSetupCommands);
            }

            Debug.Assert((uint)LaunchCompleteCommand.ExecRun == (uint)Xml.LaunchOptions.BaseLaunchOptionsLaunchCompleteCommand.execrun);
            Debug.Assert((uint)LaunchCompleteCommand.ExecContinue == (uint)Xml.LaunchOptions.BaseLaunchOptionsLaunchCompleteCommand.execcontinue);
            Debug.Assert((uint)LaunchCompleteCommand.None == (uint)Xml.LaunchOptions.BaseLaunchOptionsLaunchCompleteCommand.None);
            this.LaunchCompleteCommand = (LaunchCompleteCommand)source.LaunchCompleteCommand;

            string additionalSOLibSearchPath = source.AdditionalSOLibSearchPath;
            if (!string.IsNullOrEmpty(additionalSOLibSearchPath))
            {
                if (string.IsNullOrEmpty(this.AdditionalSOLibSearchPath))
                    this.AdditionalSOLibSearchPath = additionalSOLibSearchPath;
                else
                    this.AdditionalSOLibSearchPath = string.Concat(this.AdditionalSOLibSearchPath, ";", additionalSOLibSearchPath);
            }
            if (string.IsNullOrEmpty(this.AbsolutePrefixSOLibSearchPath))
                this.AbsolutePrefixSOLibSearchPath = source.AbsolutePrefixSOLibSearchPath;

            if (source.DebugChildProcessesSpecified)
            {
                this.DebugChildProcesses = source.DebugChildProcesses;
            }

            this.ProcessId = source.ProcessId;
            this.CoreDumpPath = source.CoreDumpPath;

            // Ensure that CoreDumpPath and ProcessId are not specified at the same time
            if (!String.IsNullOrEmpty(source.CoreDumpPath) && source.ProcessIdSpecified)
                throw new InvalidLaunchOptionsException(String.Format(CultureInfo.InvariantCulture, MICoreResources.Error_CannotSpecifyBoth, nameof(source.CoreDumpPath), nameof(source.ProcessId)));
        }
Пример #53
0
        static void Test9()
        {
            var user = UserX.FindAllWithCache()[0];
            Console.WriteLine(user.RoleName);
            Console.Clear();

            //var bn = new Binary();
            //bn.EnableTrace();
            var bn = new Xml();
            bn.Write(user);

            var sw = new Stopwatch();
            sw.Start();

            var buf = bn.GetBytes();
            Console.WriteLine(buf.ToHex());
            Console.WriteLine(bn.GetString());

            var ms = new MemoryStream(buf);
            //bn = new Binary();
            bn.Stream = ms;
            //bn.EnableTrace();
            var u = bn.Read<UserX>();

            foreach (var item in UserX.Meta.AllFields)
            {
                if (user[item.Name] == u[item.Name])
                    Console.WriteLine("{0} {1} <=> {2} 通过", item.Name, user[item.Name], u[item.Name]);
                else
                    Console.WriteLine("{0} {1} <=> {2} 失败", item.Name, user[item.Name], u[item.Name]);
            }

            //var hi = HardInfo.Current;
            //sw.Stop();
            //Console.WriteLine(sw.Elapsed);
            //Console.WriteLine(hi);

            //var ci = new ComputerInfo();
            //Console.WriteLine(ci);
        }
Пример #54
0
 private void InitializeServerOptions(Xml.LaunchOptions.LocalLaunchOptions source)
 {
     if (!String.IsNullOrWhiteSpace(source.DebugServer))
     {
         DebugServer = source.DebugServer;
         DebugServerArgs = source.DebugServerArgs;
         ServerStarted = source.ServerStarted;
         FilterStderr = source.FilterStderr;
         FilterStdout = source.FilterStdout;
         if (!FilterStderr && !FilterStdout)
         {
             FilterStdout = true;    // no pattern source specified, use stdout
         }
         ServerLaunchTimeout = source.ServerLaunchTimeoutSpecified ? source.ServerLaunchTimeout : DefaultLaunchTimeout;
     }
 }
Пример #55
0
        static internal LocalLaunchOptions CreateFromXml(Xml.LaunchOptions.LocalLaunchOptions source)
        {
            string miDebuggerPath = source.MIDebuggerPath;

            // If no path to the debugger was specified, look for the proper binary in the user's $PATH
            if (String.IsNullOrEmpty(miDebuggerPath))
            {
                string debuggerBinary = null;
                switch (source.MIMode)
                {
                    case Xml.LaunchOptions.MIMode.gdb:
                        debuggerBinary = "gdb";
                        break;

                    case Xml.LaunchOptions.MIMode.lldb:
                        debuggerBinary = "lldb-mi";
                        break;
                }

                if (!String.IsNullOrEmpty(debuggerBinary))
                {
                    miDebuggerPath = LocalLaunchOptions.ResolveFromPath(debuggerBinary);
                }

                if (String.IsNullOrEmpty(miDebuggerPath))
                {
                    throw new InvalidLaunchOptionsException(MICoreResources.Error_NoMiDebuggerPath);
                }
            }

            var options = new LocalLaunchOptions(
                RequireAttribute(miDebuggerPath, "MIDebuggerPath"),
                source.MIDebuggerServerAddress,
                source.Environment);
            options.InitializeCommonOptions(source);
            options.InitializeServerOptions(source);
            options._useExternalConsole = source.ExternalConsole;

            // when using local options the core dump path must check out
            if (options.IsCoreDump && !LocalLaunchOptions.CheckFilePath(options.CoreDumpPath))
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_InvalidLocalExePath, options.CoreDumpPath));

            return options;
        }
Пример #56
0
        private const int DefaultLaunchTimeout = 10 * 1000; // 10 seconds

        public LocalLaunchOptions(string MIDebuggerPath, string MIDebuggerServerAddress, Xml.LaunchOptions.EnvironmentEntry[] environmentEntries)
        {
            if (string.IsNullOrEmpty(MIDebuggerPath))
                throw new ArgumentNullException("MIDebuggerPath");

            this.MIDebuggerPath = MIDebuggerPath;
            this.MIDebuggerServerAddress = MIDebuggerServerAddress;

            List<EnvironmentEntry> environmentList = new List<EnvironmentEntry>();
            if (environmentEntries != null)
            {
                foreach (Xml.LaunchOptions.EnvironmentEntry xmlEntry in environmentEntries)
                {
                    environmentList.Add(new EnvironmentEntry(xmlEntry));
                }
            }

            this.Environment = new ReadOnlyCollection<EnvironmentEntry>(environmentList);
        }
Пример #57
0
 public EnvironmentEntry(Xml.LaunchOptions.EnvironmentEntry xmlEntry)
 {
     this.Name = xmlEntry.Name;
     this.Value = xmlEntry.Value;
 }
Пример #58
0
        static internal TcpLaunchOptions CreateFromXml(Xml.LaunchOptions.TcpLaunchOptions source)
        {
            var options = new TcpLaunchOptions(RequireAttribute(source.Hostname, "Hostname"), LaunchOptions.RequirePortAttribute(source.Port, "Port"), source.Secure);
            options.InitializeCommonOptions(source);

            return options;
        }
Пример #59
0
 public static MIMode ConvertMIModeAttribute(Xml.LaunchOptions.MIMode source)
 {
     Debug.Assert((uint)MIMode.Gdb == (uint)Xml.LaunchOptions.MIMode.gdb, "Enum values don't line up!");
     Debug.Assert((uint)MIMode.Lldb == (uint)Xml.LaunchOptions.MIMode.lldb, "Enum values don't line up!");
     Debug.Assert((uint)MIMode.Clrdbg == (uint)Xml.LaunchOptions.MIMode.clrdbg, "Enum values don't line up!");
     return (MIMode)source;
 }
Пример #60
0
        public static TargetArchitecture ConvertTargetArchitectureAttribute(Xml.LaunchOptions.TargetArchitecture source)
        {
            switch (source)
            {
                case Xml.LaunchOptions.TargetArchitecture.X86:
                case Xml.LaunchOptions.TargetArchitecture.x86:
                    return TargetArchitecture.X86;

                case Xml.LaunchOptions.TargetArchitecture.arm:
                case Xml.LaunchOptions.TargetArchitecture.ARM:
                    return TargetArchitecture.ARM;

                case Xml.LaunchOptions.TargetArchitecture.mips:
                case Xml.LaunchOptions.TargetArchitecture.MIPS:
                    return TargetArchitecture.Mips;

                case Xml.LaunchOptions.TargetArchitecture.x64:
                case Xml.LaunchOptions.TargetArchitecture.amd64:
                case Xml.LaunchOptions.TargetArchitecture.x86_64:
                case Xml.LaunchOptions.TargetArchitecture.X64:
                case Xml.LaunchOptions.TargetArchitecture.AMD64:
                case Xml.LaunchOptions.TargetArchitecture.X86_64:
                    return TargetArchitecture.X64;

                case Xml.LaunchOptions.TargetArchitecture.arm64:
                case Xml.LaunchOptions.TargetArchitecture.ARM64:
                    return TargetArchitecture.ARM64;

                default:
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_UnknownTargetArchitecture, source.ToString()));
            }
        }