예제 #1
0
 private void ParseEvents(XmlElement element, EventCategory eventCat)
 {
     foreach (XmlNode node1 in element.ChildNodes)
     {
       if (node1.NodeType == XmlNodeType.Element)
       {
     XmlElement element1 = (XmlElement) node1;
     if (element1.LocalName != "event")
     {
       throw new InvalidOperationException(element1.LocalName + " is not allowed in this context.");
     }
     XmlAttribute attribute1 = element1.Attributes["type"];
     if ((attribute1 == null) || (attribute1.Value == string.Empty))
     {
       throw new InvalidOperationException("type is mandatory,  it cannot be omitted or empty.");
     }
     string text1 = attribute1.Value;
     DynamicType type1 = new DynamicType(text1);
     if (!type1.IsValidType)
     {
       type1 =
     DynamicType.InitWithDefaultNameSpace(text1, "Framework.Diagnostics.EventSchema", "Framework.Diagnostics");
     }
     Type type2 = type1.GetDynamicType();
     if (type2 == null)
     {
       throw new InvalidOperationException("'" + text1 + "' is not a valid type  it the current context.");
     }
     eventCat.EventTypes.Add(type2);
       }
     }
 }
예제 #2
0
 public static DynamicType InitWithDefaultNameSpace(string typeName, string defaultNameSpace, string defaultAsm)
 {
     DynamicType type1 = new DynamicType(typeName);
       if (type1.TypeName.IndexOf('.') < 0)
       {
     typeName = defaultNameSpace + "." + type1.TypeName;
       }
       else
       {
     typeName = type1.TypeName;
       }
       return new DynamicType(typeName, (type1.AssemblyName == string.Empty) ? defaultAsm : type1.AssemblyName);
 }
예제 #3
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes the service factory dispatcher
 /// </summary>
 /// <param name="className">Service factory class name.</param>
 // -------------------------------------------------------------------------------------
 public static void SetFactory(string className)
 {
     try
       {
     if (className == null || className == String.Empty)
     {
       className = ((NameValueCollection) ConfigurationManager.GetSection("ServiceFactory"))["class"];
     }
     var plugIn = new DynamicType(className);
     m_ServiceFactory = (IServiceFactory) plugIn.CreateInstance();
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     throw ex;
       }
 }