本文整理汇总了C#中Param类的典型用法代码示例。如果您正苦于以下问题:C# Param类的具体用法?C# Param怎么用?C# Param使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Param类属于命名空间,在下文中一共展示了Param类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Expected
public Info[] Expected(Specification problem)
{
Function function = problem.Function.Invoke;
Gradient gradient = problem.Gradient.Invoke;
Param param = new Param()
{
m = m,
epsilon = epsilon,
past = past,
delta = delta,
max_iterations = max_iterations,
linesearch = (int)linesearch,
max_linesearch = max_linesearch,
min_step = min_step,
max_step = max_step,
ftol = ftol,
wolfe = wolfe,
gtol = gtol,
xtol = xtol,
orthantwise_c = orthantwise_c,
orthantwise_start = orthantwise_start,
orthantwise_end = orthantwise_end
};
NativeCode = Wrapper.Libbfgs((double[])problem.Start.Clone(), function, gradient, param);
// Convergence and success have the same
// enumeration value in the original code
if (NativeCode == "LBFGS_CONVERGENCE")
NativeCode = "LBFGS_SUCCESS";
return Wrapper.list.ToArray();
}
示例2: Clone
public virtual object Clone()
{
Param param = new Param();
param.m_identifier = m_identifier;
param.m_name = m_name;
param.m_type = m_type;
param.m_lazy = m_lazy;
if(m_value != null)
{
if(m_value is IUimlElement)
{
param.m_value = ((IUimlElement)m_value).Clone();
}
else
{
param.m_value = m_value;
}
}
if(m_subprop != null)
{
param.m_subprop = m_subprop;
}
param.PartTree = m_partTree;
return param;
}
示例3: AddElementToDataGridView
private void AddElementToDataGridView(Param element)
{
var row = new DataGridViewRow();
// пустая сточка означет разделитель между
// отдельными интерфейсами
if(element.ParamName == string.Empty)
{
dataGridView1.Rows.Add(row);
return;
}
// добавляем первую ячейку
var cell1 = new DataGridViewTextBoxCell()
{
Value = element.ParamName + ":"
};
cell1.Style.Font = new Font(dataGridView1.Font, FontStyle.Bold);
row.Cells.Add(cell1);
// добавляем вторую ячейку
var cell2 = new DataGridViewTextBoxCell()
{
Value = element.ParamValue
};
row.Cells.Add(cell2);
// добавляем строчку в dataGridView
dataGridView1.Rows.Add(row);
}
示例4: CreateSuggorateModel
public void CreateSuggorateModel()
{
// configure model (do once at app startup)
var model = RuntimeTypeModel.Default;
model.Add(typeof(Param), false).SetSurrogate(typeof(ParamSurrogate));
model.Add(typeof (FloatData), false).Add("Ranges", "AdjustValue", "Values");
//TODO: other types here
// test data
var param = new Param
{
Item = new FloatData
{
AdjustValue = 123.45F,
Ranges = new float[] { 1.0F, 2.4F },
Values = new float[] { 7.21F, 19.2F }
}
};
// note the fallowing is the same as Serializer.DeepClone, since
// model === RuntimeTypeModel.Default
var clone = (Param) model.DeepClone(param);
Assert.AreNotSame(clone, param, "Different instance");
Assert.IsInstanceOfType(typeof(FloatData), clone.Item, "Data type");
var data = (FloatData) clone.Item;
Assert.AreEqual(123.45F, data.AdjustValue);
Assert.AreEqual(2, data.Ranges.Length);
Assert.AreEqual(1.0F, data.Ranges[0]);
Assert.AreEqual(2.4F, data.Ranges[1]);
Assert.AreEqual(2, data.Values.Length);
Assert.AreEqual(7.21F, data.Values[0]);
Assert.AreEqual(19.2F, data.Values[1]);
}
示例5: FieldToCollection
public static ObservableCollection<Param> FieldToCollection(string strXml)
{
string XmlTemplete = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\r\n" +
"<Paras>" + "\r\n" +
"{0}" +
"</Paras>";
XmlTemplete = string.Format(XmlTemplete, strXml);
Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(XmlTemplete);
XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b)));
var Param = from item in xele.Descendants("Para")
select item;
ObservableCollection<Param> List = new ObservableCollection<Param>();
foreach (var vv in Param)
{
Param r = new Param();
r.FieldID = vv.Attribute("Value").Value.CvtString().Replace("{", "").Replace("}", "");
try
{
r.FieldName = vv.Attribute("ValueName").Value.CvtString();
}
catch
{
r.FieldName = string.Empty;
}
r.Description = vv.Attribute("Description").Value.CvtString();
r.TableName = vv.Attribute("TableName").Value.CvtString();
r.ParamID = vv.Attribute("Name").Value.CvtString();
r.ParamName = vv.Attribute("Description").Value.CvtString();
List.Add(r);
}
return List;
}
示例6: GetContiguousAcres
/// <summary>
/// Returns the contiguous acres associated with the user. This method does NOT
/// populate the contiguous acres' wells property.
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public List<ContiguousAcres> GetContiguousAcres(int userId, bool includeNonOwned)
{
Param[] nonOwnedCAParams = new Param[] {};
string[] nonOwnedCAParamNames = null;
if (includeNonOwned) {
var caIds = new PropertyDalc().GetAssociatedCAIds(userId);
if (caIds.Count() == 0) {
// No associations exist; don't even try to retrieve them.
includeNonOwned = false;
} else {
nonOwnedCAParams = ParameterizeInClause("caId", out nonOwnedCAParamNames, caIds.ToArray());
}
}
return ExecuteDataTable(@"
select
ca.OBJECTID,
ca.caID,
ca.area as area_m2,
ca.admin_area as area_acres,
ca.description,
ca.approved,
ca.actingId
from HP_CONTIGUOUS_ACRES" + dbTableSuffix + @" ca
where
(ca.actingId = @id" + (includeNonOwned
? " or ca.caId in (" + string.Join(", ", nonOwnedCAParamNames) + "))"
: ")") + @"
and isnull(ca.Deletion, '') <> 'True';",
new Param[] { new Param("@id", userId) }.Concat(nonOwnedCAParams).ToArray()
).AsEnumerable().Select(row => GetCAFromDataRow(row)).ToList();
}
示例7: Parse
/// <summary>
/// This static method parses the command line, storing the parameter values, and
/// returning the index of the first non-option command line argument.
/// </summary>
/// <param name="args"></param>
/// <param name="rgParam"></param>
/// <param name="index"></param>
/// <returns></returns>
public static bool Parse(string[] args, ref Param[] rgParam, out int index)
{
index = args.Length;
try
{
for (int i = 0; i < args.Length; ++i)
{
if (args[i].StartsWith("-"))
{
bool fOk;
if (args[i].StartsWith("--"))
fOk = CheckLongParamNames(args, rgParam, ref i);
else
fOk = CheckShortParamNames(args, rgParam, ref i);
if (!fOk)
throw new Exception(String.Format("Invalid option found in {0}", args[i]));
}
else
{
index = i;
return true;
}
}
index = args.Length;
return true;
}
catch (Exception ex)
{
s_sError = ex.Message;
return false;
}
}
示例8: Usage
/// <summary>
///
/// </summary>
/// <param name="rgParam"></param>
public static void Usage(Param[] rgParam)
{
int cLen = 0;
for (int i = 0; i < rgParam.Length; ++i)
{
if (!String.IsNullOrEmpty(rgParam[i].LongName))
{
int cch = rgParam[i].LongName.Length;
if (cLen < cch)
cLen = cch;
}
}
cLen += 4;
for (int i = 0; i < rgParam.Length; ++i)
{
string sShort;
if (String.IsNullOrEmpty(rgParam[i].ShortName))
sShort = " ";
else
sShort = String.Format("-{0}", rgParam[i].ShortName);
string sLong;
if (String.IsNullOrEmpty(rgParam[i].LongName))
sLong = " ";
else
sLong = String.Format("(--{0})", rgParam[i].LongName);
while (sLong.Length < cLen)
sLong = sLong + " ";
string sLine = String.Format(" {0} {1} = {2}",
sShort, sLong, rgParam[i].Description);
Console.WriteLine(sLine);
}
}
示例9: AddParameter
internal void AddParameter(string name, string sval)
{
Param p = new Param();
p.ParamName = name;
p.ParamValue = sval;
Parameters.Add(p);
}
示例10: Tv
public Tv(string nameTv, bool stateTv, Channels channelCur, byte volumeCur, byte brightCur)
: base(nameTv, stateTv)
{
channel = channelCur;
volume = new Param(volumeCur, 1, 5);
bright = new Param(brightCur, 1, 5);
}
示例11: Expected
public Info[] Expected(Specification problem)
{
Function function = problem.Function.Invoke;
Gradient gradient = problem.Gradient.Invoke;
Param param = new Param()
{
m = m,
epsilon = epsilon,
past = past,
delta = delta,
max_iterations = max_iterations,
linesearch = (int)linesearch,
max_linesearch = max_linesearch,
min_step = min_step,
max_step = max_step,
ftol = ftol,
wolfe = wolfe,
gtol = gtol,
xtol = xtol,
orthantwise_c = orthantwise_c,
orthantwise_start = orthantwise_start,
orthantwise_end = orthantwise_end
};
NativeCode = Wrapper.Libbfgs((double[])problem.Start.Clone(), function, gradient, param);
return Wrapper.list.ToArray();
}
示例12: GetParamByID
public static ParamInfo GetParamByID(int paramid)
{
Param pra = new Param();
if (!enableCaching)
return pra.GetParamByID(paramid);
string key = "param_" + paramid;
ParamInfo data = (ParamInfo)HttpRuntime.Cache[key];
// Check if the data exists in the data cache
if (data == null)
{
// If the data is not in the cache then fetch the data from the business logic tier
data = pra.GetParamByID(paramid);
// Create a AggregateCacheDependency object from the factory
AggregateCacheDependency cd = DependencyFacade.GetDeviceDependency();
// Store the output in the data cache, and Add the necessary AggregateCacheDependency object
HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(ParamTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
}
return data;
}
示例13: GenerateMethod
private static void GenerateMethod()
{
Method method = new Method();
method.Name = "MyNewProc";
method.MethodType = MethodTypeEnum.Void;
Param newParam = new Param();
TypeReferenceExpression newTypeReferenceExpression = new TypeReferenceExpression();
newTypeReferenceExpression.Name = CodeRush.Language.GetSimpleTypeName("System.Int32");
newParam.MemberTypeReference = newTypeReferenceExpression;
newParam.Name = "MyKillerParameter";
method.Parameters.Add(newParam);
MethodCall statement = new MethodCall();
statement.Name = "Start";
//UnaryIncrement newUnaryIncrement = new UnaryIncrement();
//ElementReferenceExpression elementReferenceExpression = new ElementReferenceExpression(newParam.Name);
//newUnaryIncrement.Expression = elementReferenceExpression;
//statement.AddDetailNode(newUnaryIncrement);
//int MyKillerParameter = 0;
//MyKillerParameter++;
method.AddNode(statement);
string newCode = CodeRush.Language.GenerateElement(method);
TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
if (activeTextDocument == null)
return;
activeTextDocument.InsertText(activeTextDocument.ActiveView.Caret.SourcePoint, newCode);
}
示例14: MyMethod
public void MyMethod(Param stateIdentifier)
{
GetSate(stateIdentifier);
counter++;
var sessionId = OperationContext.Current.SessionId;
Trace.WriteLine(string.Format("Counter = {0}, SessionId = {1}", counter, sessionId));
SaveState(stateIdentifier);
}
示例15: AddParam
private static void AddParam(Param p)
{
if (_params.Count > 0)
_allParams.Append(", ");
_allParams.Append(p.Name);
_params.Add(p.Name.ToLower(), p);
}