本文整理汇总了C#中PropertySet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PropertySet.Add方法的具体用法?C# PropertySet.Add怎么用?C# PropertySet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertySet
的用法示例。
在下文中一共展示了PropertySet.Add方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
public void Copy()
{
PropertySet original = new PropertySet();
original.Add("abc", "123");
original.Add("def", "");
PropertySet copy = original.Copy();
Assert.AreNotSame(original, copy);
AssertAreEqual(original, copy);
}
示例2: ExportItem
internal void ExportItem()
{
if (this.ItemToExport.GetType().Name.ToString() != "EmailMessage")
throw new InvalidOperationException("Please provide item typeof EmailMessage.");
ExchangeService ewsSession = this.GetSessionVariable();
PropertySet propertySet = new PropertySet(EmailMessageSchema.MimeContent);
propertySet.Add(EmailMessageSchema.ConversationTopic);
EmailMessage emailMessage = EmailMessage.Bind(ewsSession, this.ItemToExport.Id, propertySet);
Random rNumber = new Random();
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "EmailExport");
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
if (string.IsNullOrEmpty(this.fileName))
{
int subjectLenght = emailMessage.ConversationTopic.Length > 10 ? 10 : emailMessage.ConversationTopic.Length;
fileName = String.Format( "Email-{0}-{1}" , emailMessage.ConversationTopic.Substring( 0 , subjectLenght ) , rNumber.Next( 1 , 10 ) );
}
fileName = Path.Combine(directory, string.Format("{0}.eml", fileName));
using (FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
fileStream.Write(emailMessage.MimeContent.Content, 0, emailMessage.MimeContent.Content.Length);
}
}
示例3: SerializeToXml
public void SerializeToXml(string expectedXml, string[] keyValuePairs)
{
PropertySet map = new PropertySet();
for (int i = 0; i < keyValuePairs.Length; i += 2)
map.Add(keyValuePairs[i], keyValuePairs[i + 1]);
StringWriter writer = new StringWriter();
serializer.Serialize(writer, map);
Assert.AreEqual(expectedXml, writer.ToString());
}
示例4: GetOutlookAppointment
private OutlookAppointment GetOutlookAppointment(Microsoft.Exchange.WebServices.Data.Appointment appointment, ExchangeService service)
{
OutlookAppointment newAppointment = new OutlookAppointment();
PropertySet props = new PropertySet();
props.Add(AppointmentSchema.Body);
props.Add(AppointmentSchema.Subject);
newAppointment.IsEWS = true;
newAppointment.Service = service;
newAppointment.Id = appointment.Id.UniqueId;
newAppointment.Subject = appointment.Subject;
newAppointment.Start = appointment.Start;
newAppointment.End = appointment.End;
newAppointment.AllDayEvent = appointment.IsAllDayEvent;
newAppointment.Location = appointment.Location;
newAppointment.Organizer = appointment.Organizer.ToString();
newAppointment.ReminderMinutesBeforeStart = appointment.ReminderMinutesBeforeStart;
newAppointment.ReminderSet = appointment.IsReminderSet;
return newAppointment;
}
示例5: DumpMIME
/// <summary>
/// Get the MimeContent of each Item specified in itemIds and write it
/// to the destination folder.
/// </summary>
/// <param name="itemIds">ItemIds to retrieve</param>
/// <param name="destinationFolderPath">Folder to save messages to</param>
/// <param name="service">ExchangeService to use to make EWS calls</param>
public static void DumpMIME(
List<ItemId> itemIds,
string destinationFolderPath,
ExchangeService service)
{
DebugLog.WriteVerbose(String.Format("Getting {0} items by ItemId.", itemIds.Count));
PropertySet mimeSet = new PropertySet(BasePropertySet.IdOnly);
mimeSet.Add(EmailMessageSchema.MimeContent);
mimeSet.Add(EmailMessageSchema.Subject);
//mimeSet.Add(AppointmentSchema.MimeContent);
//mimeSet.Add(AppointmentSchema.Subject);
//mimeSet.Add(AppointmentSchema.RequiredAttendees);
//mimeSet.Add(AppointmentSchema.OptionalAttendees);
ServiceResponseCollection<GetItemResponse> responses = service.BindToItems(itemIds, mimeSet);
DebugLog.WriteVerbose("Finished getting items.");
foreach (GetItemResponse response in responses)
{
switch (response.Result)
{
case ServiceResult.Success:
DumpMIME(response.Item, destinationFolderPath);
break;
case ServiceResult.Error:
DumpErrorResponseXML(response, destinationFolderPath);
break;
case ServiceResult.Warning:
throw new NotImplementedException("DumpMIME doesn't handle ServiceResult.Warning.");
default:
throw new NotImplementedException("DumpMIME encountered an unexpected ServiceResult.");
}
}
DebugLog.WriteVerbose("Finished dumping MimeContents for each item.");
}
示例6: ProcessRecord
protected override void ProcessRecord()
{
ItemView itemView = new ItemView(30);
if (this.CustomProperty != null)
{
PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties);
foreach (PropertyDefinitionBase customProp in this.CustomProperty)
propertySet.Add(customProp);
itemView.PropertySet = propertySet;
}
EwsItem ewsItems = new EwsItem(this.EwsSession, this.FolderRoot, itemView, this.SearchFilter);
ewsItems.SearchResultFound += OnSearchResultFound;
ewsItems.FindItem(this.FolderRoot);
}
示例7: EnsurePropertyCache
private PropertySet EnsurePropertyCache(Record record)
{
var columns = record.Columns;
if (null != columns)
{
PropertySet properties;
if (!this.cache.TryGetValue(columns.QueryString, out properties))
{
properties = new PropertySet();
for (int i = 0; i < columns.Count; ++i)
{
var column = columns[i];
properties.Add(new PSAdaptedProperty(column.Key, column));
}
// Format a suitable type name if only a single table was selected.
if (null != columns.TableNames && 1 == columns.TableNames.Length)
{
properties.TypeName = typeof(Record).FullName + "#" + columns.TableNames[0];
}
this.cache.Add(columns.QueryString, properties);
}
return properties;
}
return null;
}
示例8: DumpMIMEToString
/// <summary>
/// Get the MimeContent of each Item specified in itemIds and write it
/// to a string.
/// </summary>
/// <param name="itemIds">ItemIds to retrieve</param>
/// <param name="destinationFolderPath">Folder to save messages to</param>
/// <param name="service">ExchangeService to use to make EWS calls</param>
/// <param name="TheMime">MIME string to set</param>
public static void DumpMIMEToString(
List<ItemId> itemIds,
ExchangeService service,
ref string TheMime)
{
DebugLog.WriteVerbose(String.Format("Getting {0} items by ItemId.", itemIds.Count));
string MimeToReturn = string.Empty;
PropertySet mimeSet = new PropertySet(BasePropertySet.IdOnly);
mimeSet.Add(EmailMessageSchema.MimeContent);
mimeSet.Add(EmailMessageSchema.Subject);
ServiceResponseCollection<GetItemResponse> responses = service.BindToItems(itemIds, mimeSet);
DebugLog.WriteVerbose("Finished getting items.");
foreach (GetItemResponse response in responses)
{
switch (response.Result)
{
case ServiceResult.Success:
if (response.Item.MimeContent == null)
{
throw new ApplicationException("No MIME content to write");
}
UTF8Encoding oUTF8Encoding = new UTF8Encoding();
MimeToReturn = oUTF8Encoding.GetString(response.Item.MimeContent.Content);
break;
case ServiceResult.Error:
MimeToReturn =
"ErrorCode: " + response.ErrorCode.ToString() + "\r\n" +
"\r\nErrorMessage: " + response.ErrorMessage + "\r\n";
break;
case ServiceResult.Warning:
throw new NotImplementedException("DumpMIMEToString doesn't handle ServiceResult.Warning.");
default:
throw new NotImplementedException("DumpMIMEToString encountered an unexpected ServiceResult.");
}
}
TheMime = MimeToReturn;
DebugLog.WriteVerbose("Finished dumping MimeContents for each item.");
}
示例9: DeserializeFromXml
public void DeserializeFromXml(string xml, string[] expectedKeyValuePairs)
{
PropertySet expectedMap = new PropertySet();
for (int i = 0; i < expectedKeyValuePairs.Length; i += 2)
expectedMap.Add(expectedKeyValuePairs[i], expectedKeyValuePairs[i + 1]);
PropertySet actualMap = (PropertySet) serializer.Deserialize(new StringReader(xml));
AssertAreEqual(expectedMap, actualMap);
}
示例10: GetAndSetValue
public void GetAndSetValue()
{
PropertySet set = new PropertySet();
Assert.IsNull(set.GetValue("key"));
set.SetValue("key", "value");
Assert.AreEqual("value", set.GetValue("key"));
set.SetValue("key", "different value");
Assert.AreEqual("different value", set.GetValue("key"));
set.SetValue("key", null);
Assert.IsNull(set.GetValue("key"));
set.Add("key", "value1");
Assert.AreEqual("value1", set.GetValue("key"));
}
示例11: AsReadOnly
public void AsReadOnly()
{
PropertySet original = new PropertySet();
original.Add("abc", "123");
PropertySet readOnly = original.AsReadOnly();
Assert.IsTrue(readOnly.IsReadOnly);
AssertAreEqual(original, readOnly);
MbUnit.Framework.Assert.Throws<NotSupportedException>(delegate { readOnly.Add("def", "456"); });
}
示例12: CanonicalizePropertiesToLowerCase
private static PropertySet CanonicalizePropertiesToLowerCase(PropertySet properties)
{
PropertySet result = new PropertySet();
foreach (KeyValuePair<string, string> property in properties)
result.Add(CanonicalizePropertyKey(property.Key), property.Value);
return result;
}