本文整理汇总了C#中Return类的典型用法代码示例。如果您正苦于以下问题:C# Return类的具体用法?C# Return怎么用?C# Return使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Return类属于命名空间,在下文中一共展示了Return类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegexTest
public static Return<List<string>> RegexTest(Dictionary<string, bool> dictionary, string pattern)
{
Return<List<string>> _answer = new Return<List<string>>() { data = new List<string>() };
if (dictionary == null)
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentNullException("dictionary"), typeof(Utility));
}
else
if (string.IsNullOrEmpty(pattern))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentNullException("pattern"), typeof(Utility));
}
else
{
try
{
foreach (string _key in dictionary.Keys)
{
if (Regex.IsMatch(_key, pattern) != dictionary[_key])
_answer.data.Add(_key);
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, typeof(Utility));
}
}
return _answer;
}
示例2: ArithmeticMean
public static Return<double> ArithmeticMean(List<double> numbers)
{
Return<double> _answer = new Return<double>();
try
{
if (numbers == null)
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("numbers"), typeof(Mathematics));
}
else
if (!numbers.Any())
_answer.data = 0;
else
{
double _sum = 0;
int _count = numbers.Count();
numbers.ForEach(n => _sum += n);
_answer.data = _sum / _count;
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, typeof(Mathematics));
}
return _answer;
}
示例3: LoadReturn
public void LoadReturn()
{
Return e = new Return();
if (ReturnID == 0)
{
imgOrder.ImageUrl = "none";
btnOk.Enabled = true;
}
else
{
e = ReturnBLL.Get(ReturnID);
imgOrder.ImageUrl = BarcodeBLL.Url4Return(e.ID);
btnOk.Enabled = false;
}
txtNote.Text = e.Note;
txtDate.Text = e.Date.ToStringVN_Hour();
PackOrderList = e.PackOrders.Select(r => r.ID).ToList();
urlPrint.NavigateUrl = ResolveClientUrl(string.Format("~/Store/PrintReturn.aspx?ReturnID={0}", e.ID));
GridViewPack.DataBind();
CurrentDIN = "";
imgCurrentDIN.ImageUrl = "none";
GridViewSum.DataBind();
}
示例4: CreateVocabulary
/// <summary>
/// Creates a vocabulary from a list of strings.
/// Applies grouping.
/// Applies stop words and stemming (if available for the language)
/// Does not performs a Distinct
/// </summary>
/// <param name="language">la cultura para la que se realiza el análisis</param>
/// <param name="strings">la cadenas de texto (no están divididas en words)</param>
/// <returns></returns>
public Return<List<string>> CreateVocabulary(string language, List<string> strings)
{
Return<List<string>> _answer = new Return<List<string>>();
if (strings == null)
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentNullException("strings"), this.GetType());
}
else
{
try
{
Return<EnumLanguage> _answerParseLanguage = MLUtility.ParseLanguage(language);
if (_answerParseLanguage.theresError)
{
_answer.theresError = true;
_answer.error = _answerParseLanguage.error;
}
else
_answer = CreateVocabulary(_answerParseLanguage.data, strings);
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, this.GetType());
}
}
return _answer;
}
示例5: Action
/// <summary>
/// Creates instance of the <see cref="Action"></see> class with properties initialized with specified parameters.
/// </summary>
/// <param name="returnType">The return type of the action.</param>
/// <param name="when"><see cref="T:WixSharp.When"/> the action should be executed with respect to the <paramref name="step"/> parameter.</param>
/// <param name="step"><see cref="T:WixSharp.Step"/> the action should be executed before/after during the installation.</param>
/// <param name="condition">The launch condition for the <see cref="Action"/>.</param>
protected Action(Return returnType, When when, Step step, Condition condition)
{
Return = returnType;
Step = step;
When = when;
Condition = condition;
}
示例6: LoadReturn
public void LoadReturn()
{
Return e = new Return();
if (ReturnID == 0)
{
imgOrder.ImageUrl = "none";
btnOk.Enabled = true;
}
else
{
e = ReturnBLL.Get(ReturnID);
imgOrder.ImageUrl = BarcodeBLL.Url4Return(e.ID);
btnOk.Enabled = false;
}
txtNote.Text = e.Note;
txtDate.Text = e.Date.ToStringVN_Hour();
PackOrderList = e.PackOrders.Select(r => r.ID).ToList();
GridViewPack.DataBind();
CurrentDIN = "";
imgCurrentDIN.ImageUrl = "none";
}
示例7: GetTask
public Return<Task> GetTask(string taskName)
{
Return<Task> _answer = new Return<Task>();
if (string.IsNullOrEmpty(taskName))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentNullException("taskName"), this.GetType());
}
else
{
Return<SqlConnection> _answerConnection = this.connection;
if (_answerConnection.theresError)
{
_answer.theresError = true;
_answer.error = _answerConnection.error;
}
else
{
try
{
using (SqlConnection _connection = _answerConnection.data)
{
if (_connection.State != ConnectionState.Open)
_connection.Open();
using (SqlCommand _command = new SqlCommand() { CommandType = CommandType.Text, Connection = _connection, CommandTimeout = timeoutInSecondsBD })
{//using SqlCommand
string _fields = string.Format("{0},{1},{2},{3},{4}", SQLGrp_Class.FLD_TASK_ID, SQLGrp_Class.FLD_TASK_NAME, SQLGrp_Class.FLD_TASK_GCDESCRIPTION
, SQLGrp_Class.FLD_TASK_CREATIONDATE, SQLGrp_Class.FLD_TASK_LASTMODIFICATIONDATE);
_command.CommandText = string.Format("select {0} from {1} where {2}[email protected]", _fields, SQLGrp_Class.TAB_TASK, SQLGrp_Class.FLD_TASK_NAME);
_command.Parameters.AddWithValue("@taskName", taskName);
using (SqlDataReader _dataReader = _command.ExecuteReader())
{//using SqlDataReader
using (DataTable _table = new DataTable())
{//using DataTable
_table.Load(_dataReader);
Return<List<Task>> _answerConversion = DataRowCollectionToTask(_table.Rows);
if (_answerConversion.theresError)
{
_answer.theresError = true;
_answer.error = _answerConversion.error;
}
else
_answer.data = _answerConversion.data.FirstOrDefault();
}//using DataTable
}//using SqlDataReader
}//using SqlCommand
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, this.GetType());
}
}
}
return _answer;
}
示例8: GetSqlConnection
public static Return<SqlConnection> GetSqlConnection(string connectionString)
{
Return<SqlConnection> _answer = new Return<SqlConnection>();
if (string.IsNullOrEmpty(connectionString))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("connectionString"), typeof(Utility));
}
else
{
try
{
int _indexInit = connectionString.IndexOf("["), _indexEnd = connectionString.IndexOf("]");
if (_indexInit < 0 || _indexEnd < 0 || _indexInit >= _indexEnd)
{
string _message = "The connection string has a wrong format";
_answer.theresError = true;
_answer.error = Utility.GetError(new Exception(_message), typeof(DataUtility));
}
else
{
string _password = connectionString.Substring(_indexInit + 1, _indexEnd - _indexInit - 1);
if (string.IsNullOrEmpty(_password))
{
string _message = "The password in the connection string is empty";
_answer.theresError = true;
_answer.error = Utility.GetError(new Exception(_message), typeof(DataUtility));
}
else
{
Return<string> _answerDecryptString = SecurityUtility.DecryptString(_password);
if (_answerDecryptString.theresError)
{
_answer.theresError = true;
_answer.error = _answerDecryptString.error;
}
else
{
string _firPart = connectionString.Substring(0, _indexInit)
, _lastPart = connectionString.Substring(_indexEnd + 1, connectionString.Length - _indexEnd - 1);
string _realConnectionString = string.Format("{0}{1}{2}", _firPart, _answerDecryptString.data, _lastPart);
_answer.data = new SqlConnection(_realConnectionString);
}
}
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, typeof(Utility));
}
}
return _answer;
}
示例9: DecryptString
public static Return<string> DecryptString(string inputString, string key)
{
Return<string> _answer = new Return<string>() { data = string.Empty };
if (string.IsNullOrEmpty(inputString))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("inputString"), typeof(Utility));
}
else
if (string.IsNullOrEmpty(key))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("key"), typeof(Utility));
}
else
{
try
{
TripleDESCryptoServiceProvider _tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
// Put the string into a byte array
byte[] _inputbyteArray = new byte[inputString.Length / 2]; //Encoding.UTF8.GetBytes(inputString);
// Create the crypto objects, with the key, as passed in
MD5CryptoServiceProvider _hashMD5 = new MD5CryptoServiceProvider();
_tripleDESCryptoServiceProvider.Key = _hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
_tripleDESCryptoServiceProvider.Mode = CipherMode.ECB;
// Put the input string into the byte array
for (int _x = 0; _x < _inputbyteArray.Length; _x++)
{
Int32 _iJ = (Convert.ToInt32(inputString.Substring(_x * 2, 2), 16));
_inputbyteArray[_x] = new Byte();
_inputbyteArray[_x] = (byte)_iJ;
}
MemoryStream _memoryStream = new MemoryStream();
CryptoStream _cryptoStream = new CryptoStream(_memoryStream, _tripleDESCryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
// Flush the data through the crypto stream into the memory stream
_cryptoStream.Write(_inputbyteArray, 0, _inputbyteArray.Length);
_cryptoStream.FlushFinalBlock();
// Get the decrypted data back from the memory stream
StringBuilder _stringBuilder = new StringBuilder();
byte[] _byteArray = _memoryStream.ToArray();
_memoryStream.Close();
for (int I = 0; I < _byteArray.Length; I++)
_stringBuilder.Append((char)(_byteArray[I]));
_answer.data = _stringBuilder.ToString();
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, typeof(Utility));
}
}
return _answer;
}
示例10: EncryptString
public static Return<string> EncryptString(string inputString, string key)
{
Return<string> _answer = new Return<string>() { data = string.Empty };
if (string.IsNullOrEmpty(inputString))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("inputString"), typeof(Utility));
}
else
if (string.IsNullOrEmpty(key))
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentException("key"), typeof(Utility));
}
else
{
try
{
TripleDESCryptoServiceProvider _tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
// Put the string into a byte array
byte[] _inputbyteArray = Encoding.UTF8.GetBytes(inputString);
// Create the crypto objects, with the key, as passed in
MD5CryptoServiceProvider _hashMD5 = new MD5CryptoServiceProvider();
_tripleDESCryptoServiceProvider.Key = _hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
_tripleDESCryptoServiceProvider.Mode = CipherMode.ECB;
MemoryStream _memoryStream = new MemoryStream();
CryptoStream _cryptoStream = new CryptoStream(_memoryStream, _tripleDESCryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
// Write the byte array into the crypto stream
// (It will end up in the memory stream)
_cryptoStream.Write(_inputbyteArray, 0, _inputbyteArray.Length);
_cryptoStream.FlushFinalBlock();
// Get the data back from the memory stream, and into a string
StringBuilder _stringBuilder = new StringBuilder();
byte[] _byteArray = _memoryStream.ToArray();
_memoryStream.Close();
for (int I = 0; I < _byteArray.Length; I++)
{
//Format as hex
_stringBuilder.AppendFormat("{0:X2}", _byteArray[I]);
}
_answer.data = _stringBuilder.ToString();
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, typeof(Utility));
}
}
return _answer;
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strParamID = Request["ReturnID"];
if (!string.IsNullOrEmpty(strParamID))
{
returnObj = ReturnBLL.Get(strParamID.ToInt());
if (returnObj != null)
{
LabelTitle1.Text = "BIÊN BẢN THU HỒI";
LoadReturn();
RedBloodDataContext db = new RedBloodDataContext();
var v1 = db.PackOrders.Where(r => r.ReturnID.Value == returnObj.ID)
.Select(r => r.Pack)
.ToList();
var v = v1.GroupBy(r => r.ProductCode)
.Select(r => new
{
ProductDesc = ProductBLL.GetDesc(r.Key),
ProductCode = r.Key,
Sum = r.Count(),
BloodGroupSumary = r.GroupBy(r1 => r1.Donation.BloodGroup).Select(r1 => new
{
BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
Total = r1.Count(),
VolumeSumary = r1.GroupBy(r2 => r2.Volume).Select(r2 => new
{
Volume = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
Total = r2.Count(),
DINList = r2.Select(r3 => new { DIN = r3.DIN }).OrderBy(r4 => r4.DIN),
}).OrderBy(r2 => r2.Volume)
}).OrderBy(r1 => r1.BloodGroupDesc),
});
GridViewSum.DataSource = v;
GridViewSum.DataBind();
LableCount.Text = v1.Count().ToStringRemoveZero();
}
}
}
}
示例12: JsonMtGOX
public JsonMtGOX()
{
high = new High();
low = new Low();
avg = new Avg();
vwap = new Vwap();
vol = new Vol();
lastlocal = new LastLocal();
lastorig = new LastOrig();
lastall = new LastAll();
last = new Last();
buy = new Buy();
sell = new Sell();
rootobject = new RootObject();
returnObject = new Return();
}
示例13: Add
public static int Add(List<int> packOrderIDList, string note)
{
RedBloodDataContext db = new RedBloodDataContext();
List<PackOrder> poL = PackOrderBLL.Get4Return(db, packOrderIDList);
Return re = new Return();
re.Note = note;
db.Returns.InsertOnSubmit(re);
db.SubmitChanges();
foreach (var item in packOrderIDList)
{
PackOrderBLL.Return(re.ID, item, note);
}
return re.ID;
}
示例14: Return_SetsProgramCounterToDecodedAddress
public void Return_SetsProgramCounterToDecodedAddress()
{
// Arrange
var returner = new Return();
var stack = new Mock<IStack>();
var decoder = new Mock<IDecoder>();
decoder.Setup(d => d.Decode(It.IsAny<UInt64>()))
.Returns(new Instruction { Operand = 999999999 });
var context = new ExecutionContext
{
Stack = stack.Object,
Decoder = decoder.Object
};
// Act
returner.Execute(context, null);
// Asserty
context.ProgramCounter.Should().Be(999999999);
}
示例15: Return_CallsDecodeToGetAddress
public void Return_CallsDecodeToGetAddress()
{
// Arrange
var returner = new Return();
var stack = new Mock<IStack>();
var decoder = new Mock<IDecoder>();
decoder.Setup(d => d.Decode(It.IsAny<UInt64>()))
.Returns(new Instruction { Operand = 999999999 });
var context = new ExecutionContext
{
Stack = stack.Object,
Decoder = decoder.Object
};
// Act
returner.Execute(context, null);
// Asserty
decoder.Verify(d => d.Decode(It.IsAny<UInt64>()), Times.Once);
}