本文整理汇总了C#中Provider类的典型用法代码示例。如果您正苦于以下问题:C# Provider类的具体用法?C# Provider怎么用?C# Provider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Provider类属于命名空间,在下文中一共展示了Provider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewModel
public ViewModel()
{
Provider = new Provider();
Messages = new ObservableCollection<Core.Message>();
ActivateCommands();
SendRequests();
}
示例2: AddProviderWithDefaultUser
public void AddProviderWithDefaultUser(Provider provider, User user)
{
using (TransactionScope scope = new TransactionScope())
{
using (var dataContext = new HealthReunionEntities())
{
if (CheckIfUserNameExists(user.UserName))
throw new Exception("User name already exist");
if(CheckIfProviderNameExists(provider.ProviderName))
throw new Exception("Provider name already exist");
// Add provider enity
dataContext.Providers.Add(provider);
// Save changes so that it will insert records into database.
dataContext.SaveChanges();
user.ProviderId = provider.ProviderId;
user.Password = EncryptDecrypt.EncryptData(user.Password, EncryptDecrypt.ReadCert());
// Add user entity
dataContext.Users.Add(user);
dataContext.SaveChanges();
// Complete the transaction if everything goes well.
scope.Complete();
}
}
}
示例3: RunParameters
public RunParameters(XmlElement e, Provider<IAgent, string> agentProvider)
{
exePath = e.SelectSingleNode("./cmd").InnerText;
workingDirectory = e.SelectSingleNode("./dir").InnerText;
parameters = e.SelectSingleNode("./args").InnerText;
agent = agentProvider(e.SelectSingleNode("./agent").InnerText);
}
示例4: Delegate_Leak_RemoveOnlyDelegate
public void Delegate_Leak_RemoveOnlyDelegate()
{
freeAll();
var memBegin = Process.GetCurrentProcess().PrivateMemorySize64;
Debug.WriteLine("Begin: " + (memBegin / 1000000));
var provider = new Provider();
var consumer = new Consumer(provider.Notify);
freeAll();
var afterCreation = Process.GetCurrentProcess().PrivateMemorySize64 - memBegin;
Debug.WriteLine("After creation (should be around 200MB): " + (afterCreation / 1000000));
provider = null;
freeAll();
var afterDispose = Process.GetCurrentProcess().PrivateMemorySize64 - memBegin;
Debug.WriteLine("After dispose (should be around 200MB): " + (afterDispose / 1000000));
consumer.RemoveDelegate();
freeAll();
var afterDispose2 = Process.GetCurrentProcess().PrivateMemorySize64 - memBegin;
Debug.WriteLine("After consumer dispose (should be around 100MB): " + (afterDispose2 / 1000000));
}
示例5: Config
public Config()
{
CollectionPaths = null;
DefinitionsCollection = new Definition[3];
ProvidersCollection = new Provider[2];
TrailerPath = "";
}
示例6: Insert
///<summary>Inserts one Provider into the database. Returns the new priKey.</summary>
internal static long Insert(Provider provider)
{
if(DataConnection.DBtype==DatabaseType.Oracle) {
provider.ProvNum=DbHelper.GetNextOracleKey("provider","ProvNum");
int loopcount=0;
while(loopcount<100){
try {
return Insert(provider,true);
}
catch(Oracle.DataAccess.Client.OracleException ex){
if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
provider.ProvNum++;
loopcount++;
}
else{
throw ex;
}
}
}
throw new ApplicationException("Insert failed. Could not generate primary key.");
}
else {
return Insert(provider,false);
}
}
示例7: AddResourceProvider
private bool AddResourceProvider(Provider provider, Dictionary<string, List<string>> locationMap)
{
if (locationMap == null || provider == null)
{
return false;
}
var providersLocations = provider.ResourceTypes
.CoalesceEnumerable()
.SelectMany(type => type.Locations)
.Distinct(StringComparer.InvariantCultureIgnoreCase);
providersLocations.ForEach(location =>
{
if (!locationMap.ContainsKey(location))
{
locationMap[location] = new List<string>();
}
if (!locationMap[location].Contains(provider.NamespaceProperty))
{
locationMap[location].Add(provider.NamespaceProperty);
}
});
return true;
}
示例8: ConvertProviders
private void ConvertProviders(Provider provider, Managed.Database.Provider newProvider)
{
newProvider.Name = provider.Name;
newProvider.Description = provider.Description;
newProvider.Web = provider.Web;
newProvider.Pinned = provider.Pinned;
foreach (var media in provider.Medias) {
var stream = new Stream { Name = media.Name, Description = media.Description, Web = media.Web, ChatEmbed = media.ChatEmbed, StreamGuid = media.StreamGuid, StreamEmbed = media.StreamEmbed, Tags = media.Tags, Size = media.Size };
foreach (var newEmbedData in media.ChatEmbedData.Select(embedData => new StreamDeskProperty { Name = embedData.Name, Value = embedData.Value }))
{
stream.ChatEmbedData.Add(newEmbedData);
}
foreach (var newEmbedData in media.StreamEmbedData.Select(embedData => new StreamDeskProperty { Name = embedData.Name, Value = embedData.Value }))
{
stream.StreamEmbedData.Add(newEmbedData);
}
newProvider.Streams.Add(stream);
}
foreach (var subProvider in provider.SubProviders)
{
var newSubProvider = new Managed.Database.Provider();
ConvertProviders(subProvider, newSubProvider);
newProvider.SubProviders.Add(newSubProvider);
}
}
示例9: FindCitiesWithRadius
public void FindCitiesWithRadius()
{
var providerCoventry = new Provider() { Name = "Coventry", Location = new Location() { Lat = 52.406822, Long = -1.519692999999961 }, Radius = 30 };
var rugby = new Location()
{
Lat = 52.370878,
Long = -1.2650320000000193
};
var warwik = new Location()
{
Lat = 52.28231599999999,
Long = -1.5849269999999933
};
var leicester = new Location(){Lat = 52.6368778,Long = -1.1397591999999577};
var london = new Location() { Lat = 51.5073509, Long = -0.12775829999998223 };
var calculator = new Calculator();
// Rugby and Warwik is closer than 30 km to Coventry
var rugby_yes = calculator.IsWithin(rugby, providerCoventry.Location, providerCoventry.Radius);
var warwik_yes = calculator.IsWithin(warwik, providerCoventry.Location, providerCoventry.Radius);
// Leicester is further away than 30 km
var leicester_no = calculator.IsWithin(leicester, providerCoventry.Location, providerCoventry.Radius);
Assert.IsTrue(rugby_yes);
Assert.IsTrue(warwik_yes);
Assert.IsFalse(leicester_no);
}
示例10: EditNodeForm
/// <summary>
/// Initializes a new instance of the <see cref="EditNodeForm"/> class.
/// </summary>
/// <param name="provider">
/// The provider.
/// </param>
/// <param name="oldVertexId">
/// The old vertex id.
/// </param>
public EditNodeForm(Provider.Provider provider, string oldVertexId)
{
this.InitializeComponent();
this.provider = provider;
this.oldVertexId = oldVertexId;
this.FillForm();
}
示例11: Instance
/// <summary>
/// 根据提供者信息,创建实现类
/// </summary>
/// <param name="dataProvider"></param>
/// <returns></returns>
public static Object Instance(Provider dataProvider)
{
if (dataProvider == null)
{
throw new Exception("Provider不存在,请确认配置文件中的节点Provider中的信息");
}
Type type = Type.GetType(dataProvider.Type);
object newObject = null;
if (type != null)
{
string connectionString = null;
string databaseOwner = null;
GetDataStoreParameters(dataProvider, out connectionString, out databaseOwner);
newObject = Activator.CreateInstance(type, connectionString, databaseOwner);
if (newObject == null)
{
throw new Exception("建立实例出错");
}
}
else
{
throw new Exception("加载类型出错");
}
return newObject;
}
示例12: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
try {
//1st save off the region
_selectedRegion.Title = txtTitle.Text.Trim();
_selectedRegion.ProviderId = int.Parse(ddlProvider.SelectedValue);
_selectedRegion.TemplateRegionId = int.Parse(ddlTemplateRegion.SelectedValue);
int sortOrder = 1;
int.TryParse(txtSortOrder.Text, out sortOrder);
_selectedRegion.SortOrder = sortOrder;
_selectedRegion.ShowTitle = chkShowTitle.Checked;
_selectedRegion.Save(WebUtility.GetUserName());
//2nd join it up with the page
int rowsAffected = new RegionController().JoinToPage(_selectedRegion.RegionId, pageId);
Provider provider = new Provider(int.Parse(ddlProvider.SelectedValue));
Response.Redirect(string.Format("~/admin/provider.aspx?pageId={0}®ionId={1}&providerId={2}", pageId, _selectedRegion.RegionId, provider.ProviderId), true);
}
catch (System.Threading.ThreadAbortException) {
throw;
}
catch(Exception ex) {
Logger.Error(typeof(region).Name, ex);
Master.MessageCenter.DisplayCriticalMessage(ex.Message);
}
}
示例13: GetSettings
public GlobalSettings GetSettings(Provider? provider)
{
var key = string.Format("GlobalSettingsFor{0}", provider);
var global = (GlobalSettings) MemoryCache.Default.Get(key);
if (global != null)
return global;
using (var session = nhibernateSessionFactory.OpenSession())
{
var settings = session.Query<Setting>().Where(x => x.Provider == provider || x.Provider == null).ToList();
ProviderSettings providerSettings = null;
if (provider.HasValue)
{
providerSettings = session.Query<ProviderSettings>().FirstOrDefault(p => p.Provider == provider);
}
global = new GlobalSettings(settings, providerSettings);
}
MemoryCache.Default.Set(key, global, DateTimeOffset.Now.AddMinutes(5));
return global;
}
示例14: Symmetric
/// <summary>
/// Instantiates a new symmetric encryption object using the specified provider.
/// </summary>
//public Symmetric(Provider provider)
//{
// this.Symmetric(provider,true);
//}
public Symmetric(Provider provider, bool useDefaultInitializationVector)
{
switch (provider)
{
case Provider.DES:
_crypto = new DESCryptoServiceProvider();
break;
case Provider.RC2:
_crypto = new RC2CryptoServiceProvider();
break;
case Provider.Rijndael:
_crypto = new RijndaelManaged();
break;
case Provider.TripleDES:
_crypto = new TripleDESCryptoServiceProvider();
break;
}
//-- make sure key and IV are always set, no matter what
Key = RandomKey();
if (useDefaultInitializationVector)
{
IntializationVector = new Data(_DefaultIntializationVector);
}
else
{
IntializationVector = RandomInitializationVector();
}
}
示例15: GetProviderHost
private static string GetProviderHost(Provider provider)
{
switch (provider)
{
default:
return "cache-aws-us-east-1";
}
}