本文整理汇总了C#中Map.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Map.Add方法的具体用法?C# Map.Add怎么用?C# Map.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Map<int, string> test = new Map<int, string>();
test.Add(2, "ne sum az");
test.Add(1, "az de ");
test.Add(3, "ne sum az");
test.Add(4, "az de ");
test.Add(5, "test");
test[6] = "ivan";
}
示例2: Execute
//- @OnInitProcessorExecute -//
public override InitProcessor Execute()
{
if (ParameterArray != null && ParameterArray.Length > 0)
{
Boolean forcePassThrough = false;
foreach (Object item in ParameterArray)
{
var value = item as String;
if (!String.IsNullOrEmpty(value))
{
String[] partArray = value.Split(',');
SelectorType type = SelectorType.Contains;
String criteria = String.Empty;
if (partArray.Length == 2)
{
try
{
type = (SelectorType)Enum.Parse(typeof(SelectorType), partArray[0].Trim());
}
catch
{
if (WebProcessingReportController.Reporter.Initialized)
{
var map = new Map();
map.Add("Section", "PassThrough");
map.Add("Message", "Invalid selector type");
map.Add("Selector Type", partArray[0].Trim());
//+
WebProcessingReportController.Reporter.AddMap(map);
}
continue;
}
criteria = partArray[1].Trim().ToLower(CultureInfo.CurrentCulture);
}
else if (partArray.Length == 1)
{
criteria = partArray[0].Trim().ToLower(CultureInfo.CurrentCulture);
}
else
{
return null;
}
//+
forcePassThrough = PathMatcher.Match(type, criteria) ? true : forcePassThrough;
}
}
//+
if (forcePassThrough)
{
PassThroughHttpHandler.ForceUse = true;
}
}
//+
return null;
}
示例3: Create_bi_directional_dictionary
public void Create_bi_directional_dictionary()
{
var m = new Map<string, int>(3);
m.Add("rajiv",1);
m.Add("thota", 2);
m.Add("fullname",3);
Assert.AreEqual(m.Reverse[1], "rajiv");
Assert.AreEqual(m.Reverse[2], "thota");
Assert.AreEqual(m.Forward["fullname"], 3);
//Assert.Throws<System.Collections.Generic.KeyNotFoundException>(() => m.Reverse[5]);
}
示例4: setUp
public void setUp()
{
Map<List<Percept>, Action> perceptSequenceActions = new Map<List<Percept>, Action>();
perceptSequenceActions.Add(createPerceptSequence(new DynamicPercept(
"key1", "value1")), ACTION_1);
perceptSequenceActions.Add(createPerceptSequence(new DynamicPercept(
"key1", "value1"), new DynamicPercept("key1", "value2")),
ACTION_2);
perceptSequenceActions.Add(createPerceptSequence(new DynamicPercept(
"key1", "value1"), new DynamicPercept("key1", "value2"),
new DynamicPercept("key1", "value3")), ACTION_3);
agent = new MockAgent(new TableDrivenAgentProgram(
perceptSequenceActions));
}
示例5: FetchUnhandledMailCount
public Map<string, long> FetchUnhandledMailCount()
{
Map<string, long> count = new Map<string, long>();
StringBuilder sql = new StringBuilder();
sql.Append("select mail_date from ML_Mail where folder = 'INBOX' ")
.Append("and owner_user_id = @owner_user_id ");
sql.Append("and (is_handled is null or is_handled = 0) ");
SQLiteCommand cmd = null;
DataSet ds = null;
try
{
cmd = new SQLiteCommand(sql.ToString(), DBWorker.GetConnection());
cmd.Parameters.AddWithValue("@owner_user_id", Desktop.instance.loginedPrincipal.id);
ds = new DataSet();
SQLiteDataAdapter q = new SQLiteDataAdapter(cmd);
q.Fill(ds);
}
finally
{
if (cmd != null)
cmd.Dispose();
}
DataTable dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{
if (row[0] is System.DBNull)
continue;
DateTime date = (DateTime)row[0];
foreach (TimePhase phase in timePhases)
{
if (date >= phase.begin && date < phase.end)
{
if (!count.ContainsKey(phase.name))
count.Add(phase.name, 1);
else
{
long index = count[phase.name];
count.Add(phase.name, index + 1);
}
}
}
}
return count;
}
示例6: AddOne
public void AddOne()
{
Map<int,string> t = new Map<int,string>();
t.Add(1, "one");
Assert.IsTrue("one " == Dump(t));
Assert.AreEqual(1, t.Count);
}
示例7: MakeMap
public Map MakeMap()
{
var map = new Map();
foreach (var type in _typesToMap)
map.Add(MakeClassMap(type));
return map;
}
示例8: TestMain
public void TestMain()
{
var map = new Map<int, string>();
map.Add(42, "Hello");
Assert.IsTrue(map.Forward[42] == "Hello");
Assert.IsTrue(map.Reverse["Hello"] == 42);
}
示例9: AddOneDeleteOne
public void AddOneDeleteOne()
{
Map<int,string> t = new Map<int,string>();
t.Add(1, "one");
t.Remove(1);
Assert.AreEqual("" ,Dump(t));
Assert.IsTrue(t.Count == 0);
}
示例10: AttemptHttpHandlerCreate
//- ~AttemptHttpHandlerCreate-//
internal IHttpHandler AttemptHttpHandlerCreate(EndpointData endpoint, String type)
{
IHttpHandler hh = CreateHttpHandler(type);
if (hh == null)
{
if (WebProcessingReportController.Reporter.Initialized)
{
var map = new Map();
map.Add("Section", "Handler Creation");
map.Add("Message", "Could not create handler. Either the type name is incorrect or the required handler factory was not installed correctly.");
map.Add("Handler Name", endpoint.Type);
map.Add("Handler Match Type", endpoint.Selector.ToString());
map.Add("Handler Match Text", endpoint.Text);
//+
WebProcessingReportController.Reporter.AddMap(map);
}
}
else
{
//+ initialize
IHasParameterMap iHasParameterMap;
if ((iHasParameterMap = hh as IHasParameterMap) != null)
{
if ((endpoint.ParameterMap == null || endpoint.ParameterMap.Count == 0) && !String.IsNullOrEmpty(iHasParameterMap.DefaultParameter) && !String.IsNullOrEmpty(endpoint.ParameterValue))
{
if (iHasParameterMap.ParameterMap == null)
{
iHasParameterMap.ParameterMap = new Map();
}
iHasParameterMap.ParameterMap[iHasParameterMap.DefaultParameter] = endpoint.ParameterValue;
}
else
{
iHasParameterMap.ParameterMap = endpoint.ParameterMap;
if (iHasParameterMap.ParameterMap == null)
{
iHasParameterMap.ParameterMap = new Map();
}
}
}
}
//+
return hh;
}
示例11: OnHandleError
//- ~OnHandleError -//
internal static void OnHandleError(Object sender, EventArgs ea)
{
var ha = sender as HttpApplication;
if (ha == null)
{
return;
}
HttpContext context = ha.Context;
Exception exception = null;
if (context.Error != null)
{
exception = context.Error.InnerException;
}
if (NalariumContext.Current != null && NalariumContext.Current.WebDomain != null && NalariumContext.Current.WebDomain.Configuration != null)
{
ErrorProcessorData data;
ErrorProcessor processor = ProcessorRunner.RunErrorProcessing(out data);
if (processor != null)
{
CheckAndRun(context, exception, processor, data);
}
}
else
{
if (WebProcessingReportController.Reporter.Initialized)
{
var map = new Map();
map.Add("Section", "ErrorProcessor");
map.Add("Message", "An uncaught exception was thrown, but WebDomain.CurrentData was null. However, the original error message has been preserved and is packaged in this report.");
map.Add("Url", Http.AbsoluteUrlOriginalCase);
var creator = new ExceptionReportCreator
{
Formatter = WebProcessingReportController.Reporter.Formatter
};
map.Add("Exception Report", creator.Create(exception));
//+
WebProcessingReportController.Reporter.AddMap(map);
}
}
}
示例12: SelectColumnsDialog
public SelectColumnsDialog( DataGridView dgv )
{
dataGridView = dgv;
columnToCheckboxMap = new Map<string, CheckBox>();
this.Name = "SelectColumnsDialog";
this.Text = "Select Columns";
SplitContainer splitContainer = new SplitContainer();
splitContainer.Orientation = Orientation.Horizontal;
splitContainer.Dock = DockStyle.Fill;
this.Controls.Add( splitContainer );
FlowLayoutPanel panel1 = new FlowLayoutPanel();
panel1.FlowDirection = FlowDirection.TopDown;
panel1.Dock = DockStyle.Fill;
splitContainer.Panel1.Controls.Add( panel1 );
foreach( DataGridViewColumn column in dgv.Columns )
{
CheckBox checkbox = new CheckBox();
checkbox.Text = column.HeaderText;
checkbox.Checked = column.Visible;
columnToCheckboxMap.Add( column.Name, checkbox );
panel1.Controls.Add( checkbox );
}
TableLayoutPanel panel2 = new TableLayoutPanel();
panel2.ColumnCount = 2;
panel2.RowCount = 1;
panel2.Dock = DockStyle.Fill;
splitContainer.Panel2.Controls.Add( panel2 );
Button okButton = new Button();
okButton.Text = "OK";
okButton.Click += new EventHandler( okButton_Click );
this.AcceptButton = okButton;
panel2.Controls.Add( okButton );
panel2.SetCellPosition( okButton, new TableLayoutPanelCellPosition(0,0) );
Button cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Click += new EventHandler( cancelButton_Click );
this.CancelButton = cancelButton;
panel2.Controls.Add( cancelButton );
panel2.SetCellPosition( cancelButton, new TableLayoutPanelCellPosition(1,0) );
splitContainer.FixedPanel = FixedPanel.Panel2;
splitContainer.SplitterDistance = this.Height - okButton.Height * 2;
splitContainer.IsSplitterFixed = true;
}
示例13: AssemblyDef
public AssemblyDef(Global global, IImSeq<Annotation> annotations, ISeq<CustomAttribute> customAttributes, AssemblyName name, IImSeq<AssemblyName> references, IImSeq<TypeDef> types, MethodRef entryPoint)
{
Annotations = annotations ?? Constants.EmptyAnnotations;
CustomAttributes = customAttributes ?? new Seq<CustomAttribute>();
Name = name;
References = references ?? Constants.EmptyStrongAssemblyNames;
Types = types ?? Constants.EmptyTypeDefs;
EntryPoint = entryPoint;
nameToTypeDefCache = new Map<TypeName, TypeDef>();
if (types != null)
{
foreach (var t in types)
nameToTypeDefCache.Add(t.EffectiveName(global), t);
}
}
示例14: LoadSpamHeader
private static void LoadSpamHeader()
{
spamHeader = new Map<string, string>();
String header = SPAMHeader;
if( header != null )
{
string[] headers = header.Split(';');
foreach(string h in headers )
{
string[] part = h.Split(':');
if( part.Length == 2 ){
spamHeader.Add(part[0].Trim(), part[1].Trim());
}
}
}
}
示例15: AddMany
public void AddMany()
{
Map<int,string> t = new Map<int,string>();
for (int i = 100; i >= 0; --i)
{
t.Add(i, i.ToString());
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 101; ++i)
{
sb.Append(i.ToString());
sb.Append(" ");
}
Assert.IsTrue(sb.ToString() == Dump(t));
}