本文整理汇总了C#中Association类的典型用法代码示例。如果您正苦于以下问题:C# Association类的具体用法?C# Association怎么用?C# Association使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Association类属于命名空间,在下文中一共展示了Association类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChunks
/// <summary>
/// Splits the DICOM object into chunks that are within the max PDU size
/// </summary>
/// <param name="dicomObject"> the DICOM objec to be split</param>
/// <param name="maxPduSize">the max length (in bytes) for a PDU</param>
/// <param name="asc">the association that the file will be sent</param>
/// <returns></returns>
private static List<byte[]> GetChunks(DICOMObject dicomObject, int maxPduSize, Association asc)
{
byte[] dicomBytes;
using (var stream = new MemoryStream())
{
using (var dw = new DICOMBinaryWriter(stream))
{
DICOMObjectWriter.Write(dw,
new DICOMWriteSettings
{
TransferSyntax =
TransferSyntaxHelper.GetSyntax(asc.PresentationContexts.First().TransferSyntaxes.First()),
DoWriteIndefiniteSequences = false
}, dicomObject);
dicomBytes = stream.ToArray();
}
}
var split = new List<byte[]>();
int i = 0;
while (i < dicomBytes.Length)
{
int toTake = dicomBytes.Length >= (maxPduSize - 6) + i ? maxPduSize - 6 : dicomBytes.Length - i;
byte[] fragment = dicomBytes.Skip(i).Take(toTake).ToArray();
i += fragment.Length;
split.Add(fragment);
}
return split;
}
示例2: buttonSave_Click
void buttonSave_Click(object sender, EventArgs e)
{
try
{
Page.Validate();
if (Page.IsValid)
{
Association association = AssociationBL.GetBy(base.AssociationId, false);
if (association == null)
{
// insert
association = new Association();
association.Name = TextName.Text;
association.Description = TextDescription.Text;
association = AssociationBL.Insert(association);
}
else
{
// update
association.Name = TextName.Text;
association.Description = TextDescription.Text;
association = AssociationBL.Update(association);
}
if (association == null) { message.Text = "Save failed"; }
else { _redirectToListUrl(); }
}
}
catch (Exception ex)
{
message.Text = ex.Message;
}
}
示例3: SendAccept
public static void SendAccept(Accept accept, Association asc)
{
var stream = asc.Stream;
byte[] message = accept.Write();
asc.Logger.Log("-->" + accept);
stream.Write(message, 0, message.Length);
}
示例4: Simple
public void Simple()
{
var assoc = new Association<int, string>(5, "aa");
Assert.AreEqual(assoc.Key, 5);
Assert.AreEqual(assoc.Value, "aa");
}
示例5: Add
public void Add(Association association)
{
if (string.IsNullOrEmpty(association.Name))
{
throw new Exception("You must complete the field name to continue!");
}
else if(string.IsNullOrEmpty(association.Action))
{
throw new Exception("You must choose an action to continue!");
}
else if (string.IsNullOrEmpty(association.Destination))
{
throw new Exception("You must complete the field destination choosing a folder to continue!");
}
else if (string.IsNullOrEmpty(association.Extension))
{
throw new Exception("You must add a file extension to continue!");
}
else if (!isValidExtension(association.Extension))
{
throw new Exception("The extension is not correct, It must be in this format example: *.jpg or *.yourExtension");
}
else
{
if (!(_dassociation.Add(association) >= 1))
{
throw new Exception("There was a problem adding this association, please try again.");
}
}
}
示例6: createAssociation
public static Association createAssociation(string name, string rolename, Group group)
{
Association asso = new Association();
asso.name = name;
asso.roleName = rolename;
asso.Item = group;
return asso;
}
示例7: AssociationsManager
public AssociationsManager()
{
_association = null;
InitializeComponent();
//
_bassociation = new BAssociation();
}
示例8: Equality
public void Equality()
{
var assoc = new Association<int, string>(5, "aa");
var assoc2 = new Association<int, string>(5, "aa");
Assert.AreEqual(assoc.Key, assoc2.Key);
Assert.AreEqual(assoc.Key, assoc2.Key);
Assert.AreEqual(assoc, assoc2);
}
示例9: Simple
public void Simple()
{
var assoc = new Association<int, string>(5, "aa");
var newAssoc = SerializeUtil.BinarySerializeDeserialize(assoc);
Assert.AreEqual(assoc.Key, newAssoc.Key);
Assert.AreEqual(assoc.Value, newAssoc.Value);
Assert.AreNotSame(assoc, newAssoc);
}
示例10: Add
public int Add(Association association)
{
try
{
_FileOContext.Associations.Add(association);
return _FileOContext.SaveChanges();
}
catch (Exception) { return 0; }
}
示例11: Set
/// <summary>
/// Stores an <see cref="Association"/> in the collection.
/// </summary>
/// <param name="association">The association to add to the collection.</param>
public void Set(Association association) {
Requires.NotNull(association, "association");
lock (this.associations) {
this.associations.Remove(association.Handle); // just in case one already exists.
this.associations.Add(association);
}
Assumes.True(this.Get(association.Handle) == association);
}
示例12: Set
/// <summary>
/// Stores an <see cref="Association"/> in the collection.
/// </summary>
/// <param name="association">The association to add to the collection.</param>
public void Set(Association association) {
Contract.Requires<ArgumentNullException>(association != null);
Contract.Ensures(this.Get(association.Handle) == association);
lock (this.associations) {
this.associations.Remove(association.Handle); // just in case one already exists.
this.associations.Add(association);
}
Contract.Assume(this.Get(association.Handle) == association);
}
示例13: Insert
public Association Insert(Association association)
{
association.Enabled = true;
association.ID = Guid.NewGuid();
association.Created = DateTime.Now;
association.Modified = DateTime.Now;
DataContextHelper.CurrentContext.Associations.InsertOnSubmit(association);
DataContextHelper.CurrentContext.SubmitChanges();
return association;
}
示例14: XmlSimple
public void XmlSimple()
{
var assoc = new Association<int, string>(5, "aa");
var serialize = assoc.Serialize();
var newAssoc = ObjectExtensions.Deserialize<Association<int, string>>(serialize);
Assert.AreEqual(assoc.Key, newAssoc.Key);
Assert.AreEqual(assoc.Value, newAssoc.Value);
Assert.AreEqual(assoc, newAssoc);
}
示例15: SendReleaseResponse
public static void SendReleaseResponse(Association asc)
{
var resp = new ReleaseResponse();
asc.Logger.Log("-->" + resp);
byte[] message = resp.Write();
if (asc.Stream.CanWrite)
{
asc.Stream.Write(message, 0, message.Length);
}
}