Vonhobertdoreen's Profile

165
Points

Questions
31

Answers
52

  • Asked on July 17, 2020 in XML.

    You can try the following solution.

    Lots of minutiae string handling, but seems to be working for your case. XmlNodeType enumerator has 18 entries total. Your XML is relatively simple, that’s why the switch has just 3 node types in the code. You can use StringBuilder instead of string data type while composing a well-formed XML.

    void Main() {     const string FILENAME = @"e:\temp\NoRootFile.xml";     const string NEWFILENAME = @"e:\temp\NoRootFileFixed.xml";     string xmlString = "<root>";      XmlReaderSettings settings = new XmlReaderSettings();     settings.ConformanceLevel = ConformanceLevel.Fragment;      using (XmlReader xr = XmlReader.Create(FILENAME, settings))     {         while (xr.Read())         {             if (xr.NodeType != XmlNodeType.XmlDeclaration)             {                 switch (xr.NodeType)                 {                     case XmlNodeType.Element:                         xmlString += "<" + xr.Name + ((xr.IsEmptyElement) ? "/>" : ">");                         break;                     case XmlNodeType.Text:                         xmlString += xr.Value;                         break;                     case XmlNodeType.EndElement:                         xmlString += "</" + xr.Name + ">";                         break;                 }             }         }     }     xmlString += "</root>";      XDocument xdoc = XDocument.Parse(xmlString);     xdoc.Save(NEWFILENAME); } 
    • 324 views
    • 1 answers
    • 0 votes
  • Your navigation graph needs to have at least one destination – the start destination of your graph and the first screen users see when you inflate your graph as per the Getting Started guide.

    • 453 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    You obviously cannot change the return type of your EventHandler and doing so wouldn’t help neither. What you need to do is: set a class field or property.

    Example:

    public class Example {      private string ScriptName {get; set;} = string.Empty;      public Example()     {          // register events          Autodesk.Windows.ComponentManager.ItemExecuted += new EventHandler<Autodesk.Internal.Windows.RibbonItemExecutedEventArgs>(ItemExecutedTest);     }      void ItemExecutedTest(object sender, Autodesk.Internal.Windows.RibbonItemExecutedEventArgs e)     {          ScriptName = e.Item.Text;          // class property now contains e.Item.Text     } } 

    Heads Up: If you access UI-Items inside that handler, you need to check if you are*) on the UI Thread and possibly marshal to it.

    *) "you are" as in "if the handler is executed on the UI Thread" 😉

    • 328 views
    • 2 answers
    • 0 votes
  • Please try to visit your HTTPS address, some websites may disable HTTP connection, such as Asp.Net Core Application.
    enter image description here
    Besides, try to repair the IIS Express in the console panel.
    enter image description here
    Feel free to let me know if the problem still exists.

    • 374 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    The answer at your first code part (https://i.stack.imgur.com/ktjip.png). You create the stream in using scope and dispose it at once. To avoid it copy the content of your file into MemoryStream (do not need to be deposed) and set as source of FormFile

            IFormFile formFile;         using (var fstream = new FileStream("path", FileMode.Open))         {             var mstream = new MemoryStream();             fstream.CopyTo(mstream);             formFile = new FormFile(mstream, 0, mstream.Length, null, mstream.Name);         }         // here fstream is disposed, but not mstream, and you can use your FormFile instance         // MemoryStream does not need to be disposed explicitly, it do not posess any OS specific handlers, GC is enought. 
    • 315 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    In tgat case you have to reinstall xampp. Many times happens. When its asked, dont delete your htdocs folder. If you do not want to waste time because it installs too slowly, desactivate your antivirus while installing and then activate it again

    • 290 views
    • 1 answers
    • 0 votes
  • You can do:

    select * from t where id not in (select id from t where value is not null) 
    • 368 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Java Script.

    You don’t need Promise resolve at all, just return all objects in .then, this should work for you.

      const userObject = getUserObject({     name,     lastName,     email,     password,     phone,     emailVerified,     phoneVerified,   })    return firebase     .auth()     .createUserWithEmailAndPassword(email, password)     .then((data) =>       return db         .collection('users')         .doc(data.user.uid)         .set(userObject)         .then(() => data)     )     .then((user) => ({ user, userObject })) 
    • 329 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    long to wide

    s = df.astype(str).groupby(df['info_string'].iloc[::-1].eq('.').cumsum()).agg(' '.join) Out[178]:                      ID-0         ID-1         info_string info_string                                               1            45 56 60 62    5 8 10 15       It is sweet . 2            4 6 8 12 29  20 8 6 15 9  This is an apple . 

    wide to long

    pd.concat([s[x].str.split().explode() for x in s.columns],axis=1) Out[184]:              ID-0 ID-1 info_string info_string                       1             45    5          It 1             56    8          is 1             60   10       sweet 1             62   15           . 2              4   20        This 2              6    8          is 2              8    6          an 2             12   15       apple 2             29    9           . 
    • 308 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    If you have your python2 binary located, you can just call it directly:

    /usr/bin/python2 -m pip install googlemaps 

    And if you’re not sure where your python binary is, you can use

    import sys print(sys.executable) 

    to locate it.

    And if you don’t have pip, you should install it by downloading this file: https://bootstrap.pypa.io/get-pip.py

    then running:

    /usr/bin/python2 get-pip.py 
    • 376 views
    • 2 answers
    • 0 votes