本文整理汇总了C#中Placement类的典型用法代码示例。如果您正苦于以下问题:C# Placement类的具体用法?C# Placement怎么用?C# Placement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Placement类属于命名空间,在下文中一共展示了Placement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDataWithBackupServer
//[TestCase(false)]
public void CreateDataWithBackupServer(bool useServerSession)
{
int loops = 30000;
UInt16 objectsPerPage = 300;
UInt16 pagesPerDatabase = 65000;
int j;
if (Directory.Exists(backupDir))
Directory.Delete(backupDir, true); // remove systemDir from prior runs and all its databases.
Directory.CreateDirectory(backupDir);
using (SessionBase session = useServerSession ? (SessionBase)new ServerClientSession(systemDir) : (SessionBase)new SessionNoServer(systemDir))
{
Placement place = new Placement(11, 1, 1, objectsPerPage, pagesPerDatabase);
Man aMan = null;
Woman aWoman = null;
const bool isBackupLocation = true;
session.BeginUpdate();
// we need to have backup locations special since server is not supposed to do encryption or compression
DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, isBackupLocation, session.DatabaseLocations.Default());
session.NewLocation(backupLocation);
for (j = 1; j <= loops; j++)
{
aMan = new Man(null, aMan, DateTime.Now);
aMan.Persist(place, session);
aWoman = new Woman(aMan, aWoman);
aWoman.Persist(place, session);
aMan.m_spouse = new WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
if (j % 1000000 == 0)
Console.WriteLine("Loop # " + j);
}
UInt64 id = aWoman.Id;
Console.WriteLine("Commit, done Loop # " + j);
session.Commit();
}
}
示例2: hashCodeComparerStringTest
public void hashCodeComparerStringTest()
{
Oid id;
using (SessionNoServer session = new SessionNoServer(systemDir))
{
Placement place = new Placement(223, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
session.Compact();
session.BeginUpdate();
HashCodeComparer<string> hashCodeComparer = new HashCodeComparer<string>();
BTreeSet<string> bTree = new BTreeSet<string>(hashCodeComparer, session);
bTree.Persist(place, session);
id = bTree.Oid;
for (int i = 0; i < 100000; i++)
{
bTree.Add(i.ToString());
}
session.Commit();
}
using (SessionNoServer session = new SessionNoServer(systemDir))
{
session.BeginRead();
BTreeSet<string> bTree= (BTreeSet<string>)session.Open(id);
int count = 0;
foreach (string str in bTree)
{
count++;
}
Assert.True(100000 == count);
session.Commit();
}
}
示例3: schemaUpdateMultipleSessions
public void schemaUpdateMultipleSessions()
{
using (ServerClientSession session = new ServerClientSession(systemDir))
{
session.BeginUpdate();
Placement place = new Placement(555, 1, 1, 10, 10);
Simple1 s1 = new Simple1(1);
s1.Persist(place, session);
s1 = null;
using (ServerClientSession session2 = new ServerClientSession(systemDir))
{
Placement place2 = new Placement(556, 1, 1, 10, 10);
session2.BeginUpdate();
Simple2 s2 = new Simple2(2);
s2.Persist(place2, session2);
s2 = null;
session.Commit();
session2.Commit(); // optemistic locking will fail due to session2 working with a stale schema (not the one updated by session 1)
session.BeginUpdate();
s1 = (Simple1)session.Open(555, 1, 1, false);
s2 = (Simple2)session.Open(556, 1, 1, false);
session.Commit();
session2.BeginUpdate();
s1 = (Simple1)session2.Open(555, 1, 1, false);
s2 = (Simple2)session2.Open(556, 1, 1, false);
session2.Commit();
}
}
}
示例4: aaaFakeLicenseDatabase
public void aaaFakeLicenseDatabase()
{
Assert.Throws<NoValidVelocityDBLicenseFoundException>(() =>
{
using (SessionNoServer session = new SessionNoServer(systemDir))
{
session.BeginUpdate();
Database database;
License license = new License("Mats", 1, null, null, null, 99999, DateTime.MaxValue, 9999, 99, 9999);
Placement placer = new Placement(License.PlaceInDatabase, 1, 1, 1);
license.Persist(placer, session);
for (uint i = 10; i < 20; i++)
{
database = session.NewDatabase(i);
Assert.NotNull(database);
}
session.Commit();
File.Copy(Path.Combine(systemDir, "20.odb"), Path.Combine(systemDir, "4.odb"));
session.BeginUpdate();
for (uint i = 21; i < 30; i++)
{
database = session.NewDatabase(i);
Assert.NotNull(database);
}
session.RegisterClass(typeof(VelocityDbSchema.Samples.Sample1.Person));
Graph g = new Graph(session);
session.Persist(g);
session.Commit();
}
});
}
示例5: TestCreatePlacements
public void TestCreatePlacements() {
TestUtils utils = new TestUtils();
Placement placement1 = new Placement();
placement1.name = string.Format("Medium Square AdUnit Placement #{0}", utils.GetTimeStamp());
placement1.description = "Contains ad units that can hold creatives of size 300x250";
placement1.targetedAdUnitIds = new string[] {adUnit1.id, adUnit2.id};
Placement placement2 = new Placement();
placement2.name = string.Format("Medium Square AdUnit Placement #{0}", utils.GetTimeStamp());
placement2.description = "Contains ad units that can hold creatives of size 300x250";
placement2.targetedAdUnitIds = new string[] {adUnit1.id, adUnit2.id};
Placement[] newPlacements = null;
Assert.DoesNotThrow(delegate() {
newPlacements = placementService.createPlacements(new Placement[] {placement1, placement2});
});
Assert.NotNull(newPlacements);
Assert.AreEqual(newPlacements.Length, 2);
Assert.NotNull(newPlacements[0]);
Assert.AreEqual(newPlacements[0].name, placement1.name);
Assert.AreEqual(newPlacements[0].description, placement1.description);
Assert.Contains(adUnit1.id, newPlacements[0].targetedAdUnitIds);
Assert.Contains(adUnit2.id, newPlacements[0].targetedAdUnitIds);
Assert.NotNull(newPlacements[1]);
Assert.AreEqual(newPlacements[1].name, placement2.name);
Assert.AreEqual(newPlacements[1].description, placement2.description);
Assert.Contains(adUnit1.id, newPlacements[1].targetedAdUnitIds);
Assert.Contains(adUnit2.id, newPlacements[1].targetedAdUnitIds);
}
示例6: Init
public void Init() {
TestUtils utils = new TestUtils();
placementService = (PlacementService) user.GetService(DfpService.v201511.PlacementService);
adUnit1 = utils.CreateAdUnit(user);
adUnit2 = utils.CreateAdUnit(user);
placement = utils.CreatePlacement(user, new string[] {adUnit1.id, adUnit2.id});
}
示例7: MainWindow
public MainWindow()
{
InitializeComponent();
if (Directory.Exists(systemDir))
Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
try
{
session = new SessionBase[4];
thread = new Thread[4];
session[0] = new SessionNoServer(systemDir, int.Parse(session1LockTimeout.Text));
session[1] = new SessionNoServer(systemDir, int.Parse(session2LockTimeout.Text));
session[2] = new SessionNoServer(systemDir, int.Parse(session3LockTimeout.Text));
session[3] = new SessionNoServer(systemDir, int.Parse(session4LockTimeout.Text));
session[0].BeginUpdate();
Placement place = new Placement(10);
Number number = new Number();
session[0].Persist(place, number);
number = new Number(2);
place = new Placement(11);
session[0].Persist(place, number);
number = new Number(3);
place = new Placement(12);
session[0].Persist(place, number);
session[0].Commit();
}
catch (Exception ex)
{
session1messages.Content = ex.Message;
}
}
示例8: UpdateTowerGUI
public void UpdateTowerGUI(Placement selectedTower = null)
{
Color col;
float blorbAmount = BlorbManager.Instance.BlorbAmount;
Placement[] placements = GUIManager.instance.towers.gameObject.GetComponentsInChildren<Placement>();
foreach (Placement placement in placements)
{
if (placement.cost > blorbAmount) {
col = new Color(0.3f, 0f, 0f);
}
else if (placement == selectedTower) {
continue;
}
else {
col = new Color(1f, 1f, 1f);
}
placement.GetComponent<SpriteRenderer>().color = col;
placement.transform.parent.GetComponent<SpriteRenderer>().color = col;
}
// add health button
if (blorbAmount < AddHealthButton.cost || Center.Instance.health > 90f) {
addHealthButton.GetComponent<SpriteRenderer>().color = new Color(0.3f, 0f, 0f);
} else {
addHealthButton.GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f);
}
}
示例9: Equipment
public Equipment(string _name, int a, int d, Placement p, PlayerCharacter pc, string desc)
: base(_name, pc, desc)
{
addAtk = a;
addDef = d;
part = p;
description = desc;
}
示例10: MonsterGroup
/// <summary>
/// Creates new monster group.
/// </summary>
/// <param name="name"></param>
/// <param name="puzzle"></param>
/// <param name="place"></param>
/// <param name="spawnPosition"></param>
public MonsterGroup(string name, Puzzle puzzle, PuzzlePlace place, Placement spawnPosition = Placement.Random)
{
_monsters = new List<NPC>();
this.Name = name;
this.Puzzle = puzzle;
this.Place = place;
_spawnPosition = spawnPosition;
}
示例11: Run
/// <summary>
/// Runs the code example.
/// </summary>
/// <param name="user">The AdWords user.</param>
/// <param name="adGroupId">Id of the ad group to which placements are added.
/// </param>
public void Run(AdWordsUser user, long adGroupId) {
// Get the AdGroupCriterionService.
AdGroupCriterionService adGroupCriterionService =
(AdGroupCriterionService) user.GetService(AdWordsService.v201509.AdGroupCriterionService);
// Create the placement.
Placement placement1 = new Placement();
placement1.url = "http://mars.google.com";
// Create biddable ad group criterion.
AdGroupCriterion placementCriterion1 = new BiddableAdGroupCriterion();
placementCriterion1.adGroupId = adGroupId;
placementCriterion1.criterion = placement1;
// Create the placement.
Placement placement2 = new Placement();
placement2.url = "http://venus.google.com";
// Create biddable ad group criterion.
AdGroupCriterion placementCriterion2 = new BiddableAdGroupCriterion();
placementCriterion2.adGroupId = adGroupId;
placementCriterion2.criterion = placement2;
// Create the operations.
AdGroupCriterionOperation placementOperation1 = new AdGroupCriterionOperation();
[email protected] = Operator.ADD;
placementOperation1.operand = placementCriterion1;
AdGroupCriterionOperation placementOperation2 = new AdGroupCriterionOperation();
[email protected] = Operator.ADD;
placementOperation2.operand = placementCriterion2;
try {
// Create the placements.
AdGroupCriterionReturnValue retVal = adGroupCriterionService.mutate(
new AdGroupCriterionOperation[] {placementOperation1, placementOperation2});
// Display the results.
if (retVal != null && retVal.value != null) {
foreach (AdGroupCriterion adGroupCriterion in retVal.value) {
// If you are adding multiple type of criteria, then you may need to
// check for
//
// if (adGroupCriterion is Placement) { ... }
//
// to identify the criterion type.
Console.WriteLine("Placement with ad group id = '{0}, placement id = '{1}, url = " +
"'{2}' was created.", adGroupCriterion.adGroupId,
adGroupCriterion.criterion.id, (adGroupCriterion.criterion as Placement).url);
}
} else {
Console.WriteLine("No placements were added.");
}
} catch (Exception e) {
throw new System.ApplicationException("Failed to create placements.", e);
}
}
示例12: Legend
/// <summary>
/// Default constructor.
/// </summary>
public Legend()
{
xAttach_ = PlotSurface2D.XAxisPosition.Top;
yAttach_ = PlotSurface2D.YAxisPosition.Right;
xOffset_ = 10;
yOffset_ = 1;
verticalEdgePlacement_ = Placement.Outside;
horizontalEdgePlacement_ = Placement.Inside;
neverShiftAxes_ = false;
}
示例13: OnPanelClick
protected override void OnPanelClick (Gdk.EventButton e, Placement placement)
{
if (e.TriggersContextMenu ()) {
CommandEntrySet opset = new CommandEntrySet ();
opset.AddItem (CommandSystemCommands.ToolbarList);
Gtk.Menu menu = manager.CreateMenu (opset);
menu.Popup (null, null, null, 0, e.Time);
}
base.OnPanelClick (e, placement);
}
示例14: TileInfo
/// <summary>
/// Constructor containing info for unpinning a tile.
/// </summary>
/// <param name="tileId">The Id of the tile to pin.</param>
/// <param name="anchorElement">The anchor element that the pin request dialog will display next to.</param>
/// <param name="requestPlacement">The Placement value that tells where the pin request dialog displays in relation to anchorElement.</param>
public TileInfo(
string tileId,
Windows.UI.Xaml.FrameworkElement anchorElement,
Placement requestPlacement)
{
this.TileId = tileId;
this.AnchorElement = anchorElement;
this.RequestPlacement = requestPlacement;
}
示例15: OnTapped
protected override void OnTapped(TappedRoutedEventArgs e)
{
base.OnTapped(e);
if (this.ContextMenu != null)
{
this.ContextMenu.PlacementTarget = this;
this.ContextMenu.Placement = this.Placement;
this.ContextMenu.DataContext = this.DataContext;
this.ContextMenu.IsOpen = true;
}
}