本文整理汇总了C#中Hash.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Hash.Add方法的具体用法?C# Hash.Add怎么用?C# Hash.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeLogMessage
public void writeLogMessage(String strMsg)
{
IDictionary<object, object> map = new Dictionary<object, object>();
Hash values = new Hash(map);
values.Add(CRhoRuby.CreateSymbol("url"), MutableString.Create(m_addrHost));
values.Add(CRhoRuby.CreateSymbol("body"), MutableString.Create(strMsg));
RhoParams p = new RhoParams(values);
m_aHttp.addHttpCommand(new CAsyncHttp.HttpCommand("POST", p));
}
示例2: GetAliases
public static Hash GetAliases(RubyClass/*!*/ self)
{
var context = self.Context;
var result = new Hash(context.EqualityComparer, RubyEncoding.Aliases.Count + 3);
foreach (var alias in RubyEncoding.Aliases) {
result.Add(MutableString.CreateAscii(alias.Key).Freeze(), MutableString.CreateAscii(alias.Value).Freeze());
}
result.Add(MutableString.CreateAscii("locale").Freeze(), MutableString.Create(context.RubyOptions.LocaleEncoding.Name).Freeze());
result.Add(MutableString.CreateAscii("external").Freeze(), MutableString.Create(context.DefaultExternalEncoding.Name).Freeze());
result.Add(MutableString.CreateAscii("filesystem").Freeze(), MutableString.Create(context.GetPathEncoding().Name).Freeze());
return result;
}
示例3: AppendToHash
public void AppendToHash(Hash imageParams)
{
if (Width != -1)
{
imageParams.Add("imageWidth", Width.ToString(CultureInfo.InvariantCulture));
}
if (Height != -1)
{
imageParams.Add("imageHeight", Height.ToString(CultureInfo.InvariantCulture));
}
if (Align != AlignOption.None)
{
imageParams.Add("imageAlign", GetAlignString(Align));
}
}
示例4: Render
public Task Render(IResponse response, ViewData data)
{
var register = new Hash();
register.Add(DotLiquidFileSystem.Guid, _resolver);
var hash = new Hash();
hash.Add("Data", data.Data);
hash.Add("Model", data.Model);
hash.Add("Status", data.Status);
var ctx = new Context(new List<Hash>(), hash, register, true);
using (var writer = response.GetStreamWriter()) {
_template.Render(writer, new RenderParameters {
Context = ctx
});
}
return Task.FromResult(0);
}
示例5: List
public static Hash/*!*/ List(RubyContext/*!*/ context, RubyModule/*!*/ self) {
Hash result = new Hash(context);
result.Add(MutableString.Create("TERM"), ScriptingRuntimeHelpers.Int32ToObject(15));
result.Add(MutableString.Create("SEGV"), ScriptingRuntimeHelpers.Int32ToObject(11));
result.Add(MutableString.Create("KILL"), ScriptingRuntimeHelpers.Int32ToObject(9));
result.Add(MutableString.Create("EXIT"), ScriptingRuntimeHelpers.Int32ToObject(0));
result.Add(MutableString.Create("INT"), ScriptingRuntimeHelpers.Int32ToObject(2));
result.Add(MutableString.Create("FPE"), ScriptingRuntimeHelpers.Int32ToObject(8));
result.Add(MutableString.Create("ABRT"), ScriptingRuntimeHelpers.Int32ToObject(22));
result.Add(MutableString.Create("ILL"), ScriptingRuntimeHelpers.Int32ToObject(4));
return result;
}
示例6: FromStrictDictionary
public static Hash FromStrictDictionary(this IDictionary<string, object> dictionary)
{
Hash result = new Hash();
//Hash result = new Hash((h, k) => { throw new Exception("Unknown variable '" + k + "'"); }); // Removed for now since it make "includes" not working
foreach (var keyValue in dictionary)
result.Add(keyValue);
return result;
}
示例7: Render
public override void Render(Context context, TextWriter result)
{
var template = Templates.GetCached(_templatePath);
var parameters = new Hash();
foreach (var assignment in _assignmentMap)
{
parameters.Add(assignment.Key, context[assignment.Value]);
}
result.Write(template.Render(parameters));
}
示例8: CreateDefaultTagMapping
private static Hash CreateDefaultTagMapping(RubyContext/*!*/ context) {
Hash taggedClasses = new Hash(context.EqualityComparer);
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:array"), context.GetClass(typeof(RubyArray)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:exception"), context.GetClass(typeof(Exception)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:hash"), context.GetClass(typeof(Hash)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:object"), context.GetClass(typeof(object)));
taggedClasses.Add(MutableString.CreateAscii(Tags.RubyRange), context.GetClass(typeof(Range)));
taggedClasses.Add(MutableString.CreateAscii(Tags.RubyRegexp), context.GetClass(typeof(RubyRegex)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:string"), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:struct"), context.GetClass(typeof(RubyStruct)));
taggedClasses.Add(MutableString.CreateAscii(Tags.RubySymbol), context.GetClass(typeof(RubySymbol)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:symbol"), context.GetClass(typeof(RubySymbol)));
taggedClasses.Add(MutableString.CreateAscii("tag:ruby.yaml.org,2002:time"), context.GetClass(typeof(RubyTime)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Binary), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Float), context.GetClass(typeof(Double)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Int), context.GetClass(typeof(Integer)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Map), context.GetClass(typeof(Hash)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Seq), context.GetClass(typeof(RubyArray)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Str), context.GetClass(typeof(MutableString)));
taggedClasses.Add(MutableString.CreateAscii(Tags.Timestamp), context.GetClass(typeof(RubyTime)));
taggedClasses.Add(MutableString.CreateAscii(Tags.False), context.FalseClass);
taggedClasses.Add(MutableString.CreateAscii(Tags.True), context.TrueClass);
taggedClasses.Add(MutableString.CreateAscii(Tags.Null), context.NilClass);
//if (ctor.GlobalScope.Context.TryGetModule(ctor.GlobalScope, "Date", out module)) {
// taggedClasses.Add(MutableString.CreateAscii(Tags.TimestampYmd), context.NilClass);
//}
//taggedClasses.Add(MutableString.CreateAscii("tag:yaml.org,2002:timestamp#ymd'"), );
//Currently not supported
//taggedClasses.Add(MutableString.CreateAscii("tag:yaml.org,2002:omap"), ec.GetClass(typeof()));
//taggedClasses.Add(MutableString.CreateAscii("tag:yaml.org,2002:pairs"),// ec.GetClass(typeof()));
//taggedClasses.Add(MutableString.CreateAscii("tag:yaml.org,2002:set"),// ec.GetClass(typeof()));
return taggedClasses;
}
示例9: Request
public Request(HttpRequestBase request) {
ContractUtils.RequiresNotNull(request, "request");
// http or https
this.scheme = request.Url.Scheme;
// move headers to a Ruby Hash
this.headers = new Hash(RubyEngine.Context);
foreach (string key in request.Headers.AllKeys) {
string value = request.Headers.Get(key);
if (string.IsNullOrEmpty(value)) continue;
headers.Add(key, value);
}
this.queryString = request.QueryString.ToString();
this.body = new RubyIO(RubyEngine.Context, request.InputStream, IOMode.ReadOnly);
// Save the origional request incase it's needed.
OrigionalRequest = request;
}
示例10: Check
private static bool Check(string str1, string str2, int length)
{
var hash1 = new Hash(str1.Substring(0, length));
var hashes1 = new HashSet<ulong>();
var hashes2 = new HashSet<ulong>();
hashes1.Add(hash1.Value1);
hashes2.Add(hash1.Value2);
for (int i = 0; i < str1.Length - length; i++)
{
hash1.Add(str1[length + i]);
hash1.Remove(str1[i], length);
hashes1.Add(hash1.Value1);
hashes2.Add(hash1.Value2);
}
var hash2 = new Hash(str2.Substring(0, length));
if (hashes1.Contains(hash2.Value1) &&
hashes2.Contains(hash2.Value2))
{
return true;
}
for (int i = 0; i < str2.Length - length; i++)
{
hash2.Add(str2[length + i]);
hash2.Remove(str2[i], length);
if (hashes1.Contains(hash2.Value1) &&
hashes2.Contains(hash2.Value2))
{
return true;
}
}
return false;
}
示例11: ToHash
public static Hash/*!*/ ToHash(RubyContext/*!*/ context, object/*!*/ self) {
PlatformAdaptationLayer pal = context.DomainManager.Platform;
Hash result = new Hash(context);
foreach (DictionaryEntry entry in pal.GetEnvironmentVariables()) {
result.Add(MutableString.Create(entry.Key.ToString()).Freeze(), MutableString.Create(entry.Value.ToString()).Freeze());
}
return result;
}
示例12: CreateContextHash
private Hash CreateContextHash()
{
var context = new Hash();
context.Add("IsNonDynamicHTMLOutput", nonDynamicHTMLOutput);
AddPublishingParameters(context);
return context;
}
示例13: Execute
public static RubyArray Execute(RhoDatabase/*!*/ self, MutableString/*!*/ sqlStatement, Boolean isBatch, RubyArray args)
{
try
{
RubyArray retArr = new RubyArray();
if (isBatch)
{
self.m_db.executeBatchSQL(sqlStatement.ToString());
}
else
{
Object[] values = null;
if (args != null && args.Count > 0)
{
if (args[0] != null && args[0] is RubyArray)
values = ((RubyArray)args[0]).ToArray();
else
values = args.ToArray();
}
try
{
self.m_db.Lock();
using (IDBResult rows = self.m_db.executeSQL(sqlStatement.ToString(), values, true))
{
if (rows != null)
{
MutableString[] colNames = null;
for (; !rows.isEnd(); rows.next())
{
IDictionary<object, object> map = new Dictionary<object, object>();
Hash row = new Hash(map);
for (int nCol = 0; nCol < rows.getColCount(); nCol++)
{
if (colNames == null)
colNames = getOrigColNames(rows);
row.Add(colNames[nCol], rows.getRubyValueByIdx(nCol));
}
retArr.Add(row);
}
}
}
}
finally
{
self.m_db.Unlock();
}
}
return retArr;
}catch (Exception exc)
{
//TODO: throw ruby exception
throw exc;
}
}
示例14: Render
public string Render(Hash hash)
{
var renderParams = new RenderParameters();
TextWriter textWriter = new StringWriter();
hash.Add("Context", CreateContextHash());
renderParams.LocalVariables = hash;
renderParams.RethrowErrors = true;
ParsedTemplate.Render(textWriter, renderParams);
textWriter.Flush();
return textWriter.ToString().Trim();
}
示例15: AddPublishingParameters
private void AddPublishingParameters(Hash hash)
{
var publishingHash = new Hash();
foreach(var publishFlag in publishFlags)
{
publishingHash.Add(publishFlag.Substring(0, 1).ToUpper() + publishFlag.Substring(1).ToLower(), true);
}
hash.Add("PublishingFor", publishingHash);
}