Advertisement
Guest User

Untitled

a guest
Feb 1st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. private T CreateOrGetType<T, U>(string contract) where T : ClientBase<U>
  2. {
  3. var Exists = ClientCache.OfType<T>().FirstOrDefault();
  4. if (Exists != null) return Exists;
  5. var obj = (T)typeof(T).GetConstructor(new[] { typeof(string) }).Invoke(new object[] { contract });
  6.  
  7. obj.ClientCredentials.UserName.UserName = System.Configuration.ConfigurationManager.AppSettings["ServiceNow_UserName"].ToString();
  8. obj.ClientCredentials.UserName.Password = System.Configuration.ConfigurationManager.AppSettings["ServiceNow_Password"].ToString();
  9. ClientCache.Add(obj);
  10. return obj;
  11. }
  12. public ServiceNow.InsertChange.ServiceNowSoapClient CHG
  13. {
  14. get
  15. {
  16. return CreateOrGetType<ServiceNow.InsertChange.ServiceNowSoapClient, ServiceNow.InsertChange.ServiceNowSoap>("sn_insertchange");
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement