public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); stateSaver.Add("TARGETDIR", Context.Parameters["DP_TargetDir"].ToString()); m_TargetDir = stateSaver["TARGETDIR"].ToString(); this.CreateConnection(); }
//not pretty or efficient but works public void GetValueToDict(Type keyType, Type valType, System.Collections.IDictionary val) { uint ln = ReadUInt32(); if (ln > Protocol.MaxArrayLength) { throw new Exception("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); } //advance to the alignment of the element //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type))); ReadPad(8); int endPos = pos + (int)ln; //while (stream.Position != endPos) while (pos < endPos) { ReadPad(8); val.Add(ReadValue(keyType), ReadValue(valType)); } if (pos != endPos) { throw new Exception("Read pos " + pos + " != ep " + endPos); } }
//not pretty or efficient but works public void GetValueToDict(Type keyType, Type valType, System.Collections.IDictionary val) { uint ln; GetValue(out ln); //advance to the alignment of the element //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type))); ReadPad(8); int endPos = pos + (int)ln; //while (stream.Position != endPos) while (pos < endPos) { ReadPad(8); object keyVal; GetValue(keyType, out keyVal); object valVal; GetValue(valType, out valVal); val.Add(keyVal, valVal); } if (pos != endPos) { throw new Exception("Read pos " + pos + " != ep " + endPos); } }
private void AddKeyToDictionary(object key) { IDictionary[] targetArray = this.GetValue().Cast <IDictionary>().Where(v => v != null).ToArray(); Type valueType = GetIDictionaryValueType(this.EditedType); Type reflectedValueType = PropertyEditor.ReflectDynamicType(valueType, targetArray.Select(a => GetIDictionaryValueType(a.GetType()))); for (int t = 0; t < targetArray.Length; t++) { IDictionary target = targetArray[t]; if (target != null) { if (!target.IsFixedSize && !target.IsReadOnly) { if (!target.Contains(key)) { // Add a new key value pair target.Add(key, valueType.IsValueType ? reflectedValueType.CreateInstanceOf() : null); } } else { // Just some read-only container? Well, can't do anything here. } } } }
public virtual void AddEntry(object key, object value) { if (map == null) { map = new NeoDatis.Tool.Wrappers.Map.OdbHashMap(); } map.Add(key, value); }
public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); if (!string.IsNullOrEmpty(base.Context.Parameters["TARGETDIR"].ToString())) { stateSaver.Add("TARGETDIR", base.Context.Parameters["TARGETDIR"].ToString()); } }
internal static void AddSkillInfos() { System.Collections.IDictionary skillInfoDict = (System.Collections.IDictionary)SkillLink.dict.GetValue(null); foreach (KeyValuePair <string, object> kvp in ModSkillDescriptions) { skillInfoDict.Add(kvp.Key, kvp.Value); } }
protected override void PreFilterProperties(System.Collections.IDictionary properties) { base.PreFilterProperties(properties); properties.Add("SchemeMode", TypeDescriptor.CreateProperty(typeof(BorderLayoutDesigner), "SchemeMode", typeof(bool), new DescriptionAttribute("Show border layout as scheme"), DesignOnlyAttribute.Yes)); }
/// <summary> /// Add the design-time only properties to the list. /// </summary> protected override void PreFilterProperties( System.Collections.IDictionary properties) { // It is much likely that "Document" is already // in the dictionary, so use unique key for the // surrogate properties.Add("Document_Surrogate", TypeDescriptor.CreateProperty(typeof(RulerDesigner), "Document", typeof(FlowChart), null)); }
public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); string curPath = GetPath(); stateSaver.Add("previousPath", curPath); string newPath = AddPath(curPath, MyPath()); if (curPath != newPath) { stateSaver.Add("changedPath", true); stateSaver.Add("newPath", newPath); SetPath(newPath); } else { stateSaver.Add("changedPath", false); } }
protected void odsEquipTypes_OnInserting(object source, ObjectDataSourceMethodEventArgs e) { System.Collections.IDictionary paramsFromPage = e.InputParameters; TrackerDotNet.control.EquipTypeTbl _et = new TrackerDotNet.control.EquipTypeTbl(); _et.EquipTypeName = paramsFromPage["EquipTypeName"].ToString(); _et.EquipTypeDesc = paramsFromPage["EquipTypeDesc"].ToString(); paramsFromPage.Clear(); paramsFromPage.Add("objEquipType", _et); }
public static void AddContext(string key, object obj) { if (obj == null) { ExecutionContext.Remove(key); } else { ExecutionContext.Add(key, obj); } }
void System.Collections.IDictionary.Add(object key, object value) { System.Collections.IDictionary dic = (System.Collections.IDictionary)_dictionary; if (dic.Contains(key)) { dic[key] = value; } else { dic.Add(key, value); } }
private static void LoadImages() { mImages = new System.Collections.Hashtable(); string imagename; System.Drawing.Image img = null; foreach (Char item in _Seed) { imagename = "NBear.Web.EmbeddedImages." + item + ".gif"; img = System.Drawing.Image.FromStream(typeof(SerialNumberValidator).Assembly.GetManifestResourceStream(imagename)); mImages.Add(item.ToString(), img); } }
/// <summary> /// Used to save an item to the current HTTPRequests items collection. This is useful if multiple blocks /// on the same page will need access to the same object. The first block can read the object and save /// it using this method for the other blocks to reference /// </summary> /// <param name="key"></param> /// <param name="item"></param> public void SaveSharedItem(string key, object item) { string itemKey = string.Format("{0}:Item:{1}", PageCache.CacheKey(Id), key); System.Collections.IDictionary items = HttpContext.Current.Items; if (items.Contains(itemKey)) { items[itemKey] = item; } else { items.Add(itemKey, item); } }
public void TestIDictionary() { IDictionary dictionary = ImmutableSortedTreeDictionary.CreateBuilder <int, int>(); Assert.False(dictionary.IsFixedSize); Assert.False(dictionary.IsReadOnly); Assert.False(dictionary.IsSynchronized); Assert.Throws <ArgumentNullException>("key", () => dictionary.Add(key: null !, value: 1)); Assert.Throws <ArgumentException>("value", () => dictionary.Add(key: 1, value: null)); Assert.Throws <ArgumentException>("key", () => dictionary.Add(key: "string value", value: 0)); Assert.Throws <ArgumentException>("value", () => dictionary.Add(key: 0, value: "string value")); for (int i = 0; i < 11; i++) { dictionary.Add(i, i + 1); } // Adding the same key/value pair does not throw or change the collection size Assert.Equal(11, dictionary.Count); dictionary.Add(10, 11); Assert.Equal(11, dictionary.Count); Assert.Throws <ArgumentNullException>("key", () => dictionary[key: null !]);
/// ========================================================================================================================================================= /// <summary> /// Sets a value in the dictionary. If the key does not yet exist, the value is added to the dictionary. If it exists, the value is replaced. /// </summary> /// <param name="dictionary">The dictionary to insert the value into</param> /// <param name="key">The key of the value that should be inserted or replaced</param> /// <param name="value">The value that should be inserted or replaced</param> /// ========================================================================================================================================================= public static void Set(this System.Collections.IDictionary dictionary, object key, object value) { if (key == null) { return; } bool isKeyAvailable = dictionary.Contains(key); if (isKeyAvailable) { dictionary[key] = value; } else { dictionary.Add(key, value); } }
public virtual void AddBase(string baseIdentifier, string fileName, string user, string password) { NeoDatis.Odb.Core.Server.Layers.Layer3.ServerFileParameter fileParameter = new NeoDatis.Odb.Core.Server.Layers.Layer3.ServerFileParameter (baseIdentifier, fileName, true); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = null; engine = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetServerStorageEngine(fileParameter , user, password); engine.Commit(); bases.Add(baseIdentifier, engine); connectionManagers.Add(baseIdentifier, new NeoDatis.Odb.Core.Server.Connection.ConnectionManager (engine)); if (NeoDatis.Odb.OdbConfiguration.IsInfoEnabled(LogId)) { NeoDatis.Tool.DLogger.Info("ODBServer:Adding base : name=" + baseIdentifier + " (file=" + fileName + ") to server"); } }
/* public void setToUseFields() * { * //setValueinObject = setValueinObjectAsField; * setValueinObject = setValueinObjectAsMember; * } * * public void setToUseProperties() * { * //setValueinObject = setValueinObjectAsProperty; * setValueinObject = setValueinObjectAsMember; * } */ static bool setValueAsMap(object target, string propertyName, object propertyValue) { if (!typeof(IDictionaryNonGeneric).IsAssignableFrom(target.GetType())) { return(false); } IDictionaryNonGeneric dict = (IDictionaryNonGeneric)target; Type [] gTypes = target.GetType().GetGenericArguments(); object key = propertyName; if (gTypes.Length == 2 && gTypes[0] != typeof(object)) { key = Convert.ChangeType(key, gTypes[0]); } dict.Add(key, propertyValue); return(true); }
/// <summary> /// Converts a table to a <see cref="Dictionary{K,V}"/> /// </summary> internal static object ConvertTableToDictionaryOfGenericType(Type dictionaryType, Type keyType, Type valueType, Table table) { if (dictionaryType.GetGenericTypeDefinition() != typeof(Dictionary <,>)) { dictionaryType = typeof(Dictionary <,>); dictionaryType = dictionaryType.MakeGenericType(keyType, valueType); } System.Collections.IDictionary dic = (System.Collections.IDictionary)Activator.CreateInstance(dictionaryType); foreach (var kvp in table.Pairs) { object key = ScriptToClrConversions.DynValueToObjectOfType(kvp.Key, keyType, null, false); object val = ScriptToClrConversions.DynValueToObjectOfType(kvp.Value, valueType, null, false); dic.Add(key, val); } return(dic); }
object System.Collections.IDictionary.this[object key] { get { System.Collections.IDictionary dic = (System.Collections.IDictionary)_dictionary; if (dic.Contains(key)) { return(dic[key]); } return(null); } set { System.Collections.IDictionary dic = (System.Collections.IDictionary)_dictionary; if (dic.Contains(key)) { dic[key] = value; } else { dic.Add(key, value); } } }
static StackObject *Add_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object @value = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Object @key = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Collections.IDictionary instance_of_this_method = (System.Collections.IDictionary) typeof(System.Collections.IDictionary).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@key, @value); return(__ret); }
protected void AddKeyButtonPressed(object sender, EventArgs e) { if (this.addKey == null) { return; } IDictionary[] targetArray = this.GetValue().Cast <IDictionary>().ToArray(); Type valueType = this.GetValueType(); for (int t = 0; t < targetArray.Length; t++) { IDictionary target = targetArray[t]; if (target != null) { if (!target.IsFixedSize && !target.IsReadOnly) { if (!target.Contains(this.addKey)) { // Add a new key value pair target.Add(this.addKey, valueType.IsValueType ? ReflectionHelper.CreateInstanceOf(valueType) : null); } } else { // Just some read-only container? Well, can't do anything here. } } } // Focus-Unfocus to trigger some kind of "select all" / "reset" behaivor in the "Add Key" field. this.ParentGrid.Focus(this); this.addKeyEditor.Focus(); // Reset add key editor and update sub-editors this.addKey = null; this.PerformGetValue(); }
private System.Reflection.FieldInfo GetField(int fieldIndex, object o) { System.Type clazz = o.GetType(); string key = clazz.FullName + fieldNames[fieldIndex]; System.Reflection.FieldInfo field = (System.Reflection.FieldInfo)map[key]; if (field != null) { return(field); } System.Collections.IList l = classIntrospector.GetAllFields(clazz.FullName); for (int i = 0; i < l.Count; i++) { field = (System.Reflection.FieldInfo)l[i]; if (field.Name.Equals(fieldNames[fieldIndex])) { map.Add(key, field); return(field); } } throw new System.Exception("Field " + fieldNames[fieldIndex] + " does not exist on class " + o.GetType()); }
public override object Deserialize(BytePacker packer) { int length = packer.ReadInt(); if (length < 0) { return(null); } else { System.Collections.IDictionary dictionary = (System.Collections.IDictionary)Activator.CreateInstance(type); object key, value; for (int i = 0; i < length; i++) { key = keyConverter.Deserialize(packer); value = valueConverter.Deserialize(packer); dictionary.Add(key, value); } return(dictionary); } }
static int _m_Add(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Collections.IDictionary gen_to_be_invoked = (System.Collections.IDictionary)translator.FastGetCSObj(L, 1); { object _key = translator.GetObject(L, 2, typeof(object)); object _value = translator.GetObject(L, 3, typeof(object)); gen_to_be_invoked.Add(_key, _value); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public object FromBytes(byte[] bytes) { List <byte[]> keybytes = new List <byte[]>(); List <byte[]> valuebytes = new List <byte[]>(); int KeyByteLen = BitConverter.ToInt32(bytes, 0); int ValueByteLen = BitConverter.ToInt32(bytes, 4); if (KeyByteLen == 0) { return(null); } byte[] KeyTotalBytes = new byte[KeyByteLen]; byte[] ValueTotalBytes = new byte[ValueByteLen]; System.Buffer.BlockCopy(bytes, 8, KeyTotalBytes, 0, KeyByteLen); System.Buffer.BlockCopy(bytes, 8 + KeyByteLen, ValueTotalBytes, 0, ValueByteLen); int keystartposition = 0; while (true) { if (this.KeyLength > 0) { byte[] onekeybytes = new byte[this.KeyLength]; System.Buffer.BlockCopy(KeyTotalBytes, keystartposition, onekeybytes, 0, this.KeyLength); keystartposition += this.KeyLength; keybytes.Add(onekeybytes); } else { int len = BitConverter.ToInt32(KeyTotalBytes, keystartposition); keystartposition += 4; if (len > 0) { byte[] onekeybytes = new byte[len]; System.Buffer.BlockCopy(KeyTotalBytes, keystartposition, onekeybytes, 0, len); keystartposition += len; keybytes.Add(onekeybytes); } else {// TODO: Maybe need to check keytype = string and insert string.empty now. keybytes.Add(null); } } if (keystartposition >= KeyByteLen) { break; } } int valuestartposition = 0; while (true) { if (this.Valuelength > 0) { byte[] onebytes = new byte[this.Valuelength]; System.Buffer.BlockCopy(ValueTotalBytes, valuestartposition, onebytes, 0, this.Valuelength); valuestartposition += this.Valuelength; valuebytes.Add(onebytes); } else { int len = BitConverter.ToInt32(ValueTotalBytes, valuestartposition); valuestartposition += 4; if (len > 0) { byte[] onebytes = new byte[len]; System.Buffer.BlockCopy(ValueTotalBytes, valuestartposition, onebytes, 0, len); valuestartposition += len; valuebytes.Add(onebytes); } else { valuebytes.Add(null); } } if (valuestartposition >= ValueByteLen) { break; } } System.Collections.IDictionary dict = null; if (this.IsIgnoreCase) { List <object> para = new List <object>(); para.Add(StringComparer.OrdinalIgnoreCase); dict = Activator.CreateInstance(this.DictionaryType, para.ToArray()) as System.Collections.IDictionary; } else { dict = Activator.CreateInstance(this.DictionaryType) as System.Collections.IDictionary; } int count = keybytes.Count; for (int i = 0; i < count; i++) { var keybyte = keybytes[i]; var valuebyte = valuebytes[i]; if (keybyte != null) { var dictkey = this.GetKeyObjectValue(keybyte); if (valuebyte == null) { dict.Add(dictkey, null); } else { var dictvalue = this.GetValueObjectValue(valuebyte); dict.Add(dictkey, dictvalue); } } else if (KeyType == typeof(string)) { if (valuebyte == null) { dict.Add(string.Empty, null); } else { var dictvalue = this.GetValueObjectValue(valuebyte); dict.Add(string.Empty, dictvalue); } } } return(dict); }
internal static T MapException <T>(Exception x, bool remap, bool unused) where T : Exception { #if FIRST_PASS return(null); #else Exception org = x; bool nonJavaException = !(x is Throwable); if (nonJavaException && remap) { if (x is TypeInitializationException) { return((T)MapTypeInitializeException((TypeInitializationException)x, typeof(T))); } object obj = exceptions.get(x); Exception remapped = (Exception)obj; if (remapped == null) { remapped = Throwable.__mapImpl(x); if (remapped == x) { exceptions.put(x, NOT_REMAPPED); } else { exceptions.put(x, remapped); x = remapped; } } else if (remapped != NOT_REMAPPED) { x = remapped; } } if (IsInstanceOfType <T>(x, remap)) { Throwable t = x as Throwable; if (t != null) { if (!unused && t.tracePart1 == null && t.tracePart2 == null && t.stackTrace == Throwable.UNASSIGNED_STACK) { t.tracePart1 = new StackTrace(org, true); t.tracePart2 = new StackTrace(true); } if (t != org) { t.original = org; exceptions.remove(org); } } else { IDictionary data = x.Data; if (data != null && !data.IsReadOnly) { lock (data.SyncRoot) { if (!data.Contains(EXCEPTION_DATA_KEY)) { data.Add(EXCEPTION_DATA_KEY, new ExceptionInfoHelper(x, true)); } } } } if (nonJavaException && !remap) { exceptions.put(x, NOT_REMAPPED); } return((T)x); } return(null); #endif }
public override void Install(System.Collections.IDictionary stateSaver) { // Call the base implementation. base.Install(stateSaver); string allUsersString = this.Context.Parameters["allUsers"]; string solutionCodeGroupName = this.Context.Parameters["solutionCodeGroupName"]; string solutionCodeGroupDescription = this.Context.Parameters["solutionCodeGroupDescription"]; string targetDir = this.Context.Parameters["targetDir"]; string assemblyName = this.Context.Parameters["assemblyName"]; string assemblyCodeGroupName = this.Context.Parameters["assemblyCodeGroupName"]; string assemblyCodeGroupDescription = this.Context.Parameters["assemblyCodeGroupDescription"]; // Note that a code group with solutionCodeGroupName name is created in the // Install method and removed in the Rollback and Uninstall methods. // The solutionCodeGroupName must be a unique name to ensure that the // correct code group is removed during Rollback and Uninstall. if (String.IsNullOrEmpty(solutionCodeGroupName)) { throw new InstallException("Cannot set the security policy. The specified solution code group name is not valid."); } if (String.IsNullOrEmpty(solutionCodeGroupDescription)) { throw new InstallException("Cannot set the security policy. The specified solution code group description is not valid."); } if (String.IsNullOrEmpty(targetDir)) { throw new InstallException("Cannot set the security policy. The specified target directory is not valid."); } if (String.IsNullOrEmpty(assemblyName)) { throw new InstallException("Cannot set the security policy. The specified assembly name is not valid."); } if (String.IsNullOrEmpty(assemblyCodeGroupName)) { throw new InstallException("Cannot set the security policy. The specified assembly code group name is not valid."); } if (String.IsNullOrEmpty(assemblyCodeGroupDescription)) { throw new InstallException("Cannot set the security policy. The specified assembly code group description is not valid."); } if (stateSaver == null) { throw new ArgumentNullException("stateSaver"); } try { bool allUsers = String.Equals(allUsersString, "1"); string assemblyPath = Path.Combine(targetDir, assemblyName); // Note that Install method may be invoked during Repair mode and the code group // may already exist. // To prevent adding of another code group, remove the code group if it exists. try { // The solutionCodeGroupName must be a unique name; otherwise, the method might delete wrong code group. CaspolSecurityPolicyCreator.RemoveSecurityPolicy(allUsers, solutionCodeGroupName); } catch {} CaspolSecurityPolicyCreator.AddSecurityPolicy( allUsers, solutionCodeGroupName, solutionCodeGroupDescription, assemblyPath, assemblyCodeGroupName, assemblyCodeGroupDescription); stateSaver.Add("allUsers", allUsers); } catch (Exception ex) { throw new InstallException("Cannot set the security policy.", ex); } }
/// <summary> /// Schedules the error to be e-mailed synchronously. /// </summary> protected virtual void ReportError(Error error) { if (error == null) { throw new ArgumentNullException("error"); } // // Start by checking if we have a sender and a recipient. // These values may be null if someone overrides the // implementation of OnInit but does not override the // MailSender and MailRecipient properties. // string sender = Mask.NullString(this.MailSender); string recipient = Mask.NullString(this.MailRecipient); string copyRecipient = Mask.NullString(this.MailCopyRecipient); #if NET_1_0 || NET_1_1 // // The sender can be defaulted in the <system.net> settings in 2.0 // if (sender.Length == 0) { return; } #endif if (recipient.Length == 0) { return; } // // Create the mail, setting up the sender and recipient and priority. // MailMessage mail = new MailMessage(); mail.Priority = this.MailPriority; #if NET_1_0 || NET_1_1 mail.From = sender; mail.To = recipient; if (copyRecipient.Length > 0) { mail.Cc = copyRecipient; } #else mail.From = new MailAddress(sender); mail.To.Add(recipient); if (copyRecipient.Length > 0) { mail.CC.Add(copyRecipient); } #endif // // Format the mail subject. // string subjectFormat = Mask.EmptyString(this.MailSubjectFormat, "Error ({1}): {0}"); mail.Subject = string.Format(subjectFormat, error.Message, error.Type). Replace('\r', ' ').Replace('\n', ' '); // // Format the mail body. // ErrorTextFormatter formatter = CreateErrorFormatter(); StringWriter bodyWriter = new StringWriter(); formatter.Format(bodyWriter, error); mail.Body = bodyWriter.ToString(); switch (formatter.MimeType) { #if NET_1_0 || NET_1_1 case "text/html": mail.BodyFormat = MailFormat.Html; break; case "text/plain": mail.BodyFormat = MailFormat.Text; break; #else case "text/html": mail.IsBodyHtml = true; break; case "text/plain": mail.IsBodyHtml = false; break; #endif default: { throw new ApplicationException(string.Format( "The error mail module does not know how to handle the {1} media type that is created by the {0} formatter.", formatter.GetType().FullName, formatter.MimeType)); } } #if NET_1_1 // // If the mail needs to be delivered to a particular SMTP server // then set-up the corresponding CDO configuration fields of the // mail message. // string smtpServer = Mask.NullString(this.SmtpServer); if (smtpServer.Length > 0) { IDictionary fields = mail.Fields; fields.Add(CdoConfigurationFields.SendUsing, /* cdoSendUsingPort */ 2); fields.Add(CdoConfigurationFields.SmtpServer, smtpServer); int smtpPort = this.SmtpPort; fields.Add(CdoConfigurationFields.SmtpServerPort, smtpPort <= 0 ? 25 : smtpPort); // // If the SMTP server requires authentication (indicated by // non-blank user name and password settings) then set-up // the corresponding CDO configuration fields of the mail // message. // string userName = Mask.NullString(this.AuthUserName); string password = Mask.NullString(this.AuthPassword); if (userName.Length > 0 && password.Length > 0) { fields.Add(CdoConfigurationFields.SmtpAuthenticate, 1); fields.Add(CdoConfigurationFields.SendUserName, userName); fields.Add(CdoConfigurationFields.SendPassword, password); } } #endif MailAttachment ysodAttachment = null; ErrorMailEventArgs args = new ErrorMailEventArgs(error, mail); try { // // If an HTML message was supplied by the web host then attach // it to the mail if not explicitly told not to do so. // if (!NoYsod && error.WebHostHtmlMessage.Length > 0) { ysodAttachment = CreateHtmlAttachment("YSOD", error.WebHostHtmlMessage); if (ysodAttachment != null) { mail.Attachments.Add(ysodAttachment); } } // // Send off the mail with some chance to pre- or post-process // using event. // OnMailing(args); SendMail(mail); OnMailed(args); } finally { #if NET_1_0 || NET_1_1 // // Delete any attached files, if necessary. // if (ysodAttachment != null) { File.Delete(ysodAttachment.Filename); mail.Attachments.Remove(ysodAttachment); } #endif OnDisposingMail(args); #if !NET_1_0 && !NET_1_1 mail.Dispose(); #endif } }
/// <summary> Read a particular segmentFileName. Note that this may /// throw an IOException if a commit is in process. /// /// </summary> /// <param name="directory">-- directory containing the segments file /// </param> /// <param name="segmentFileName">-- segment file to load /// </param> /// <throws> CorruptIndexException if the index is corrupt </throws> /// <throws> IOException if there is a low-level IO error </throws> public void Read(Directory directory, System.String segmentFileName) { bool success = false; // Clear any previous segments: Clear(); ChecksumIndexInput input = new ChecksumIndexInput(directory.OpenInput(segmentFileName)); generation = GenerationFromSegmentsFileName(segmentFileName); lastGeneration = generation; try { int format = input.ReadInt(); if (format < 0) { // file contains explicit format info // check that it is a format we can understand if (format < CURRENT_FORMAT) throw new CorruptIndexException("Unknown format version: " + format); version = input.ReadLong(); // read version counter = input.ReadInt(); // read counter } else { // file is in old format without explicit format info counter = format; } for (int i = input.ReadInt(); i > 0; i--) { // read segmentInfos Add(new SegmentInfo(directory, format, input)); } if (format >= 0) { // in old format the version number may be at the end of the file if (input.GetFilePointer() >= input.Length()) version = System.DateTime.Now.Millisecond; // old file format without version number else version = input.ReadLong(); // read version } if (format <= FORMAT_USER_DATA) { if (format <= FORMAT_DIAGNOSTICS) { userData = input.readStringStringMap(); } else if (0 != input.ReadByte()) { userData = new System.Collections.Hashtable(); userData.Add("userData", input.ReadString()); } else { userData = (System.Collections.IDictionary) new System.Collections.Hashtable(); } } else { userData = (System.Collections.IDictionary) new System.Collections.Hashtable(); } if (format <= FORMAT_CHECKSUM) { long checksumNow = input.GetChecksum(); long checksumThen = input.ReadLong(); if (checksumNow != checksumThen) throw new CorruptIndexException("checksum mismatch in segments file"); } success = true; } finally { input.Close(); if (!success) { // Clear any segment infos we had loaded so we // have a clean slate on retry: Clear(); } } }