C# Задаем прокси с логин паролем ( Credentials) для .NET приложения

Этот способ пробовал,работает точно


WebProxy wproxy = new WebProxy("new proxy",true);
wproxy.Credentials = new NetworkCredential("user", "pass");

WebRequest.DefaultWebProxy = wproxy;
И в конфиг

  <system.net>
    <defaultProxy
      useDefaultCredentials="true" >
    </defaultProxy>
  </system.net>

Ниже способ не пробовал но по виду должен работать

Create an assembly called SomeAssembly.dll with this class :
namespace SomeNameSpace
{
    public class MyProxy : IWebProxy
    {
        public ICredentials Credentials
        {
            get { return new NetworkCredential("user", "password"); }
            //or get { return new NetworkCredential("user", "password","domain"); }
            set { }
        }

        public Uri GetProxy(Uri destination)
        {
            return new Uri("http://my.proxy:8080");
        }

        public bool IsBypassed(Uri host)
        {
            return false;
        }
    }
}

Add this to your config file :
<defaultProxy enabled="true" useDefaultCredentials="false">
  <module type = "SomeNameSpace.MyProxy, SomeAssembly" />
</defaultProxy>

Сложность алгоритма в LINQ



MembershipUserCollection membershipUsers = new MembershipUserCollection();
users.ToList().ForEach(membershipUsers.Add); //what is the complexity of this line?
http://stackoverflow.com/questions/4008682/what-is-the-complexity-of-this-linq-example?rq=1


There are very, very few guarantees, but there are a few optimizations:
  • Extension methods that use indexed access, such as ElementAtSkipLast or LastOrDefault, will check to see whether or not the underlying type implements IList<T>, so that you get O(1) access instead of O(N).
  • The Count method checks for an ICollection implementation, so that this operation is O(1) instead of O(N).
  • DistinctGroupBy Join, and I believe also the set-aggregation methods (UnionIntersect and Except) use hashing, so they should be close to O(N) instead of O(N²).
  • Contains checks for an ICollection implementation, so it may be O(1) if the underlying collection is also O(1), such as a HashSet<T>, but this is depends on the actual data structure and is not guaranteed. Hash sets override the Contains method, that's why they are O(1).
  • OrderBy methods use a stable quicksort, so they're O(N log N) average case.
http://stackoverflow.com/questions/2799427/what-guarantees-are-there-on-the-run-time-complexity-big-o-of-linq-methods

C# Скачать файл

bool DownLoadFile()
{
  WebClient myWebClient = new WebClient();
  myWebClient.DownloadFile("http://e-trust.gosuslugi.ru/CA/DownloadTSL?schemaVersion=0", @"c:\temp\ListOfCA.xml");
  return true;
}


///с Proxy
        public static bool DownLoadFile()
        {
            WebProxy wproxy = new WebProxy("10.10.0.2:8080", true);
            wproxy.Credentials = new NetworkCredential("int", "FSinet1234","fsrar");

            WebClient myWebClient = new WebClient();
            myWebClient.Proxy = wproxy;
            myWebClient.DownloadFile("http://e-trust.gosuslugi.ru/CA/DownloadTSL?schemaVersion=0", @"\\iis2\certs\ListOfCA.xml");
            
            return true;
        }

Генерируем классы,xsd по xml и в обратную сторону

Генерируем класс по xsd
 xsd /c /language:CS XSDSchemaFile.xsd

Генерируем xsd по xml
xsd file.xml /outputdir:c:\temp\

В xsd.exe есть баг с массивами.Решение по ссылкам ниже

http://stackoverflow.com/questions/6678934/unable-to-generate-a-temporary-class-result-1-error-cs0030-cannot-convert-ty
Ниже как по мне неверный совет,но пусть лежит ссылка
http://satov.blogspot.ru/2006/12/xsdexe-generated-classes-causing.html

c# Получить и десериализовать xml по ссылке

//UpdateInfo updinfo = (UpdateInfo)DeserializeFromFile("http://mysite.ru/files/UpdateInfo.xml");
 
public static object DeserializeFromFile(string path)
{
  var serializer = new XmlSerializer(typeof(UpdateTerminalInfo));
 
  using (XmlReader reader = XmlReader.Create(path))
  {
    return serializer.Deserialize(reader);
  }
}

c# How to read/write xml data from MSSQL

//SELECT [xml_data] FROM [MyDB]
 
using (SqlDataReader reader = cmd.ExecuteReader())
{
  while (reader.Read())
  {
    var xdoc = new XmlDocument();
    xdoc.Load(reader.GetSqlXml(0).CreateReader());
  }
}

public static void InsertXML(string xmlstring)
{
            string Qry = string.Format("INSERT INTO [dbo].[my_table] ([xml_data]) values('{0}')", xmlstring);
            using (SqlConnection cnn = new SqlConnection())
            using (SqlCommand cmd = new SqlCommand(Qry, cnn))
            {
                try
                {
                    cnn.ConnectionString = "Data Source=10.10.0.10;Initial Catalog=MYDB;User ID=user;Password=pass";
                    cnn.Open();
                    cmd.ExecuteNonQuery();
                }
 
                catch (Exception ex)
                {
                    throw ex;
                }
            }
}

MVVM WPF

mouse move event command http://www.codeproject.com/Tips/478643/Mouse-Event-Commands-for-MVVM