本文整理汇总了C#中Resource类的典型用法代码示例。如果您正苦于以下问题:C# Resource类的具体用法?C# Resource怎么用?C# Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于命名空间,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Car
private IEnumerable<Event> Car(string name, Environment env, Resource gasStation, Container fuelPump)
{
/*
* A car arrives at the gas station for refueling.
*
* It requests one of the gas station's fuel pumps and tries to get the
* desired amount of gas from it. If the stations reservoir is
* depleted, the car has to wait for the tank truck to arrive.
*/
var fuelTankLevel = env.RandUniform(MinFuelTankLevel, MaxFuelTankLevel + 1);
env.Log("{0} arriving at gas station at {1}", name, env.Now);
using (var req = gasStation.Request()) {
var start = env.Now;
// Request one of the gas pumps
yield return req;
// Get the required amount of fuel
var litersRequired = FuelTankSize - fuelTankLevel;
yield return fuelPump.Get(litersRequired);
// The "actual" refueling process takes some time
yield return env.Timeout(TimeSpan.FromSeconds(litersRequired / RefuelingSpeed));
env.Log("{0} finished refueling in {1} seconds.", name, (env.Now - start).TotalSeconds);
}
}
示例2: NeedsExecutionFor
public override bool NeedsExecutionFor(Resource resource)
{
var rpfName = GetRpfNameFor(resource);
if (!File.Exists(rpfName))
{
return true;
}
// if not, test modification times
var requiredFiles = GetRequiredFilesFor(resource).Select(a => Path.Combine(resource.Path, a));
requiredFiles = requiredFiles.Concat(resource.ExternalFiles.Select(a => a.Value.FullName));
var modDate = requiredFiles.Select(a => File.GetLastWriteTime(a)).OrderByDescending(a => a).First();
var rpfModDate = File.GetLastWriteTime(rpfName);
if (modDate > rpfModDate)
{
return true;
}
// and get the hash of the client package to store for ourselves (yes, we do this on every load; screw big RPF files, we're reading them anyway)
var hash = Utils.GetFileSHA1String(rpfName);
resource.ClientPackageHash = hash;
return false;
}
示例3: Tile
public Tile(Resource r, Vector3 gl, Vector2 p, int chitValue)
{
resource = r;
geoLocation = gl;
position = p;
this.chitValue = chitValue;
}
示例4: DynamicFetch
public void DynamicFetch()
{
using (ISession s = OpenSession())
using (ITransaction tx = s.BeginTransaction())
{
DateTime now = DateTime.Now;
User me = new User("me");
User you = new User("you");
Resource yourClock = new Resource("clock", you);
Task task = new Task(me, "clean", yourClock, now); // :)
s.Save(me);
s.Save(you);
s.Save(yourClock);
s.Save(task);
tx.Commit();
}
using (IStatelessSession ss = sessions.OpenStatelessSession())
using (ITransaction tx = ss.BeginTransaction())
{
ss.BeginTransaction();
Task taskRef =
(Task)ss.CreateQuery("from Task t join fetch t.Resource join fetch t.User").UniqueResult();
Assert.True(taskRef != null);
Assert.True(NHibernateUtil.IsInitialized(taskRef));
Assert.True(NHibernateUtil.IsInitialized(taskRef.User));
Assert.True(NHibernateUtil.IsInitialized(taskRef.Resource));
Assert.False(NHibernateUtil.IsInitialized(taskRef.Resource.Owner));
tx.Commit();
}
cleanup();
}
示例5: ShouldMatchResourceOnKeyAndValue
public void ShouldMatchResourceOnKeyAndValue()
{
var filter = new ResourceFilter { KeyRegex = new Regex(@"Kiwi"), ValueRegex = new Regex(@"amazing kiwi") };
var resource = new Resource("This_is_my_Kiwi_resource", "What an amazing kiwi");
filter.IsMatch(resource).ShouldBeTrue();
}
示例6: run
public override Statistics run()
{
Environment env = new Environment();
//dist
List<double> valueList = new List<double>() { 1, 2, 3, 4, 5 };
List<double> distribution = new List<double>() { 0.5, 0.6, 0.7, 0.8, 1.0 };
Discrete d = new Discrete(valueList, distribution);
//dist1
Uniform n = new Uniform(1, 3);
Distribution dist = new Distribution(d);
Distribution dist1 = new Distribution(n);
Create c = new Create(env, 0, 20, dist);
Dispose di = new Dispose(env, 1);
Queue q = new Queue(env, 3);
q.Capacity = 1;
Resource r = new Resource(env, 2, 1, dist1, q);
c.Next_AID.Add("First", 2);
r.Next_AID.Add("First", 1);
env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);
env.Setup_Simulation();
return env.Simulate();
}
示例7: Label
/// <summary>
/// Initializes a new instance of the <see cref="Textbox"/> class.
/// </summary>
public Label()
{
this.Text = "";
this.font = AlmiranteEngine.Resources.LoadSync<BitmapFont>("Fonts\\Pixel16");
this.Color = Color.White;
this.Alignment = FontAlignment.Left;
}
示例8: OnInitialize
/// <summary>
/// Scene initialization
/// </summary>
protected override void OnInitialize()
{
var device = AlmiranteEngine.Device;
this.background = new Texture2D(device, 1, 1);
this.background.SetData(new Color[] { Color.FromNonPremultiplied(0, 0, 0, 255) });
this.map = AlmiranteEngine.Resources.LoadSync<Texture2D>("Objects\\Back");
this.text = new Textbox()
{
Size = new Vector2(620, 30),
Position = new Vector2(10, 720 - 40),
MaxLength = 60
};
this.text.KeyDown += OnKeyDown;
this.text.Enter += OnFocus;
this.text.Leave += OnUnfocus;
this.Interface.Controls.Add(this.text);
this.chat = new Chat()
{
Size = new Vector2(620, 620),
Position = new Vector2(10, 720 - 40 - 10 - 620),
MaxEntries = 50
};
this.Interface.Controls.Add(this.chat);
Player.Instance.Protocol.Subscribe<PlayerMessage>(this.OnMessage);
}
示例9: recieveResource
public void recieveResource(Resource resource)
{
for (int i = 0; i < spawnAmount; i++)
{
mobQueue.Enqueue(resource);
}
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Browser detection and redirecting to error page
if (Request.Browser.Browser.ToLower() == "ie" && Convert.ToDouble(Request.Browser.Version) < 7)
{
SPUtility.TransferToErrorPage("To view this report use later versions of IE 6.0");
}
else
{
try
{
string siteurl = MyUtilities.ProjectServerInstanceURL(SPContext.Current);
var Resource_Svc = new Resource()
{
AllowAutoRedirect = true,
Url = siteurl + "/_vti_bin/psi/resource.asmx",
UseDefaultCredentials = true
};
var result = MyUtilities.GetGovernanceReport(siteurl, Resource_Svc.GetCurrentUserUid());
//Repeater1.DataSource = result;
//Repeater1.DataBind();
JSONData.Text = result.Rows.Count > 0 ? MyUtilities.Serialize(result) : "";
}
catch (Exception ex)
{
MyUtilities.ErrorLog(ex.Message, EventLogEntryType.Error);
}
}
}
示例11: CloneFrom
public void CloneFrom(ResourceCollection other)
{
int e = 0, o = 0;
while (e < Resources.Count || o < other.Resources.Count) {
int oid = o;
if (e < Resources.Count) {
for (; oid < other.Resources.Count; ++oid) if (other.Resources[oid].Name == Resources[e].Name) break;
} else oid = other.Resources.Count;
if (e == Resources.Count || oid < other.Resources.Count) {
for (; o < oid; ++o) {
var otherEntity = other.Resources[o];
var myEntity = new Resource() { Name = otherEntity.Name };
myEntity.Amount = otherEntity.Amount;
Resources.Insert(e++, myEntity);
}
}
if (e < Resources.Count) {
if (oid < other.Resources.Count) {
if (oid != o) Debug.LogError("Id missmatch");
Resources[e++].Amount = other.Resources[o++].Amount;
} else {
Resources.RemoveAt(e);
}
}
}
}
示例12: WindowsAzureAddOn
/// <summary>
/// Creates new instance from AddOn
/// </summary>
/// <param name="resource">The add on details</param>
/// <param name="geoRegion">The add on region</param>
public WindowsAzureAddOn(Resource resource, string geoRegion, string cloudService)
{
Type = resource.Namespace == DataSetType ? DataType : AppServiceType;
AddOn = resource.Type;
Name = resource.Name;
Plan = resource.Plan;
SchemaVersion = resource.SchemaVersion;
ETag = resource.ETag;
State = resource.State;
UsageMeters = resource.UsageLimits.ToList();
OutputItems = (Type == AppServiceType) ? new Dictionary<string, string>(resource.OutputItems) :
new Dictionary<string, string>();
LastOperationStatus = resource.Status;
Location = geoRegion;
CloudService = cloudService;
}
示例13: Handle_ShouldReturnContentResultWithLastModified_WhenDataIsResource
public void Handle_ShouldReturnContentResultWithLastModified_WhenDataIsResource()
{
var handler = new ResourceRouteHandler();
var resource = new Resource(Resources.ResourceManager, Resources.StringResources.test);
var result = handler.Handle(null, new RouteData { Data = resource });
Assert.AreEqual(resource.LastModified, (result as ContentResult).LastModified);
}
示例14: SetResource
// Initialization
public void SetResource(Resource newResource)
{
resource = newResource;
// Update models
resourceModel.sprite = resource.MapIcon;
resourceModel.color = resource.MapIconColor;
}
示例15: Process
public ProcessingResult Process(Resource resource)
{
var eventRecorder = new EventRecorder();
this.Target = new StubTarget();
var concordionBuilder = new ConcordionBuilder()
.withEvaluatorFactory(this.EvaluatorFactory)
.withIOUtil(new IOUtil())
.withSource(this.Source)
.withTarget(this.Target)
.withAssertEqualsListener(eventRecorder)
.withThrowableListener(eventRecorder);
if (this.Fixture != null)
{
new ExtensionLoader(this.Configuration).AddExtensions(this.Fixture, concordionBuilder);
}
if (this.Extension != null)
{
this.Extension.addTo(concordionBuilder);
}
var concordion = concordionBuilder.build();
ResultSummary resultSummary = concordion.process(resource, this.Fixture);
string xml = this.Target.GetWrittenString(resource);
return new ProcessingResult(resultSummary, eventRecorder, xml);
}