本文整理汇总了C#中Parameters.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.Get方法的具体用法?C# Parameters.Get怎么用?C# Parameters.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParametersToPDL
/// <summary>
/// Converts a <see cref="Parameters"/> to a PDL gramma formatted <b>string</b>.
/// </summary>
/// <param name="data">The <see cref="Parameters"/> to be converted.</param>
/// <param name="cooked">Set <b>true</b> to create a string formatted for human reading.</param>
/// <param name="indent">The indent for human readability.</param>
/// <returns>The <b>string</b> containing the converted <paramref name="data"/>.</returns>
public static string ParametersToPDL(Parameters data, bool cooked = false, string indent = "")
{
StringBuilder ret = new StringBuilder();
if (cooked) ret.Append("{\r\n");
else ret.Append('{');
bool wasItem = false;
string[] names = data.GetNames();
for (int i = 0; i < names.Length; i++)
{
string name = names[i];
object value = data.Get(name);
if (cooked)
{
string newIndent = indent + '\t';
try
{
string val = "";
if (value is long) val = value.ToString();
else if (value is double)
{
val = ((double)value).ToString("G16", NeutralCulture);
}
else if (value is string) val = StringToPDL((string)value);
else if (value is bool) val = ((bool)value) ? "true" : "false";
else if (value is byte[]) val = DataBlobToPDL((byte[])value, true);
else if (value is Parameters) val = ParametersToPDL((Parameters)value, true, newIndent);
else if (value is List<string>) val = StringListToPDL((List<string>)value, true, newIndent);
else if (value is List<Parameters>) val = ParametersListToPDL((List<Parameters>)value, true, newIndent);
else if (value is List<long>) val = IntegerListToPDL((List<long>)value, true, newIndent);
else if (value is List<double>) val = FloatListToPDL((List<double>)value, true, newIndent);
else if (value is List<bool>) val = BooleanListToPDL((List<bool>)value, true, newIndent);
if (val.Length > 0)
{
ret.Append(newIndent);
ret.Append(name);
ret.Append('=');
ret.Append(val);
ret.Append(";\r\n");
wasItem = true;
}
}
catch
{
} // ignore
}
else
{
try
{
string val = "";
if (value is long) val = value.ToString();
else if (value is double)
{
val = value.ToString();
val = val.Replace(',', '.');
}
else if (value is string) val = StringToPDL((string)value);
else if (value is bool) val = ((bool)value) ? "true" : "false";
else if (value is byte[]) val = DataBlobToPDL((byte[])value, false);
else if (value is Parameters) val = ParametersToPDL((Parameters)value);
else if (value is List<string>) val = StringListToPDL((List<string>)value, false, indent);
else if (value is List<Parameters>) val = ParametersListToPDL((List<Parameters>)value, false, indent);
else if (value is List<long>) val = IntegerListToPDL((List<long>)value, false, indent);
else if (value is List<double>) val = FloatListToPDL((List<double>)value, false, indent);
else if (value is List<bool>) val = BooleanListToPDL((List<bool>)value, false, indent);
if (val.Length > 0)
{
ret.Append(name);
ret.Append('=');
ret.Append(val);
ret.Append(';');
wasItem = true;
}
}
catch
{
} // ignore
}
}
if (!wasItem) return "";
if (cooked) ret.Append(indent);
ret.Append('}');
return ret.ToString();
//.........这里部分代码省略.........
示例2: RemoveLink
/// <inhertidoc />
public void RemoveLink(UUID l, Parameters parameters)
{
if (!Neighbours.ContainsKey(l))
throw new Exception("The link to be remove is not a known link.");
IMNodeInternal neighbour = _neighbours[l];
IMLink link = _links[neighbour.ID];
link.OnWeightChanged -= _weightDelegate;
lock (_links) {
_links.Remove(neighbour.ID);
_links.Remove(l);
} lock (_neighbours)
_neighbours.Remove(link.ID);
if (OnLinkRemoved != null && !parameters.Get<bool>("Clearing")) {
OnLinkRemoved(ID, link, parameters);
Logger.Debug(Name + " triggered OnLinkRemoved for '" + link.Name + "'.");
}
}
示例3: GenPropertyDescriptorCollection
public static PropertyDescriptorCollection GenPropertyDescriptorCollection(Parameters param)
{
PropertyDescriptorCollection props=new PropertyDescriptorCollection(null);
foreach(string key in param.Keys)
{
object obj=param.Get(key);
if(obj is Parameters)
{
TypeInParametersPropertyDescriptor<Parameters> prop=new TypeInParametersPropertyDescriptor<Parameters>(key, (Parameters)obj,
new TypeConverterAttribute(typeof(ParametersConverter)),
new EditorAttribute(typeof(ParametersEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.ParametersInParametersDescription));
props.Add(prop);
}
else if(obj is long)
{
TypeInParametersPropertyDescriptor<long> prop=new TypeInParametersPropertyDescriptor<long>(key, (long)obj,
new EditorAttribute(typeof(NumericUpDownTypeEditor), typeof(UITypeEditor)),
new TypeConverterAttribute(typeof(NumericUpDownTypeConverter)),
new DescriptionAttribute(Properties.Resources.LongInParametersDescription));
props.Add(prop);
}
else if(obj is double)
{
TypeInParametersPropertyDescriptor<double> prop=new TypeInParametersPropertyDescriptor<double>(key, (double)obj,
new EditorAttribute(typeof(NumericUpDownTypeEditor), typeof(UITypeEditor)),
new TypeConverterAttribute(typeof(NumericUpDownTypeConverter)),
new DescriptionAttribute(Properties.Resources.DoubleInParametersDescription));
props.Add(prop);
}
else if(obj is string)
{
TypeInParametersPropertyDescriptor<string> prop=new TypeInParametersPropertyDescriptor<string>(key, (string)obj,
new EditorAttribute(typeof(MultilineStringEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.StringInParametersDescription));
props.Add(prop);
}
else if(obj is bool)
{
TypeInParametersPropertyDescriptor<bool> prop=new TypeInParametersPropertyDescriptor<bool>(key, (bool)obj,
new DescriptionAttribute(Properties.Resources.BoolInParametersDescription));
props.Add(prop);
}
else if(obj is byte[])
{
TypeInParametersPropertyDescriptor<byte[]> prop=new TypeInParametersPropertyDescriptor<byte[]>(key, (byte[])obj,
new TypeConverterAttribute(typeof(ByteArrayConverter)),
new EditorAttribute(typeof(ArrayEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.ByteArrayInParametersDescription));
props.Add(prop);
}
else if(obj is List<long>)
{
TypeInParametersPropertyDescriptor<List<long>> prop=new TypeInParametersPropertyDescriptor<List<long>>(key, (List<long>)obj,
new TypeConverterAttribute(typeof(NumberListConverter<long>)),
new EditorAttribute(typeof(LongListEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.LongListInParametersDescription));
props.Add(prop);
}
else if(obj is List<double>)
{
TypeInParametersPropertyDescriptor<List<double>> prop=new TypeInParametersPropertyDescriptor<List<double>>(key, (List<double>)obj,
new TypeConverterAttribute(typeof(NumberListConverter<double>)),
new EditorAttribute(typeof(DoubleListEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.DoubleListInParametersDescription));
props.Add(prop);
}
else if(obj is List<string>)
{
TypeInParametersPropertyDescriptor<List<string>> prop=new TypeInParametersPropertyDescriptor<List<string>>(key, (List<string>)obj,
new TypeConverterAttribute(typeof(MultilineStringListConverter)),
new EditorAttribute(typeof(MultilineStringListEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.StringListInParametersDescription));
props.Add(prop);
}
else if(obj is List<bool>)
{
TypeInParametersPropertyDescriptor<List<bool>> prop=new TypeInParametersPropertyDescriptor<List<bool>>(key, (List<bool>)obj,
new TypeConverterAttribute(typeof(BoolListConverter)),
new DescriptionAttribute(Properties.Resources.BoolListInParametersDescription));
props.Add(prop);
}
else if(obj is List<Parameters>)
{
TypeInParametersPropertyDescriptor<List<Parameters>> prop=new TypeInParametersPropertyDescriptor<List<Parameters>>(key, (List<Parameters>)obj,
new TypeConverterAttribute(typeof(ParametersListConverter)),
new EditorAttribute(typeof(ParametersListEditor), typeof(UITypeEditor)),
new DescriptionAttribute(Properties.Resources.ParametersListInParametersDescription));
props.Add(prop);
}
}
return props;
}
示例4: VisualiseAlgorithm
public override void VisualiseAlgorithm(UUID to, Parameters parameters)
{
if (Equals(VisualisedNode)) {
ResetAlgorithm();
_visualise = false;
VisualisedNode = null;
return;
}
else if (VisualisedNode != null)
VisualisedNode.Stop();
IMNodeInternal target = KnownNodes.ContainsKey(to) ? KnownNodes[to] : null;
_text = Dijkstra.AlwaysPrint || (Dijkstra.EverPrint && parameters != null && parameters.Get<bool>("Text"));
VisualisedNode = this;
RunAlgorithm("Visualise Dijkstra's Algorithm", target, true);
}
示例5: AddNode
public override INode AddNode(string name, Parameters parameters, Vector3 position = default(Vector3), Color colour = default(Color))
{
INode node = base.AddNode(name, MakeParameters(parameters), position, colour);
if (!parameters.Get<bool>("IsEP")) {
node.OnWorldTouch += (source, args) => {
if (!DisplayForwardingTable(node.ID, "Blah", UUID.Zero)) {
if (_selected != null) {
_selected.Selected = 0d;
_selected = null;
}
Model.VisualiseRouting(source, new Parameters());
}
};
} else {
node.OnWorldTouch += (source, args) => {
if (DisplayForwardingTable(node.ID, "Blah", UUID.Zero) && _selected == null) {
_selected = node;
_selected.Selected = ToggleGlow;
} else if (_selected != null) {
if (!_selected.ID.Equals(source)) {
UUID from = _selected.ID;
UUID to = source;
Thread sendThread = new Thread(() => {
for (int packet = 0; packet < MultiSendNumber; packet++) {
if (_stopped || !IsNode(from) || !IsNode(to))
break;
Model.Send(from, to, new Parameters());
JM726.Lib.Static.Util.Wait(MultiSendWait);
}
});
sendThread.Name = name + " send thread.";
sendThread.Start();
}
_selected.Selected = 0d;
_selected = null;
}
};
}
return node;
}
示例6: MakeNode
protected override IControlNode MakeNode(string name, Parameters parameters, Vector3 position = default(Vector3), Color colour = default(Color))
{
Logger.Debug("Creating node '" + name + "'.");
UUID ownerID = parameters.Get<UUID>(Control.OwnerID);
bool isEP = parameters.Get<bool>(SandboxControl.IsEP);
INode n = Model.AddNode(name, parameters, position, colour);
IControlNode node = null;
if (isEP)
node = new SandboxControlEP(n, position, this, ControlConfig, Permissions);
else
node = new SandboxControlRouter(n, position, this, Permissions);
Logger.Info("Created node '" + name + "'.");
return RecordNode(node);
}
示例7: MakeLink
protected override IControlLink MakeLink(UUID from, UUID to, Parameters parameters, float weight = default(float), bool bidirectional = true)
{
Logger.Debug("Creating link between '" + GetNode(from).Name + "' and '" + GetNode(to).Name + "'.");
UUID creator = parameters.Get<UUID>(Control.OwnerID);
ILink l = Model.AddLink(from, to, parameters, weight, bidirectional);
IControlLink link = new SandboxControlLink(l, GetNode(from), GetNode(to), this, _tableFactory, Factory, Permissions);
Logger.Debug("Created '" + link.Name + "'.");
return Record.MakeMapped<IControlLink>(link);
}