本文整理汇总了C#中ObjectCollection类的典型用法代码示例。如果您正苦于以下问题:C# ObjectCollection类的具体用法?C# ObjectCollection怎么用?C# ObjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectCollection类属于命名空间,在下文中一共展示了ObjectCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ctor_ExecuteBothOverloads_MatchExpectation
public void Ctor_ExecuteBothOverloads_MatchExpectation()
{
// Use default validator
ObjectCollection<string> c = new ObjectCollection<string>();
c.Add("value1");
c.Insert(0, "value2");
Assert.Throws<ArgumentNullException>(() => { c.Add(null); });
Assert.Throws<ArgumentNullException>(() => { c[0] = null; });
Assert.Equal(2, c.Count);
Assert.Equal("value2", c[0]);
Assert.Equal("value1", c[1]);
// Use custom validator
c = new ObjectCollection<string>(item =>
{
if (item == null)
{
throw new InvalidOperationException("custom");
}
});
c.Add("value1");
c[0] = "value2";
Assert.Throws<InvalidOperationException>(() => { c.Add(null); });
Assert.Throws<InvalidOperationException>(() => { c[0] = null; });
Assert.Equal(1, c.Count);
Assert.Equal("value2", c[0]);
}
示例2: AreEqualCollections_UseSetOfNotEqualCollections_ReturnsFalse
public void AreEqualCollections_UseSetOfNotEqualCollections_ReturnsFalse()
{
ObjectCollection<NameValueHeaderValue> x = new ObjectCollection<NameValueHeaderValue>();
ObjectCollection<NameValueHeaderValue> y = new ObjectCollection<NameValueHeaderValue>();
Assert.True(HeaderUtilities.AreEqualCollections(x, y), "Expected '<empty>' == '<empty>'");
x.Add(new NameValueHeaderValue("a"));
x.Add(new NameValueHeaderValue("c"));
x.Add(new NameValueHeaderValue("b"));
x.Add(new NameValueHeaderValue("c"));
y.Add(new NameValueHeaderValue("a"));
y.Add(new NameValueHeaderValue("b"));
y.Add(new NameValueHeaderValue("c"));
y.Add(new NameValueHeaderValue("d"));
Assert.False(HeaderUtilities.AreEqualCollections(x, y));
Assert.False(HeaderUtilities.AreEqualCollections(y, x));
y.Clear();
y.Add(new NameValueHeaderValue("a"));
y.Add(new NameValueHeaderValue("b"));
y.Add(new NameValueHeaderValue("b"));
y.Add(new NameValueHeaderValue("c"));
Assert.False(HeaderUtilities.AreEqualCollections(x, y));
Assert.False(HeaderUtilities.AreEqualCollections(y, x));
}
示例3: Start
void Start()
{
objectCollection = gameObject.GetComponent<ObjectCollection>();
stateList = new Dictionary<int, State>();
AddNewState();
activeState = stateList[0];
stateNumberDisplay.text = string.Format(CURRENT_STATE_TEXT, 0);
}
示例4: ScriptingExtension
public ScriptingExtension()
{
languages = new List<IScriptEngine>();
publishedMethods = new MethodCollection();
publishedObjects = new ObjectCollection();
PublishedMethods.Added += new TalkingCollectionEventHandler<string, Delegate>(HandleNewMethod);
PublishedMethods.Removed += new TalkingCollectionEventHandler<string, Delegate>(HandleRemoveMethod);
}
示例5: Structure
protected Structure(ILocation orbiting, Corporation owner)
: base(orbiting)
{
Owner = owner;
this.ships = new ObjectCollection<Ship>(this);
this.personnel = new ObjectCollection<Agent>(this);
this.stores = new ItemCollection<IItem>();
}
示例6: State
public State(SerialState ss, ObjectCollection objectCollection)
{
stateObjects = new Dictionary<int, StateObject>();
grid = GameObject.FindGameObjectWithTag(GRID_TAG);
stateObjectButtonTemplate = (GameObject)Resources.Load(STATE_OBJECT_BUTTON_NAME);
name = ss.name;
id = ss.id;
InitializeStateObjects(ss, objectCollection);
}
示例7: CreateWithValueTypes
public virtual void CreateWithValueTypes()
{
int[] sequence = new int[] { 1, 2, 3 };
ObjectCollection collection = new ObjectCollection(sequence);
Assert.AreEqual(sequence.Length, collection.Count, "Collection should be the same size as the sequence!");
for (int i = 0; i < sequence.Length; i++)
{
Assert.AreEqual(sequence[i], collection[i], "collection[{0}] does not match sequence[{0}]!", i);
}
}
示例8: CreateWithReferenceTypes
public virtual void CreateWithReferenceTypes()
{
string[] sequence = new string[] { "Hello", "World" };
ObjectCollection collection = new ObjectCollection(sequence);
Assert.AreEqual(sequence.Length, collection.Count, "Collection should be the same size as the sequence!");
for (int i = 0; i < sequence.Length; i++)
{
Assert.AreEqual(sequence[i], collection[i], "collection[{0}] does not match sequence[{0}]!", i);
}
}
示例9: DataGridViewComboBoxCell
public DataGridViewComboBoxCell () : base() {
autoComplete = true;
dataSource = null;
displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
displayStyleForCurrentCellOnly = false;
dropDownWidth = 1;
flatStyle = FlatStyle.Standard;
items = new ObjectCollection(this);
maxDropDownItems = 8;
sorted = false;
owningColumnTemlate = null;
}
示例10: ComboBox
public ComboBox ()
{
items = new ObjectCollection (this);
DropDownStyle = ComboBoxStyle.DropDown;
item_height = FontHeight + 2;
//background_color = ThemeEngine.Current.ColorWindow;
border_style = BorderStyle.None;
drop_down_height = default_drop_down_height;
flat_style = FlatStyle.Standard;
}
示例11: PointSelector
public PointSelector()
{
markerChart.SetBinding(Panel.ZIndexProperty, new Binding("(Panel.ZIndex)") { Source = this });
// initializing built-in commands
removePointCommand = new LambdaCommand((param) => RemovePointExecute(param), RemovePointCanExecute);
changeModeCommand = new LambdaCommand((param) => ChangeModeExecute(param), ChangeModeCanExecute);
addPointCommand = new LambdaCommand((param) => AddPointExecute(param), AddPointCanExecute);
InitializeComponent();
// adding context menu binding to markers
markerChart.AddPropertyBinding(DefaultContextMenu.PlotterContextMenuProperty, data =>
{
ObjectCollection menuItems = new ObjectCollection();
MenuItem item = new MenuItem { Header = UIResources.PointSelector_RemovePoint, Command = PointSelectorCommands.RemovePoint, CommandTarget = this };
item.SetBinding(MenuItem.CommandParameterProperty, new Binding());
menuItems.Add(item);
return menuItems;
});
// loading marker template
var markerTemplate = (DataTemplate)Resources["markerTemplate"];
markerChart.MarkerBuilder = new TemplateMarkerGenerator(markerTemplate);
markerChart.ItemsSource = points;
// adding bindings to commands from PointSelectorCommands static class
CommandBinding removePointBinding = new CommandBinding(
PointSelectorCommands.RemovePoint,
RemovePointExecute,
RemovePointCanExecute
);
CommandBindings.Add(removePointBinding);
CommandBinding changeModeBinding = new CommandBinding(
PointSelectorCommands.ChangeMode,
ChangeModeExecute,
ChangeModeCanExecute);
CommandBindings.Add(changeModeBinding);
CommandBinding addPointBinding = new CommandBinding(
PointSelectorCommands.AddPoint,
AddPointExecute,
AddPointCanExecute);
CommandBindings.Add(addPointBinding);
// init add point menu item
addPointMenuItem.Click += addPointMenuItem_Click;
points.CollectionChanged += points_CollectionChanged;
}
示例12: Universe
public Universe()
{
this.syncRoot = new object();
this.factory = new ObjectFactory(this);
this.starClusters = new ObjectCollection<StarCluster>(this);
this.corporations = new ObjectCollection<Corporation>(this);
Location = this;
EventPump = new EventPump();
this.nextObjectID = 0;
EnsureObjectID();
}
示例13: GameMakerFile
public GameMakerFile()
{
Sprites = new SpriteCollection();
Sounds = new SoundCollection();
Backgrounds = new BackgroundCollection();
Paths = new PathCollection();
Scripts = new ScriptCollection();
Fonts = new FontCollection();
TimeLines = new TimeLineCollection();
Objects = new ObjectCollection();
Rooms = new RoomCollection();
Triggers = new TriggerCollection();
Includes = new IncludedFileCollection();
Constants = new ConstantCollection();
Information = new GameInformation();
Settings = new GameSettings();
ResourceTree = new ResourceTree();
}
示例14: InitializeStateObjects
private void InitializeStateObjects(SerialState serialState, ObjectCollection objectCollection)
{
foreach (SerialStateObject s in serialState.stateObjects)
{
foreach (GameObject g in objectCollection.GetUserObjects())
{
if (g.name.Equals(s.modelName))
{
GameObject toSpawn = MonoBehaviour.Instantiate(g);
StateObject stateObject = new StateObject(toSpawn);
s.InitializeStateObject(stateObject);
AddToState(stateObject);
nextStateObjectId = Mathf.Max(s.id, nextStateObjectId);
Debug.Log(id + ", " +s.id);
break;
}
}
}
nextStateObjectId++;
}
示例15: AreEqualCollections_UseSetOfEqualCollections_ReturnsTrue
public void AreEqualCollections_UseSetOfEqualCollections_ReturnsTrue()
{
ObjectCollection<NameValueHeaderValue> x = new ObjectCollection<NameValueHeaderValue>();
ObjectCollection<NameValueHeaderValue> y = new ObjectCollection<NameValueHeaderValue>();
Assert.True(HeaderUtilities.AreEqualCollections(x, y));
x.Add(new NameValueHeaderValue("a"));
x.Add(new NameValueHeaderValue("c"));
x.Add(new NameValueHeaderValue("b"));
x.Add(new NameValueHeaderValue("c"));
y.Add(new NameValueHeaderValue("c"));
y.Add(new NameValueHeaderValue("c"));
y.Add(new NameValueHeaderValue("b"));
y.Add(new NameValueHeaderValue("a"));
Assert.True(HeaderUtilities.AreEqualCollections(x, y));
Assert.True(HeaderUtilities.AreEqualCollections(y, x));
}