Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

eggie5

@eggie5
About
Posts
1.4k
Topics
347
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • DateTime Format
    E eggie5

    ok

    /\ |_ E X E GG

    C# question

  • Amazon SQS REST API Date header issue
    E eggie5

    Anybody tried to use the Amazon SQS REST API with .net and ran into the Date header issue? http://developer.amazonwebservices.com/connect/thread.jspa?threadID=18758&tstart=0[^]

    /\ |_ E X E GG

    .NET (Core and Framework) json csharp com help question

  • DateTime Format
    E eggie5

    How can I get DateTime.now in this format: "Wed, 05 Apr 2006 21:12:00 GMT" ?

    /\ |_ E X E GG

    C# question

  • Process.Start
    E eggie5

    Currently, this code will return immediately after the process is started. How can I modify it so that it will not return until the process has stopped? using (Process process = new Process()) { process.StartInfo.FileName = @"C:\myprocess.exe"; process.StartInfo.Arguments = String.Format("-j {0}", path); process.Start(); }

    /\ |_ E X E GG

    C# question

  • Set XmlSerialize to ignore fields in their default value
    E eggie5

    Doesn't XmlIgnore completely ignore the field without any exception?

    /\ |_ E X E GG

    C# question xml

  • Set XmlSerialize to ignore fields in their default value
    E eggie5

    I have the below campaign class. It is serialized to xml in my code. However, I do not want it to serialize the field if it's set to it's default value. In my case, 0 and 2001-01-01T00:00:00-08:00 for int's and datetime's respectively. How can I have the XmlSerializer ignore them? Is there a global setting for the XmlSerializer class or attributes I can set for each field?

    public class campaign : RESTResource
    {
        public override String get\_endpoint\_url()
        {
            return campaign.endpoint\_url;
        }
    
        public static string endpoint\_url = "/campaigns/";
    
        public int id; //if 0; don't serialize
        public string name;
        public int category\_id; if 0; don't serialize
        public string subject; 
        public string body; 
        public string thumbnail; 
        public string notes; 
        public int ad\_id\_source; //If 0; don't serialize
        public int campaign\_status\_id; //If 0; don't serialize
        public DateTime valid\_after; //if 2001-01-01T00:00:00-08:00, don't serialize
        public int billing\_code; //If 0; don't serialize
        public DateTime created\_at; //if 2001-01-01T00:00:00-08:00, don't serialize
        public DateTime updated\_at; //if 2001-01-01T00:00:00-08:00, don't serialize
    }
    

    /\ |_ E X E GG

    C# question xml

  • Force XmlSerializer.Deserilize to ignore empty XML tags
    E eggie5

    Hi, I've just decided to impliment a support layer that removes empty nodes. This is working now and I haven't found any issues with it:

    string ct = this.HttpWebResponse.Headers["Content-Type"];
    if (ct.Contains("application/xml"))
    this.response_text = FilterOutEmptyNodes(this.response_text);
    }

        private string FilterOutEmptyNodes(string p)
        {
            //run regex to remove empty Ruby/Rails ActiveRecord nodes for C#/Asp.net compatability
            return System.Text.RegularExpressions.Regex.Replace(p, "<\[^>\]\*><\[^>\]\*>", "");
        }
    

    /\ |_ E X E GG

    C# question ruby database xml

  • Force XmlSerializer.Deserilize to ignore empty XML tags
    E eggie5

    Sorry, But I'm a little overwhelmed. Maybe you can help me more if I'm more specific. I have this XML that I'm trying to serilize into a ContentCampaign obj.: 0 serilizatoin test 4 i am subject i am body 0001-01-01T00:00:00 4 0001-01-01 0 0001-01-01T00:00:00 0001-01-01T00:00:00 It works find until a field node is empty. For example . This xml is generated from a database table and when a value is null it simple generates an empty xml node. The problem with the empty ad_id_source node is tha now, when the deserializer runs, it throws an exception. Simply, is there a way for the deserializer to ignore these empty nodes? I noticed that if a node that maps to a string is empty is just defaults to null. Can I configure the deserilizer to set any empty nodes respective type to it's default value? eg. 0 for int, 0001-01-01 for DateTimes? -- modified at 19:59 Tuesday 2nd October, 2007 /\ |_ E X E GG

    C# question ruby database xml

  • Force XmlSerializer.Deserilize to ignore empty XML tags
    E eggie5

    I'm having trouble deserilizing an xml node that has empty tags. See XML: 2007-08-24T16:15:16-07:00 this campaign has alerady been sent 1 4 complete_campaign this campaign is read to send This XML is generated from a rails web service and respresents a table in the database. When I try to deserilize this the deserlizer fails on the empty tags. How can I make the deserializer simply ignore these tags as they have no value anyways...? /\ |_ E X E GG

    C# question ruby database xml

  • simple XPATH help
    E eggie5

    All I want to do is select all the nodes under the docment root. e.g: 1 2 Traffic Alerts 1 1 News Alerts 1 3 testing category What xpath would return all the Category nodes? But I don't want it to be specific to this xml file. /\ |_ E X E GG

    XML / XSL xml testing beta-testing help question

  • Implying method return type
    E eggie5

    Thanks

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    I get a compile error on this line: T myClass = new T(); Error 1 Cannot create an instance of the variable type 'T' because it does not have the new() constraint

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    TJoe wrote:

    If Category and any possible other classes have common functionality, then you should go with an abstract base class

    Yeah, I have a few other classes... I was just using Category as an example. I'll try out what you've worked out first thing tomorrow. Thanks, Alex

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    just fixed it.

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    I have this class structure:

    public class Test
    {
      public Response Create<T1>()
      {
        string url=//How can I get Category.endpoint\_url here?
      }
    }
    
    public class Category
    {
        public static string endpoint\_url = "/categories";
        public int id;
        public string name;
        public int content\_provider\_id;
    
    } 
    

    My Category class has a static string endpoint_url. I want to get that string from inside of create using the Type T1 and save it to url. My expected results are to have url set to "/categories"

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    Thanks. I think I'm going to head in a different direction with this... Now, is this the right use of generics? Category has a static string endpoint_url. I would like to get that from T1 in the Create method.

    Create<Category>();
    .
    .
    .

    public Response Create<T1>()
    {
        string url=//How can I get Category.endpoint\_url here?
    }
    
    public class Category
    {
        public static string endpoint\_url = "/categories";
        public int id;
        public string name;
        public int content\_provider\_id;
    
    } 
    

    -- modified at 1:50 Tuesday 2nd October, 2007

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    I guess ruby got my hopes up...

    /\ |_ E X E GG

    C# question tutorial

  • Implying method return type
    E eggie5

    I have a class Categroy that derives from it's base RESTResource.

    public class Category : RESTResource
    {
    }

    public class RESTResource
    {
    public < derived type > Get()
    {
    }
    }

    The above example should evaluate to ... public Category Get() ... at runtime. Depending on the Type of the derviced class from RESTResource, how Can I set the return type of RESTResource.Get()?

    /\ |_ E X E GG

    C# question tutorial

  • Help me impliment this class structure
    E eggie5

    I have a class Category, that derives from the ServiceResource class.

    //Base class for all resources
    //Lots of these properties must be overridden by the derived class
    //Starting to think it makes more sense for this to be an interface instead...
    public class ServiceResource
    {
    
        public string endpoint\_url; //this MUST be over ridden by the derived class
        
    
        //this takes the object and saves it via API call
        public ServiceResponse Save()
        {
            string post\_params = BuildParameters(); //this should call BuildParameters in the derived class
    
            ServiceRequest request = new ServiceRequest();
    
            ServiceResponse resp = request.Send("POST", this.endpoint\_url, post\_params);
    
            return resp;
        }
    
        public string BuildParameters()
        {
            throw new Exception("You must set this in the derived class");
            //this MUST overridded by descendent class so this class can make the requests to the API endpoint
        }
    }
    

    And the Category class:

    public class Category : ServiceResource
    {
    private int id;
    private string name;

            public string BuildParameters()
            {
    
                return "I am overriding base.BuildParameters()";
            }
            
            //Override base.endpoint\_url
            public string endpoint\_url = "/categories";
    
            public int Id
            {
                get { return id; }
                set { id = value; }
            }
    
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
        }
    

    Now I would like to be able to use the Category class like this:

    Category c = new Category();
    c.Name="new category";
    c.Save();

    Now when Save is called, it will call the method BuildParameters. However, I want it to call BuildParameters in the derived class and not the base class, same with endpoint_url. At this point, base.BuildParameters is called instead. How can I do this.

    /\ |_ E X E GG

    Web Development json help question

  • Deseralize an array of objects
    E eggie5

    How can I have XmlSerializer.Deserializer deserialize an array of Category objects? Right now it'll only work on a single Category object. − 1 2 Traffic Alerts − 1 1 News Alerts − 1 3 testing category − 1 7 curl test − 1 8 sapce test

    C# question data-structures testing beta-testing announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups